Unverified Commit 80da080d authored by Akke Viitanen's avatar Akke Viitanen
Browse files

add update dr1 catalog script

parent a58b082f
Loading
Loading
Loading
Loading
Loading
+66 −0
Original line number Diff line number Diff line
#!/usr/bin/env python3
# Author: Akke Viitanen
# Email: akke.viitanen@helsinki.fi
# Date: 2026-02-25 13:50:08

"""
Update the DR1 catalog and database with respect to new columns
"""


import os

import astropy.coordinates as c
import numpy as np
from lsst_inaf_agile import lightcurve, util
from lsst_inaf_agile.catalog_combined import CatalogCombined

dirname = "data/catalog/dr1_new_new"
columns = ["ID", "Z", "M", "is_agn", "magabs_lsst-i_point", "MBH", "is_optical_type2"]
for band in "ugrizy":
    columns.append(f"lsst-{band}_point")
catalog = CatalogCombined(dirname, columns=columns)

tau_sf_infs: list[list[float]] = []

mjd = util.get_mjd_vec()
for b in "ugrizy":
    band = f"lsst-{b}"
    i = catalog[catalog["is_agn"]]["ID"][0]
    lckw = {
        "mjd0": 0.0,
        "mjd": mjd,
        "band": band,
        "flux": catalog[f"{band}_point"][i],
        "z": catalog["Z"][i],
        "mag_i": catalog["magabs_lsst-i_point"][i],
        "logMbh": catalog["MBH"][i],
        "type2": catalog["is_optical_type2"][i],
        "T": mjd.max() + 1,
        "deltatc": 1,
        "seed": 9999,
        "return_tau_sf_inf": True,
    }
    lc = lightcurve.get_lightcurve_agn(**lckw)
    print(lc)

    if b == "u":
        tau_sf_infs.append([])
    tau_sf_infs[-1].append(lc)


print(np.array(tau_sf_infs).shape)
quit()

# add the columns
print(c["tau"])
print(c["sf_inf"])
quit()

table = "Truth"
filename = "test.db"
if os.path.exists(filename):
    os.remove(filename)
c.write_database(table, filename)

print(c)