def __init__(self, x_start: u.Quantity, y_start: u.Quantity, x_step: u.Quantity, y_step: u.Quantity, frequency: u.Quantity, samples: np.ndarray, *, band: str, antenna: Optional[str] = None, receiver: Optional[str] = None) -> None: super().__init__() # Canonicalise the units to simplify to_hdf5 (and also remove the # cost of conversions when methods are called with canonical units, # with a side benefit of failing hard if the wrong units are # provided). self.x_start = x_start.to(u.m) self.y_start = y_start.to(u.m) self.x_step = x_step.to(u.m) self.y_step = y_step.to(u.m) self.frequency = frequency.astype(np.float32, copy=False, casting='same_kind') if len(frequency) > 1: self._frequency_resolution = np.min(np.diff(frequency)) if self._frequency_resolution <= 0 * u.Hz: raise ValueError('frequencies must be strictly increasing') else: # We can set _frequency_resolution easily enough, but # scipy.interpolate also refuses to work with just a single (or zero) # elements on the interpolation axis. raise NotImplementedError( 'at least 2 frequencies are currently required') self.samples = samples.astype(np.complex64, copy=False, casting='same_kind') scale = samples.shape[-1] * samples.shape[-2] # Normalisation factor self._interp_samples = scipy.interpolate.interp1d( self.frequency.to_value(u.Hz), self.samples / scale, axis=0, copy=False, bounds_error=False, fill_value=np.nan, assume_sorted=True) self._antenna = antenna self._receiver = receiver self._band = band
def __init__(self, frequency: u.Quantity, coefs: Tuple[ArrayLike, ArrayLike], correlator_efficiency: Optional[float], *, band: str, antenna: Optional[str] = None, receiver: Optional[str] = None) -> None: super().__init__() self.frequency = frequency.astype(np.float32, copy=False, casting='same_kind') if len(frequency) > 1: self._frequency_resolution = np.min(np.diff(frequency)) if self._frequency_resolution <= 0 * u.Hz: raise ValueError('frequencies must be strictly increasing') else: raise NotImplementedError('at least 2 frequencies are currently required') self.coefs = coefs if correlator_efficiency is not None: self._correlator_efficiency = correlator_efficiency else: self._correlator_efficiency = 1.0 self._band = band self._antenna = antenna self._receiver = receiver