diff --git a/docs/check.html b/docs/check.html index d59b3d4..8a2a488 100644 --- a/docs/check.html +++ b/docs/check.html @@ -503,7 +503,7 @@

Module deeplenstronomy.check

errs = [] # check that transmission curves exist for the bands - if model_name not in ['flat', 'flatnoise', 'variable', 'variablenoise']: + if model_name not in ['flat', 'flatnoise', 'variable', 'variablenoise', 'static']: if not self.checked_ts_bands: for band in self.config["SURVEY"]["PARAMETERS"]["BANDS"].split(','): try: @@ -923,11 +923,20 @@

Module deeplenstronomy.check

except TypeError: errs.append("Listed NITES in GEOMETRY." + k + ".TIMESERIES.NITES must be numeric") + # Check validity of PEAK argument, if passed + if "PEAK" in self.config['GEOMETRY'][k][config_k].keys(): + if not isinstance(self.config['GEOMETRY'][k][config_k]["PEAK"], dict): + try: + peak = int(float(self.config['GEOMETRY'][k][config_k]["PEAK"])) + del peak + except TypeError: + errs.append("PEAK argument in GEOMETRY." + k + ".TIMESERIES.PEAK must be numeric") + # Impose restriction on num_exposures if isinstance(self.config["SURVEY"]["PARAMETERS"]["num_exposures"], dict): errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") else: - if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] != 1: + if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] < 0.99 or self.config["SURVEY"]["PARAMETERS"]["num_exposures"] > 1.01: errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") elif config_k == 'NAME' or config_k == 'FRACTION': @@ -1456,7 +1465,7 @@

Classes

errs = [] # check that transmission curves exist for the bands - if model_name not in ['flat', 'flatnoise', 'variable', 'variablenoise']: + if model_name not in ['flat', 'flatnoise', 'variable', 'variablenoise', 'static']: if not self.checked_ts_bands: for band in self.config["SURVEY"]["PARAMETERS"]["BANDS"].split(','): try: @@ -1876,11 +1885,20 @@

Classes

except TypeError: errs.append("Listed NITES in GEOMETRY." + k + ".TIMESERIES.NITES must be numeric") + # Check validity of PEAK argument, if passed + if "PEAK" in self.config['GEOMETRY'][k][config_k].keys(): + if not isinstance(self.config['GEOMETRY'][k][config_k]["PEAK"], dict): + try: + peak = int(float(self.config['GEOMETRY'][k][config_k]["PEAK"])) + del peak + except TypeError: + errs.append("PEAK argument in GEOMETRY." + k + ".TIMESERIES.PEAK must be numeric") + # Impose restriction on num_exposures if isinstance(self.config["SURVEY"]["PARAMETERS"]["num_exposures"], dict): errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") else: - if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] != 1: + if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] < 0.99 or self.config["SURVEY"]["PARAMETERS"]["num_exposures"] > 1.01: errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") elif config_k == 'NAME' or config_k == 'FRACTION': @@ -2439,11 +2457,20 @@

Methods

except TypeError: errs.append("Listed NITES in GEOMETRY." + k + ".TIMESERIES.NITES must be numeric") + # Check validity of PEAK argument, if passed + if "PEAK" in self.config['GEOMETRY'][k][config_k].keys(): + if not isinstance(self.config['GEOMETRY'][k][config_k]["PEAK"], dict): + try: + peak = int(float(self.config['GEOMETRY'][k][config_k]["PEAK"])) + del peak + except TypeError: + errs.append("PEAK argument in GEOMETRY." + k + ".TIMESERIES.PEAK must be numeric") + # Impose restriction on num_exposures if isinstance(self.config["SURVEY"]["PARAMETERS"]["num_exposures"], dict): errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") else: - if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] != 1: + if self.config["SURVEY"]["PARAMETERS"]["num_exposures"] < 0.99 or self.config["SURVEY"]["PARAMETERS"]["num_exposures"] > 1.01: errs.append("You must set SURVEY.PARAMETERS.num_exposures to 1 if you use TIMESERIES") elif config_k == 'NAME' or config_k == 'FRACTION': diff --git a/docs/input_reader.html b/docs/input_reader.html index 0cd274a..e4d41d1 100644 --- a/docs/input_reader.html +++ b/docs/input_reader.html @@ -534,15 +534,17 @@

