Add files via upload

fixed issues relating to finding and selecting between orbits
LT1AB
Microwave Remote Sensing Laboratory 2019-09-27 13:21:43 -04:00 committed by GitHub
parent ab805ed1a3
commit 14418467ae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 31 additions and 32 deletions

View File

@ -283,25 +283,22 @@ class Sentinel1(Component):
self.populateMetadata() self.populateMetadata()
self.populateBbox() self.populateBbox()
####Tru and locate an orbit file ####Try and locate an orbit file
if self.orbitFile is None: if self.orbitFile is None:
if self.orbitDir is not None: if self.orbitDir is not None:
self.orbitFile = self.findOrbitFile() self.orbitFile = self.findOrbitFile()
print('Found this orbitfile: %s' %self.orbitFile)
####Read in the orbits ####Read in the orbits
if self.orbitFile: if '_POEORB_' in self.orbitFile:
try: orb = self.extractPreciseOrbit()
orb = self.extractPreciseOrbit() elif '_RESORB_' in self.orbitFile:
except:
pass
orb = self.extractOrbit() orb = self.extractOrbit()
self.product.orbit.setOrbitSource('Header') self.product.orbit.setOrbitSource('Header')
for sv in orb: for sv in orb:
self.product.orbit.addStateVector(sv) self.product.orbit.addStateVector(sv)
self.populateIPFVersion() self.populateIPFVersion()
self.extractBetaLUT() self.extractBetaLUT()
self.extractNoiseLUT() self.extractNoiseLUT()
@ -465,31 +462,33 @@ class Sentinel1(Component):
datefmt = "%Y%m%dT%H%M%S" datefmt = "%Y%m%dT%H%M%S"
types = ['POEORB', 'RESORB'] types = ['POEORB', 'RESORB']
filelist = []
match = [] match = []
timeStamp = self.product.sensingMid timeStamp = self.product.sensingStart+(self.product.sensingStop - self.product.sensingStart)/2.
for orbType in types: for orbType in types:
files = glob.glob( os.path.join(self.orbitDir, 'S1A_OPER_AUX_' + orbType + '_OPOD*')) files = glob.glob( os.path.join(self.orbitDir, 'S1A_OPER_AUX_' + orbType + '_OPOD*'))
filelist.extend(files)
###List all orbit files ###List all orbit files
for result in files:
fields = result.split('_')
taft = datetime.datetime.strptime(fields[-1][0:15], datefmt)
tbef = datetime.datetime.strptime(fields[-2][1:16], datefmt)
#####Get all files that span the acquisition for result in filelist:
if (tbef <= timeStamp) and (taft >= timeStamp): fields = result.split('_')
tmid = tbef + 0.5 * (taft - tbef) taft = datetime.datetime.strptime(fields[-1][0:15], datefmt)
match.append((result, abs((timeStamp-tmid).total_seconds()))) tbef = datetime.datetime.strptime(fields[-2][1:16], datefmt)
print(taft, tbef)
#####Return the file with the image is aligned best to the middle of the file #####Get all files that span the acquisition
if len(match) != 0: if (tbef <= timeStamp) and (taft >= timeStamp):
bestmatch = min(match, key = lambda x: x[1]) tmid = tbef + 0.5 * (taft - tbef)
return bestmatch[0] match.append((result, abs((timeStamp-tmid).total_seconds())))
#####Return the file with the image is aligned best to the middle of the file
if len(match) != 0:
bestmatch = min(match, key = lambda x: x[1])
return bestmatch[0]
if len(match) == 0: if len(match) == 0:
raise Exception('No suitable orbit file found. If you want to process anyway - unset the orbitdir parameter') raise Exception('No suitable orbit file found. If you want to process anyway - unset the orbitdir parameter')
def extractOrbit(self): def extractOrbit(self):
''' '''
@ -530,11 +529,11 @@ class Sentinel1(Component):
except IOError as strerr: except IOError as strerr:
print("IOError: %s" % strerr) print("IOError: %s" % strerr)
return return
#_xml_root = ElementTree(file=fp).getroot()
node = self._xml_root.find('Data_Block/List_of_OSVs') _xml_root = ElementTree.ElementTree(file=fp).getroot()
node = _xml_root.find('Data_Block/List_of_OSVs')
print('Extracting orbit from Orbit File: ', self.orbitFile)
orb = Orbit() orb = Orbit()
orb.configure() orb.configure()