Skip to content

Commit

Permalink
Merge pull request #5 from gaetanfacchinetti/news_from_swyft
Browse files Browse the repository at this point in the history
adding more efficient search of runs
  • Loading branch information
gaetanfacchinetti committed Jul 5, 2024
2 parents 991dbc9 + f34fa14 commit e15c0f7
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions src/py21cmcast/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -646,13 +646,14 @@ def __init__(self, dir_path : str, z_bins : np.ndarray = None, z_array : np.ndar
# one has to find a lightcone for the fiducial in the datafiles
if (load is False or _loading_success is False) and lightcone is None:

_str_file_name = self._dir_path + "/Lightcone_rs*_" + name + ".h5" if (rs is None) else self._dir_path + "/Lightcone_rs" + str(rs) + "_" + name + ".h5"
_lightcone_file_name = glob.glob(_str_file_name)
_file_name = _lightcone_file_name[0].split('/')[-1]

assert len(_lightcone_file_name) == 1, 'No fiducial lightcone found or too many'
self._rs = _file_name.split('_')[-2][2:]

if rs is None:
_str_file_name = self._dir_path + "/Lightcone_rs*_" + name + ".h5"
_lightcone_file_name = glob.glob(_str_file_name)
_file_name = _lightcone_file_name[0].split('/')[-1]
self._rs = _file_name.split('_')[-2][2:]
else:
_file_name = "Lightcone_rs" + str(rs) + "_" + name + ".h5"
self._rs = rs

# Initialise the parent object
super().__init__(self._dir_path, _file_name, z_bins, z_array, k_bins, logk, 0., lightcone = lightcone, load=load, save=save, verbose = verbose)
Expand Down

0 comments on commit e15c0f7

Please sign in to comment.