def doc_theme():
return theme_minimal() + theme(
panel_grid_minor=element_line(color="gray", linetype="--"),
)Using Firecrown to Serialize Redshift Distributions
version 1.11.0a0
Purpose of this document
In the previous tutorial, we discussed using the ZDistLSSTSRD class in Firecrown to generate redshift distributions for galaxies. In this tutorial, we will cover how to serialize these distributions to disk and read them back in.
While InferredGalaxyZDist objects can be serialized, the resulting files are not human-readable because they contain the final redshift distribution. To achieve a human-readable format, we need to serialize the parameters used to generate the distribution.
Firecrown addresses this by introducing the ZDistLSSTSRDBin and ZDistLSSTSRDBinCollection dataclasses.1 These classes store the parameters used to generate the redshift distributions and can be serialized to disk and read back in, providing a human-readable representation. These files can be shared and modified by users to generate new redshift distributions.
1 Strictly speaking, these are subclasses of pydantic.BaseModel. In most cases, these behave like dataclasses.dataclass subtypes.
In this tutorial, we will demonstrate how to serialize and read back these dataclasses.
Serializing and reading back ZDistLSSTSRDBin
First, we discuss the ZDistLSSTSRDBin dataclass. This class stores the parameters used to generate a single photometric redshift bin. The code snippet below demonstrates how to initialize and serialize this dataclass.
from firecrown.generators.inferred_galaxy_zdist import ZDistLSSTSRDBin, LinearGrid1D
from firecrown.metadata_types import Galaxies
from firecrown.utils import base_model_to_yaml
z = LinearGrid1D(start=0.01, end=0.5, num=20)
bin0 = ZDistLSSTSRDBin(
zpl=0.1,
zpu=0.2,
sigma_z=0.03,
z=z,
bin_name="bin0",
measurements={Galaxies.COUNTS},
)
bin0_yaml = base_model_to_yaml(bin0)When serilized, the ZDistLSSTSRDBin object produces a human-readable YAML file.
Code
import yaml
from IPython.display import Markdown
Markdown(f"```yaml\n{bin0_yaml}\n```")zpl: 0.1
zpu: 0.2
sigma_z: 0.03
z: {start: 0.01, end: 0.5, num: 20}
bin_name: bin0
measurements:
- {subject: Galaxies, property: COUNTS}Note that since the redshift array needs to be serialized, we used the LinearGrid1D class to generate a linear grid of redshifts. Alternatively, you can use RawGrid1D, which holds a list of redshifts.
Serializing and reading back ZDistLSSTSRDBinCollection
Next, we discuss the ZDistLSSTSRDBinCollection dataclass. This class stores the parameters used to generate all the photometric redshift bins, including the ZDistLSSTSRD parameters. The code snippet below demonstrates how to initialize and serialize this dataclass.
from firecrown.generators.inferred_galaxy_zdist import (
ZDistLSSTSRDBinCollection,
Y1_LENS_ALPHA,
Y1_LENS_BETA,
Y1_LENS_Z0,
)
# We add a bin1, to demonstrate the use of multiple bins.
# We want the new bin to be like the old, but with a different
# range of integration (and a new name, of course).
# To create the bin, we go through a dictionary...
d = bin0.model_dump()
d.update(bin_name="bin1", zpl=0.2, zpu=0.3)
bin1 = ZDistLSSTSRDBin.model_validate(d)
bin_collection = ZDistLSSTSRDBinCollection(
alpha=Y1_LENS_ALPHA,
beta=Y1_LENS_BETA,
z0=Y1_LENS_Z0,
bins=[bin0, bin1],
)
bin_collection_yaml = base_model_to_yaml(bin_collection)When serialized, the ZDistLSSTSRDBinCollection object produces a human-readable YAML file.
Code
Markdown(f"```yaml\n{bin_collection_yaml}\n```")alpha: 0.94
beta: 2.0
z0: 0.26
bins:
- zpl: 0.1
zpu: 0.2
sigma_z: 0.03
z: {start: 0.01, end: 0.5, num: 20}
bin_name: bin0
measurements:
- {subject: Galaxies, property: COUNTS}
- zpl: 0.2
zpu: 0.3
sigma_z: 0.03
z: {start: 0.01, end: 0.5, num: 20}
bin_name: bin1
measurements:
- {subject: Galaxies, property: COUNTS}
max_z: 5.0
use_autoknot: true
autoknots_reltol: 0.0001
autoknots_abstol: 1.0e-15Reading back the serialized data
To read back the serialized data, use the base_model_from_yaml function.
from firecrown.utils import base_model_from_yaml
bin_collection_read = base_model_from_yaml(
ZDistLSSTSRDBinCollection, bin_collection_yaml
)
assert bin_collection.alpha == bin_collection_read.alpha
assert bin_collection.beta == bin_collection_read.beta
assert bin_collection.z0 == bin_collection_read.z0
assert len(bin_collection.bins) == 2
assert bin_collection.bins[0].zpl == bin_collection_read.bins[0].zpl
assert bin_collection.bins[0].zpu == bin_collection_read.bins[0].zpu
assert bin_collection.bins[0].sigma_z == bin_collection_read.bins[0].sigma_z
assert bin_collection.bins[0].bin_name == bin_collection_read.bins[0].bin_name
assert bin_collection.bins[0].measurements == bin_collection_read.bins[0].measurements
assert bin_collection.bins[0].z == bin_collection_read.bins[0].zCalling generate on the read object will generate the redshift distribution dataclasses InferredGalaxyZDist.
from pprint import pprint
zdist = bin_collection_read.generate()
pprint(zdist)[InferredGalaxyZDist(bin_name='bin0',
z=array([0.01 , 0.01038281, 0.01076563, 0.01114844, 0.01153125,
0.01229688, 0.0130625 , 0.01382813, 0.01459375, 0.01535938,
0.016125 , 0.01765625, 0.0191875 , 0.02071875, 0.02225 ,
0.02378125, 0.0253125 , 0.02684375, 0.028375 , 0.02990625,
0.0314375 , 0.03296875, 0.0345 , 0.03603125, 0.0375625 ,
0.03909375, 0.040625 , 0.04215625, 0.0436875 , 0.04521875,
0.04675 , 0.0498125 , 0.052875 , 0.0559375 , 0.059 ,
0.0620625 , 0.065125 , 0.0681875 , 0.07125 , 0.0743125 ,
0.077375 , 0.0804375 , 0.0835 , 0.0865625 , 0.089625 ,
0.0926875 , 0.09575 , 0.0988125 , 0.101875 , 0.1049375 ,
0.108 , 0.114125 , 0.12025 , 0.126375 , 0.1325 ,
0.1355625 , 0.138625 , 0.1416875 , 0.14475 , 0.1478125 ,
0.150875 , 0.1539375 , 0.157 , 0.1600625 , 0.163125 ,
0.1661875 , 0.16925 , 0.1723125 , 0.175375 , 0.1784375 ,
0.1815 , 0.1845625 , 0.187625 , 0.1906875 , 0.19375 ,
0.1968125 , 0.199875 , 0.2029375 , 0.206 , 0.2090625 ,
0.212125 , 0.2151875 , 0.21825 , 0.2213125 , 0.224375 ,
0.2274375 , 0.2305 , 0.2335625 , 0.236625 , 0.2396875 ,
0.24275 , 0.2458125 , 0.248875 , 0.2519375 , 0.255 ,
0.2580625 , 0.261125 , 0.2641875 , 0.26725 , 0.2703125 ,
0.273375 , 0.2764375 , 0.2795 , 0.2825625 , 0.285625 ,
0.2886875 , 0.29175 , 0.2948125 , 0.297875 , 0.3009375 ,
0.304 , 0.3070625 , 0.310125 , 0.3131875 , 0.31625 ,
0.3193125 , 0.322375 , 0.3254375 , 0.3285 , 0.3315625 ,
0.334625 , 0.3376875 , 0.34075 , 0.34228125, 0.3438125 ,
0.34534375, 0.346875 , 0.34840625, 0.3499375 , 0.35146875,
0.353 , 0.35453125, 0.3560625 , 0.35759375, 0.359125 ,
0.36065625, 0.3621875 , 0.36371875, 0.36525 , 0.36678125,
0.3683125 , 0.36984375, 0.371375 , 0.37290625, 0.3744375 ,
0.37596875, 0.3775 , 0.37903125, 0.3805625 , 0.38209375,
0.383625 , 0.38515625, 0.3866875 , 0.38821875, 0.38975 ,
0.39128125, 0.3928125 , 0.39434375, 0.395875 , 0.39740625,
0.3989375 , 0.40046875, 0.402 , 0.40353125, 0.4050625 ,
0.40659375, 0.408125 , 0.40965625, 0.4111875 , 0.41271875,
0.41425 , 0.41578125, 0.4173125 , 0.41884375, 0.420375 ,
0.42190625, 0.4234375 , 0.42496875, 0.4265 , 0.42803125,
0.4295625 , 0.43109375, 0.432625 , 0.43415625, 0.4356875 ,
0.43721875, 0.43875 , 0.44028125, 0.4418125 , 0.44334375,
0.444875 , 0.44640625, 0.4479375 , 0.44946875, 0.451 ,
0.45253125, 0.4540625 , 0.45559375, 0.457125 , 0.45865625,
0.4601875 , 0.46171875, 0.46325 , 0.46478125, 0.4663125 ,
0.46784375, 0.469375 , 0.47090625, 0.4724375 , 0.47396875,
0.4755 , 0.47703125, 0.4785625 , 0.48009375, 0.481625 ,
0.48315625, 0.4846875 , 0.48621875, 0.48775 , 0.48928125,
0.4908125 , 0.49234375, 0.493875 , 0.49464063, 0.49540625,
0.49617188, 0.4969375 , 0.49770313, 0.49846875, 0.49923438,
0.5 ]),
dndz=array([1.77316045e-04, 1.98068643e-04, 2.20623990e-04, 2.45098983e-04,
2.71616489e-04, 3.31301826e-04, 4.00791682e-04, 4.81309365e-04,
5.74198507e-04, 6.80932218e-04, 8.03122714e-04, 1.10107960e-03,
1.48414522e-03, 1.97131833e-03, 2.58491283e-03, 3.35097964e-03,
4.29975623e-03, 5.46614124e-03, 6.89019042e-03, 8.61762944e-03,
1.07003777e-02, 1.31970761e-02, 1.61736119e-02, 1.97036296e-02,
2.38690196e-02, 2.87603733e-02, 3.44773919e-02, 4.11292374e-02,
4.88348124e-02, 5.77229568e-02, 6.79325465e-02, 9.29215701e-02,
1.25110152e-01, 1.65953108e-01, 2.17031710e-01, 2.80023765e-01,
3.56664018e-01, 4.48695780e-01, 5.57815382e-01, 6.85611740e-01,
8.33503831e-01, 1.00267920e+00, 1.19403672e+00, 1.40813656e+00,
1.64516014e+00, 1.90488184e+00, 2.18665391e+00, 2.48940477e+00,
2.81165031e+00, 3.15151688e+00, 3.50677417e+00, 4.25300337e+00,
5.02699948e+00, 5.80260650e+00, 6.55226827e+00, 6.90867827e+00,
7.24824162e+00, 7.56762998e+00, 7.86362808e+00, 8.13316551e+00,
8.37335131e+00, 8.58151174e+00, 8.75523141e+00, 8.89239702e+00,
8.99124265e+00, 9.05039474e+00, 9.06891469e+00, 9.04633668e+00,
8.98269812e+00, 8.87856052e+00, 8.73501859e+00, 8.55369611e+00,
8.33672759e+00, 8.08672555e+00, 7.80673388e+00, 7.50016855e+00,
7.17074761e+00, 6.82241286e+00, 6.45924610e+00, 6.08538291e+00,
5.70492725e+00, 5.32186968e+00, 4.94001202e+00, 4.56290086e+00,
4.19377145e+00, 3.83550362e+00, 3.49059005e+00, 3.16111728e+00,
2.84875889e+00, 2.55478011e+00, 2.28005250e+00, 2.02507735e+00,
1.79001605e+00, 1.57472564e+00, 1.37879786e+00, 1.20160013e+00,
1.04231673e+00, 8.99989074e-01, 7.73553942e-01, 6.61878720e-01,
5.63793149e-01, 4.78117109e-01, 4.03684274e-01, 3.39361609e-01,
2.84064843e-01, 2.36770162e-01, 1.96522452e-01, 1.62440485e-01,
1.33719454e-01, 1.09631293e-01, 8.95231982e-02, 7.28147368e-02,
5.89939088e-02, 4.76124802e-02, 3.82808622e-02, 3.06627696e-02,
2.44698463e-02, 1.94564077e-02, 1.54144098e-02, 1.21687269e-02,
9.57278822e-03, 7.50460376e-03, 5.86318910e-03, 5.17591627e-03,
4.56538627e-03, 4.02353073e-03, 3.54306546e-03, 3.11742225e-03,
2.74068560e-03, 2.40753418e-03, 2.11318670e-03, 1.85335215e-03,
1.62418382e-03, 1.42223726e-03, 1.24443160e-03, 1.08801422e-03,
9.50528464e-04, 8.29784136e-04, 7.23830702e-04, 6.30932875e-04,
5.49548466e-04, 4.78308301e-04, 4.15998046e-04, 3.61541774e-04,
3.13987135e-04, 2.72491992e-04, 2.36312385e-04, 2.04791719e-04,
1.77351056e-04, 1.53480406e-04, 1.32730936e-04, 1.14707998e-04,
9.90649065e-05, 8.54973792e-05, 7.37385922e-05, 6.35547735e-05,
5.47412883e-05, 4.71191620e-05, 4.05319963e-05, 3.48432371e-05,
2.99337570e-05, 2.56997170e-05, 2.20506793e-05, 1.89079416e-05,
1.62030693e-05, 1.38766039e-05, 1.18769259e-05, 1.01592568e-05,
8.68478205e-06, 7.41988313e-06, 6.33546362e-06, 5.40636006e-06,
4.61082646e-06, 3.93008407e-06, 3.34792833e-06, 2.85038613e-06,
2.42541715e-06, 2.06265387e-06, 1.75317545e-06, 1.48931120e-06,
1.26446992e-06, 1.07299189e-06, 9.10020478e-07, 7.71391008e-07,
6.53534531e-07, 5.53394622e-07, 4.68355489e-07, 3.96179887e-07,
3.34955565e-07, 2.83049087e-07, 2.39066057e-07, 2.01816875e-07,
1.70287287e-07, 1.43613062e-07, 1.21058251e-07, 1.01996517e-07,
8.58951270e-08, 7.23012302e-08, 6.08301024e-08, 5.11550865e-08,
4.29989864e-08, 3.61267111e-08, 3.03389909e-08, 2.54670128e-08,
2.13678446e-08, 1.79205326e-08, 1.50227778e-08, 1.25881045e-08,
1.05434521e-08, 8.82712607e-09, 7.38705695e-09, 6.17932139e-09,
5.16688661e-09, 4.31854524e-09, 3.60801215e-09, 3.01315905e-09,
2.51536629e-09, 2.09897417e-09, 1.75081876e-09, 1.45983943e-09,
1.21674717e-09, 1.01374454e-09, 8.44289134e-10, 7.70390580e-10,
7.02894173e-10, 6.41251416e-10, 5.84960238e-10, 5.33561115e-10,
4.86633515e-10, 4.43792629e-10, 4.04686376e-10]),
measurements={<Galaxies.COUNTS: '5'>},
type_source='default'),
InferredGalaxyZDist(bin_name='bin1',
z=array([0.01 , 0.01019141, 0.01038281, 0.01057422, 0.01076563,
0.01114844, 0.01153125, 0.01191406, 0.01229688, 0.01267969,
0.0130625 , 0.01382813, 0.01459375, 0.01497656, 0.01535938,
0.01574219, 0.016125 , 0.01650781, 0.01689062, 0.01727344,
0.01765625, 0.01803906, 0.01842187, 0.01880469, 0.0191875 ,
0.01995313, 0.02071875, 0.02148438, 0.02225 , 0.02301562,
0.02378125, 0.02454687, 0.0253125 , 0.02607813, 0.02684375,
0.02760937, 0.028375 , 0.02914062, 0.02990625, 0.03067187,
0.0314375 , 0.03220312, 0.03296875, 0.03373437, 0.0345 ,
0.03526562, 0.03603125, 0.03679687, 0.0375625 , 0.03832812,
0.03909375, 0.03985937, 0.040625 , 0.04139062, 0.04215625,
0.04292187, 0.0436875 , 0.04445312, 0.04521875, 0.04598438,
0.04675 , 0.04751562, 0.04828125, 0.04904687, 0.0498125 ,
0.05057812, 0.05134375, 0.05210937, 0.052875 , 0.05364062,
0.05440625, 0.05517188, 0.0559375 , 0.05670313, 0.05746875,
0.05823437, 0.059 , 0.05976562, 0.06053125, 0.06129687,
0.0620625 , 0.06282812, 0.06359375, 0.06435937, 0.065125 ,
0.06589062, 0.06665625, 0.06742187, 0.0681875 , 0.06895312,
0.06971875, 0.07048437, 0.07125 , 0.07201562, 0.07278125,
0.07354687, 0.0743125 , 0.07507812, 0.07584375, 0.07660938,
0.077375 , 0.07890625, 0.0804375 , 0.08196875, 0.0835 ,
0.08503125, 0.0865625 , 0.08809375, 0.089625 , 0.09115625,
0.0926875 , 0.09421875, 0.09575 , 0.09728125, 0.0988125 ,
0.10034375, 0.101875 , 0.10340625, 0.1049375 , 0.10646875,
0.108 , 0.10953125, 0.1110625 , 0.11259375, 0.114125 ,
0.11565625, 0.1171875 , 0.11871875, 0.12025 , 0.1233125 ,
0.126375 , 0.1294375 , 0.1325 , 0.1355625 , 0.138625 ,
0.1416875 , 0.14475 , 0.1478125 , 0.150875 , 0.1539375 ,
0.157 , 0.1600625 , 0.163125 , 0.1661875 , 0.16925 ,
0.1723125 , 0.175375 , 0.1784375 , 0.1815 , 0.1845625 ,
0.187625 , 0.1906875 , 0.19375 , 0.1968125 , 0.199875 ,
0.2029375 , 0.206 , 0.2090625 , 0.212125 , 0.2151875 ,
0.21825 , 0.2213125 , 0.224375 , 0.2274375 , 0.2305 ,
0.2335625 , 0.236625 , 0.2396875 , 0.24275 , 0.2458125 ,
0.248875 , 0.2519375 , 0.255 , 0.2580625 , 0.261125 ,
0.2641875 , 0.26725 , 0.2703125 , 0.273375 , 0.2764375 ,
0.2795 , 0.2825625 , 0.285625 , 0.2886875 , 0.29175 ,
0.2948125 , 0.297875 , 0.3009375 , 0.304 , 0.3070625 ,
0.310125 , 0.3131875 , 0.31625 , 0.3193125 , 0.322375 ,
0.3254375 , 0.3285 , 0.3315625 , 0.334625 , 0.3376875 ,
0.34075 , 0.3438125 , 0.346875 , 0.3499375 , 0.353 ,
0.359125 , 0.36525 , 0.371375 , 0.3775 , 0.3805625 ,
0.383625 , 0.3866875 , 0.38975 , 0.3928125 , 0.395875 ,
0.3989375 , 0.402 , 0.4050625 , 0.408125 , 0.4111875 ,
0.41425 , 0.4173125 , 0.420375 , 0.4234375 , 0.4265 ,
0.4295625 , 0.432625 , 0.4356875 , 0.43875 , 0.4418125 ,
0.444875 , 0.4479375 , 0.451 , 0.4540625 , 0.457125 ,
0.4601875 , 0.46325 , 0.46478125, 0.4663125 , 0.46784375,
0.469375 , 0.47090625, 0.4724375 , 0.47396875, 0.4755 ,
0.47703125, 0.4785625 , 0.48009375, 0.481625 , 0.4846875 ,
0.48775 , 0.48928125, 0.4908125 , 0.49234375, 0.493875 ,
0.49540625, 0.4969375 , 0.49770313, 0.49846875, 0.49923438,
0.5 ]),
dndz=array([1.14844401e-11, 1.24580765e-11, 1.35042110e-11, 1.46276720e-11,
1.58335812e-11, 1.85147980e-11, 2.15953518e-11, 2.51285760e-11,
2.91743108e-11, 3.37996373e-11, 3.90796884e-11, 5.19502240e-11,
6.85844554e-11, 7.86151087e-11, 8.99775697e-11, 1.02834297e-10,
1.17366135e-10, 1.33774253e-10, 1.52282283e-10, 1.73138657e-10,
1.96619189e-10, 2.23029889e-10, 2.52710062e-10, 2.86035702e-10,
3.23423208e-10, 4.12276239e-10, 5.23573002e-10, 6.62567436e-10,
8.35659296e-10, 1.05062750e-09, 1.31690785e-09, 1.64592293e-09,
2.05147342e-09, 2.55020129e-09, 3.16213727e-09, 3.91134687e-09,
4.82669127e-09, 5.94272230e-09, 7.30073314e-09, 8.94999016e-09,
1.09491746e-08, 1.33680674e-08, 1.62895150e-08, 1.98117193e-08,
2.40509022e-08, 2.91443991e-08, 3.52542475e-08, 4.25713425e-08,
5.13202414e-08, 6.17647114e-08, 7.42141257e-08, 8.90308268e-08,
1.06638592e-07, 1.27532348e-07, 1.52289316e-07, 1.81581756e-07,
2.16191546e-07, 2.57026818e-07, 3.05140925e-07, 3.61754024e-07,
4.28277624e-07, 5.06342435e-07, 5.97829951e-07, 7.04908199e-07,
8.30072156e-07, 9.76189375e-07, 1.14655144e-06, 1.34493188e-06,
1.57565131e-06, 1.84365059e-06, 2.15457282e-06, 2.51485525e-06,
2.93183198e-06, 3.41384879e-06, 3.97039113e-06, 4.61222680e-06,
5.35156460e-06, 6.20223074e-06, 7.17986446e-06, 8.30213497e-06,
9.58898144e-06, 1.10628784e-05, 1.27491285e-05, 1.46761858e-05,
1.68760109e-05, 1.93844627e-05, 2.22417271e-05, 2.54927885e-05,
2.91879462e-05, 3.33833783e-05, 3.81417593e-05, 4.35329328e-05,
4.96346456e-05, 5.65333460e-05, 6.43250523e-05, 7.31162951e-05,
8.30251392e-05, 9.41822906e-05, 1.06732293e-04, 1.20834821e-04,
1.36666073e-04, 1.74311305e-04, 2.21468081e-04, 2.80309483e-04,
3.53447866e-04, 4.44010587e-04, 5.55726058e-04, 6.93021013e-04,
8.61129877e-04, 1.06621704e-03, 1.31551286e-03, 1.61746397e-03,
1.98189868e-03, 2.42020753e-03, 2.94553965e-03, 3.57301462e-03,
4.31994976e-03, 5.20610228e-03, 6.25392550e-03, 7.48883792e-03,
8.93950352e-03, 1.06381214e-02, 1.26207226e-02, 1.49274701e-02,
1.76029612e-02, 2.06965251e-02, 2.42625148e-02, 2.83605867e-02,
3.30559637e-02, 4.45287766e-02, 5.93224997e-02, 7.81798127e-02,
1.01946702e-01, 1.31571017e-01, 1.68096740e-01, 2.12653429e-01,
2.66440488e-01, 3.30706123e-01, 4.06721163e-01, 4.95748188e-01,
5.99006742e-01, 7.17635664e-01, 8.52653860e-01, 1.00492100e+00,
1.17509972e+00, 1.36362098e+00, 1.57065408e+00, 1.79608265e+00,
2.03948788e+00, 2.30013947e+00, 2.57699495e+00, 2.86870722e+00,
3.17363992e+00, 3.48988995e+00, 3.81531591e+00, 4.14757152e+00,
4.48414228e+00, 4.82238424e+00, 5.15956340e+00, 5.49289461e+00,
5.81957901e+00, 6.13683918e+00, 6.44195179e+00, 6.73227735e+00,
7.00528719e+00, 7.25858809e+00, 7.48994462e+00, 7.69729997e+00,
7.87879546e+00, 8.03278909e+00, 8.15787345e+00, 8.25289286e+00,
8.31695964e+00, 8.34946911e+00, 8.35011280e+00, 8.31888913e+00,
8.25611089e+00, 8.16240863e+00, 8.03872930e+00, 7.88632959e+00,
7.70676337e+00, 7.50186312e+00, 7.27371543e+00, 7.02463069e+00,
6.75710778e+00, 6.47379429e+00, 6.17744355e+00, 5.87086943e+00,
5.55690029e+00, 5.23833341e+00, 4.91789104e+00, 4.59817948e+00,
4.28165211e+00, 3.97057728e+00, 3.66701182e+00, 3.37278058e+00,
3.08946218e+00, 2.81838103e+00, 2.56060539e+00, 2.31695106e+00,
2.08799016e+00, 1.87406424e+00, 1.67530115e+00, 1.49163464e+00,
1.32282609e+00, 1.02810452e+00, 7.86658833e-01, 5.92719710e-01,
4.39878705e-01, 3.76827515e-01, 3.21625366e-01, 2.73508568e-01,
2.31749988e-01, 1.95664509e-01, 1.64612780e-01, 1.38003457e-01,
1.15294134e-01, 9.59911785e-02, 7.96486505e-02, 6.58665188e-02,
5.42883259e-02, 4.45984681e-02, 3.65192217e-02, 2.98076339e-02,
2.42523735e-02, 1.96706208e-02, 1.59050578e-02, 1.28210047e-02,
1.03037353e-02, 8.25599296e-03, 6.59571684e-03, 5.25398437e-03,
4.17316515e-03, 3.30527989e-03, 2.61055318e-03, 2.05614693e-03,
1.61505981e-03, 1.42993238e-03, 1.26517731e-03, 1.11866025e-03,
9.88457148e-04, 8.72835126e-04, 7.70234925e-04, 6.79254786e-04,
5.98635676e-04, 5.27247760e-04, 4.64078036e-04, 4.08219049e-04,
3.58858590e-04, 2.76805267e-04, 2.12989728e-04, 1.86661753e-04,
1.63489844e-04, 1.43108941e-04, 1.25194454e-04, 1.09458004e-04,
9.56435839e-05, 8.93851257e-05, 8.35240988e-05, 7.80361241e-05,
7.28982579e-05]),
measurements={<Galaxies.COUNTS: '5'>},
type_source='default')]
LSST SRD redshift distributions
The LSST SRD provides the parameters used to generate the redshift distributions. Firecrown includes dataclass instances LSST_Y1_LENS_HARMONIC_BIN_COLLECTION and LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION, which store the parameters for generating redshift distributions for the Y1 lens and source samples, respectively. Similar collections, LSST_Y10_LENS_HARMONIC_BIN_COLLECTION and LSST_Y10_SOURCE_HARMONIC_BIN_COLLECTION, exist for the Y10 samples.
Below is a code snippet demonstrating how to serialize and read back these dataclasses:
from firecrown.generators.inferred_galaxy_zdist import (
LSST_Y1_LENS_HARMONIC_BIN_COLLECTION,
LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION,
)
lsst_y1_lens_yaml = base_model_to_yaml(LSST_Y1_LENS_HARMONIC_BIN_COLLECTION)
lsst_y1_source_yaml = base_model_to_yaml(LSST_Y1_SOURCE_HARMONIC_BIN_COLLECTION)The produced YAML for the lens is:
Code
Markdown(f"```yaml\n{lsst_y1_lens_yaml}\n```")alpha: 0.94
beta: 2.0
z0: 0.26
bins:
- zpl: 0.2
zpu: 0.4
sigma_z: 0.03
z:
values: [0.0, 3.5]
bin_name: lens_0.2_0.4_y1
measurements:
- {subject: Galaxies, property: COUNTS}
- zpl: 0.4
zpu: 0.6000000000000001
sigma_z: 0.03
z:
values: [0.0, 3.5]
bin_name: lens_0.4_0.6_y1
measurements:
- {subject: Galaxies, property: COUNTS}
- zpl: 0.6000000000000001
zpu: 0.8
sigma_z: 0.03
z:
values: [0.0, 3.5]
bin_name: lens_0.6_0.8_y1
measurements:
- {subject: Galaxies, property: COUNTS}
- zpl: 0.8
zpu: 1.0
sigma_z: 0.03
z:
values: [0.0, 3.5]
bin_name: lens_0.8_1.0_y1
measurements:
- {subject: Galaxies, property: COUNTS}
- zpl: 1.0
zpu: 1.2
sigma_z: 0.03
z:
values: [0.0, 3.5]
bin_name: lens_1.0_1.2_y1
measurements:
- {subject: Galaxies, property: COUNTS}
max_z: 5.0
use_autoknot: true
autoknots_reltol: 0.0001
autoknots_abstol: 1.0e-15And for the source:
Code
Markdown(f"```yaml\n{lsst_y1_source_yaml}\n```")alpha: 0.78
beta: 2.0
z0: 0.13
bins:
- zpl: 0.0
zpu: 0.3469503615882613
sigma_z: 0.05
z:
values: [0.0, 3.5]
bin_name: source_0.0_0.3_y1
measurements:
- {subject: Galaxies, property: SHEAR_E}
- zpl: 0.3469503615882613
zpu: 0.5450937583511176
sigma_z: 0.05
z:
values: [0.0, 3.5]
bin_name: source_0.3_0.5_y1
measurements:
- {subject: Galaxies, property: SHEAR_E}
- zpl: 0.5450937583511176
zpu: 0.772197703213008
sigma_z: 0.05
z:
values: [0.0, 3.5]
bin_name: source_0.5_0.8_y1
measurements:
- {subject: Galaxies, property: SHEAR_E}
- zpl: 0.772197703213008
zpu: 1.1138743446239814
sigma_z: 0.05
z:
values: [0.0, 3.5]
bin_name: source_0.8_1.1_y1
measurements:
- {subject: Galaxies, property: SHEAR_E}
- zpl: 1.1138743446239814
zpu: 3.499999994073796
sigma_z: 0.05
z:
values: [0.0, 3.5]
bin_name: source_1.1_3.5_y1
measurements:
- {subject: Galaxies, property: SHEAR_E}
max_z: 5.0
use_autoknot: true
autoknots_reltol: 0.0001
autoknots_abstol: 1.0e-15Conclusion
In this tutorial, we demonstrated how to serialize and read back the ZDistLSSTSRDBin and ZDistLSSTSRDBinCollection dataclasses. We also showed how to serialize and read back the LSST SRD redshift distributions.