From dbfc2a3d069bcdb81f863b94b37efc9041089e86 Mon Sep 17 00:00:00 2001 From: Andrei Cuceu Date: Fri, 1 Dec 2023 13:09:00 -0500 Subject: [PATCH] Add option to pass separate cov matrix --- vega/data.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/vega/data.py b/vega/data.py index 1752440..6b1b647 100644 --- a/vega/data.py +++ b/vega/data.py @@ -46,8 +46,9 @@ def __init__(self, corr_item): # Read the data file and init the corrdinate grids data_path = corr_item.config['data'].get('filename') dmat_path = corr_item.config['data'].get('distortion-file', None) + cov_path = corr_item.config['data'].get('covariance-file', None) - self._read_data(data_path, corr_item.config['cuts'], dmat_path) + self._read_data(data_path, corr_item.config['cuts'], dmat_path, cov_path) self.corr_item.init_coordinates( self.model_coordinates, self.dist_model_coordinates, self.data_coordinates) @@ -203,7 +204,7 @@ def has_distortion(self): """ return self._distortion_mat is not None - def _read_data(self, data_path, cuts_config, dmat_path=None): + def _read_data(self, data_path, cuts_config, dmat_path=None, cov_path=None): """Read the data, mask it and prepare the environment. Parameters @@ -251,7 +252,11 @@ def _read_data(self, data_path, cuts_config, dmat_path=None): raise ValueError(f"Unknown blinding strategy {self._blinding_strat}.") # Read the covariance matrix - if 'CO' in hdul[1].columns.names: + if cov_path is not None: + print(f'Reading covariance matrix file {cov_path}\n') + with fits.open(find_file(cov_path)) as cov_hdul: + self._cov_mat = cov_hdul[1].data['CO'] + elif 'CO' in hdul[1].columns.names: self._cov_mat = hdul[1].data['CO'] # Get the cosmological parameters