def get_rma(): # type: () -> RMAType img_geometry = img['image_geometry'] near_range = img_geometry['range_to_first_sample'] center_time = parse_timestring(img['center_pixel']['center_time'], precision='us') first_time = parse_timestring(img_geometry['first_line_time'], precision='us') zd_time_scp = get_seconds(center_time, first_time, 'us') r_ca_scp = near_range + image_data.SCPPixel.Row * grid.Row.SS time_ca_poly = numpy.array( [zd_time_scp, -look * ss_zd_s / grid.Col.SS], dtype='float64') timecoa_value = get_seconds(center_time, start_time) arp_velocity = position.ARPPoly.derivative_eval(timecoa_value, der_order=1) vm_ca = numpy.linalg.norm(arp_velocity) inca = INCAType(R_CA_SCP=r_ca_scp, FreqZero=fc, TimeCAPoly=time_ca_poly, DRateSFPoly=[ [1 / (vm_ca * ss_zd_s / grid.Col.SS)], ]) return RMAType(RMAlgoType='RG_DOP', INCA=inca)
def get_rma() -> RMAType: dop_centroid_poly = Poly2DType(Coefs=dop_centroid_poly_coeffs) dop_centroid_coa = True if collect_info.RadarMode.ModeType == 'SPOTLIGHT': dop_centroid_poly = None dop_centroid_coa = None # NB: DRateSFPoly is defined as a function of only range - reshape appropriately inca = INCAType( R_CA_SCP=r_ca_scp, FreqZero=center_freq, DRateSFPoly=Poly2DType( Coefs=numpy.reshape(drate_sf_poly_coefs, (-1, 1))), DopCentroidPoly=dop_centroid_poly, DopCentroidCOA=dop_centroid_coa, TimeCAPoly=Poly1DType(Coefs=time_ca_poly_coeffs)) return RMAType(RMAlgoType='OMEGA_K', INCA=inca)
def get_rma(): # type: () -> RMAType inca = INCAType(FreqZero=center_frequency) return RMAType(RMAlgoType='OMEGA_K', INCA=inca)
def get_rma(): # type: () -> RMAType return RMAType(RMAlgoType='OMEGA_K', INCA=INCAType(DopCentroidCOA=True))
def _get_rma_adjust_grid(self, scpcoa, grid, image_data, position, collection_info): """ Gets the RMA metadata, and adjust the Grid.Col metadata. Parameters ---------- scpcoa : SCPCOAType grid : GridType image_data : ImageDataType position : PositionType collection_info : CollectionInfoType Returns ------- RMAType """ look = scpcoa.look start_time = self._get_start_time() center_freq = self._get_center_frequency() doppler_bandwidth = float( self._find('./imageGenerationParameters' '/sarProcessingInformation' '/totalProcessedAzimuthBandwidth').text) zero_dop_last_line = parse_timestring( self._find('./imageGenerationParameters' '/sarProcessingInformation' '/zeroDopplerTimeLastLine').text) zero_dop_first_line = parse_timestring( self._find('./imageGenerationParameters' '/sarProcessingInformation' '/zeroDopplerTimeFirstLine').text) if look > 1: # SideOfTrack == 'L' # we explicitly want negative time order if zero_dop_first_line < zero_dop_last_line: zero_dop_first_line, zero_dop_last_line = zero_dop_last_line, zero_dop_first_line else: # we explicitly want positive time order if zero_dop_first_line > zero_dop_last_line: zero_dop_first_line, zero_dop_last_line = zero_dop_last_line, zero_dop_first_line col_spacing_zd = get_seconds(zero_dop_last_line, zero_dop_first_line, precision='us') / (image_data.NumCols - 1) # zero doppler time of SCP relative to collect start time_scp_zd = get_seconds(zero_dop_first_line, start_time, precision='us') + \ image_data.SCPPixel.Col*col_spacing_zd if self.generation == 'RS2': near_range = float( self._find('./imageGenerationParameters' '/sarProcessingInformation' '/slantRangeNearEdge').text) elif self.generation == 'RCM': near_range = float( self._find('./sceneAttributes' '/imageAttributes' '/slantRangeNearEdge').text) else: raise ValueError('unhandled generation {}'.format(self.generation)) inca = INCAType(R_CA_SCP=near_range + (image_data.SCPPixel.Row * grid.Row.SS), FreqZero=center_freq) # doppler rate calculations velocity = position.ARPPoly.derivative_eval(time_scp_zd, 1) vel_ca_squared = numpy.sum(velocity * velocity) # polynomial representing range as a function of range distance from SCP r_ca = numpy.array([inca.R_CA_SCP, 1], dtype=numpy.float64) # doppler rate coefficients if self.generation == 'RS2': doppler_rate_coeffs = numpy.array([ float(entry) for entry in self._find( './imageGenerationParameters' '/dopplerRateValues' '/dopplerRateValuesCoefficients').text.split() ], dtype=numpy.float64) doppler_rate_ref_time = float( self._find('./imageGenerationParameters' '/dopplerRateValues' '/dopplerRateReferenceTime').text) elif self.generation == 'RCM': doppler_rate_coeffs = numpy.array([ float(entry) for entry in self._find( './dopplerRate' '/dopplerRateEstimate' '/dopplerRateCoefficients').text.split() ], dtype=numpy.float64) doppler_rate_ref_time = float( self._find('./dopplerRate' '/dopplerRateEstimate' '/dopplerRateReferenceTime').text) else: raise ValueError('unhandled generation {}'.format(self.generation)) # the doppler_rate_coeffs represents a polynomial in time, relative to # doppler_rate_ref_time. # to construct the doppler centroid polynomial, we need to change scales # to a polynomial in space, relative to SCP. doppler_rate_poly = Poly1DType(Coefs=doppler_rate_coeffs) alpha = 2.0 / speed_of_light t_0 = doppler_rate_ref_time - alpha * inca.R_CA_SCP dop_rate_scaled_coeffs = doppler_rate_poly.shift(t_0, alpha, return_poly=False) # DRateSFPoly is then a scaled multiple of this scaled poly and r_ca above coeffs = -numpy.convolve(dop_rate_scaled_coeffs, r_ca) / ( alpha * center_freq * vel_ca_squared) inca.DRateSFPoly = Poly2DType( Coefs=numpy.reshape(coeffs, (coeffs.size, 1))) # modify a few of the other fields ss_scale = numpy.sqrt(vel_ca_squared) * inca.DRateSFPoly[0, 0] grid.Col.SS = col_spacing_zd * ss_scale grid.Col.ImpRespBW = -look * doppler_bandwidth / ss_scale inca.TimeCAPoly = Poly1DType(Coefs=[time_scp_zd, 1. / ss_scale]) # doppler centroid if self.generation == 'RS2': doppler_cent_coeffs = numpy.array([ float(entry) for entry in self._find( './imageGenerationParameters' '/dopplerCentroid' '/dopplerCentroidCoefficients').text.split() ], dtype=numpy.float64) doppler_cent_ref_time = float( self._find('./imageGenerationParameters' '/dopplerCentroid' '/dopplerCentroidReferenceTime').text) doppler_cent_time_est = parse_timestring( self._find('./imageGenerationParameters' '/dopplerCentroid' '/timeOfDopplerCentroidEstimate').text) elif self.generation == 'RCM': doppler_cent_coeffs = numpy.array([ float(entry) for entry in self._find( './dopplerCentroid' '/dopplerCentroidEstimate' '/dopplerCentroidCoefficients').text.split() ], dtype=numpy.float64) doppler_cent_ref_time = float( self._find('./dopplerCentroid' '/dopplerCentroidEstimate' '/dopplerCentroidReferenceTime').text) doppler_cent_time_est = parse_timestring( self._find('./dopplerCentroid' '/dopplerCentroidEstimate' '/timeOfDopplerCentroidEstimate').text) else: raise ValueError('unhandled generation {}'.format(self.generation)) doppler_cent_poly = Poly1DType(Coefs=doppler_cent_coeffs) alpha = 2.0 / speed_of_light t_0 = doppler_cent_ref_time - alpha * inca.R_CA_SCP scaled_coeffs = doppler_cent_poly.shift(t_0, alpha, return_poly=False) inca.DopCentroidPoly = Poly2DType( Coefs=numpy.reshape(scaled_coeffs, (scaled_coeffs.size, 1))) # adjust doppler centroid for spotlight, we need to add a second # dimension to DopCentroidPoly if collection_info.RadarMode.ModeType == 'SPOTLIGHT': doppler_cent_est = get_seconds(doppler_cent_time_est, start_time, precision='us') doppler_cent_col = (doppler_cent_est - time_scp_zd) / col_spacing_zd dop_poly = numpy.zeros((scaled_coeffs.shape[0], 2), dtype=numpy.float64) dop_poly[:, 0] = scaled_coeffs dop_poly[0, 1] = -look * center_freq * alpha * numpy.sqrt( vel_ca_squared) / inca.R_CA_SCP # dopplerCentroid in native metadata was defined at specific column, # which might not be our SCP column. Adjust so that SCP column is correct. dop_poly[0, 0] = dop_poly[0, 0] - (dop_poly[0, 1] * doppler_cent_col * grid.Col.SS) inca.DopCentroidPoly = Poly2DType(Coefs=dop_poly) grid.Col.DeltaKCOAPoly = Poly2DType( Coefs=inca.DopCentroidPoly.get_array() * col_spacing_zd / grid.Col.SS) # compute grid.Col.DeltaK1/K2 from DeltaKCOAPoly coeffs = grid.Col.DeltaKCOAPoly.get_array()[:, 0] # get roots roots = polynomial.polyroots(coeffs) # construct range bounds (in meters) range_bounds = ( numpy.array([0, image_data.NumRows - 1], dtype=numpy.float64) - image_data.SCPPixel.Row) * grid.Row.SS possible_ranges = numpy.copy(range_bounds) useful_roots = ((roots > numpy.min(range_bounds)) & (roots < numpy.max(range_bounds))) if numpy.any(useful_roots): possible_ranges = numpy.concatenate( (possible_ranges, roots[useful_roots]), axis=0) azimuth_bounds = ( numpy.array([0, (image_data.NumCols - 1)], dtype=numpy.float64) - image_data.SCPPixel.Col) * grid.Col.SS coords_az_2d, coords_rg_2d = numpy.meshgrid(azimuth_bounds, possible_ranges) possible_bounds_deltak = grid.Col.DeltaKCOAPoly( coords_rg_2d, coords_az_2d) grid.Col.DeltaK1 = numpy.min( possible_bounds_deltak) - 0.5 * grid.Col.ImpRespBW grid.Col.DeltaK2 = numpy.max( possible_bounds_deltak) + 0.5 * grid.Col.ImpRespBW # Wrapped spectrum if (grid.Col.DeltaK1 < -0.5 / grid.Col.SS) or (grid.Col.DeltaK2 > 0.5 / grid.Col.SS): grid.Col.DeltaK1 = -0.5 / abs(grid.Col.SS) grid.Col.DeltaK2 = -grid.Col.DeltaK1 time_coa_poly = fit_time_coa_polynomial(inca, image_data, grid, dop_rate_scaled_coeffs, poly_order=2) if collection_info.RadarMode.ModeType == 'SPOTLIGHT': # using above was convenience, but not really sensible in spotlight mode grid.TimeCOAPoly = Poly2DType(Coefs=[ [ time_coa_poly.Coefs[0, 0], ], ]) inca.DopCentroidPoly = None elif collection_info.RadarMode.ModeType == 'STRIPMAP': # fit TimeCOAPoly for grid grid.TimeCOAPoly = time_coa_poly inca.DopCentroidCOA = True else: raise ValueError('unhandled ModeType {}'.format( collection_info.RadarMode.ModeType)) return RMAType(RMAlgoType='OMEGA_K', INCA=inca)