Commit 0dc8fdb9 authored by Antoine Grouazel's avatar Antoine Grouazel

add doppler centroid variable in safegeotiff mapper

parent 4c489e49
......@@ -192,7 +192,7 @@ class SAFEGeoTiffFile(AbstractMapper):
'digital_number', 'gamma0_lut', 'beta0_lut', 'sigma0_lut',
'gamma0', 'beta0', 'sigma0', 'complex', 'azimuth_time',
'slant_range_time', 'doppler_centroid','sigma0_corrected','noise',
'gamma0_corrected','noise_linear_equivalent']
'gamma0_corrected','noise_linear_equivalent','doppler_centroid_quality']
def read_field_attributes(self, fieldname):
"""
......@@ -353,6 +353,10 @@ class SAFEGeoTiffFile(AbstractMapper):
description = 'doppler centroid'
units = 'Hz'
datatype = np.dtype(np.float32)
elif fieldname =='doppler_centroid_quality':
description = 'quality flag for doppler centroid estimates (RMS between fit and the 4 estimates in range 1 in azimuth)'
units = ''
datatype = np.dtype(np.bool)
else:
raise NotImplementedError
variable = Variable(shortname=shortname,
......@@ -407,7 +411,9 @@ class SAFEGeoTiffFile(AbstractMapper):
if isslice == False:
raise Exception('slices has to be a list of two slice objects')
slices = list(slices) # copy
for isl, dim in zip(range(2), dims.values()):
tmp = slices[isl].indices(dim)
(start, stop, step) = slices[isl].indices(dim)
slices[isl] = slice(start, stop, step)
# Read by blocks for memory issues
......@@ -685,8 +691,8 @@ class SAFEGeoTiffFile(AbstractMapper):
ky=ky)
# xint = self.read_values('azimuth_time', slices=slices)[:, 0]
# yint = self.read_values('slant_range_time', slices=slices)[0, :]
mid = (self._attributes['number_of_lines']/2,
self._attributes['number_of_samples']/2)
mid = (int(self._attributes['number_of_lines']/2),
int(self._attributes['number_of_samples']/2))
azislices = list(slices)
azislices[1] = slice(mid[1], mid[1]+1, 1)
xint = self.read_values('azimuth_time', slices=azislices)
......@@ -694,6 +700,8 @@ class SAFEGeoTiffFile(AbstractMapper):
ranslices[0] = slice(mid[0], mid[0]+1, 1)
yint = self.read_values('slant_range_time', slices=ranslices)
values = func(xint, yint).astype('float32')
elif fieldname == 'doppler_centroid_quality':
values = self._get_doppler_centroid_quality()
else:
raise NotImplementedError
return values
......@@ -789,6 +797,13 @@ class SAFEGeoTiffFile(AbstractMapper):
"""
return self._attributes['doppler_centroid_estimates']
def _get_doppler_centroid_quality( self ):
"""
:return:
"""
return self._attributes['doppler_centroid_estimate_quality']
def _get_lookup_tables(self):
"""
"""
......@@ -1152,6 +1167,23 @@ class SAFEGeoTiffFile(AbstractMapper):
dce['frequency'][iline, ipixel] = \
finedce.find('./frequency').text
dic['doppler_centroid_estimates'] = dce
dic['doppler_centroid_estimate_quality'] = self._fill_dopplercentroidqualityflag(pads,dic)
def _fill_dopplercentroidqualityflag( self,pads,dic ):
"""
to read the xml annotation file and get the value (bool) of the flag for the doppler centroid estimates
:param pads:
:param dic:
:return:
"""
ads = pads.findall('./qualityInformation/qualityDataList')
for toto in ads:
qdata = toto.find('./qualityData/dopplerCentroidQuality/dopplerCentroidUncertainFlag')
if qdata.text=='false':
qc_dce = False
else:
qc_dce = True
return qc_dce
#@staticmethod
def _fill_swathtiming(self, pads, dic):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment