Skip to content

Commit

Permalink
Merge pull request #21 from lsst-dm/assemble_update
Browse files Browse the repository at this point in the history
Updating the assemble step to include u-band
  • Loading branch information
psferguson authored Aug 13, 2024
2 parents 3b4c0e0 + 583b428 commit dba50e2
Show file tree
Hide file tree
Showing 6 changed files with 485 additions and 126 deletions.
16 changes: 16 additions & 0 deletions colorterms/SDSS_to_SynthLSST_band_u.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
flux_offset: 0.0
nodes:
- -0.5
- 0.16666666666666663
- 0.8333333333333333
- 1.5
source_color_field_1: g
source_color_field_2: r
source_field: u
source_survey: SDSS
spline_values:
- 1.0299405999929636
- 0.8856042812299526
- 0.9952965102079128
- 1.1646918068493601
target_survey: SynthLSST
409 changes: 343 additions & 66 deletions python/lsst/the/monster/assemble.py

Large diffs are not rendered by default.

20 changes: 16 additions & 4 deletions python/lsst/the/monster/measure_synth_colorterms.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,14 @@ def measure_synth_spline_fit(self, bands=["g", "r", "i", "z", "y"], do_plots=Tru
tput_lambda = throughputs[band]["wavelength"]*10.
f_nu = int_func(tput_lambda)

num = integrate.simpson(f_nu*throughputs[band]["throughput"]/tput_lambda, tput_lambda)
denom = integrate.simpson(throughputs[band]["throughput"]/tput_lambda, tput_lambda)
num = integrate.simpson(
x=f_nu*throughputs[band]["throughput"]/tput_lambda,
y=tput_lambda
)
denom = integrate.simpson(
x=throughputs[band]["throughput"]/tput_lambda,
y=tput_lambda
)

synth_lsst_cat[lsst_info.get_flux_field(band)][i] = num/denom

Expand Down Expand Up @@ -179,8 +185,14 @@ def measure_synth_spline_fit(self, bands=["g", "r", "i", "z", "y"], do_plots=Tru
tput_lambda = des_passbands["LAMBDA"]
f_nu = int_func(tput_lambda)

num = integrate.simpson(f_nu*des_passbands[band]/tput_lambda, tput_lambda)
denom = integrate.simpson(des_passbands[band], tput_lambda)
num = integrate.simpson(
x=f_nu*des_passbands[band]/tput_lambda,
y=tput_lambda
)
denom = integrate.simpson(
x=des_passbands[band],
y=tput_lambda
)

synth_des_cat[des_info.get_flux_field(band)][i] = num/denom

Expand Down
59 changes: 38 additions & 21 deletions python/lsst/the/monster/refcats.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,33 @@


__all__ = [
"FLAG_DICT",
"DESInfo",
"GaiaDR3Info",
"GaiaXPInfo",
"GaiaXPuInfo",
"LATISSInfo",
"PS1Info",
"SDSSInfo",
"SDSSuInfo",
"SkyMapperInfo",
"SynthLSSTInfo",
"VSTInfo",
]

FLAG_DICT = {
"GaiaDR3": 0,
"DES": 2,
"GaiaXP": 4,
"PS1": 8,
"SkyMapper": 16,
"VST": 32,
"SDSS": 64,
"SLR": 128,
"SynthLSST": 256,
"LATISS": 512,
}


class RefcatInfo(ABC):
PATH = ""
Expand Down Expand Up @@ -278,8 +294,9 @@ def get_mag_colors(self, catalog, band):
return mag_color

def get_transformed_flux_field(self, band):
"""Get the transformed-to-DES flux field associated with a band.
"""Get the transformed-to-internal reference flux field associated
with a band. This should be decam for grizy-bands and sdss
for u-band
Parameters
----------
band : `str`
Expand All @@ -290,7 +307,12 @@ def get_transformed_flux_field(self, band):
flux_field : `str`
Name of flux field appropriate for this catalog.
"""
return f"decam_{band}_from_{self.NAME}_flux"
if band in "grizy":
return f"decam_{band}_from_{self.NAME}_flux"
elif band in "u":
return f"sdss_{band}_from_{self.NAME}_flux"
else:
raise ValueError(f"Unsupported band: {band}")

def get_transformed_mag_colors(self, catalog, band):
"""Get magnitude colors appropriate for correcting a given band.
Expand Down Expand Up @@ -370,7 +392,7 @@ def select_stars(self, catalog, band):
class GaiaDR3Info(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/GAIA_DR3/gaia_dr3"
NAME = "GaiaDR3"
FLAG = 0
FLAG = FLAG_DICT[NAME]

def get_flux_field(self, band):
return f"phot_{band.lower()}_mean_flux"
Expand All @@ -385,7 +407,7 @@ def get_imz_color_range(self):
class GaiaXPInfo(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/gaia_xp_ps_des_sdss_sm_20240116"
NAME = "GaiaXP"
FLAG = 8
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z", "y"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -418,7 +440,7 @@ def get_mag_range(self, band):
class DESInfo(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/des_y6_calibration_stars_20230511"
NAME = "DES"
FLAG = 16
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z", "y"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -476,7 +498,7 @@ def select_stars(self, catalog, band):
class SkyMapperInfo(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/sky_mapper_dr2_20221205"
NAME = "SkyMapper"
FLAG = 2
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -517,7 +539,7 @@ class PS1Info(RefcatInfo):
PATH = "/sdf/group/rubin/datasets/refcats/htm/v1/ps1_pv3_3pi_20170110"
TRANSFORMED_PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/ps1_transformed"
NAME = "PS1"
FLAG = 4
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z", "y"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -572,7 +594,7 @@ def select_stars(self, catalog, band):
class VSTInfo(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/vst_atlas_20221205"
NAME = "VST"
FLAG = 1
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -611,7 +633,7 @@ def get_sn_range(self, band):

class SynthLSSTInfo(RefcatInfo):
NAME = "SynthLSST"
FLAG = 32
FLAG = FLAG_DICT[NAME]
bands = ["u", "g", "r", "i", "z", "y"]

def get_flux_field(self, band):
Expand All @@ -626,7 +648,6 @@ def get_imz_color_range(self):


class GaiaXPuInfo(GaiaXPInfo):
FLAG = 64
NAME = "GaiaXPu"
bands = ["u"]
TRANSFORMED_PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/gaia_xp_u_20240116_transformed"
Expand All @@ -649,19 +670,11 @@ def colorterm_file(self, band):

return filename

def get_transformed_flux_field(self, band):
"""for u band internal bandpass is sdss
"""
if band != "u":
raise NotImplementedError(f"{self.NAME} should only be used with u-band, not band={band}")

return f"sdss_{band}_from_{self.NAME}_flux"


class SDSSInfo(RefcatInfo):
PATH = "/sdf/data/rubin/shared/the_monster/sharded_refcats/sdss_16_standards_20221205"
NAME = "SDSS"
FLAG = 128
FLAG = FLAG_DICT[NAME]
bands = ["u", "g", "r", "i", "z"]

def get_flux_field(self, band):
Expand Down Expand Up @@ -693,9 +706,13 @@ def colorterm_file(self, band):
return filename


class SDSSuInfo(SDSSInfo):
bands = ["u"]


class LATISSInfo(RefcatInfo):
NAME = "LATISS"
FLAG = 256
FLAG = FLAG_DICT[NAME]
bands = ["g", "r", "i", "z", "y"]

def get_flux_field(self, band):
Expand Down
24 changes: 14 additions & 10 deletions python/lsst/the/monster/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from lsst.afw.table import SimpleCatalog
import lsst.afw.table as afwTable
from .refcats import FLAG_DICT

__all__ = ["read_stars", "makeRefSchema", "makeRefCat",
"makeMonsterSchema", "makeMonsterCat"]
Expand Down Expand Up @@ -142,7 +143,7 @@ def makeRefCat(refSchema, refTable, cat_info, reference_name):
return refCat


def makeMonsterSchema(gaia_catalog_columns, bands, output_system='lsst'):
def makeMonsterSchema(gaia_catalog_columns, target_systems):
"""
Make the monster refcat schema. Include all columns from Gaia, as well
as transformed fluxes, flux errors, and flags identifying the source
Expand All @@ -154,7 +155,7 @@ def makeMonsterSchema(gaia_catalog_columns, bands, output_system='lsst'):
Gaia catalog columns (e.g., from "gaia_stars_all.itercols()")
bands : `List` of `str`
Names of the bands to include in the monster refcat
output_system : `str`
target_system : `str`
Name of the output system to use.
Returns
Expand All @@ -173,10 +174,10 @@ def makeMonsterSchema(gaia_catalog_columns, bands, output_system='lsst'):
# units in the input table, so we'll treat them separately to add the
# units. Thus we exclude them from the "transfer" loop as well.
exclude_columns = ["id", "coord_ra", "coord_dec"]
for band in bands:
exclude_columns.append(f"monster_{output_system}_{band}_flux")
exclude_columns.append(f"monster_{output_system}_{band}_fluxErr")
exclude_columns.append(f"monster_{output_system}_{band}_source_flag")
for target_system, band in target_systems:
exclude_columns.append(f"monster_{target_system}_{band}_flux")
exclude_columns.append(f"monster_{target_system}_{band}_fluxErr")
exclude_columns.append(f"monster_{target_system}_{band}_source_flag")

fieldtype_dict = {'float32': 'F', 'float64': 'D',
'int64': 'L', 'bool': 'B'}
Expand All @@ -201,18 +202,21 @@ def makeMonsterSchema(gaia_catalog_columns, bands, output_system='lsst'):
)

# Add columns to the schema for the flux, flux error, and flags.
for band in bands:
fluxcolname = f"monster_{output_system}_{band}_flux"
for target_system, band in target_systems:
fluxcolname = f"monster_{target_system}_{band}_flux"
fluxcolname_err = fluxcolname+'Err'
flagcolname = f"monster_{output_system}_{band}_source_flag"
flagcolname = f"monster_{target_system}_{band}_source_flag"
monsterSchema.addField(fluxcolname, type='D',
doc='flux transformed to synthetic system',
units='nJy')
monsterSchema.addField(fluxcolname_err, type='D',
doc='error on flux transformed to synthetic system',
units='nJy')

flag_doc = ", ".join([str(FLAG_DICT[key]) + ":" + key for key in FLAG_DICT.keys()])
monsterSchema.addField(flagcolname, type='I',
doc='source of flux (1:VST, 2:Skymapper, 4:PS1, 8:GaiaXP, 16:DES)',
doc=f'source of flux ({flag_doc})',
# TO DO: source of flux flags need to be updated
units='')

return monsterSchema
Expand Down
Loading

0 comments on commit dba50e2

Please sign in to comment.