def test_strip_atm_container_by_bandwidth(self): c = atm.AtmDataContainer(AtmModel.from_dataframe(pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: up.arange(0, 100, 10, dtype=np.float), settings.ATM_MODEL_DATAFRAME_WAVE: up.arange(10, dtype=np.float) })), 10, 10, 10) l_band, r_band = 3.1, 7.8 result = atm.strip_atm_container_by_bandwidth(c, l_band, r_band) expected_df = pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: [31, 40, 50, 60, 70, 78], settings.ATM_MODEL_DATAFRAME_WAVE: [3.1, 4., 5., 6., 7., 7.8] }) assert_frame_equal(expected_df, result.model.to_dataframe(), check_dtype=False) # global is set but right and left are valid for given model gl_band, gr_band = 4.0, 6.5 result = atm.strip_atm_container_by_bandwidth(c, l_band, r_band, global_left=gl_band, global_right=gr_band) assert_frame_equal(expected_df, result.model.to_dataframe(), check_dtype=False) # global is set l_band, r_band = -1, 10000 gl_band, gr_band = 4.0, 6.5 result = atm.strip_atm_container_by_bandwidth(c, l_band, r_band, global_left=gl_band, global_right=gr_band) expected_df = pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: [40, 50, 60, 65], settings.ATM_MODEL_DATAFRAME_WAVE: [4, 5., 6, 6.5] }) assert_frame_equal(expected_df, result.model.to_dataframe(), check_dtype=False)
def test_phase_crv_symmetry(self): phase = up.arange(0, 1.2, 0.2) obtained = dynamic.phase_crv_symmetry(MockSelf, phase) expected = np.array([0, 0.2, 0.4]), np.array([0, 1, 2, 2, 1, 0], dtype=int) self.assertTrue(np.all(obtained[0] == expected[0])) self.assertTrue(np.all(obtained[1] == expected[1])) # is imutable??? self.assertTrue(np.all(up.arange(0, 1.2, 0.2) == phase))
def test_extend_atm_container_on_bandwidth_boundary(self): c = atm.AtmDataContainer(AtmModel.from_dataframe(pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: up.arange(0, 100, 10, dtype=np.float), settings.ATM_MODEL_DATAFRAME_WAVE: up.arange(10, dtype=np.float) })), 10, 10, 10) l_band, r_band = 0.4, 8.8 result = atm.extend_atm_container_on_bandwidth_boundary(c, l_band, r_band).\ model.to_dataframe().sort_index(axis=1) expected = pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_WAVE: [0.4] + list(range(1, 9, 1)) + [8.8], settings.ATM_MODEL_DATAFRAME_FLUX: [4] + list(range(10, 90, 10)) + [88] }).sort_index(axis=1) assert_frame_equal(result, expected, check_dtype=False)
def test_BinarySystem_phase_interval_reduce_has_pulsation(self): s1 = SingleSystemMock(p=True, s=True) s2 = SingleSystemMock(p=True, s=False) o1 = Observer(self._passband, s1) o2 = Observer(self._passband, s2) o1._system_cls = SingleSystem o2._system_cls = SingleSystem phases = np.array([ -0.1, 0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 3.5 ]) obtained_ph1, obtained_ri1 = o1.phase_interval_reduce(phases) obtained_ph2, obtained_ri2 = o2.phase_interval_reduce(phases) expected_ph = phases expected_ri = up.arange(0, 14, 1) assert_array_equal(np.round(expected_ph, 2), np.round(obtained_ph1, 2)) assert_array_equal(np.round(expected_ph, 2), np.round(obtained_ph2, 2)) assert_array_equal(expected_ri, obtained_ri1) assert_array_equal(expected_ri, obtained_ri2) expected_phases = np.array(phases) obtained_phases1 = obtained_ph1[obtained_ri1] obtained_phases2 = obtained_ph2[obtained_ri2] assert_array_equal(np.round(expected_phases, 2), np.round(obtained_phases1, 2)) assert_array_equal(np.round(expected_phases, 2), np.round(obtained_phases2, 2))
def test_apply_passband(self): atmc = atm.AtmDataContainer(AtmModel.from_dataframe(pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: up.arange(10, dtype=np.float), settings.ATM_MODEL_DATAFRAME_WAVE: up.arange(0, 100, 10, dtype=np.float) })), 0, 0, 0) bandc = PassbandContainer( pd.DataFrame({ settings.PASSBAND_DATAFRAME_THROUGHPUT: [0.2, 1.0, 0.2, 0.2, 0.4], settings.PASSBAND_DATAFRAME_WAVE: [1, 10, 25, 40, 50] }), passband="bandc" ) passband = dict(bandc=bandc) obtained = np.round(atm.apply_passband([atmc], passband)["bandc"][0].model.to_dataframe(), 4) expected = pd.DataFrame({ settings.ATM_MODEL_DATAFRAME_FLUX: [0.02, 1., 0.8117, 0.5077, 0.8, 2.], settings.ATM_MODEL_DATAFRAME_WAVE: [1., 10., 20., 30., 40., 50.] }) assert_frame_equal(expected, obtained, check_dtype=False)
def test_BinarySystem_phase_interval_reduce_has_pulsation_and_no_spots( self): s = BinarySystemMock(pp=False, sp=True) o = Observer(self._passband, s) o._system_cls = BinarySystem phases = np.array([ -0.1, 0.0, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 3.5 ]) obtained_ph, obtained_ri = o.phase_interval_reduce(phases) expected_ph = phases expected_ri = up.arange(0, 14, 1) assert_array_equal(np.round(expected_ph, 2), np.round(obtained_ph, 2)) assert_array_equal(expected_ri, obtained_ri) expected_phases = np.array(phases) obtained_phases = obtained_ph[obtained_ri] assert_array_equal(np.round(expected_phases, 2), np.round(obtained_phases, 2))
def setUp(self): super(BinaryRadialCurvesTestCase, self).setUp() self.phases = up.arange(-0.2, 1.25, 0.05)
def setUp(self): super(RadialVelocityObserverTestCase, self).setUp() self.phases = up.arange(-0.2, 1.25, 0.05)