Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update exoplanet notebooks #480

Merged
merged 6 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .jp_app_launcher_stellarphot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,17 @@
# Notebook in the "Stellarphot analysis and tools" section of the launcher

- title: Generate TESS target list
description: View and export photometry results
description: Retrieve TESS target list and TIC information
source: ../stellarphot/tess-target-source-list-generator.ipynb
icon: ../stellarphot/stellarphot-logo.svg
cwd: not_used
type: notebook
catalog: Stellarphot analysis and tools

- title: Calculate relative flux
description: Add a relative flux column to the photometry table
source: ../stellarphot/relative-flux-calculation.ipynb
icon: ../stellarphot/stellarphot-logo.svg
cwd: not_used
type: notebook
catalog: Stellarphot analysis and tools
60 changes: 59 additions & 1 deletion stellarphot/differential_photometry/aij_rel_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from astropy.coordinates import SkyCoord
from astropy.table import QTable, Table

__all__ = ["add_in_quadrature", "calc_aij_relative_flux"]
from stellarphot import PhotometryData, SourceListData

__all__ = ["add_in_quadrature", "calc_aij_relative_flux", "add_relative_flux_column"]


def add_in_quadrature(array):
Expand Down Expand Up @@ -192,3 +194,59 @@
star_data["comparison error"] = comp_error_vector

return star_data


def add_relative_flux_column(
photometry_data_file,
source_list_file,
add_name="-relative-flux",
verbose=False,
):
"""
Add AIJ-style relative flux columns to a photometry data file.

Parameters
----------

photometry_data_file : str
Path to the photometry data file.

source_list_file : str
Path to the source list file.

add_name : str, optional
String to add to the end of the new file name before the suffix.

Returns
-------

None; writes a file with the relative flux columns added.
"""
if verbose:
print("Reading photometry data and source list")
photometry_data = PhotometryData.read(photometry_data_file)
source_list = SourceListData.read(source_list_file)
output_file = photometry_data_file.stem + add_name + photometry_data_file.suffix
source_list["coord"] = SkyCoord(

Check warning on line 230 in stellarphot/differential_photometry/aij_rel_fluxes.py

View check run for this annotation

Codecov / codecov/patch

stellarphot/differential_photometry/aij_rel_fluxes.py#L225-L230

Added lines #L225 - L230 were not covered by tests
ra=source_list["ra"], dec=source_list["dec"], frame="icrs"
)
comp_bool = source_list["marker name"] == ["APASS comparison"]
only_comp_stars = source_list[comp_bool]
if verbose:
print("Adding AIJ-style relative flux columns to photomotry data")
flux_table = calc_aij_relative_flux(photometry_data, only_comp_stars)

Check warning on line 237 in stellarphot/differential_photometry/aij_rel_fluxes.py

View check run for this annotation

Codecov / codecov/patch

stellarphot/differential_photometry/aij_rel_fluxes.py#L233-L237

Added lines #L233 - L237 were not covered by tests
# Add bjd if needed

if "bjd" not in flux_table.colnames:
if verbose:
print("Adding BJD column to photometry data")

Check warning on line 242 in stellarphot/differential_photometry/aij_rel_fluxes.py

View check run for this annotation

Codecov / codecov/patch

stellarphot/differential_photometry/aij_rel_fluxes.py#L240-L242

Added lines #L240 - L242 were not covered by tests
# Add dummy BJD column so the whole table has one
flux_table["bjd"] = np.nan
flux_group = flux_table.group_by("file")
for group in flux_group.groups:
mean_ra = group["ra"].mean()
mean_dec = group["dec"].mean()
group.add_bjd_col(bjd_coordinates=SkyCoord(mean_ra, mean_dec))
if verbose:
print("Writing photometry data with relative flux columns")
flux_table.write(output_file, overwrite=True)

Check warning on line 252 in stellarphot/differential_photometry/aij_rel_fluxes.py

View check run for this annotation

Codecov / codecov/patch

stellarphot/differential_photometry/aij_rel_fluxes.py#L244-L252

Added lines #L244 - L252 were not covered by tests

This file was deleted.

Loading