@@ -120,19 +120,13 @@ def test_compute_aperture_photometry():
120120@pytest .mark .remote_data
121121def test_poscorr_smooth ():
122122 machine = TPFMachine .from_TPFs (tpfs , apply_focus_mask = False )
123- machine ._get_source_mask ()
124- machine .poscorr_filter_size = 0.4
125- (
126- time_original ,
127- time_binned ,
128- flux_binned_raw ,
129- flux_binned ,
130- flux_err_binned ,
131- poscorr1_smooth ,
132- poscorr2_smooth ,
133- poscorr1_binned ,
134- poscorr2_binned ,
135- ) = machine ._time_bin (npoints = 3 )
123+ machine .build_shape_model (plot = False )
124+ # no segments
125+ machine .time_corrector = "pos_corr"
126+ machine .poscorr_filter_size = 1
127+ machine .build_time_model (
128+ split_time_segments = False , bin_method = "bin" , focus_component = False
129+ )
136130
137131 median_pc1 = np .nanmedian (machine .pos_corr1 , axis = 0 )
138132 median_pc2 = np .nanmedian (machine .pos_corr2 , axis = 0 )
@@ -143,24 +137,29 @@ def test_poscorr_smooth():
143137 median_pc2 .max () - median_pc2 .mean ()
144138 )
145139
146- assert np . isclose ( poscorr1_smooth , median_pc1 , atol = 1e-3 ). all ()
147- assert np . isclose ( poscorr2_smooth , median_pc2 , atol = 1e-3 ). all ()
140+ assert (( machine . P3 . other_vectors [:, 0 ] - median_pc1 ) ** 2 ). sum () ** 0.5 < 1
141+ assert (( machine . P3 . other_vectors [:, 1 ] - median_pc2 ) ** 2 ). sum () ** 0.5 < 1
148142
149143
150144@pytest .mark .remote_data
151145def test_segment_time_model ():
152146 # testing segment with the current test dataset we have that only has 10 cadences
153147 # isn't the best, but we can still do some sanity checks.
154- machine = TPFMachine .from_TPFs (tpfs , apply_focus_mask = False , n_time_points = 3 )
148+ machine = TPFMachine .from_TPFs (
149+ tpfs , apply_focus_mask = False , n_time_points = 3 , time_corrector = "polynomial"
150+ )
155151 machine .build_shape_model (plot = False )
156152 # no segments
157- machine .build_time_model (split_time_model = False , downsample = True )
158- assert machine .time_model_w .shape [0 ] == machine .seg_splits .shape [0 ] - 1
159- assert machine .time_model_w .shape [0 ] == machine ._time_masked .shape [0 ]
153+ machine .build_time_model (
154+ split_time_segments = False , bin_method = "bin" , focus_component = False
155+ )
156+ assert machine .P3 .vectors .shape == (10 , 4 )
160157
161- # need tighter knot spacing
162- machine .n_time_points = 2
158+ # fake 2 time breaks
159+ machine .time [4 :] += 0.5
160+ machine .time [7 :] += 0.41
163161 # user defined segments
164- machine .build_time_model (split_time_model = [5 ], downsample = True )
165- assert machine .time_model_w .shape [0 ] == machine .seg_splits .shape [0 ] - 1
166- assert machine .time_model_w .shape [0 ] == machine ._time_masked .shape [0 ]
162+ machine .build_time_model (
163+ split_time_segments = True , bin_method = "bin" , focus_component = False
164+ )
165+ assert machine .P3 .vectors .shape == (10 , 4 * 3 )
0 commit comments