Skip to content

Commit

Permalink
Add fix for adding BJD column
Browse files Browse the repository at this point in the history
  • Loading branch information
mwcraig committed Nov 27, 2024
1 parent 506c488 commit 0ca7260
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions stellarphot/differential_photometry/aij_rel_fluxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import numpy as np
from astropy.coordinates import SkyCoord
from astropy.table import QTable, Table
from astropy.time import Time

from stellarphot import PhotometryData, SourceListData

Expand Down Expand Up @@ -240,13 +241,20 @@ def add_relative_flux_column(
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
# Accumulate the BJD here
bjds = []

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))
bjds.extend(group["bjd"].jd)

# Each (ephemeral) group had a BJD, this adds the column to the
# original table.
flux_group["bjd"] = Time(bjds, scale="tdb", format="jd")

if verbose:
print("Writing photometry data with relative flux columns")
flux_table.write(output_file, overwrite=True)
flux_group.write(output_file, overwrite=True)

0 comments on commit 0ca7260

Please sign in to comment.