Skip to content

Commit 5bab29a

Browse files
authored
Add util to save LC count by field given catalog_completeness file (#567)
* Add util to save LC count by field given catalog_completeness file * Finish docstring * Be verbose about file saved
1 parent da95f3d commit 5bab29a

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

scope/utils.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,38 @@ def read_parquet(filepath: str, meta_key: str = "scope"):
242242
return dataframe
243243

244244

245+
def get_field_count(
246+
completeness_file: str,
247+
field_counts_file: str = "field_counts.json",
248+
):
249+
"""
250+
Given a catalog completeness file (see tools.generate_features_slurm.check_quads_for_sources),
251+
save another json file containing field-by-field light curve counts
252+
253+
:param completeness_file: name of completeness file, e.g. DR19_catalog_completeness.json (str)
254+
:param field_counts_file: name of field counts file (str)
255+
"""
256+
257+
with open(completeness_file) as f:
258+
field_dct = json.load(f)
259+
260+
field_counts = {}
261+
for field in field_dct.keys():
262+
int_field = int(field)
263+
fdict = field_dct[field]
264+
field_counts[int_field] = 0
265+
for ccd in fdict.keys():
266+
cdict = fdict[ccd]
267+
for quad in cdict.keys():
268+
qval = cdict[quad]
269+
field_counts[int_field] += qval
270+
271+
with open(field_counts_file, "w") as f:
272+
json.dump(field_counts, f)
273+
274+
print(f"Saved {field_counts_file} containing light curve counts by field.")
275+
276+
245277
def plot_light_curve_data(
246278
light_curve_data: pd.DataFrame,
247279
period: Optional[float] = None,

0 commit comments

Comments
 (0)