def get_los_geometry(self, geom_obj, print_msg=False): lat, lon = self.get_stat_lat_lon(print_msg=print_msg) # get LOS geometry if isinstance(geom_obj, str): # geometry file atr = readfile.read_attribute(geom_obj) coord = coordinate(atr, lookup_file=geom_obj) y, x = coord.geo2radar(lat, lon, print_msg=print_msg)[0:2] box = (x, y, x + 1, y + 1) inc_angle = readfile.read(geom_obj, datasetName='incidenceAngle', box=box, print_msg=print_msg)[0][0, 0] az_angle = readfile.read(geom_obj, datasetName='azimuthAngle', box=box, print_msg=print_msg)[0][0, 0] head_angle = ut.azimuth2heading_angle(az_angle) elif isinstance(geom_obj, dict): # use mean inc/head_angle from metadata inc_angle = ut.incidence_angle(geom_obj, dimension=0, print_msg=print_msg) head_angle = float(geom_obj['HEADING']) # for old reading of los.rdr band2 data into headingAngle directly if (head_angle + 180.) > 45.: head_angle = ut.azimuth2heading_angle(head_angle) else: raise ValueError( 'input geom_obj is neight str nor dict: {}'.format(geom_obj)) return inc_angle, head_angle
def get_incidence_angle(self, box=None): """Generate 2D slant range distance if missing from input template file""" if not self.extraMetadata: return None if 'Y_FIRST' in self.extraMetadata.keys(): # for dataset in geo-coordinates, use contant value from INCIDENCE_ANGLE. key = 'INCIDENCE_ANGLE' print('geocoded input, use contant value from metadata {}'.format(key)) if key in self.extraMetadata.keys(): length = int(self.extraMetadata['LENGTH']) width = int(self.extraMetadata['WIDTH']) inc_angle = float(self.extraMetadata[key]) data = np.ones((length, width), dtype=np.float32) * inc_angle else: return None else: # read DEM if available for more previse calculation if 'height' in self.dsNames: dem = readfile.read(self.datasetDict['height'], datasetName='height')[0] else: dem = None # for dataset in radar-coordinates, calculate 2D pixel-wise value from geometry data = ut.incidence_angle(self.extraMetadata, dem=dem, dimension=2, print_msg=False) # subset if box is not None: data = data[box[1]:box[3], box[0]:box[2]] return data
def get_incidence_angle(self, box=None): if not self.extraMetadata or 'Y_FIRST' in self.extraMetadata.keys(): return None if 'height' in self.dsNames: dem = readfile.read(self.datasetDict['height'], datasetName='height')[0] else: dem = None data = ut.incidence_angle(self.extraMetadata, dem=dem, dimension=2, print_msg=False) if box is not None: data = data[box[1]:box[3], box[0]:box[2]] return data