@@ -80,7 +80,7 @@ def open_calibration_dataset(
80
80
cal_attrs = esa_safe .parse_tag (
81
81
calibration , ".//calibrationInformation" , "calibration"
82
82
)
83
- attrs ["absolute_calibration_constant " ] = cal_attrs ["absoluteCalibrationConstant" ]
83
+ attrs ["absoluteCalibrationConstant " ] = cal_attrs ["absoluteCalibrationConstant" ]
84
84
azimuth_time_list = []
85
85
pixel_list = []
86
86
line_list = []
@@ -111,8 +111,8 @@ def open_calibration_dataset(
111
111
)
112
112
data_vars = {
113
113
"azimuth_time" : ("line" , [np .datetime64 (dt , "ns" ) for dt in azimuth_time_list ]),
114
- "sigma_nought " : (("line" , "pixel" ), sigmaNought_list ),
115
- "beta_nought " : (("line" , "pixel" ), betaNought_list ),
114
+ "sigmaNought " : (("line" , "pixel" ), sigmaNought_list ),
115
+ "betaNought " : (("line" , "pixel" ), betaNought_list ),
116
116
"gamma" : (("line" , "pixel" ), gamma_list ),
117
117
"dn" : (("line" , "pixel" ), dn_list ),
118
118
}
@@ -122,39 +122,42 @@ def open_calibration_dataset(
122
122
123
123
124
124
def open_reference_replica_dataset (
125
- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
125
+ annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
126
126
) -> xr .Dataset :
127
127
reference_replica = esa_safe .parse_tag_as_list (
128
128
annotation_path , ".//replicaInformationList/replicaInformation/referenceReplica"
129
129
)[0 ]
130
- attrs .update ({
131
- "azimuth_time" : reference_replica ["azimuthTime" ],
132
- "chirp_source" : reference_replica ["chirpSource" ],
133
- "pg_source" : reference_replica ["pgSource" ],
134
- "time_delay" : reference_replica ["timeDelay" ],
135
- "gain" : reference_replica ["gain" ],
136
- })
130
+ attrs .update (
131
+ {
132
+ "azimuth_time" : reference_replica ["azimuthTime" ],
133
+ "chirpSource" : reference_replica ["chirpSource" ],
134
+ "pgSource" : reference_replica ["pgSource" ],
135
+ "timeDelay" : reference_replica ["timeDelay" ],
136
+ "gain" : reference_replica ["gain" ],
137
+ }
138
+ )
137
139
138
- reference_replica_amplitude_coefficients = [float (v ) for v in
139
- reference_replica ["amplitudeCoefficients" ]["$" ].split ()]
140
+ reference_replica_amplitude_coefficients = [
141
+ float (v ) for v in reference_replica ["amplitudeCoefficients" ]["$" ].split ()
142
+ ]
140
143
141
- reference_replica_phase_coefficients = [float (v ) for v in reference_replica ["phaseCoefficients" ]["$" ].split ()]
144
+ reference_replica_phase_coefficients = [
145
+ float (v ) for v in reference_replica ["phaseCoefficients" ]["$" ].split ()
146
+ ]
142
147
143
148
coords : Dict [str , Any ] = {
144
149
"degree" : range (len (reference_replica_amplitude_coefficients ))
145
150
}
146
151
data_vars = {
147
- "reference_replica_amplitude_coefficients" : (
148
- ("degree" ), reference_replica_amplitude_coefficients ),
149
- "reference_replica_phase_coefficients" : (
150
- ("degree" ), reference_replica_phase_coefficients )
152
+ "amplitudeCoefficients" : (("degree" ), reference_replica_amplitude_coefficients ),
153
+ "phaseCoefficients" : (("degree" ), reference_replica_phase_coefficients ),
151
154
}
152
155
da = xr .Dataset (data_vars = data_vars , coords = coords , attrs = attrs )
153
156
return da
154
157
155
158
156
159
def open_antenna_pattern (
157
- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
160
+ annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
158
161
) -> xr .Dataset :
159
162
antenna_pattern_list = esa_safe .parse_tag_as_list (
160
163
annotation_path , ".//antennaPattern/antennaPatternList/antennaPattern"
@@ -170,18 +173,26 @@ def open_antenna_pattern(
170
173
171
174
for vector in antenna_pattern_list :
172
175
azimuth_time_list .append (vector ["azimuthTime" ])
173
- slant_range_time = np .fromstring (vector ["slantRangeTime" ]["$" ], dtype = np .float32 , sep = " " )
176
+ slant_range_time = np .fromstring (
177
+ vector ["slantRangeTime" ]["$" ], dtype = np .float32 , sep = " "
178
+ )
174
179
slant_range_time_list .append (slant_range_time )
175
180
176
- elevation_angle = np .fromstring (vector ["elevationAngle" ]["$" ], dtype = np .float32 , sep = " " )
181
+ elevation_angle = np .fromstring (
182
+ vector ["elevationAngle" ]["$" ], dtype = np .float32 , sep = " "
183
+ )
177
184
elevation_angle_list .append (elevation_angle )
178
185
179
- elevation_pattern = np .fromstring (vector ["elevationPattern" ]["$" ], dtype = np .float32 , sep = " " )
186
+ elevation_pattern = np .fromstring (
187
+ vector ["elevationPattern" ]["$" ], dtype = np .float32 , sep = " "
188
+ )
180
189
elevation_pattern_list .append (
181
190
elevation_pattern [::2 ] * 1j + elevation_pattern [1 ::2 ]
182
191
)
183
192
184
- incidence_angle = np .fromstring (vector ["slantRangeTime" ]["$" ], dtype = np .float32 , sep = " " )
193
+ incidence_angle = np .fromstring (
194
+ vector ["incidenceAngle" ]["$" ], dtype = np .float32 , sep = " "
195
+ )
185
196
incidence_angle_list .append (incidence_angle )
186
197
187
198
terrain_height_list .append (vector ["terrainHeight" ])
@@ -193,25 +204,33 @@ def open_antenna_pattern(
193
204
"Unable to organise noise vectors in a regular line-pixel grid"
194
205
)
195
206
data_vars = {
196
- "elevation_angle" : (
197
- ("azimuth_time" , "slant_range_time" ), np .array (elevation_angle_list )),
198
- # "elevation_pattern": (
207
+ "elevationAngle" : (
208
+ ("azimuth_time" , "slant_range_time" ),
209
+ np .array (elevation_angle_list ),
210
+ ),
211
+ # "elevationPattern": (
199
212
# ( "azimuth_time", "slant_range_time"), np.array(elevation_pattern_list)),
200
- "incidence_angle" : (
201
- ( "azimuth_time" , "slant_range_time" ), np .array (incidence_angle_list )),
202
- "terrain_height" : ("azimuth_time" , terrain_height_list ),
213
+ "incidenceAngle" : (
214
+ ("azimuth_time" , "slant_range_time" ),
215
+ np .array (incidence_angle_list ),
216
+ ),
217
+ "terrainHeight" : ("azimuth_time" , terrain_height_list ),
203
218
"roll" : ("azimuth_time" , roll_list ),
204
219
}
205
- coords = {"slant_range_time" : slant_range_time_list [0 ], "azimuth_time" : [np .datetime64 (dt , "ns" ) for dt in azimuth_time_list ]}
220
+ coords = {
221
+ "slant_range_time" : slant_range_time_list [0 ],
222
+ "azimuth_time" : [np .datetime64 (dt , "ns" ) for dt in azimuth_time_list ],
223
+ }
206
224
da = xr .Dataset (data_vars = data_vars , coords = coords , attrs = attrs )
207
225
return da
208
226
209
227
210
228
def open_replica_dataset (
211
- annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
229
+ annotation_path : esa_safe .PathType , attrs : Dict [str , Any ] = {}
212
230
) -> xr .Dataset :
213
231
replicaList = esa_safe .parse_tag_as_list (
214
- annotation_path , ".//replicaInformationList/replicaInformation/replicaList/replica"
232
+ annotation_path ,
233
+ ".//replicaInformationList/replicaInformation/replicaList/replica" ,
215
234
)
216
235
azimuth_time_list = []
217
236
cross_correlation_bandwidth_list = []
@@ -230,32 +249,54 @@ def open_replica_dataset(
230
249
azimuth_time_list .append (replica ["azimuthTime" ])
231
250
cross_correlation_bandwidth_list .append (replica ["crossCorrelationBandwidth" ])
232
251
cross_correlation_pslr_list .append (replica ["crossCorrelationPslr" ])
233
- cross_correlation_peak_location_list .append (replica ["crossCorrelationPeakLocation" ])
234
- reconstructed_replica_valid_flag_list .append (replica ["reconstructedReplicaValidFlag" ])
252
+ cross_correlation_peak_location_list .append (
253
+ replica ["crossCorrelationPeakLocation" ]
254
+ )
255
+ reconstructed_replica_valid_flag_list .append (
256
+ replica ["reconstructedReplicaValidFlag" ]
257
+ )
235
258
pg_product_amplitude_list .append (replica ["pgProductAmplitude" ])
236
259
pg_product_phase_list .append (replica ["pgProductPhase" ])
237
260
model_pg_product_amplitude_list .append (replica ["modelPgProductAmplitude" ])
238
261
model_pg_product_phase_list .append (replica ["modelPgProductPhase" ])
239
- relative_pg_product_valid_flag_list .append (replica ["relativePgProductValidFlag" ])
240
- absolute_pg_product_valid_flag_list .append (replica ["absolutePgProductValidFlag" ])
262
+ relative_pg_product_valid_flag_list .append (
263
+ replica ["relativePgProductValidFlag" ]
264
+ )
265
+ absolute_pg_product_valid_flag_list .append (
266
+ replica ["absolutePgProductValidFlag" ]
267
+ )
241
268
internal_time_delay_list .append (replica ["internalTimeDelay" ])
242
269
243
270
coords : Dict [str , Any ] = {
244
271
"azimuth_time" : [np .datetime64 (dt , "ns" ) for dt in azimuth_time_list ],
245
272
}
246
273
data_vars = {
247
- "cross_correlation_bandwidth" : (("azimuth_time" ), cross_correlation_bandwidth_list ),
248
- "cross_correlation_pslr" : (("azimuth_time" ), cross_correlation_pslr_list ),
249
- "cross_correlation_peak_location" : (("azimuth_time" ), cross_correlation_peak_location_list ),
250
- "reconstructed_replica_valid_flag" : (("azimuth_time" ), reconstructed_replica_valid_flag_list ),
251
- "pg_product_amplitude" : (("azimuth_time" ), pg_product_amplitude_list ),
252
- "pg_product_phase" : (("azimuth_time" ), pg_product_phase_list ),
253
- "model_pg_product_amplitude" : (("azimuth_time" ), model_pg_product_amplitude_list ),
254
- "model_pg_product_phase" : (("azimuth_time" ), model_pg_product_phase_list ),
255
- "relative_pg_product_valid_flag" : (("azimuth_time" ), relative_pg_product_valid_flag_list ),
256
- "absolute_pg_product_valid_flag" : (("azimuth_time" ), absolute_pg_product_valid_flag_list ),
257
- "internal_time_delay" : (("azimuth_time" ), internal_time_delay_list ),
258
-
274
+ "crossCorrelationBandwidth" : (
275
+ ("azimuth_time" ),
276
+ cross_correlation_bandwidth_list ,
277
+ ),
278
+ "crossCorrelationPslr" : (("azimuth_time" ), cross_correlation_pslr_list ),
279
+ "crossCorrelationPeakLocation" : (
280
+ ("azimuth_time" ),
281
+ cross_correlation_peak_location_list ,
282
+ ),
283
+ "reconstructedReplicaValidFlag" : (
284
+ ("azimuth_time" ),
285
+ reconstructed_replica_valid_flag_list ,
286
+ ),
287
+ "pgProductAmplitude" : (("azimuth_time" ), pg_product_amplitude_list ),
288
+ "pgProductPhase" : (("azimuth_time" ), pg_product_phase_list ),
289
+ "modelPgProductAmplitude" : (("azimuth_time" ), model_pg_product_amplitude_list ),
290
+ "modelPgProductPhase" : (("azimuth_time" ), model_pg_product_phase_list ),
291
+ "relativePgProductValidFlag" : (
292
+ ("azimuth_time" ),
293
+ relative_pg_product_valid_flag_list ,
294
+ ),
295
+ "absolutePgProductValidFlag" : (
296
+ ("azimuth_time" ),
297
+ absolute_pg_product_valid_flag_list ,
298
+ ),
299
+ "internalTimeDelay" : (("azimuth_time" ), internal_time_delay_list ),
259
300
}
260
301
261
302
da = xr .Dataset (data_vars = data_vars , coords = coords , attrs = attrs )
@@ -316,7 +357,7 @@ def open_noise_azimuth_dataset(
316
357
data_vars = {}
317
358
coords = {}
318
359
if first_range_sample :
319
- data_vars ["noise_azimuth_lut " ] = ("line" , noise_azimuth_lut_list [0 ])
360
+ data_vars ["noiseAzimuthLut " ] = ("line" , noise_azimuth_lut_list [0 ])
320
361
coords ["line" ] = line_list [0 ]
321
362
322
363
return xr .Dataset (data_vars = data_vars , coords = coords , attrs = attrs )
@@ -675,9 +716,9 @@ def find_available_groups(
675
716
"gcp" ,
676
717
"replica" ,
677
718
"reference_replica" ,
678
- "antenna_pattern"
719
+ "antenna_pattern" ,
679
720
]:
680
- if product_type == "GRD" and metadata_group == "antenna_pattern" :
721
+ if product_type == "GRD" and metadata_group == "antenna_pattern" :
681
722
continue
682
723
groups [f"{ swath_pol_group } /{ metadata_group } " ] = [abspath ]
683
724
if product_type == "GRD" :
0 commit comments