Skip to content

Commit

Permalink
Merge eaabfce into 67b4795
Browse files Browse the repository at this point in the history
  • Loading branch information
andreicuceu committed Jan 15, 2024
2 parents 67b4795 + eaabfce commit 5905acb
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 63 deletions.
19 changes: 12 additions & 7 deletions bin/picca_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
from picca.utils import smooth_cov, compute_cov
from picca.utils import userprint

# TODO: add tags here when we are allowed to unblind them
UNBLINDABLE_STRATEGIES = ["none", "desi_m2", "desi_y1"]


def main(cmdargs):
"""Export auto and cross-correlation for the fitter."""
Expand Down Expand Up @@ -220,8 +223,7 @@ def main(cmdargs):
'name': "BLINDING",
'value': blinding,
'comment': 'String specifying the blinding strategy'
},
{
}, {
'name': 'RPMIN',
'value': r_par_min,
'comment': 'Minimum r-parallel'
Expand Down Expand Up @@ -264,14 +266,17 @@ def main(cmdargs):
'Covariance matrix', 'Distortion matrix', 'Number of pairs'
]

# Check if we need to unblind
if blinding in UNBLINDABLE_STRATEGIES:
userprint(f"'{blinding}' correlations are not blinded.")
blinding = 'none'
data_name = 'DA'
dmat_name = 'DM'

# Check if we need blinding and apply it
if 'BLIND' in data_name or blinding != 'none':
blinding_dir = '/global/cfs/projectdirs/desi/science/lya/y1-kp6/blinding/'
blinding_templates = {'desi_m2': {'standard': 'm2_blinding_v1.2_standard_29_03_2022.h5',
'grid': 'm2_blinding_v1.2_regular_grid_29_03_2022.h5'},
'desi_y1': {'standard': 'y1_blinding_v2_standard_17_12_2022.h5',
'grid': 'y1_blinding_v2_regular_grid_17_12_2022.h5'},
'desi_y3': {'standard': 'y3_blinding_v3_standard_18_12_2022.h5',
blinding_templates = {'desi_y3': {'standard': 'y3_blinding_v3_standard_18_12_2022.h5',
'grid': 'y3_blinding_v3_regular_grid_18_12_2022.h5'}}

if blinding in blinding_templates:
Expand Down
18 changes: 2 additions & 16 deletions py/picca/delta_extraction/data_catalogues/desi_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@
from picca.delta_extraction.quasar_catalogues.desi_quasar_catalogue import (
defaults as defaults_quasar_catalogue)
from picca.delta_extraction.utils import (
ACCEPTED_BLINDING_STRATEGIES, UNBLINDABLE_STRATEGIES)
ACCEPTED_BLINDING_STRATEGIES)
from picca.delta_extraction.utils_pk1d import spectral_resolution_desi, exp_diff_desi
from picca.delta_extraction.utils import (
ABSORBER_IGM, update_accepted_options, update_default_options)

accepted_options = update_accepted_options(accepted_options, accepted_options_quasar_catalogue)
accepted_options = update_accepted_options(
accepted_options,
["unblind", "use non-coadded spectra", "wave solution"])
["use non-coadded spectra", "wave solution"])

defaults = update_default_options(defaults, {
"delta lambda": 0.8,
"delta log lambda": 3e-4,
"unblind": False,
"use non-coadded spectra": False,
"wave solution": "lin",
})
Expand Down Expand Up @@ -106,7 +105,6 @@ def __init__(self, config):
super().__init__(config)

# load variables from config
self.unblind = None
self.use_non_coadded_spectra = None
self.__parse_config(config)

Expand Down Expand Up @@ -141,10 +139,6 @@ def __parse_config(self, config):
DataError upon missing required variables
"""
# instance variables
self.unblind = config.getboolean("unblind")
if self.unblind is None:
raise DataError("Missing argument 'unblind' required by DesiData")

self.use_non_coadded_spectra = config.getboolean(
"use non-coadded spectra")
if self.use_non_coadded_spectra is None:
Expand Down Expand Up @@ -197,14 +191,6 @@ def set_blinding(self, is_mock):
else:
self.blinding = "desi_y3"

if self.unblind:
if self.blinding not in UNBLINDABLE_STRATEGIES:
raise DataError(
"In DesiData: Requested unblinding but data requires blinding strategy "
f"{self.blinding} and this strategy do not support "
"unblinding. If you believe this is an error, contact "
"picca developers")

if self.blinding not in ACCEPTED_BLINDING_STRATEGIES:
raise DataError(
"Unrecognized blinding strategy. Accepted strategies "
Expand Down
2 changes: 0 additions & 2 deletions py/picca/delta_extraction/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,6 @@

ACCEPTED_BLINDING_STRATEGIES = [
"none", "desi_m2", "desi_y1", "desi_y3"]
# TODO: add tags here when we are allowed to unblind them
UNBLINDABLE_STRATEGIES = []

def class_from_string(class_name, module_name):
"""Return a class from a string. The class must be saved in a module
Expand Down
38 changes: 0 additions & 38 deletions py/picca/tests/delta_extraction/data_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,19 +747,9 @@ def test_desi_data_parse_config(self):

data = DesiHealpix(config["data"])

# run __parse_config with missing 'blinding'
config = ConfigParser()
config.read_dict({"data": {
}})
expected_message = "Missing argument 'unblind' required by DesiData"
with self.assertRaises(DataError) as context_manager:
data._DesiData__parse_config(config["data"])
self.compare_error_message(context_manager, expected_message)

# run __parse_config with missing 'use_non_coadded_spectra'
config = ConfigParser()
config.read_dict({"data": {
"unblind": "True",
}})
expected_message = (
"Missing argument 'use non-coadded spectra' required by DesiData"
Expand Down Expand Up @@ -954,34 +944,6 @@ def test_desi_healpix_parse_config(self):
DesiHealpix(config["data"])
self.compare_error_message(context_manager, expected_message)

# create a DesiHealpix with missing DesiData options
config = ConfigParser()
config.read_dict({"data": {
"catalogue": f"{THIS_DIR}/data/QSO_cat_fuji_dark_healpix.fits.gz",
"keep surveys": "all",
"input directory": f"{THIS_DIR}/data/",
"out dir": f"{THIS_DIR}/results/",
"use non-coadded spectra": False,
"num processors": 1,
"wave solution": "lin",
"delta lambda": 0.8,
"lambda max": 5500.0,
"lambda max rest frame": 1200.0,
"lambda min": 3600.0,
"lambda min rest frame": 1040.0,
"analysis type": "BAO 3D",
"minimum number pixels in forest": 50,
"rejection log file": "rejection.fits",
"minimal snr bao3d": 0.0,
"save format": "BinTableHDU",
}})
expected_message = (
"Missing argument 'unblind' required by DesiData"
)
with self.assertRaises(DataError) as context_manager:
DesiHealpix(config["data"])
self.compare_error_message(context_manager, expected_message)

def test_desi_healpix_read_data(self):
"""Test method read_data from DesiHealpix"""
# run with one processor; case: only sv data
Expand Down

0 comments on commit 5905acb

Please sign in to comment.