def new_cosmo_model(self, p): if model_type == "wwa": model = cosmo.Cosmow0wa() model.Omega_k = p['Omega_k'].free model.wa = p['wa'].free else: model = cosmo.CosmoLambda() model.Omega_lambda = p['Omega_lambda'].free model.Omega_m = p['Omega_m'].free model.w = p['w'].free model.H0 = p['H0'].free model.Omega_b_h2 = p['Omega_b_h2'].free return model
def generate_sample(obslog): """ generate a sample, with 1 sn per redshift bin """ cosmo_model = cosmo.CosmoLambda() norm = 1.E-9 / (4. * np.pi) z = np.arange(0.05, 1.2, 0.05) nsn_tot = len(z) mjd_start, mjd_end = obslog.mjd.min(), obslog.mjd.max() dl = cosmo_model.dL(z) X1 = np.zeros_like(z) Color = np.zeros_like(z) # DayMax = np.random.uniform(mjd_start, mjd_end, size=nsn_tot) DayMax = np.zeros_like(z) ra = np.zeros_like(z) dec = np.zeros_like(z) sample = np.rec.fromarrays( (z, dl, DayMax, X1, Color, ra, dec), names=['z', 'dL', 'DayMax', 'X1', 'Color', 'ra', 'dec']) return sample
def __init__(self, pxlobs, z=0.5, rf_phase_range=(-20., 45.), nside=64, etc=None, lc_template=None, model_filename=None): """ Constructor. Takes a file """ self.pixel_obs = pxlobs self.mjd = np.unique(np.floor(pxlobs['mjd'])).astype(int) self.mjd = self.mjd[self.mjd>0] self.nside, self.npix = nside, hp.nside2npix(nside) self.rf_phase_range = np.array(rf_phase_range) self.min_rf_phase_range = np.array(rf_phase_range) + np.array([10., -10.]) self.accept = [] self.fig_odometer = 0 self.cache_mjd_min = 0. self.cache_mjd_max = 0. self.cache = None # add an etc logging.info('loading ETC') self.etc = psf.find(instrument_name) if etc is None else etc suffix = self.etc.instrument.name + '::' self.pixel_obs['bandname'][:] = np.core.defchararray.add(suffix, self.pixel_obs['band']) # add a LC model self.sn = np.rec.fromarrays(([0.] * 7), names=['z', 'dL', 'DayMax', 'X1', 'Color', 'ra', 'dec']) self.sn['X1'], self.sn['Color'] = -2., 0.2 logging.info('instantiating Cosmo model') self.cosmo = cosmo.CosmoLambda() logging.info('loading SALT2 from: %s' % model_filename) # self.lcmodel = snsim.init_lc_model(np.unique(self.pixel_obs['bandname']), # model_filename) logging.info('done.') # add something to manage the LC templates # print lc_template if lc_template is not None: self.lc_template_cache = self._build_lc_template_cache(lc_template) else: self.lc_template_cache = None
import pyfits from saunerie.spectrum import Spectrum from saunerie.instruments import FilterWheel from glob import glob ### # Choix du modèle pour les performances ### # model_type = "wwa" model_type = "lambdaCDM" if model_type == "wwa": mod = cosmo.Cosmow0wa() else: mod = cosmo.CosmoLambda() ### # Extraction du spectre SALT2 ### class NotKeptError(Exception): pass print 'Starting --- ' + time.ctime() m = InstrumentModel("LSSTPG") cfg = saltpath.read_card_file(saltpath.fitmodel_filename) salt2_model_path = saltpath.SALTPATH + os.sep + cfg['SALT2'] M0_filename = salt2_model_path + os.sep + 'salt2_template_0.dat'