diff --git a/py/picca/bin/picca_fast_metal_dmat.py b/py/picca/bin/picca_fast_metal_dmat.py index f428656de..01a2fbd2f 100644 --- a/py/picca/bin/picca_fast_metal_dmat.py +++ b/py/picca/bin/picca_fast_metal_dmat.py @@ -472,8 +472,7 @@ def main(cmdargs=None): cf.cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) t0 = time.time() diff --git a/py/picca/bin/picca_fast_metal_xdmat.py b/py/picca/bin/picca_fast_metal_xdmat.py index d5a0f2e68..d8c812be0 100644 --- a/py/picca/bin/picca_fast_metal_xdmat.py +++ b/py/picca/bin/picca_fast_metal_xdmat.py @@ -444,8 +444,7 @@ def main(cmdargs=None): cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) xcf.cosmo = cosmo t0 = time.time() diff --git a/py/picca/bin/picca_metal_dmat.py b/py/picca/bin/picca_metal_dmat.py index 09693d0bf..874c08436 100644 --- a/py/picca/bin/picca_metal_dmat.py +++ b/py/picca/bin/picca_metal_dmat.py @@ -322,8 +322,7 @@ def main(cmdargs=None): cf.cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) t0 = time.time() diff --git a/py/picca/bin/picca_metal_xdmat.py b/py/picca/bin/picca_metal_xdmat.py index 0f6b2aa4f..b63885e06 100644 --- a/py/picca/bin/picca_metal_xdmat.py +++ b/py/picca/bin/picca_metal_xdmat.py @@ -300,8 +300,7 @@ def main(cmdargs=None): cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) xcf.cosmo = cosmo t0 = time.time() diff --git a/py/picca/bin/picca_wick.py b/py/picca/bin/picca_wick.py index 2fead65bf..1d2113d4d 100644 --- a/py/picca/bin/picca_wick.py +++ b/py/picca/bin/picca_wick.py @@ -311,8 +311,7 @@ def main(cmdargs): cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) # read data 1 data, num_data, z_min, z_max = io.read_deltas(args.in_dir, diff --git a/py/picca/bin/picca_xcf_angl.py b/py/picca/bin/picca_xcf_angl.py index e3fa77c08..ebb5ccf02 100644 --- a/py/picca/bin/picca_xcf_angl.py +++ b/py/picca/bin/picca_xcf_angl.py @@ -259,8 +259,7 @@ def main(cmdargs): cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) ### Read deltas data, num_data, z_min, z_max = io.read_deltas( diff --git a/py/picca/bin/picca_xwick.py b/py/picca/bin/picca_xwick.py index 0ed4bded1..877d5f97c 100644 --- a/py/picca/bin/picca_xwick.py +++ b/py/picca/bin/picca_xwick.py @@ -285,8 +285,7 @@ def main(cmdargs): cosmo = constants.Cosmo(Om=args.fid_Om, Or=args.fid_Or, Ok=args.fid_Ok, - wl=args.fid_wl, - blinding=blinding) + wl=args.fid_wl,) ### Read deltas data, num_data, z_min, z_max = io.read_deltas(args.in_dir, diff --git a/py/picca/constants.py b/py/picca/constants.py index cdbe5ef0d..519e73934 100644 --- a/py/picca/constants.py +++ b/py/picca/constants.py @@ -7,7 +7,6 @@ import numpy as np from scipy import interpolate from scipy.constants import speed_of_light as speed_light -from pkg_resources import resource_filename from picca.utils import userprint # TODO: this constant is unused. They should be removed at some point @@ -17,10 +16,6 @@ SPEED_LIGHT = speed_light/1000. # [km/s] -# different strategies are explained in -# https://desi.lbl.gov/trac/wiki/keyprojects/y1kp6/Blinding -ACCEPTED_BLINDING_STRATEGIES = ["none", "minimal", "strategyB", "strategyC", - "strategyBC", "corr_yshift"] class Cosmo(object): """This class defines the fiducial cosmology @@ -182,31 +177,9 @@ def __init__(self,Om,Ok=0.,Or=0.,wl=-1.,blinding=False,verbose=True): # make what we are doing more clear. H0 = 100.0 - # Blind data - if blinding == "none": - if verbose: - userprint("ATTENTION: Analysis is not blinded!") - else: - userprint(f"ATTENTION: Analysis is blinded with strategy {blinding}") - - if blinding not in ["strategyB", "strategyBC"]: - if verbose: - userprint(f"Om={Om}, Or={Or}, wl={wl}") - else: - userprint("The specified cosmology is " - f"not used: Om={Om}, Or={Or}, wl={wl}") - # blind test small - filename = "DR16_blind_test_small/DR16_blind_test_small.fits" - # blind test large - #filename = "DR16_blind_test_small/DR16_blind_test_large.fits" - # load Om - filename = resource_filename('picca', 'fitter2')+'/models/{}'.format(filename) - hdu = fitsio.FITS(filename) - Om = hdu[1].read_header()['OM'] - Or = hdu[1].read_header()['OR'] - wl = hdu[1].read_header()['W'] - H0 = hdu[1].read_header()['H0'] - hdu.close() + if verbose and blinding == "none": + userprint("ATTENTION: Analysis is not blinded!") + userprint(f"Om={Om}, Or={Or}, wl={wl}") # Ignore evolution of neutrinos from matter to radiation Ol = 1. - Ok - Om - Or diff --git a/py/picca/delta_extraction/expected_fluxes/true_continuum.py b/py/picca/delta_extraction/expected_fluxes/true_continuum.py index aa96fc369..ccd346830 100644 --- a/py/picca/delta_extraction/expected_fluxes/true_continuum.py +++ b/py/picca/delta_extraction/expected_fluxes/true_continuum.py @@ -1,4 +1,5 @@ """This module defines the class TrueContinuum""" +from importlib import resources import logging import multiprocessing @@ -6,7 +7,6 @@ import numpy as np from scipy.interpolate import interp1d import healpy -from pkg_resources import resource_filename from picca.delta_extraction.astronomical_objects.forest import Forest from picca.delta_extraction.astronomical_objects.pk1d_forest import Pk1dForest @@ -391,32 +391,34 @@ def read_raw_statistics(self): if self.raw_statistics_filename != "": filename = self.raw_statistics_filename else: - filename = resource_filename( - 'picca', 'delta_extraction') + '/expected_fluxes/raw_stats/' + file_path_aux = "" if Forest.wave_solution == "log": - filename += 'colore_v9_lya_log.fits.gz' + file_path_aux += 'colore_v9_lya_log.fits.gz' elif Forest.wave_solution == "lin" and np.isclose( 10**Forest.log_lambda_grid[1] - 10**Forest.log_lambda_grid[0], 0.8, rtol=0.1): - filename += 'colore_v9_lya_lin_0.8.fits.gz' + file_path_aux += 'colore_v9_lya_lin_0.8.fits.gz' elif Forest.wave_solution == "lin" and np.isclose( 10**Forest.log_lambda_grid[1] - 10**Forest.log_lambda_grid[0], 2.4, rtol=0.1): - filename += 'colore_v9_lya_lin_2.4.fits.gz' + file_path_aux += 'colore_v9_lya_lin_2.4.fits.gz' elif Forest.wave_solution == "lin" and np.isclose( 10**Forest.log_lambda_grid[1] - 10**Forest.log_lambda_grid[0], 3.2, rtol=0.1): - filename += 'colore_v9_lya_lin_3.2.fits.gz' + file_path_aux += 'colore_v9_lya_lin_3.2.fits.gz' else: raise ExpectedFluxError( "Couldn't find compatible raw satistics file. Provide a " "custom one using 'raw statistics file' field.") + with resources.path("picca.delta_extraction.expected_fluxes.raw_stats", + file_path_aux) as file_path: + filename = str(file_path) self.logger.info( f'Reading raw statistics var_lss and mean_flux from file: {filename}' ) diff --git a/py/picca/tests/test_helpers.py b/py/picca/tests/test_helpers.py index 59c38ad12..4409ac8a6 100644 --- a/py/picca/tests/test_helpers.py +++ b/py/picca/tests/test_helpers.py @@ -7,7 +7,9 @@ import sys import unittest import shutil, tempfile -from pkg_resources import resource_filename + +THIS_DIR = os.path.dirname(os.path.abspath(__file__)) +PICCA_BASE = THIS_DIR.replace("py/picca/tests", "") ### Make ConfigParser case sensitive class CaseConfigParser(ConfigParser.ConfigParser): @@ -253,8 +255,7 @@ def setUpClass(cls): """ cls._branchFiles = tempfile.mkdtemp() + "/" cls.produce_folder(cls) - cls.picca_base = resource_filename('picca', - './').replace('py/picca/./', '') + cls.picca_base = PICCA_BASE cls.send_requirements(cls.load_requirements(cls.picca_base)) np.random.seed(42) cls._masterFiles = cls.picca_base + '/py/picca/tests/data/'