Module deeplenstronomy.input_reader

return output_dict - def _flatten_and_fill_time_series(self, config_dict, cosmo, configuration, obj_strings, objid): + def _flatten_and_fill_time_series(self, config_dict, cosmo, configuration, obj_strings, objid, peakshift): """ Generate an image info dictionary for each step in the time series :param config_dict: dictionary built up by self.breakup() :param configuration: CONFIGURATION_1, CONFIGURATION_2, etc. :param obj_string: list of the strings targetting the object in the flattened dictionary (e.g. ['PLANE_2-OBJECT_2']) + :param peakshifts: int or float in units of NITES to shift the peak :return: flattened_and_filled dictionary: dict ready for individual image sim """ + output_dicts = [] bands = self.main_dict['SURVEY']['PARAMETERS']['BANDS'].split(',') # Get flattened and filled dictionary @@ -555,10 +557,9 @@

Module deeplenstronomy.input_reader

lcs = eval('self.{0}_{1}_lightcurves'.format(configuration, obj_name)) closest_redshift_lcs.append(lcs['library'][np.argmin(np.abs(redshift - lcs['redshifts']))]) - # overwrite the image sim dictionary - fake_noise = np.random.normal(scale=0.15, loc=0, size=len(obj_strings) * len(bands) * len(self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES'])) - noise_idx = 0 - for nite in self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES']: + # overwrite the image sim dictionary + for orig_nite in self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES']: + nite = orig_nite - peakshift output_dict = base_output_dict.copy() for band in bands: for obj_sting, closest_redshift_lc in zip(obj_strings, closest_redshift_lcs): @@ -570,14 +571,14 @@

Module deeplenstronomy.input_reader

#linearly interpolate between the closest two nights band_df = closest_redshift_lc['lc'][closest_redshift_lc['lc']['BAND'].values == band].copy().reset_index(drop=True) closest_nite_indices = np.abs(nite - band_df['NITE'].values).argsort()[:2] - output_dict[band][obj_string + '-magnitude'] = (band_df['MAG'].values[closest_nite_indices[1]] - band_df['MAG'].values[closest_nite_indices[0]]) * (nite - band_df['NITE'].values[closest_nite_indices[1]]) / (band_df['NITE'].values[closest_nite_indices[1]] - band_df['NITE'].values[closest_nite_indices[0]]) + band_df['MAG'].values[closest_nite_indices[1]] + fake_noise[noise_idx] + output_dict[band][obj_string + '-magnitude'] = (band_df['MAG'].values[closest_nite_indices[1]] - band_df['MAG'].values[closest_nite_indices[0]]) * (nite - band_df['NITE'].values[closest_nite_indices[1]]) / (band_df['NITE'].values[closest_nite_indices[1]] - band_df['NITE'].values[closest_nite_indices[0]]) + band_df['MAG'].values[closest_nite_indices[1]] + output_dict[band][obj_string + '-magnitude_measured'] = np.random.normal(loc=output_dict[band][obj_string + '-magnitude'], scale=0.03) - output_dict[band][obj_string + '-nite'] = nite + output_dict[band][obj_string + '-nite'] = orig_nite + output_dict[band][obj_string + '-peaknite'] = peakshift output_dict[band][obj_string + '-id'] = closest_redshift_lc['sed'] output_dict[band][obj_string + '-type'] = closest_redshift_lc['obj_type'] - noise_idx += 1 - # Use independent observing conditions for each nite if conditions are drawn from distributions # seeing if isinstance(self.main_dict["SURVEY"]["PARAMETERS"]["seeing"], dict): @@ -755,10 +756,20 @@

