def extract_multilook_number( geom_dir, meta=dict(), fext_list=['.rdr', '.geo', '.rdr.full', '.geo.full']): for fbase in ['hgt', 'lat', 'lon', 'los']: fbase = os.path.join(geom_dir, fbase) for fext in fext_list: fnames = glob.glob(fbase + fext) if len(fnames) > 0: break if len(fnames) > 0: fullXmlFile = '{}.full.xml'.format(fnames[0]) if os.path.isfile(fullXmlFile): fullXmlDict = readfile.read_isce_xml(fullXmlFile) xmlDict = readfile.read_attribute(fnames[0]) meta['ALOOKS'] = int( int(fullXmlDict['LENGTH']) / int(xmlDict['LENGTH'])) meta['RLOOKS'] = int( int(fullXmlDict['WIDTH']) / int(xmlDict['WIDTH'])) break # default value for key in ['ALOOKS', 'RLOOKS']: if key not in meta: meta[key] = 1 # NCORRLOOKS for coherence calibration rgfact = float(meta['rangeResolution']) / float(meta['rangePixelSize']) azfact = float(meta['azimuthResolution']) / float(meta['azimuthPixelSize']) meta['NCORRLOOKS'] = meta['RLOOKS'] * meta['ALOOKS'] / (rgfact * azfact) return meta
def extract_multilook_number(geom_dir, metadata=dict()): for fbase in ['hgt','lat','lon','los']: fbase = os.path.join(geom_dir, fbase) fnames = glob.glob('{}*.rdr'.format(fbase)) + glob.glob('{}*.geo'.format(fbase)) if len(fnames) > 0: fullXmlFile = '{}.full.xml'.format(fnames[0]) if os.path.isfile(fullXmlFile): fullXmlDict = readfile.read_isce_xml(fullXmlFile) xmlDict = readfile.read_attribute(fnames[0]) metadata['ALOOKS'] = int(int(fullXmlDict['LENGTH']) / int(xmlDict['LENGTH'])) metadata['RLOOKS'] = int(int(fullXmlDict['WIDTH']) / int(xmlDict['WIDTH'])) break # default for key in ['ALOOKS', 'RLOOKS']: if key not in metadata: metadata[key] = 1 return metadata