Skip to content

Commit

Permalink
Merge pull request #480 from mwcraig/update-exoplanet-notebooks
Browse files Browse the repository at this point in the history
Update exoplanet notebooks
  • Loading branch information
mwcraig authored Nov 20, 2024
2 parents 309e322 + 972b356 commit 6be45ab
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 264 deletions.
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 @@ def calc_aij_relative_flux(
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(
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)
# Add bjd if needed

if "bjd" not in flux_table.colnames:
if verbose:
print("Adding BJD column to photometry data")
# 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)

This file was deleted.

Loading

0 comments on commit 6be45ab

Please sign in to comment.