Skip to content

Commit

Permalink
Add option to pass separate cov matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
andreicuceu committed Dec 1, 2023
1 parent 38ba683 commit dbfc2a3
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions vega/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')

Check warning on line 256 in vega/data.py

View check run for this annotation

Codecov / codecov/patch

vega/data.py#L256

Added line #L256 was not covered by tests
with fits.open(find_file(cov_path)) as cov_hdul:
self._cov_mat = cov_hdul[1].data['CO']

Check warning on line 258 in vega/data.py

View check run for this annotation

Codecov / codecov/patch

vega/data.py#L258

Added line #L258 was not covered by tests
elif 'CO' in hdul[1].columns.names:
self._cov_mat = hdul[1].data['CO']

# Get the cosmological parameters
Expand Down

0 comments on commit dbfc2a3

Please sign in to comment.