Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions py/picca/bin/picca_fast_metal_dmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_fast_metal_xdmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_metal_dmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_metal_xdmat.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_wick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_xcf_angl.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions py/picca/bin/picca_xwick.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
33 changes: 3 additions & 30 deletions py/picca/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
16 changes: 9 additions & 7 deletions py/picca/delta_extraction/expected_fluxes/true_continuum.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""This module defines the class TrueContinuum"""
from importlib import resources
import logging
import multiprocessing

import fitsio
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
Expand Down Expand Up @@ -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}'
)
Expand Down
7 changes: 4 additions & 3 deletions py/picca/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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/'
Expand Down