Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def elevation_range(self):
"""Return the elevation range of this dataset."""
if self._elevation_range is None:
startel = self._obj.attrs['startelA']
stopel = self._obj.attrs['stopelA']
elevation_data = (startel + stopel) / 2.
da = xr.DataArray(elevation_data, dims=['dim_0'], attrs=el_attrs)
self._elevation_range = da
return self._elevation_range
def azimuth_range(self):
"""Return the azimuth range of this dataset."""
if self._azimuth_range is None:
startaz = self._obj.attrs['startazA']
stopaz = self._obj.attrs['stopazA']
zero_index = np.where(stopaz < startaz)
stopaz[zero_index[0]] += 360
azimuth_data = (startaz + stopaz) / 2.
da = xr.DataArray(azimuth_data, attrs=az_attrs)
self._azimuth_range = da
return self._azimuth_range
def time_range(self):
"""Return the time range of this dataset."""
if self._time_range is None:
times = self._obj['timestamp'] / 1e6
attrs = {'units': 'seconds since 1970-01-01T00:00:00Z',
'standard_name': 'time'}
da = xr.DataArray(times, attrs=attrs)
self._time_range = da
return self._time_range
def elevation_range2(self):
"""Return the elevation range of this dataset."""
if self._elevation_range is None:
nrays = self._obj.attrs['nrays']
elangle = self._obj.attrs['elangle']
elevation_data = np.ones(nrays, dtype='float32') * elangle
da = xr.DataArray(elevation_data, dims=['dim_0'], attrs=el_attrs)
self._elevation_range = da
return self._elevation_range
def prt(self):
if self._prt is None:
try:
prt = 1. / self._obj.attrs['prf']
da = xr.DataArray(prt, dims=['dim_0'])
self._prt = da
except KeyError:
pass
return self._prt
def azimuth_range2(self):
"""Return the azimuth range of this dataset."""
if self._azimuth_range is None:
nrays = self._obj.attrs['nrays']
res = 360. / nrays
azimuth_data = np.arange(res / 2.,
360.,
res,
dtype='float32')
da = xr.DataArray(azimuth_data, dims=['dim_0'], attrs=az_attrs)
self._azimuth_range = da
return self._azimuth_range