How to use sncosmo - 2 common examples

To help you get started, we’ve selected a few sncosmo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Samreay / SurveyVisualiser / surveyvis / View on Github external
def get_colors(self, time, style="ivu3", layers=1):
        import sncosmo
        model = sncosmo.Model(source='salt2')

        # Get band filter name to work with sncosmo
        bands = ["bessellr", "bessellv", "bessellb", "besselli", "bessellux"]

        colours = []
        for x0, x1, c, t, z in zip(self.x0s, self.x1s, self.cs, self.ts, self.z):
            if not self.redshift:
                z = 0.2
            # z = 0.05
            model.set(z=z, t0=t, x0=x0, x1=x1, c=c)
            fluxes = []
            for b in bands:
                    flux = model.bandflux(b, time)
                except ValueError:
                    flux = 0
github astrocatalogs / supernovae / tasks / View on Github external
        }])[0][QUANTITY.VALUE] == 'Ia'):
            source = sncosmo.get_source('salt2', version='2.4')
            model = sncosmo.Model(source=source)
            mredchisq = np.inf
            fm = None
            for zmin in np.linspace(0.0, 1.0, 19):
                zmax = zmin + 0.1  # Overlapping intervals
                    resl, fml = sncosmo.fit_lc(
                        model, ['z', 't0', 'x0', 'x1', 'c'],
                        bounds={'z': (zmin, zmax)})
                except RuntimeError:
                except sncosmo.fitting.DataQualityError:
                if resl.ndof < 15:
                redchiq = resl.chisq / resl.ndof
                if (redchiq < mredchisq and redchiq < 2.0 and not np.isclose(
                        zmin, fml.get('z'), rtol=1.0e-3) and not np.isclose(
                            zmax, fml.get('z'), rtol=1.e-3)):
                    mredchisq = resl.chisq
                    res, fm = resl, fml

            if fm:
                print(event, res.chisq / res.ndof,
                      if SUPERNOVA.REDSHIFT in catalog.entries[event] else
                      'no redshift')


Package for supernova cosmology based on astropy

Latest version published 1 month ago

Package Health Score

75 / 100
Full package analysis

Similar packages