Esempio n. 1
0
    def __init__(self, time_domain: u.Quantity, flux_array: u.Quantity,
                 int_time: u.Quantity, read_time: u.Quantity, frame_sum: int):
        self._time_domain_lw = time_domain.to('s').value
        self._time_domain = time_domain.copy()
        self._flux_array = flux_array.copy()
        self._flux_array_lw = self._flux_array.to('ct').value
        self._int_time = int_time.copy()
        self._int_time_lw = int_time.to('s').value
        self._read_time = read_time.copy()
        self._read_time_lw = read_time.to('s').value
        self._frame_cadence = self._int_time + self._read_time
        self._frame_cadence_lw = self._frame_cadence.to('s').value
        self._data_cadence = self._frame_cadence * frame_sum
        self._data_cadence_lw = self._frame_cadence_lw * frame_sum
        self._frame_sum = frame_sum
        self._bounds = [
            (1, np.inf),  # amplitude, in counts
            (1E-1, np.inf),  # rise time
            (1E-2, np.inf),  # decay const
            (self._time_domain_lw[0], self._time_domain_lw[-1])
        ]  # flare time

        if np.abs((self._time_domain[1] - self._time_domain[0]) -
                  self._data_cadence).to(u.s).value > 1E-6:
            raise AttributeError(
                "Time domain and cadence do not match within tolerance: "
                "\nCadence: ", self._data_cadence, "\ndt",
                self._time_domain[1] - self._time_domain[0])
Esempio n. 2
0
def theta_range(theta: units.Quantity):
    theta = check_iterable(theta.copy())
    theta = units.Quantity(theta)

    theta[theta > 90 * units.deg] -= 180 * units.deg
    theta[theta < -90 * units.deg] += 180 * units.deg

    return theta
Esempio n. 3
0
 def __init__(self,
              min_frequency: u.Quantity, max_frequency: u.Quantity,
              coeffs: u.Quantity, frequency_unit: u.Unit,
              correlator_efficiency: float) -> None:
     self.min_frequency = min_frequency
     self.max_frequency = max_frequency
     self._coeffs = coeffs.copy()
     self._frequency_unit = frequency_unit
     self.correlator_efficiency = correlator_efficiency
Esempio n. 4
0
 def test_inplace_conversion(self):
     q_pv = Quantity(self.pv, self.pv_unit)
     q1 = q_pv.copy()
     q_link = q1
     q1 <<= StructuredUnit(('AU', 'AU/day'))
     assert q1 is q_link
     assert q1['p'].unit == u.AU
     assert q1['v'].unit == u.AU / u.day
     assert np.all(q1['p'] == q_pv['p'].to(u.AU))
     assert np.all(q1['v'] == q_pv['v'].to(u.AU/u.day))
     q_pv_t = Quantity(self.pv_t, self.pv_t_unit)
     q2 = q_pv_t.copy()
     q_link = q2
     q2 <<= '(kpc,kpc/Myr),Myr'
     assert q2 is q_link
     assert q2['pv']['p'].unit == u.kpc
     assert q2['pv']['v'].unit == u.kpc / u.Myr
     assert q2['t'].unit == u.Myr
     assert np.all(q2['pv']['p'] == q_pv_t['pv']['p'].to(u.kpc))
     assert np.all(q2['pv']['v'] == q_pv_t['pv']['v'].to(u.kpc/u.Myr))
     assert np.all(q2['t'] == q_pv_t['t'].to(u.Myr))