Skip to content

Commit

Permalink
Allow max_timestamp_hjd to be specified as argument in generate_featu…
Browse files Browse the repository at this point in the history
…res.py
  • Loading branch information
bfhealy committed Nov 8, 2023
1 parent c525751 commit bc6459f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doc/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ inputs:
30. --skipCloseSources: flag to skip removal of sources too close to bright stars via Gaia (bool)
31. --top_n_periods: number of (E)LS, (E)CE periods to pass to (E)AOV if using (E)LS_(E)CE_(E)AOV algorithm (int)
32. --max_freq: maximum frequency [1 / days] to use for period finding (float). Overridden by --doScaleMinPeriod
33. --fg_dataset*: path to parquet, hdf5 or csv file containing specific sources for feature generation (str)
34. --max_timestamp_hjd*: maximum timestamp of queried light curves, HJD (float)

output:
feature_df : dataframe containing generated features
Expand Down
13 changes: 10 additions & 3 deletions scope/fritz.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,17 @@ def get_lightcurves_via_coords(
limit_per_query=1000,
Ncore=1,
get_basic_data=False,
max_timestamp_hjd=None,
):

if catalog is None:
raise ValueError(
'No catalog specified. Please add one to config.yaml under kowalski: collectons: sources:'
)

if max_timestamp_hjd is None:
max_timestamp_hjd = config['kowalski']['max_timestamp_hjd']

light_curve_ids = []
query = {
"query_type": "near",
Expand Down Expand Up @@ -142,6 +146,7 @@ def get_lightcurves_via_coords(
limit_per_query=limit_per_query,
Ncore=Ncore,
get_basic_data=get_basic_data,
max_timestamp_hjd=max_timestamp_hjd,
)


Expand All @@ -153,9 +158,11 @@ def get_lightcurves_via_ids(
limit_per_query=1000,
Ncore=1,
get_basic_data=False,
max_timestamp_hjd=None,
):

cutoff_hjd = config['kowalski']['max_timestamp_hjd']
if max_timestamp_hjd is None:
max_timestamp_hjd = config['kowalski']['max_timestamp_hjd']

itr = 0
lcs = []
Expand Down Expand Up @@ -190,8 +197,8 @@ def get_lightcurves_via_ids(
Nqueries = int(np.ceil(Nsources / limit_per_query))

time_filter = {"$gt": 0.0}
if cutoff_hjd is not None:
time_filter["$lte"] = cutoff_hjd
if max_timestamp_hjd is not None:
time_filter["$lte"] = max_timestamp_hjd

queries = [
{
Expand Down
10 changes: 10 additions & 0 deletions tools/generate_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ def generate_features(
top_n_periods: int = 50,
max_freq: float = 48.0,
fg_dataset: str = None,
max_timestamp_hjd: float = None,
):
"""
Generate features for ZTF light curves
Expand Down Expand Up @@ -498,7 +499,9 @@ def generate_features(
:param doSpecificIDs: flag to perform feature generation for ztf_id column in config-specified file (bool)
:param skipCloseSources: flag to skip removal of sources too close to bright stars via Gaia (bool)
:param top_n_periods: number of (E)LS, (E)CE periods to pass to (E)AOV if using (E)LS_(E)CE_(E)AOV algorithm (int)
:param max_freq: maximum frequency [1 / days] to use for period finding. Overridden by --doScaleMinPeriod (float)
:param fg_dataset*: path to parquet, hdf5 or csv file containing specific sources for feature generation (str)
:param max_timestamp_hjd*: maximum timestamp of queried light curves, HJD (float)
:return feature_df: dataframe containing generated features
Expand Down Expand Up @@ -673,6 +676,7 @@ def generate_features(
limit_per_query=lc_limit,
Ncore=Ncore,
get_basic_data=True,
max_timestamp_hjd=max_timestamp_hjd,
)

# Remake feature_gen_source_dict if some light curves are missing
Expand Down Expand Up @@ -1362,6 +1366,11 @@ def generate_features(
default=None,
help="path to parquet, hdf5 or csv file containing specific sources for feature generation",
)
parser.add_argument(
"--max_timestamp_hjd",
type=float,
help="maximum timestamp for queried light curves (HJD)",
)

args = parser.parse_args()

Expand Down Expand Up @@ -1399,4 +1408,5 @@ def generate_features(
top_n_periods=args.top_n_periods,
max_freq=args.max_freq,
fg_dataset=args.fg_dataset,
max_timestamp_hjd=args.max_timestamp_hjd,
)

0 comments on commit bc6459f

Please sign in to comment.