|
15 | 15 | from scipy.interpolate import InterpolatedUnivariateSpline, interp1d
|
16 | 16 | from packaging import version
|
17 | 17 |
|
| 18 | +from isce3.core import speed_of_light |
| 19 | + |
18 | 20 | # Minimum IPF version from which the S1 product's Noise Annotation
|
19 | 21 | # Data Set (NADS) includes azimuth noise vector annotation
|
20 | 22 | min_ipf_version_az_noise_vector = version.parse('2.90')
|
@@ -333,6 +335,7 @@ class ProductAnnotation(AnnotationBase):
|
333 | 335 |
|
334 | 336 | slant_range_time: float
|
335 | 337 |
|
| 338 | + |
336 | 339 | @classmethod
|
337 | 340 | def from_et(cls, et_in: ET):
|
338 | 341 | '''
|
@@ -897,3 +900,120 @@ def _anx2height(cls, delta_anx):
|
897 | 900 | h_t += h_i * np.sin((i+1) * worb * delta_anx + phi[i])
|
898 | 901 |
|
899 | 902 | return h_t
|
| 903 | + |
| 904 | + |
| 905 | +@dataclass |
| 906 | +class BurstExtendedCoeffs: |
| 907 | + ''' |
| 908 | + Segments of FM rate / Doppler centroid polynomial coefficients. |
| 909 | + For (linear) interpolation of FM rate / Doppler Centroid along azimuth. |
| 910 | + To be used for calculating azimuth FM rate mismatch mitigation |
| 911 | + ''' |
| 912 | + |
| 913 | + # FM rate |
| 914 | + fm_rate_aztime_vec: np.ndarray |
| 915 | + fm_rate_coeff_arr: np.ndarray |
| 916 | + fm_rate_tau0_vec:np.ndarray |
| 917 | + |
| 918 | + # Doppler centroid |
| 919 | + dc_aztime_vec: np.ndarray |
| 920 | + dc_coeff_arr: np.ndarray |
| 921 | + dc_tau0_vec: np.ndarray |
| 922 | + |
| 923 | + @classmethod |
| 924 | + def from_polynomial_lists(cls, |
| 925 | + az_fm_rate_list: list, |
| 926 | + doppler_centroid_list: list, |
| 927 | + sensing_start: datetime.datetime, |
| 928 | + sensing_end: datetime.datetime): |
| 929 | + ''' |
| 930 | + Extract coefficients from the list of the polynomial lists that fall within |
| 931 | + the provided sensing start / end times of a burst. |
| 932 | +
|
| 933 | + Parameters: |
| 934 | + ----------- |
| 935 | + az_fm_rate_list: list[isce3.core.Poly1d] |
| 936 | + List of azimuth FM rate polynomials |
| 937 | + doppler_centroid_list: list[isce3.core.Poly1d] |
| 938 | + List of doppler centroid polynomials |
| 939 | + sensing_start: datetime.datetime |
| 940 | + Azimuth start time of the burst |
| 941 | + sensing_end: datetime.datetime |
| 942 | + Azimuth end time of the burst |
| 943 | + ''' |
| 944 | + |
| 945 | + # Extract polynomial info for azimuth FM rate |
| 946 | + (fm_rate_aztime_burst_vec, |
| 947 | + fm_rate_coeff_burst_arr, |
| 948 | + fm_rate_tau0_burst_vec) = cls.extract_polynomial_sequence(az_fm_rate_list, |
| 949 | + sensing_start, |
| 950 | + sensing_end) |
| 951 | + |
| 952 | + (dc_aztime_burst_vec, |
| 953 | + dc_coeff_burst_arr, |
| 954 | + dc_tau0_burst_vec) = cls.extract_polynomial_sequence(doppler_centroid_list, |
| 955 | + sensing_start, |
| 956 | + sensing_end) |
| 957 | + |
| 958 | + return cls(fm_rate_aztime_burst_vec, fm_rate_coeff_burst_arr, fm_rate_tau0_burst_vec, |
| 959 | + dc_aztime_burst_vec, dc_coeff_burst_arr, dc_tau0_burst_vec) |
| 960 | + |
| 961 | + |
| 962 | + @classmethod |
| 963 | + def extract_polynomial_sequence(cls, polynomial_list: list, |
| 964 | + datetime_start: datetime.datetime, |
| 965 | + datetime_end: datetime.datetime): |
| 966 | + ''' |
| 967 | + Scan `vec_azimuth_time` end find indices of the vector |
| 968 | + that covers the period defined with |
| 969 | + `datetime_start` and `datetime_end` |
| 970 | +
|
| 971 | + Parameters: |
| 972 | + ----------- |
| 973 | + polynomial_list: list |
| 974 | + list of (azimuth_time, isce3.core.Poly1d) |
| 975 | + datetime_start: datetime.datetime |
| 976 | + Start time of the period |
| 977 | + datetime_end: datetime.datetime |
| 978 | + end time of the period |
| 979 | +
|
| 980 | + Returns: |
| 981 | + -------- |
| 982 | + tuple |
| 983 | + Tuple of (vec_aztime_sequence, |
| 984 | + arr_coeff_sequence, |
| 985 | + vec_tau0_sequence) |
| 986 | + as a sequence of polynomial info that covers the period |
| 987 | + defined in the parameters. |
| 988 | + vec_aztime_sequence: azimuth time of each sample in the sequence |
| 989 | + arr_coeff_sequence: N by 3 npy array whose row is coefficients of |
| 990 | + each sample in the sequence |
| 991 | + vec_tau0_sequence: Range start time of each sample in the sequence |
| 992 | + ''' |
| 993 | + |
| 994 | + # NOTE: dt is defined as: [azimuth time] - [start/end time] |
| 995 | + # find index of poly time closest to start time that is less than start time |
| 996 | + dt_wrt_start = np.array([(poly[0] - datetime_start).total_seconds() for poly in polynomial_list]) |
| 997 | + dt_wrt_start = np.ma.masked_array(dt_wrt_start, mask=dt_wrt_start > 0) |
| 998 | + index_start = np.argmax(dt_wrt_start) |
| 999 | + |
| 1000 | + # find index of poly time closest to end time that is greater than end time |
| 1001 | + dt_wrt_end = np.array([(poly[0] - datetime_end).total_seconds() for poly in polynomial_list]) |
| 1002 | + dt_wrt_end = np.ma.masked_array(dt_wrt_end, mask=dt_wrt_end < 0) |
| 1003 | + index_end = np.argmin(dt_wrt_end) |
| 1004 | + |
| 1005 | + # Done extracting the IDs. Extract the polynomial sequence |
| 1006 | + vec_aztime_sequence = [] |
| 1007 | + arr_coeff_sequence = [] |
| 1008 | + vec_tau0_sequence = [] |
| 1009 | + |
| 1010 | + # Scale factor to convert range (in meters) to seconds (tau) |
| 1011 | + range_to_tau = 2.0 / speed_of_light |
| 1012 | + for poly in polynomial_list[index_start:index_end+1]: |
| 1013 | + vec_aztime_sequence.append(poly[0]) |
| 1014 | + arr_coeff_sequence.append(poly[1].coeffs) |
| 1015 | + vec_tau0_sequence.append(poly[1].mean * range_to_tau) |
| 1016 | + |
| 1017 | + return (np.array(vec_aztime_sequence), |
| 1018 | + np.array(arr_coeff_sequence), |
| 1019 | + np.array(vec_tau0_sequence)) |
0 commit comments