Skip to content

Commit a9d6a1c

Browse files
authored
Merge pull request #18 from umr-lops/noise_range_issue17
add azimuthTime variable for range noise LUT as variable
2 parents 3ce7158 + 428a561 commit a9d6a1c

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

safe_s1/sentinel1_xml_mappings.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ def or_ipf28(xpath):
118118
return xpath
119119

120120

121+
121122
def list_poly_from_list_string_coords(str_coords_list):
122123
footprints = []
123124
for gmlpoly in str_coords_list:
@@ -187,7 +188,8 @@ def list_poly_from_list_string_coords(str_coords_list):
187188
'sample': (int_1Darray_from_string, '//calibration/calibrationVectorList/calibrationVector[1]/pixel'),
188189
'sigma0_lut': (
189190
float_2Darray_from_string_list, '//calibration/calibrationVectorList/calibrationVector/sigmaNought'),
190-
'gamma0_lut': (float_2Darray_from_string_list, '//calibration/calibrationVectorList/calibrationVector/gamma')
191+
'gamma0_lut': (float_2Darray_from_string_list, '//calibration/calibrationVectorList/calibrationVector/gamma'),
192+
'azimuthTime': (datetime64_array, '/calibration/calibrationVectorList/calibrationVector/azimuthTime')
191193
},
192194
'noise': {
193195
'mode': (scalar, '/noise/adsHeader/mode'),
@@ -198,7 +200,8 @@ def list_poly_from_list_string_coords(str_coords_list):
198200
or_ipf28('/noise/noiseRangeVectorList/noiseRangeVector/pixel')),
199201
'noiseLut': (
200202
lambda x: [np.fromstring(s, dtype=float, sep=' ') for s in x],
201-
or_ipf28('/noise/noiseRangeVectorList/noiseRangeVector/noiseRangeLut'))
203+
or_ipf28('/noise/noiseRangeVectorList/noiseRangeVector/noiseRangeLut')),
204+
'azimuthTime': (datetime64_array, '/noise/noiseRangeVectorList/noiseRangeVector/azimuthTime')
202205
},
203206
'azi': {
204207
'swath': '/noise/noiseAzimuthVectorList/noiseAzimuthVector/swath',
@@ -309,17 +312,19 @@ def list_poly_from_list_string_coords(str_coords_list):
309312
}
310313

311314

312-
def signal_lut_raw(line, sample, lut_sigma0, lut_gamma0):
315+
def signal_lut_raw(line, sample, lut_sigma0, lut_gamma0,azimuth_times):
313316
ds = xr.Dataset()
314317
ds['sigma0_lut'] = xr.DataArray(lut_sigma0, dims=['line', 'sample'], coords={'line': line, 'sample': sample},
315318
name='sigma0', attrs={'description': 'look up table sigma0'})
316319
ds['gamma0_lut'] = xr.DataArray(lut_gamma0, dims=['line', 'sample'], coords={'line': line, 'sample': sample},
317320
name='gamma0', attrs={'description': 'look up table gamma0'})
321+
ds['azimuthTime'] = xr.DataArray(azimuth_times, dims=['line'],coords={'line': line},
322+
attrs={'description': 'azimuth times associated to the signal look up table'})
318323

319324
return ds
320325

321326

322-
def noise_lut_range_raw(lines, samples, noiseLuts):
327+
def noise_lut_range_raw(lines, samples, noiseLuts, azimuthTimes):
323328
"""
324329
325330
Parameters
@@ -330,6 +335,8 @@ def noise_lut_range_raw(lines, samples, noiseLuts):
330335
arrays of samples. list length is same as samples. each array define samples where lut is defined
331336
noiseLuts: list of np.ndarray
332337
arrays of luts. Same structure as samples.
338+
azimuthTimes: np.ndarray
339+
1D array of azimuth dates associated to each lines of the noise range grid
333340
334341
Returns
335342
-------
@@ -351,6 +358,10 @@ def noise_lut_range_raw(lines, samples, noiseLuts):
351358
ds['noise_lut'] = xr.DataArray(tmp_noise,
352359
coords={'line': lines, 'sample': samples[0][0:minimum_pts]},
353360
dims=['line', 'sample'])
361+
try:
362+
ds['azimuthTime'] = xr.DataArray(azimuthTimes,coords={'line': lines},dims=['line'])
363+
except: #for IPF2.72 for instance there is no azimuthTimes associated to the noise range LUT
364+
ds['azimuthTime'] = xr.DataArray(np.ones(len(lines))*np.nan, coords={'line': lines}, dims=['line'])
354365
# ds['sample'] = xr.DataArray(np.stack(normalized_samples), coords={'lines': lines, 'sample_index': np.arange(minimum_pts)},
355366
# dims=['lines', 'sample_index'])
356367

@@ -749,11 +760,12 @@ def geolocation_grid(line, sample, values):
749760
},
750761
'luts_raw': {
751762
'func': signal_lut_raw,
752-
'args': ('calibration.line', 'calibration.sample', 'calibration.sigma0_lut', 'calibration.gamma0_lut')
763+
'args': ('calibration.line', 'calibration.sample', 'calibration.sigma0_lut', 'calibration.gamma0_lut',
764+
'calibration.azimuthTime')
753765
},
754766
'noise_lut_range_raw': {
755767
'func': noise_lut_range_raw,
756-
'args': ('noise.range.line', 'noise.range.sample', 'noise.range.noiseLut')
768+
'args': ('noise.range.line', 'noise.range.sample', 'noise.range.noiseLut', 'noise.range.azimuthTime')
757769
},
758770
'noise_lut_azi_raw_grd': {
759771
'func': noise_lut_azi_raw_grd,

0 commit comments

Comments
 (0)