diff --git a/bin/run_vega_mpi.py b/bin/run_vega_mpi.py index bc543b9..5feacf6 100644 --- a/bin/run_vega_mpi.py +++ b/bin/run_vega_mpi.py @@ -55,10 +55,6 @@ def print_func(message): raise ValueError('You asked to run over a Monte Carlo simulation,' ' but no "[monte carlo]" section provided.') - # run compute_model once to initialize all the caches - # vega.set_fast_metals() - # _ = vega.compute_model(run_init=False) - # Run sampler if vega.has_sampler: print_func('Running the sampler') diff --git a/vega/correlation_item.py b/vega/correlation_item.py index 165d1f3..4f38acb 100644 --- a/vega/correlation_item.py +++ b/vega/correlation_item.py @@ -1,6 +1,3 @@ -import numpy as np - - class CorrelationItem: """Class for handling the info and config of each correlation function component. @@ -9,18 +6,6 @@ class CorrelationItem: model_coordinates = None dist_model_coordinates = None data_coordinates = None - # _rp_rt_grid = None - # _r_mu_grid = None - # _z_grid = None - # _bin_size_rp_model = None - # _bin_size_rt_model = None - # _bin_size_rp_data = None - # _bin_size_rt_data = None - # rp_min_model = None - # rp_max_model = None - # rt_max_model = None - # num_bins_rp_model = None - # num_bins_rt_model = None def __init__(self, config, model_pk=False): """ @@ -106,92 +91,3 @@ def init_coordinates( self.data_coordinates = model_coordinates if data_coordinates is None else data_coordinates self.dist_model_coordinates = (model_coordinates if dist_model_coordinates is None else dist_model_coordinates) - - # @property - # def r_mu_grid(self): - # return self._r_mu_grid - - # @r_mu_grid.setter - # def r_mu_grid(self, r_mu_grid): - # self._r_mu_grid = np.array(r_mu_grid) - # assert (self._r_mu_grid[1] <= 1).all() - # assert (self._r_mu_grid[1] >= -1).all() - - # # Compute rp/rt from r/mu - # rp_grid = self._r_mu_grid[0] * self._r_mu_grid[1] - # rt_grid = np.sqrt(self._r_mu_grid[0]**2 - rp_grid**2) - - # # Save the rp/rt grid - # self._rp_rt_grid = np.array([rp_grid, rt_grid]) - - # @property - # def rp_rt_grid(self): - # return self._rp_rt_grid - - # @rp_rt_grid.setter - # def rp_rt_grid(self, rp_rt_grid): - # self._rp_rt_grid = np.array(rp_rt_grid) - - # # Compute r/mu from rp/rt - # r_grid = np.sqrt(self._rp_rt_grid[0]**2 + self._rp_rt_grid[1]**2) - # mu_grid = np.zeros(r_grid.size) - # w = r_grid > 0. - # mu_grid[w] = self._rp_rt_grid[0, w] / r_grid[w] - - # # Save the r/mu grid - # self._r_mu_grid = np.array([r_grid, mu_grid]) - - # @property - # def z_grid(self): - # return self._z_grid - - # @z_grid.setter - # def z_grid(self, z_grid): - # if not isinstance(z_grid, float): - # assert (z_grid >= 0).all() and (z_grid <= 10).all() - # self._z_grid = np.array(z_grid) - # else: - # assert z_grid >= 0 and z_grid <= 10 - # self._z_grid = z_grid - - # @property - # def bin_size_rp_model(self): - # if self._bin_size_rp_model is None: - # raise ValueError('You must set the value of "bin_size_rp_model" in vega.corr_items to ' - # 'compute model without data.') - # return self._bin_size_rp_model - - # @bin_size_rp_model.setter - # def bin_size_rp_model(self, bin_size_rp_model): - # self._bin_size_rp_model = bin_size_rp_model - - # @property - # def bin_size_rt_model(self): - # if self._bin_size_rt_model is None: - # raise ValueError('You must set the value of "bin_size_rt_model" in vega.corr_items to ' - # 'compute model without data.') - # return self._bin_size_rt_model - - # @bin_size_rt_model.setter - # def bin_size_rt_model(self, bin_size_rt_model): - # self._bin_size_rt_model = bin_size_rt_model - - # @property - # def bin_size_rp_data(self): - # if self._bin_size_rp_data is None: - # return self.bin_size_rp_model - # return self._bin_size_rp_data - - # @bin_size_rp_data.setter - # def bin_size_rp_data(self, bin_size_rp_data): - # self._bin_size_rp_data = bin_size_rp_data - - # @property - # def bin_size_rt_data(self): - # if self._bin_size_rt_data is None: - # return self.bin_size_rt_model - # return self._bin_size_rt_data - - # @bin_size_rt_data.setter - # def bin_size_rt_data(self, bin_size_rt_data): - # self._bin_size_rt_data = bin_size_rt_data diff --git a/vega/data.py b/vega/data.py index c415022..6d33542 100644 --- a/vega/data.py +++ b/vega/data.py @@ -363,89 +363,6 @@ def _read_dmat(self, dmat_path, cuts_config): hdul.close() - # self.rp_min_model = header['RPMIN'] - # self.rp_max_model = header['RPMAX'] - # self.rt_max_model = header['RTMAX'] - # self.coeff_binning_model = header['COEFMOD'] - # self.num_bins_rp_model = header['NP'] * self.coeff_binning_model - # self.num_bins_rt_model = header['NT'] * self.coeff_binning_model - - # Get the model bin size - # TODO If RTMIN is ever added to the cf data files this needs modifying - # self.bin_size_rp_model = (self.rp_max_model - self.rp_min_model) / self.num_bins_rp_model - # self.bin_size_rt_model = self.rt_max_model / self.num_bins_rt_model - - # if ((self.bin_size_rp_model != self.bin_size_rp_data) - # or (self.bin_size_rt_model != self.bin_size_rt_data)): - # rp_custom_grid = np.arange(self.rp_min_model + self.bin_size_rp_data / 2, - # self.rp_max_model, self.bin_size_rp_data) - # rt_custom_grid = np.arange(self.bin_size_rt_data / 2, - # self.rt_max_model, self.bin_size_rt_data) - - # rt_custom_grid, rp_custom_grid = np.meshgrid(rt_custom_grid, rp_custom_grid) - - # self.model_mask = self._build_mask( - # rp_custom_grid.flatten(), rt_custom_grid.flatten(), cuts_config, self.rp_min_model, - # self.bin_size_rp_data, self.bin_size_rt_data - # ) - # self.rp_rt_custom_grid = np.r_[rp_custom_grid, rt_custom_grid] - # else: - # self.model_mask = self._build_mask( - # rp_grid, rt_grid, cuts_config, self.rp_min_model, - # self.bin_size_rp_data, self.bin_size_rt_data - # ) - - # return rp_grid, rt_grid, z_grid - - # def _build_mask(self, rp_grid, rt_grid, cuts_config, rp_min, bin_size_rp, bin_size_rt): - # """Build the mask for the data by comparing - # the cuts from config with the data limits. - - # Parameters - # ---------- - # rp_grid : 1D Array - # Vector of data rp coordinates - # rt_grid : 1D Array - # Vector of data rt coordinates - # cuts_config : ConfigParser - # cuts section from config - # header : fits header - # Data file header - - # Returns - # ------- - # (ND Array, float, float) - # Mask, Bin size in rp, Bin size in rt - # """ - # # Read the cuts - # rp_min_cut = cuts_config.getfloat('rp-min', 0.) - # rp_max_cut = cuts_config.getfloat('rp-max', 200.) - - # rt_min_cut = cuts_config.getfloat('rt-min', 0.) - # rt_max_cut = cuts_config.getfloat('rt-max', 200.) - - # self.r_min_cut = cuts_config.getfloat('r-min', 10.) - # self.r_max_cut = cuts_config.getfloat('r-max', 180.) - - # self.mu_min_cut = cuts_config.getfloat('mu-min', -1.) - # self.mu_max_cut = cuts_config.getfloat('mu-max', +1.) - - # # Compute bin centers - # bin_index_rp = np.floor((rp_grid - rp_min) / bin_size_rp) - # bin_center_rp = rp_min + (bin_index_rp + 0.5) * bin_size_rp - # bin_center_rt = (np.floor(rt_grid / bin_size_rt) + 0.5) * bin_size_rt - - # bin_center_r = np.sqrt(bin_center_rp**2 + bin_center_rt**2) - # bin_center_mu = bin_center_rp / bin_center_r - - # # Build the mask by comparing the data bins to the cuts - # mask = (bin_center_rp > rp_min_cut) & (bin_center_rp < rp_max_cut) - # mask &= (bin_center_rt > rt_min_cut) & (bin_center_rt < rt_max_cut) - # mask &= (bin_center_r > self.r_min_cut) & (bin_center_r < self.r_max_cut) - # mask &= (bin_center_mu > self.mu_min_cut) & (bin_center_mu < self.mu_max_cut) - - # return mask - def _init_metal_tracers(self, metal_config): assert ('in tracer1' in metal_config) or ('in tracer2' in metal_config) @@ -516,9 +433,6 @@ def _init_metals(self, metal_config): self.metal_mats = {} self.metal_coordinates = {} - # self.metal_rp_grids = {} - # self.metal_rt_grids = {} - # self.metal_z_grids = {} # Read the metal file metal_hdul = fits.open(find_file(metal_config.get('filename'))) @@ -619,10 +533,6 @@ def _read_metal_correlation(self, metal_hdul, tracers, name, dm_prefix): z_grid=metal_hdul[2].data['Z_' + name] ) - # self.metal_rp_grids[tracers] = metal_hdul[2].data['RP_' + name] - # self.metal_rt_grids[tracers] = metal_hdul[2].data['RT_' + name] - # self.metal_z_grids[tracers] = metal_hdul[2].data['Z_' + name] - metal_mat_size = self.metal_coordinates[tracers].rp_grid.size dm_name = dm_prefix + name diff --git a/vega/metals.py b/vega/metals.py index 6c837b0..289435e 100644 --- a/vega/metals.py +++ b/vega/metals.py @@ -102,21 +102,6 @@ def __init__(self, corr_item, fiducial, scale_params, PktoXi_obj, data=None): else: # Read rp and rt for the metal correlation metal_coordinates = data.metal_coordinates[(name1, name2)] - # rp_grid = data.metal_rp_grids[(name1, name2)] - # rt_grid = data.metal_rt_grids[(name1, name2)] - # z_grid = data.metal_z_grids[(name1, name2)] - - # Compute the corresponding r/mu coords - # r_grid = np.sqrt(rp_grid**2 + rt_grid**2) - # mask = r_grid != 0 - # mu_grid = np.zeros(len(r_grid)) - # mu_grid[mask] = rp_grid[mask] / r_grid[mask] - - # Initialize the coords grid dictionary - # coords_grid = {} - # coords_grid['r'] = r_grid - # coords_grid['mu'] = mu_grid - # coords_grid['z'] = z_grid # Get bin sizes if self._data is not None: diff --git a/vega/model.py b/vega/model.py index ba35d4d..a6bf6bf 100644 --- a/vega/model.py +++ b/vega/model.py @@ -27,10 +27,6 @@ def __init__(self, corr_item, fiducial, scale_params, data=None): self._model_pk = corr_item.model_pk assert corr_item.model_coordinates is not None - # self._coords_grid = {} - # self._coords_grid['r'] = corr_item.r_mu_grid[0] - # self._coords_grid['mu'] = corr_item.r_mu_grid[1] - # self._coords_grid['z'] = corr_item.z_grid self._data = data data_has_distortion = False diff --git a/vega/output.py b/vega/output.py index 5e2ce75..302a8f8 100644 --- a/vega/output.py +++ b/vega/output.py @@ -233,10 +233,6 @@ def _bestfit_hdu(self, minimizer): bestfit_hdu.name = 'Bestfit' # Add all the attributes of the minimum to the header - # for item, value in minimizer.fmin.items(): - # name = item - # if len(item) > 8: - # name = 'hierarch ' + item bestfit_hdu.header['FVAL'] = minimizer.fmin.fval bestfit_hdu.header['VALID'] = minimizer.minuit.valid bestfit_hdu.header['ACCURATE'] = minimizer.minuit.accurate