2019-01-16 19:40:08 +00:00
|
|
|
#!/usr/bin/env python3
|
2020-10-04 23:30:18 +00:00
|
|
|
# modified to pass the segment number to UAVSAR_STACK sensor EJF 2020/08/02
|
2019-01-16 19:40:08 +00:00
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
import os
|
|
|
|
import glob
|
|
|
|
import argparse
|
|
|
|
import shelve
|
2019-01-16 19:40:08 +00:00
|
|
|
import isce
|
|
|
|
from isceobj.Sensor import createSensor
|
|
|
|
from isceobj.Util import Poly1D
|
|
|
|
from isceobj.Planet.AstronomicalHandbook import Const
|
2022-02-01 21:50:40 +00:00
|
|
|
|
2019-01-16 19:40:08 +00:00
|
|
|
|
|
|
|
def cmdLineParse():
|
|
|
|
'''
|
|
|
|
Command line parser.
|
|
|
|
'''
|
|
|
|
|
2020-10-04 23:30:18 +00:00
|
|
|
parser = argparse.ArgumentParser(description='Unpack UAVSAR SLC data and store metadata in pickle file.')
|
2022-02-01 21:50:40 +00:00
|
|
|
parser.add_argument('-i','--input', dest='metaFile', type=str,
|
|
|
|
required=True, help='metadata file')
|
2019-01-16 19:40:08 +00:00
|
|
|
parser.add_argument('-d','--dop_file', dest='dopFile', type=str,
|
|
|
|
default=None, help='Doppler file')
|
2020-10-04 23:30:18 +00:00
|
|
|
parser.add_argument('-s','--segment', dest='stackSegment', type=int,
|
|
|
|
default=1, help='stack segment')
|
2022-02-01 21:50:40 +00:00
|
|
|
parser.add_argument('-o', '--output', dest='slcDir', type=str,
|
2019-01-16 19:40:08 +00:00
|
|
|
required=True, help='Output SLC directory')
|
|
|
|
return parser.parse_args()
|
|
|
|
|
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
def unpack(metaFile, slcDir, dopFile, stackSegment, parse=False):
|
2019-01-16 19:40:08 +00:00
|
|
|
'''
|
2022-02-01 21:50:40 +00:00
|
|
|
Prepare shelve/pickle file for the binary SLC file.
|
2019-01-16 19:40:08 +00:00
|
|
|
'''
|
|
|
|
|
|
|
|
obj = createSensor('UAVSAR_STACK')
|
|
|
|
obj.configure()
|
2022-02-01 21:50:40 +00:00
|
|
|
obj.metadataFile = metaFile
|
2019-01-16 19:40:08 +00:00
|
|
|
obj.dopplerFile = dopFile
|
2020-10-04 23:30:18 +00:00
|
|
|
obj.segment_index = stackSegment
|
2019-01-16 19:40:08 +00:00
|
|
|
obj.parse()
|
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
if not os.path.isdir(slcDir):
|
|
|
|
os.mkdir(slcDir)
|
2019-01-16 19:40:08 +00:00
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
pickName = os.path.join(slcDir, 'data')
|
2019-01-16 19:40:08 +00:00
|
|
|
with shelve.open(pickName) as db:
|
|
|
|
db['frame'] = obj.frame
|
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
|
2019-01-16 19:40:08 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
'''
|
|
|
|
Main driver.
|
|
|
|
'''
|
|
|
|
|
|
|
|
inps = cmdLineParse()
|
2022-02-01 21:50:40 +00:00
|
|
|
inps.slcDir = inps.slcDir.rstrip('/')
|
|
|
|
inps.metaFile = os.path.abspath(inps.metaFile)
|
|
|
|
inps.dopFile = os.path.abspath(inps.dopFile)
|
|
|
|
inps.slcDir = os.path.abspath(inps.slcDir)
|
2019-01-16 19:40:08 +00:00
|
|
|
|
2022-02-01 21:50:40 +00:00
|
|
|
unpack(inps.metaFile, inps.slcDir, inps.dopFile, inps.stackSegment)
|