Skip to content

Commit

Permalink
prepare for transfunctioncode
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian-Belkner committed Jul 2, 2023
1 parent df0eb29 commit eaf73ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
10 changes: 6 additions & 4 deletions delensalot/config/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ def __init__(self, parser, config_model=None):
else:
self.configfile.dlensalot_model.job.jobs.append(sortedjob)
TEMP = transform(self.configfile.dlensalot_model, l2T_Transformer())
if parser.status == '':
if mpi.rank == 0:
self.store(parser, self.configfile, TEMP)
self.parser = parser
self.TEMP = TEMP

Expand All @@ -72,7 +69,9 @@ def collect_model(self, djob_id=''):
Args:
job_id (str, optional): _description_. Defaults to ''.
"""

if self.parser.status == '':
if mpi.rank == 0:
self.store(self.parser, self.configfile, self.TEMP)
## Making sure that specific job request from run() is processed
self.configfile.dlensalot_model.job.jobs = [djob_id]
self.djob_id = djob_id
Expand All @@ -90,6 +89,9 @@ def collect_models(self, djob_id=''):
Args:
job_id (str, optional): A specific job which should be performed. This one is not necessarily defined in the configuration file. It is handed over via command line or in interactive mode. Defaults to ''.
"""
if self.parser.status == '':
if mpi.rank == 0:
self.store(self.parser, self.configfile, self.TEMP)
self.djobmodels = []
for job_id in self.configfile.dlensalot_model.job.jobs:
self.djobmodels.append(transform3d(self.configfile.dlensalot_model, job_id, l2delensalotjob_Transformer()))
Expand Down
15 changes: 5 additions & 10 deletions delensalot/core/handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import numpy as np
import healpy as hp
import hashlib

import logging
log = logging.getLogger(__name__)
Expand Down Expand Up @@ -242,14 +243,17 @@ def __init__(self, dlensalot_model):
self.fns_sky = self.simulationdata.fns
lenjob_geomstr = 'unknown_lensinggeometry'
else:
hlib = hashlib.sha256()
hlib.update(str(self.simulationdata.transfunction).encode())
transfunctioncode = hlib.hexdigest()[:4]
# some flavour provided, and we need to generate the sky and obs maps from this.
lenjob_geomstr = get_dirname(str(self.simulationdata.len_lib.lenjob_geominfo))
self.libdir_suffix = 'generic' if self.libdir_suffix == '' else self.libdir_suffix
self.libdir_sky = opj(os.environ['SCRATCH'], 'simulation/', self.libdir_suffix, get_dirname(str(self.simulationdata.geominfo)), lenjob_geomstr)
self.fns_sky = self.set_basename_sky()
self.fnsP = 'philm_{}.npy'
self.libdir_suffix = 'generic' if self.libdir_suffix == '' else self.libdir_suffix
self.libdir = opj(os.environ['SCRATCH'], 'simulation/', self.libdir_suffix, get_dirname(str(self.simulationdata.geominfo)), get_dirname(lenjob_geomstr), get_dirname(str(sorted(self.simulationdata.nlev.items()))))
self.libdir = opj(os.environ['SCRATCH'], 'simulation/', self.libdir_suffix, get_dirname(str(self.simulationdata.geominfo)), get_dirname(lenjob_geomstr), get_dirname(str(sorted(self.simulationdata.nlev.items())))) # +'_{}'.format(transfunctioncode)
self.fns = self.set_basename_obs()

first_rank = mpi.bcast(mpi.rank)
Expand Down Expand Up @@ -563,7 +567,6 @@ def init_cinv(self):
#@log_on_end(logging.INFO, "QE.collect_jobs(recalc={recalc}) finished: jobs={self.jobs}")
def collect_jobs(self, recalc=False):

self.simgen.collect_jobs()
# qe_tasks overwrites task-list and is needed if MAP lensrec calls QE lensrec
jobs = list(range(len(self.qe_tasks)))
for taski, task in enumerate(self.qe_tasks):
Expand Down Expand Up @@ -620,7 +623,6 @@ def init_aniso_filter(self):
def run(self, task=None):
## task may be set from MAP lensrec, as MAP lensrec has prereqs to QE lensrec
## if None, then this is a normal QE lensrec call
self.simgen.run()

# Only now instantiate aniso filter
if self.qe_filter_directional == 'anisotropic':
Expand Down Expand Up @@ -853,8 +855,6 @@ def __init__(self, dlensalot_model):
#@log_on_start(logging.INFO, "MAP.map.collect_jobs() started")
#@log_on_end(logging.INFO, "MAP.collect_jobs() finished: jobs={self.jobs}")
def collect_jobs(self):
self.simgen.collect_jobs()
self.qe.collect_jobs(recalc=False)
jobs = list(range(len(self.it_tasks)))
# TODO order of task list matters, but shouldn't
for taski, task in enumerate(self.it_tasks):
Expand Down Expand Up @@ -896,10 +896,7 @@ def collect_jobs(self):
def run(self):
for taski, task in enumerate(self.it_tasks):
log.info('{}, task {} started, jobs: {}'.format(mpi.rank, task, self.jobs[taski]))

if task == 'calc_phi':
self.simgen.run()
self.qe.run(task=task)
for simidx in self.jobs[taski][mpi.rank::mpi.size]:
libdir_MAPidx = self.libdir_MAP(self.k, simidx, self.version)
if self.itmax >= 0 and rec.maxiterdone(libdir_MAPidx) < self.itmax:
Expand All @@ -911,14 +908,12 @@ def run(self):
log.info('{}, simidx {} done with it {}'.format(mpi.rank, simidx, it))

if task == 'calc_meanfield':
self.qe.run(task=task)
# TODO I don't like barriers and not sure if they are still needed
mpi.barrier()
self.get_meanfields_it(np.arange(self.itmax+1), calc=True)
mpi.barrier()

if task == 'calc_blt':
self.qe.run(task=task)
for simidx in self.jobs[taski][mpi.rank::mpi.size]:
self.libdir_MAPidx = self.libdir_MAP(self.k, simidx, self.version)
self.itlib_iterator = transform(self, iterator_transformer(self, simidx, self.dlensalot_model))
Expand Down
3 changes: 2 additions & 1 deletion delensalot/sims/sims_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def __init__(self, nlev, lmax=DNaV, libdir=DNaV, fns=DNaV, spin=DNaV, space=DNaV
if libdir == DNaV:
self.nlev = nlev
assert libdir_suffix != DNaV, 'must give libdir_suffix'
self.libdir_phas = os.environ['SCRATCH']+'/simulation/{}/{}/phas/{}/'.format(libdir_suffix, get_dirname(str(geominfo)), get_dirname(str(sorted(self.nlev.items()))))
self.libdir_phas = os.environ['SCRATCH']+'/simulation/{}/{}/phas/{}/'.format(libdir_suffix, get_dirname(str(geominfo)), get_dirname(str(sorted(self.nlev.items()))), )
self.pix_lib_phas = phas.pix_lib_phas(self.libdir_phas, 3, (self.geom_lib.npix(),))
else:
if fns == DNaV:
Expand Down Expand Up @@ -846,6 +846,7 @@ def __init__(self, flavour, space, geominfo=DNaV, maps=DNaV, field=DNaV, cls_lib
self.space = space
self.nlev = nlev
self.maps = maps
self.transfunction = transfunction
if space == 'map':
if flavour == 'obs':
if np.all(maps == DNaV):
Expand Down

0 comments on commit eaf73ba

Please sign in to comment.