diff --git a/tessilator/tessilator.py b/tessilator/tessilator.py index fc38298..09ca572 100644 --- a/tessilator/tessilator.py +++ b/tessilator/tessilator.py @@ -1,8 +1,8 @@ """ -Alexander Binks', r'Moritz Guenther, 2024 +Alexander Binks, Moritz Guenther, 2024 -Licence: MIT 2024 +License: MIT 2024 The TESSILATOR @@ -21,7 +21,6 @@ # Third party imports import numpy as np import pyinputplus as pyip -import time from astropy.nddata.utils import Cutout2D from astropy.table import Table, MaskedColumn from astropy.io import ascii, fits @@ -189,7 +188,7 @@ def create_table_template(): fill_value=fill_value, ) ) - return Table(cols) + return Table(cols, masked=True) def setup_input_parameters(): @@ -645,10 +644,9 @@ def make_target_row(t_targets, r, scc): returns ------- dr : dict - A dicty for the target star containing input data + A dictionary for the target star containing input data """ copycols = [ - "name", "source_id", "ra", "dec", @@ -656,11 +654,9 @@ def make_target_row(t_targets, r, scc): "Gmag", "BPmag", "RPmag", - "log_tot_bg_star", - "log_max_bg_star", - "n_conts", ] dr = {col: t_targets[col] for col in copycols} + dr["original_id"] = t_targets["name"] dr["Sector"] = scc[0] dr["Camera"] = scc[1] dr["CCD"] = scc[2] diff --git a/tessilator/tests/test_tessilator.py b/tessilator/tests/test_tessilator.py index c604521..1138349 100644 --- a/tessilator/tests/test_tessilator.py +++ b/tessilator/tests/test_tessilator.py @@ -4,6 +4,7 @@ import pytest from astropy.table import Table, join from tessilator import tessilator +from contextlib import chdir ABDor = Table( { @@ -35,20 +36,31 @@ def test_xy_pixel_data(): @pytest.mark.remote_data -def test_all_sources_sector(): +def test_all_sources_sector_no_data(tmpdir): """Test the all_sources_sector function.""" xy_pixel_data = tessilator.get_tess_pixel_xy(ABDor) # For GAIA numbers, the source_id comes out as int64 xy_pixel_data["source_id"] = np.asarray(xy_pixel_data["source_id"], dtype=str) tTargets = join(ABDor, xy_pixel_data, keys="source_id") - tessilator.all_sources_sector( - tTargets, - scc=[34, 4, 3], - make_plots=True, - period_file="temp/period", - file_ref="ABDor", - keep_data=True, - ) - # Put some real tests here. But that requires me to be able to run - # it first... - assert False \ No newline at end of file + with chdir(tmpdir): + tessilator.all_sources_sector( + tTargets, + scc=[34, 4, 3], + make_plots=True, + period_file="period", + file_ref="ABDor", + keep_data=True, + ) + out = Table.read(f"{tmpdir}/period_4_3.csv") + assert len(out) == 1 + + for col in ABDor.colnames[2:]: + assert out[col] == pytest.approx(ABDor[col]) + # This is special, because it uses a different column name + assert out["original_id"][0] == ABDor["name"] + # Just test a few representative columns + assert out["Sector"][0] == 34 + assert out["n_conts"].mask[0] + assert out["ap_rad"][0] == 1.0 + assert out["power_4"].mask[0] + assert out["period_shuffle"].mask[0]