mwvgroup / csp-cmfgen Goto Github PK
View Code? Open in Web Editor NEWA comparison spectral SNe models against CSP data
Home Page: https://mwvgroup.github.io/nir-comparison/
A comparison spectral SNe models against CSP data
Home Page: https://mwvgroup.github.io/nir-comparison/
In
nir-comparison/analysis/spectra_chisq/_synthetic_photometry.py
there are a few for
loops. I would recommend that the body of each of these for loops be defined as a function. That makes the bodies of these loops testable.
In the following code:
import sncosmo
sources = [Chandra()]
for i in range(0, 1):
# select 14 names of SN from the 3rd CSP data release
name = csp.master_table[i*10]['SN']
data_formatted = csp.get_input_for_id(name)
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_u')] = 'cspu'
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_B')] = 'cspb'
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_V0')] = 'cspv3014'
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_g')] = 'cspg'
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_i')] = 'cspi'
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_r')] = 'cspr'
for source in sources:
# create a model
model = sncosmo.Model(source=source)
model.set(z=data_formatted.meta['redshift'])
result, fitted_model = sncosmo.fit_lc(
data_formatted, model,
['t0', 'x0']) # parameters of model to vary
# bounds={'z': (0.3, 0.7)}) # bounds on parameters (if any)
print("SN: ", name, " MODEL: ", source.name)
print(" param_names:", result.param_names)
print(" parameters:", result.parameters)
print(" chisq:", result.chisq)
print(" ndof:", result.ndof)
print(" errors", result.errors)
print(" covariance", result.covariance)
# Plot results
fig = sncosmo.plot_lc(data_formatted, model=fitted_model, errors=result.errors, model_label=source.name)
fig.show()
I need to map the band names, for example:
data_formatted['band'][np.where(data_formatted['band'] == '91bg_proj_csp_u')] = 'cspu'
else the plots will have band names like <Bandpass at 0x183ea94c88>
PR #5 added figures comparing the original CMFGEN models and the interpolated versions we use in SNCosmo. I gave the results a cursory glance and it looked good, but haven't checked every model / phase.
CSP light curves need to be fitted using the CMFGEN models ported to SNCosmo models. Deliverables for this issue include:
The fluxes we are using to define each custom model are simulated at a distance of 1 kpc away. However, sncosmo
asserts a default redshift of 0
for each instantiated Model
class. Technically this isn't a big deal because 1 kpc is a pretty small redshift:
>>> from astropy import units as u
>>> from astropy.cosmology import WMAP9
>>> from astropy.coordinates import Distance
>>>
>>> d = Distance(value=1, unit=u.kpc)
>>> d.compute_z(WMAP9)
2.3120594343144655e-07
However, I would still prefer us porting the model correctly.
PR #3 added a comparison of the color evolution for each CMFGEN model against DR3 photometry. Colors were determined for each DR3 target by interpolating in time with a gaussian regression. These values were then compared against the color evolution of each CMFGEN model. This work was a step in the right direction but was incomplete. Remaining steps include:
The Gaussian regression can run away for phase values outside the observed phase range. The easiest way to fix this is to bound the Gaussian regression in each band between the first and last data point. (Finished in PR #6)
The observed photometry suffers from extinction while the models do not. Extinction values for each target need to be looked up and applied to the models before comparison. These values are probably available on the Open Supernova Catalog. (Finished in PR #6)
The error values returned by the Gaussian regression are too small. A "correct" (a word I use loosely) error implementation would involve resampling and looking at the variation in the Gaussian fits.
This issue should culminate in a series of plots summarizing chi-squared values globally and band-by-band. We should plot chisquared distribution over all targets for two fixed phase ranges (-10 to 15 and something larger)
We should also plot delta color over 15 days for the model vs the data.
We are currently skipping targets without a CSP published t0 value or E(B-V) value. In the future, we can fit for and / or look up these values in other literature sources.
We can calculate the chi-squared value between our models and DR2 spectroscopy. I imagine the general steps for this include:
t0
values to shift out modeled phase values to the same t=0
point as each observationThe chi-squared should be calculated for the total spectrum but also for individual regions overlapping with different bandpasses. These regions can be defined as the point where the transmission drops below 10%. u-band should have a lower bound around 3200 A (It has a long blueward tail).
A major road block is that error values for the DR1 spectra are note published.
We are converting from various time formats to JD at multiple points of the analysis pipeline. For consistency and to avoid mistakes, this should be done in utils.py
and whenever we call upon sndata
. This is both more consistent and will lead to fewer bugs.
The color evolution of the CMFGEN models are very similar for phases near peak B-band magnitude. To understand our ability to constrain the models in color space, we should plot the predicted SNR ratio of LSST as a function of phase and redshift (i.e., A 2d plot where SNR is a third, color axis).
This plot will involve combining information from the single visit quoted depth for LSST and a supernova model (likely Salt2).
As a validation step for the data we are using, the published CSP photometry should be compared against the integrated flux from the spectroscopic observations. Steps for this include:
This issue should culminate with a table having columns similar to obj_id
, time
, flux_val
, phot_val
.
We can use the DR1 data until DR2 is ported to SNData.
The equivalent widths of CMFGEN spectra should be compared against spectral observations from CSP DR2. The equivalent width calculation should ideally follow Folatelli et al. 2013. Doing so will allow us to validate our results while also ensuring any equivalent widths we publish for features not in the CSP paper can be interpreted more easily.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.