Git Product home page Git Product logo

csp-cmfgen's People

Contributors

djperrefort avatar

Watchers

 avatar

csp-cmfgen's Issues

band name mappings

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>

Inspect grid interpolation residuals

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.

Fit CSP light-curves with CMFGEN

CSP light curves need to be fitted using the CMFGEN models ported to SNCosmo models. Deliverables for this issue include:

  1. A plot of the global chi-squared / dof distribution determined by fitting all bands together
  2. A plot of the global chi-squared / dof distribution determined by fitting each band individually
  3. A plot of the band specific chi-squared / dof distribution determined by fitting each band individually
  4. A plot of the chi-squared in J-band determined by fitting all bands vs by just fitting J-band

Incorrect redshift for models.

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.

Compare photometric colors

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.

Calculate chi-squared between model and observed spectra

We can calculate the chi-squared value between our models and DR2 spectroscopy. I imagine the general steps for this include:

  • Color-warping the observed spectra to account for the wavelength dependence of the flux calibration
  • Using published t0 values to shift out modeled phase values to the same t=0 point as each observation
  • Modeling the flux with each model at for each observed time
  • Tabulating chi-squared values
  • summarizing results in a few plots

The 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.

Plot projected SNR for LSST

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).

Compare CSP spectra with CSP photometry

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:

  1. Pick a spectrum and photometric band-pass
  2. Select the spectroscopic flux values in that band-pass
  3. Integrate the observed flux times the band-pass transmission
  4. Fit the light curve (most likely with a Gaussian regression for consistency)
  5. Compare (tabulate) the fitted photometric value with the integrated flux value
  6. Repeat for each spectrum / bandpass combo

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.

Compare equivalent widths

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.

  • Calculate pw using feature bounds determined from the observed spectra
  • Calculate pw leaving the feature bounds unfixed
  • Repeat the CSP silicon plots for Tmax
  • Plot modeld and observed pw as a function of phase
  • Validate we are converting modeled to observed phase correctly when tabulating pew per phase

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.