-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ERS stack processing #736
Open
yjzhenglamarmota
wants to merge
8
commits into
isce-framework:main
Choose a base branch
from
yjzhenglamarmota:ersStack
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
ERS stack processing #736
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
077615a
adding scripts -preparing ERS for stack processing
yjzhenglamarmota 1be3ad7
Combine prepareERS_ENVstack,py with unpackFrame_ERS_ENV.py in the lat…
yjzhenglamarmota 84b7a4f
Fix bugs
yjzhenglamarmota 9bf4721
Add geolocation constraint option
yjzhenglamarmota 5d62ff7
Update unpackFrame_ERS_ENV.py
yjzhenglamarmota 704085d
Update ODR.py
yjzhenglamarmota 2de84c0
adding scripts -preparing ERS for stack processing
yjzhenglamarmota f226619
Combine prepareERS_ENVstack,py with unpackFrame_ERS_ENV.py in the lat…
yjzhenglamarmota File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#!/usr/bin/env python3 | ||
|
||
import isce | ||
from isceobj.Sensor import createSensor | ||
import isceobj | ||
import shelve | ||
import argparse | ||
import glob | ||
from isceobj.Util import Poly1D | ||
from isceobj.Planet.AstronomicalHandbook import Const | ||
import os | ||
import datetime | ||
import numpy as np | ||
|
||
def cmdLineParse(): | ||
''' | ||
Command line parser. | ||
''' | ||
|
||
parser = argparse.ArgumentParser(description='Unpack ERS(ESA) SLC data and store metadata in pickle file.') | ||
parser.add_argument('-i','--input', dest='datadir', type=str, | ||
required=True, help='Input ERS files path') | ||
parser.add_argument('-b', '--box' ,dest='bbox', type=float, nargs=4, default=None, | ||
help='Bbox (SNWE in degrees)') | ||
parser.add_argument('-o', '--output', dest='slcdir', type=str, | ||
required=True, help='Output SLC directory') | ||
parser.add_argument('--orbitdir', dest='orbitdir', type=str, required=True, help='Orbit directory') | ||
parser.add_argument('--orbittype',dest='orbittype', type = str, default='ODR', help='ODR, PDS, PDS') | ||
return parser.parse_args() | ||
|
||
def get_Date(file): | ||
yyyymmdd=file[14:22] | ||
return yyyymmdd | ||
|
||
def write_xml(shelveFile, slcFile): | ||
with shelve.open(shelveFile,flag='r') as db: | ||
frame = db['frame'] | ||
|
||
length = frame.numberOfLines | ||
width = frame.numberOfSamples | ||
print (width,length) | ||
|
||
slc = isceobj.createSlcImage() | ||
slc.setWidth(width) | ||
slc.setLength(length) | ||
slc.filename = slcFile | ||
slc.setAccessMode('write') | ||
slc.renderHdr() | ||
slc.renderVRT() | ||
|
||
def unpack(fname, slcname, orbitdir, orbittype): | ||
''' | ||
Unpack .E* file to binary SLC file. | ||
''' | ||
|
||
obj = createSensor('ERS_ENviSAT_SLC') | ||
obj._imageFileName = fname | ||
obj._orbitDir = orbitdir | ||
obj._orbitType = orbittype | ||
#obj.instrumentDir = '/Users/agram/orbit/INS_DIR' | ||
obj.output = os.path.join(slcname,os.path.basename(slcname)+'.slc') | ||
obj.extractImage() | ||
obj.frame.getImage().renderHdr() | ||
obj.extractDoppler() | ||
|
||
# #### computation of "poly" adapted from line 339 - line 353 of Components/isceobj/Sensor/ERS_EnviSAT_SLC.py ### | ||
####### removed this section and added obj.extractDoppler() above instead. Doesn't seem to change anything in the processing. The latter is required for cropFrame. | ||
# coeffs = obj.dopplerRangeTime | ||
# dr = obj.frame.getInstrument().getRangePixelSize() | ||
# rref = 0.5 * Const.c * obj.rangeRefTime | ||
# r0 = obj.frame.getStartingRange() | ||
# norm = 0.5 * Const.c / dr | ||
|
||
# dcoeffs = [] | ||
# for ind, val in enumerate(coeffs): | ||
# dcoeffs.append( val / (norm**ind)) | ||
|
||
# poly = Poly1D.Poly1D() | ||
# poly.initPoly(order=len(coeffs)-1) | ||
# poly.setMean( (rref - r0)/dr - 1.0) | ||
# poly.setCoeffs(dcoeffs) | ||
Comment on lines
+66
to
+81
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please remove commented code. |
||
|
||
|
||
pickName = os.path.join(slcname, 'data') | ||
with shelve.open(pickName) as db: | ||
db['frame'] = obj.frame | ||
# db['doppler'] = poly | ||
|
||
|
||
if __name__ == '__main__': | ||
''' | ||
Main driver. | ||
''' | ||
|
||
inps = cmdLineParse() | ||
if inps.slcdir.endswith('/'): | ||
inps.slcdir = inps.slcdir[:-1] | ||
if not os.path.isdir(inps.slcdir): | ||
os.mkdir(inps.slcdir) | ||
for fname in glob.glob(os.path.join(inps.datadir, '*.E*')): | ||
date = get_Date(os.path.basename(fname)) | ||
slcname = os.path.abspath(os.path.join(inps.slcdir, date)) | ||
os.makedirs(slcname, exist_ok=True) | ||
|
||
print(fname) | ||
unpack(fname, slcname, inps.orbitdir, inps.orbittype) | ||
|
||
slcFile = os.path.abspath(os.path.join(slcname, date+'.slc')) | ||
|
||
shelveFile = os.path.join(slcname, 'data') | ||
write_xml(shelveFile,slcFile) | ||
|
||
if inps.bbox is not None: | ||
slccropname = os.path.abspath(os.path.join(inps.slcdir+'_crop',date)) | ||
os.makedirs(slccropname, exist_ok=True) | ||
cmd = 'cropFrame.py -i {} -o {} -b {}'.format(slcname, slccropname, ' '.join([str(x) for x in inps.bbox])) | ||
print(cmd) | ||
os.system(cmd) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the commented code.