Module deeplenstronomy.input_reader

# Get string referencing the varaible object obj_strings = [self._find_obj_string(x, k) for x in self.main_dict['GEOMETRY'][k]['TIMESERIES']['OBJECTS']] + # Get the PEAK for the configuration + if 'PEAK' in self.main_dict['GEOMETRY'][k]['TIMESERIES'].keys(): + if isinstance(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'], dict): + peakshifts = [self._draw(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK']['DISTRIBUTION'], bands='b')[0] for _ in range(v['SIZE'])] + else: + peakshifts = [float(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'])] * v['SIZE'] + else: + peakshifts = [0.0] * v['SIZE'] + + for objid in range(v['SIZE']): if time_series: - flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid) + flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid, peakshifts[objid]) for flattened_image_info in flattened_image_infos: configuration_sim_dicts[k].append(flattened_image_info) else: @@ -1125,15 +1136,17 @@

Args

return output_dict - def _flatten_and_fill_time_series(self, config_dict, cosmo, configuration, obj_strings, objid): + def _flatten_and_fill_time_series(self, config_dict, cosmo, configuration, obj_strings, objid, peakshift): """ Generate an image info dictionary for each step in the time series :param config_dict: dictionary built up by self.breakup() :param configuration: CONFIGURATION_1, CONFIGURATION_2, etc. :param obj_string: list of the strings targetting the object in the flattened dictionary (e.g. ['PLANE_2-OBJECT_2']) + :param peakshifts: int or float in units of NITES to shift the peak :return: flattened_and_filled dictionary: dict ready for individual image sim """ + output_dicts = [] bands = self.main_dict['SURVEY']['PARAMETERS']['BANDS'].split(',') # Get flattened and filled dictionary @@ -1146,10 +1159,9 @@

Args

lcs = eval('self.{0}_{1}_lightcurves'.format(configuration, obj_name)) closest_redshift_lcs.append(lcs['library'][np.argmin(np.abs(redshift - lcs['redshifts']))]) - # overwrite the image sim dictionary - fake_noise = np.random.normal(scale=0.15, loc=0, size=len(obj_strings) * len(bands) * len(self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES'])) - noise_idx = 0 - for nite in self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES']: + # overwrite the image sim dictionary + for orig_nite in self.main_dict['GEOMETRY'][configuration]['TIMESERIES']['NITES']: + nite = orig_nite - peakshift output_dict = base_output_dict.copy() for band in bands: for obj_sting, closest_redshift_lc in zip(obj_strings, closest_redshift_lcs): @@ -1161,14 +1173,14 @@

Args

#linearly interpolate between the closest two nights band_df = closest_redshift_lc['lc'][closest_redshift_lc['lc']['BAND'].values == band].copy().reset_index(drop=True) closest_nite_indices = np.abs(nite - band_df['NITE'].values).argsort()[:2] - output_dict[band][obj_string + '-magnitude'] = (band_df['MAG'].values[closest_nite_indices[1]] - band_df['MAG'].values[closest_nite_indices[0]]) * (nite - band_df['NITE'].values[closest_nite_indices[1]]) / (band_df['NITE'].values[closest_nite_indices[1]] - band_df['NITE'].values[closest_nite_indices[0]]) + band_df['MAG'].values[closest_nite_indices[1]] + fake_noise[noise_idx] + output_dict[band][obj_string + '-magnitude'] = (band_df['MAG'].values[closest_nite_indices[1]] - band_df['MAG'].values[closest_nite_indices[0]]) * (nite - band_df['NITE'].values[closest_nite_indices[1]]) / (band_df['NITE'].values[closest_nite_indices[1]] - band_df['NITE'].values[closest_nite_indices[0]]) + band_df['MAG'].values[closest_nite_indices[1]] + output_dict[band][obj_string + '-magnitude_measured'] = np.random.normal(loc=output_dict[band][obj_string + '-magnitude'], scale=0.03) - output_dict[band][obj_string + '-nite'] = nite + output_dict[band][obj_string + '-nite'] = orig_nite + output_dict[band][obj_string + '-peaknite'] = peakshift output_dict[band][obj_string + '-id'] = closest_redshift_lc['sed'] output_dict[band][obj_string + '-type'] = closest_redshift_lc['obj_type'] - noise_idx += 1 - # Use independent observing conditions for each nite if conditions are drawn from distributions # seeing if isinstance(self.main_dict["SURVEY"]["PARAMETERS"]["seeing"], dict): @@ -1346,10 +1358,20 @@

