3 from .base
import Creator
6 from refractor
import framework
as rf
9 "Extracts the surface pressure value from the attached meterological file" 23 array_with_unit_fields = [
34 'spectral_coefficient',
37 def _as_list(self, accessor):
38 num_channels = self.
l1b().number_spectrometer
41 for chan_idx
in range(num_channels):
42 vals.append(accessor(chan_idx))
45 def _as_array(self, accessor):
46 return np.array(self.
_as_list(accessor))
48 def _as_array_with_unit(self, accessor):
50 num_channels = self.
l1b().number_spectrometer
54 for chan_idx
in range(num_channels):
55 chan_val = accessor(chan_idx)
56 vals.append(chan_val.value)
57 new_units = chan_val.units
58 if units !=
None and new_units.name != units.name:
59 raise param.ParamError(
"All units for L1B values must be the same to compact as an array")
63 val_arr = np.array(vals)
65 if len(val_arr.shape) == 1:
66 return rf.ArrayWithUnit_double_1(vals, units)
67 if len(val_arr.shape) == 2:
68 return rf.ArrayWithUnit_double_2(vals, units)
72 def create(self, channel_index=None, **kwargs):
74 field_val = getattr(self.
l1b(), self.
field(),
None)
79 if np.isscalar(field_val):
80 return np.full(1, field_val)
81 elif callable(field_val):
82 if channel_index
is not None:
83 return field_val(channel_index)
99 def create(self, channel_index=None, **kwargs):
115 orig_units = l1b.sounding_azimuth(0).units;
118 deg_units = rf.Unit(
"deg")
119 for chan_idx
in range(l1b.number_spectrometer):
120 val = (180 + l1b.sounding_azimuth(chan_idx).convert(deg_units).value) - \
121 l1b.solar_azimuth(chan_idx).convert(deg_units).value
128 rel_azm_vals.append(val)
130 return rf.ArrayWithUnit_double_1(rel_azm_vals, orig_units)
141 num_channels = l1b.number_spectrometer
143 solar_dist_vals = np.empty(num_channels)
144 solar_dist_units =
None 145 for chan_idx
in range(num_channels):
146 chan_doppler_shift = \
147 rf.SolarDopplerShiftPolynomial(l1b.time(chan_idx),
148 l1b.latitude(chan_idx),
149 l1b.solar_zenith(chan_idx),
150 l1b.solar_azimuth(chan_idx),
151 l1b.altitude(chan_idx),
154 chan_solar_dist = chan_doppler_shift.solar_distance
155 solar_dist_vals[chan_idx] = chan_solar_dist.value
156 solar_dist_units = chan_solar_dist.units
158 return rf.ArrayWithUnit_double_1(solar_dist_vals, solar_dist_units)
list array_with_unit_fields
def _as_array(self, accessor)
def _as_array_with_unit(self, accessor)
def create(self, channel_index=None, kwargs)
def create(self, channel_index=None, kwargs)
def _as_list(self, accessor)