Skip to content

Commit

Permalink
Make table masked and run remote test
Browse files Browse the repository at this point in the history
  • Loading branch information
hamogu committed May 21, 2024
1 parent a637df6 commit 4ecc9a5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 21 deletions.
14 changes: 5 additions & 9 deletions tessilator/tessilator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
"""
Alexander Binks', r'Moritz Guenther, 2024
Alexander Binks, Moritz Guenther, 2024
Licence: MIT 2024
License: MIT 2024
The TESSILATOR
Expand All @@ -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
Expand Down Expand Up @@ -189,7 +188,7 @@ def create_table_template():
fill_value=fill_value,
)
)
return Table(cols)
return Table(cols, masked=True)


def setup_input_parameters():
Expand Down Expand Up @@ -645,22 +644,19 @@ 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",
"parallax",
"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]
Expand Down
36 changes: 24 additions & 12 deletions tessilator/tests/test_tessilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pytest
from astropy.table import Table, join
from tessilator import tessilator
from contextlib import chdir

ABDor = Table(
{
Expand Down Expand Up @@ -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
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]

0 comments on commit 4ecc9a5

Please sign in to comment.