Args

# Get string referencing the varaible object obj_strings = [self._find_obj_string(x, k) for x in self.main_dict['GEOMETRY'][k]['TIMESERIES']['OBJECTS']] + # Get the PEAK for the configuration + if 'PEAK' in self.main_dict['GEOMETRY'][k]['TIMESERIES'].keys(): + if isinstance(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'], dict): + peakshifts = [self._draw(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK']['DISTRIBUTION'], bands='b')[0] for _ in range(v['SIZE'])] + else: + peakshifts = [float(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'])] * v['SIZE'] + else: + peakshifts = [0.0] * v['SIZE'] + + for objid in range(v['SIZE']): if time_series: - flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid) + flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid, peakshifts[objid]) for flattened_image_info in flattened_image_infos: configuration_sim_dicts[k].append(flattened_image_info) else: @@ -1495,10 +1517,20 @@

Args

# Get string referencing the varaible object obj_strings = [self._find_obj_string(x, k) for x in self.main_dict['GEOMETRY'][k]['TIMESERIES']['OBJECTS']] + # Get the PEAK for the configuration + if 'PEAK' in self.main_dict['GEOMETRY'][k]['TIMESERIES'].keys(): + if isinstance(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'], dict): + peakshifts = [self._draw(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK']['DISTRIBUTION'], bands='b')[0] for _ in range(v['SIZE'])] + else: + peakshifts = [float(self.main_dict['GEOMETRY'][k]['TIMESERIES']['PEAK'])] * v['SIZE'] + else: + peakshifts = [0.0] * v['SIZE'] + + for objid in range(v['SIZE']): if time_series: - flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid) + flattened_image_infos = self._flatten_and_fill_time_series(v.copy(), cosmo, k, obj_strings, objid, peakshifts[objid]) for flattened_image_info in flattened_image_infos: configuration_sim_dicts[k].append(flattened_image_info) else: diff --git a/docs/timeseries.html b/docs/timeseries.html index ed4b226..1a1bebd 100644 --- a/docs/timeseries.html +++ b/docs/timeseries.html @@ -275,6 +275,35 @@

Module deeplenstronomy.timeseries

