Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
else:
raise ValueError("Invalid dimension names for band data")
try:
scene[name] = (chn_data *
rootgrp.variables["scale"+str_res][i] +
rootgrp.variables["offset"+str_res][i])
#FIXME complete this
#scene[name].info
except KeyError:
# build the channel on the fly
from satpy.channel import Channel
wv_var = rootgrp.variables["nominal_wavelength"+str_res]
wb_var = rootgrp.variables[getattr(wv_var, "bounds")]
minmax = wb_var[i]
scene.channels.append(Channel(name,
resolution,
(minmax[0],
wv_var[i][0],
minmax[1])))
scene[name] = (chn_data *
rootgrp.variables["scale"+str_res][i] +
rootgrp.variables["offset"+str_res][i])
if area is not None:
scene[name].area = area
area = None
for attr in rootgrp.ncattrs():
scene.info[attr] = getattr(rootgrp, attr)
scene.add_to_history("Loaded from netcdf4/cf by satpy")
def __rdiv__(self, other):
return Channel(name="new", data=self.data / other)
for nbr, name in enumerate(names):
name = str(name)
try:
if cnt == 0:
chn_data = data[nbr, :, :].squeeze()
if cnt == 1:
chn_data = data[:, nbr, :].squeeze()
if cnt == 2:
chn_data = data[:, :, nbr].squeeze()
scene[name] = (np.ma.masked_equal(chn_data, data._FillValue)
* scales[nbr] + offsets[nbr])
scene[name].info["units"] = var.units
except KeyError:
from satpy.channel import Channel
scene.channels.append(Channel(name))
if area is not None:
scene[name].area = area
processed |= set([var_name, dim])
non_processed = set(rootgrp.variables.keys()) - processed
for var_name in non_processed:
var = rootgrp.variables[var_name]
if not (hasattr(var, "standard_name") or
hasattr(var, "long_name")):
LOG.info("Delayed processing of " + var_name)
continue
dims = var.dimensions
def __rpow__(self, other):
return Channel(name="new", data=self.data ** other)
def __rsub__(self, other):
return Channel(name="new", data=self.data - other)
def project(self, coverage_instance):
"""Make a projected copy of the current channel using the given
*coverage_instance*.
See also the :mod:`satpy.projector` module.
"""
res = Channel(name=self.name,
resolution=self.resolution,
wavelength_range=self.wavelength_range,
data=None,
calibration_unit=self.unit)
res.area = coverage_instance.out_area
res.info = self.info
if self.is_loaded():
LOG.info("Projecting channel %s (%fμm)..."
% (self.name, self.wavelength_range[1]))
data = coverage_instance.project_array(self._data)
res.data = data
return res
else:
raise NotLoadedError("Can't project, channel %s (%fμm) not loaded."
% (self.name, self.wavelength_range[1]))
def __mul__(self, other):
return Channel(name="new", data=self.data * other)
def __div__(self, other):
return Channel(name="new", data=self.data / other)