Skip to content
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

unpackFrame_ROIPAC_raw.py fixes #767

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
166 changes: 83 additions & 83 deletions contrib/stack/stripmapStack/unpackFrame_ROIPAC_raw.py
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
#!/usr/bin/env python3
import isce
from isceobj.Sensor import createSensor
import shelve
import argparse
import glob
from isceobj.Util import Poly1D
from isceobj.Planet.AstronomicalHandbook import Const
import os
from mroipac.dopiq.DopIQ import DopIQ
import copy
def cmdLineParse():
'''
Command line parser.
'''
parser = argparse.ArgumentParser(description='Unpack raw data and store metadata in pickle file.')
parser.add_argument('-i','--input', dest='rawfile', type=str,
required=True, help='Input ROI_PAC file')
parser.add_argument('-r','--hdr', dest='hdrfile', type=str,
required=True, help='Input hdr (orbit) file')
parser.add_argument('-o', '--output', dest='slcdir', type=str,
required=True, help='Output data directory')
return parser.parse_args()
def unpack(rawname, hdrname, slcname):
'''
Unpack raw to binary file.
'''
if not os.path.isdir(slcname):
os.mkdir(slcname)
date = os.path.basename(slcname)
obj = createSensor('ROI_PAC')
obj.configure()
obj._rawFile = rawname
obj._hdrFile = hdrname
obj.output = os.path.join(slcname, date+'.raw')
print(obj._rawFile)
print(obj._hdrFile)
print(obj.output)
obj.extractImage()
obj.frame.getImage().renderHdr()
#####Estimate doppler
dop = DopIQ()
dop.configure()
img = copy.deepcopy(obj.frame.getImage())
img.setAccessMode('READ')
dop.wireInputPort('frame', object=obj.frame)
dop.wireInputPort('instrument', object=obj.frame.instrument)
dop.wireInputPort('image', object=img)
dop.calculateDoppler()
dop.fitDoppler()
fit = dop.quadratic
coef = [fit['a'], fit['b'], fit['c']]
print(coef)
obj.frame._dopplerVsPixel = [x*obj.frame.PRF for x in coef]
pickName = os.path.join(slcname, 'raw')
with shelve.open(pickName) as db:
db['frame'] = obj.frame
if __name__ == '__main__':
'''
Main driver.
'''
inps = cmdLineParse()
if inps.slcdir.endswith('/'):
inps.slcdir = inps.slcdir[:-1]
unpack(inps.rawfile, inps.hdrfile, inps.slcdir)
#!/usr/bin/env python3

import isce
from isceobj.Sensor import createSensor
import shelve
import argparse
import os
from mroipac.dopiq.DopIQ import DopIQ
import copy

def cmdLineParse():
'''
Command line parser.
'''

parser = argparse.ArgumentParser(description='Unpack raw data and store metadata in pickle file.')
parser.add_argument('-i','--input', dest='rawfile', type=str,
required=True, help='Input ROI_PAC file')
parser.add_argument('-r','--hdr', dest='hdrfile', type=str,
required=True, help='Input hdr (orbit) file')
parser.add_argument('-o', '--output', dest='slcdir', type=str,
required=True, help='Output data directory')

parser.add_argument('-d','--default', dest='defaultDoppler', type=str, action='store_true'
required=False, help='use DEFAULT to estimate doppler')

return parser.parse_args()


def unpack(rawname, hdrname, slcname, default):
'''
Unpack raw to binary file.
'''

if not os.path.isdir(slcname):
os.mkdir(slcname)
date = os.path.basename(slcname)
obj = createSensor('ROI_PAC')
obj.configure()
obj._rawFile = os.path.abspath(rawname)
obj._hdrFile = hdrname
obj.output = os.path.join(slcname, date+'.raw')

print(obj._rawFile)
print(obj._hdrFile)
print(obj.output)
obj.extractImage()
obj.frame.getImage().renderHdr()

if defaultDoppler == True:
obj.extractDoppler()
else:
dop = DopIQ()
dop.configure()

img = copy.deepcopy(obj.frame.getImage())
img.setAccessMode('READ')

dop.wireInputPort('frame', object=obj.frame)
dop.wireInputPort('instrument', object=obj.frame.instrument)
dop.wireInputPort('image', object=img)
dop.calculateDoppler()
dop.fitDoppler()
fit = dop.quadratic
coef = [fit['a'], fit['b'], fit['c']]

print(coef)
obj.frame._dopplerVsPixel = [x*obj.frame.PRF for x in coef]

pickName = os.path.join(slcname, 'raw')
with shelve.open(pickName) as db:
db['frame'] = obj.frame

if __name__ == '__main__':
'''
Main driver.
'''

inps = cmdLineParse()
if inps.slcdir.endswith('/'):
inps.slcdir = inps.slcdir[:-1]

unpack(inps.rawfile, inps.hdrfile, inps.slcdir, inps.defaultDoppler)