'obj_type': 'Flat', 'sed': 'Flat'} + def gen_static(self, redshift, nites, sed=None, sed_filename=None, cosmo=None): + """ + Make a static source capable of having time-series data by introducing a mag=99 source + on each NITE of the simulation. + + Args: + redshift (float): ignored + nites (List[int]): a list of night relative to peak you want to obtain a magnitude for + sed_filename (str): ignored + cosmo (astropy.cosmology): ignored + Returns: + lc_dict: a dictionary with keys ['lc, 'obj_type', 'sed'] + - 'lc' contains a dataframe of the light from the object + - 'obj_type' contains a string for the type of object. Will always be 'Static' here + - 'sed' contains the filename of the sed used. Will always be 'Flat' here """ + output_data_cols = ['NITE', 'BAND', 'MAG'] + central_mag = 99.0 + mags = {band: central_mag for band in self.bands} + output_data = [] + for nite in nites: + for band in self.bands: + output_data.append([nite, band, mags[band]]) + + return {'lc': pd.DataFrame(data=output_data, columns=output_data_cols), + 'obj_type': 'Static', + 'sed': 'Static'} + + + def gen_variablenoise(self, redshift, nites, sed=None, sed_filename=None, cosmo=None): """ Generate a variable light curve with small random noise @@ -759,6 +788,35 @@

Args

'obj_type': 'Flat', 'sed': 'Flat'} + def gen_static(self, redshift, nites, sed=None, sed_filename=None, cosmo=None): + """ + Make a static source capable of having time-series data by introducing a mag=99 source + on each NITE of the simulation. + + Args: + redshift (float): ignored + nites (List[int]): a list of night relative to peak you want to obtain a magnitude for + sed_filename (str): ignored + cosmo (astropy.cosmology): ignored + Returns: + lc_dict: a dictionary with keys ['lc, 'obj_type', 'sed'] + - 'lc' contains a dataframe of the light from the object + - 'obj_type' contains a string for the type of object. Will always be 'Static' here + - 'sed' contains the filename of the sed used. Will always be 'Flat' here """ + output_data_cols = ['NITE', 'BAND', 'MAG'] + central_mag = 99.0 + mags = {band: central_mag for band in self.bands} + output_data = [] + for nite in nites: + for band in self.bands: + output_data.append([nite, band, mags[band]]) + + return {'lc': pd.DataFrame(data=output_data, columns=output_data_cols), + 'obj_type': 'Static', + 'sed': 'Static'} + + + def gen_variablenoise(self, redshift, nites, sed=None, sed_filename=None, cosmo=None): """ Generate a variable light curve with small random noise @@ -1369,6 +1427,65 @@

Returns

'sed': sed_filename} +
+def gen_static(self, redshift, nites, sed=None, sed_filename=None, cosmo=None) +
+
+

Make a static source capable of having time-series data by introducing a mag=99 source +on each NITE of the simulation.

+

Args

+
+
redshift : float
+
ignored
+
nites : List[int]
+
a list of night relative to peak you want to obtain a magnitude for
+
sed_filename : str
+
ignored +
+
cosmo : astropy.cosmology
+
ignored +
+
+

Returns

+
+
lc_dict
+
a dictionary with keys ['lc, 'obj_type', 'sed'] +- 'lc' contains a dataframe of the light from the object +- 'obj_type' contains a string for the type of object. Will always be 'Static' here +- 'sed' contains the filename of the sed used. Will always be 'Flat' here
+
+
+ +Expand source code + +
def gen_static(self, redshift, nites, sed=None, sed_filename=None, cosmo=None):
+    """
+    Make a static source capable of having time-series data by introducing a mag=99 source
+    on each NITE of the simulation.
+
+    Args:
+        redshift (float): ignored 
+        nites (List[int]): a list of night relative to peak you want to obtain a magnitude for
+        sed_filename (str): ignored                                                                                                                                                               
+        cosmo (astropy.cosmology): ignored                                                                                                                                                                                            
+    Returns:
+        lc_dict: a dictionary with keys ['lc, 'obj_type', 'sed']
+          - 'lc' contains a dataframe of the light from the object
+          - 'obj_type' contains a string for the type of object. Will always be 'Static' here
+          - 'sed' contains the filename of the sed used. Will always be 'Flat' here                                                                                                                        """
+    output_data_cols = ['NITE', 'BAND', 'MAG']
+    central_mag = 99.0
+    mags = {band: central_mag for band in self.bands}
+    output_data = []
+    for nite in nites:
+        for band in self.bands:
+            output_data.append([nite, band, mags[band]])
+
+    return {'lc': pd.DataFrame(data=output_data, columns=output_data_cols),
+            'obj_type': 'Static',
+            'sed': 'Static'}
+
+
def gen_user(self, redshift, nites, sed=None, sed_filename=None, cosmo=None)
@@ -1561,6 +1678,7 @@

gen_ia
  • gen_kn
  • gen_lc_from_sed
  • +
  • gen_static
  • gen_user
  • gen_variable
  • gen_variablenoise