From 0eac7d3475a1d51fba195a747712e086d9688b9b Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Thu, 9 Jul 2020 14:26:54 +0200 Subject: [PATCH] fixes #390. Fixes #392. Disables PA rotation by default (see #389) --- cubical/DefaultParset.cfg | 8 +++++--- cubical/machines/interval_gain_machine.py | 4 ++++ cubical/main.py | 14 ++++++++------ cubical/workers.py | 14 +++++++++++--- 4 files changed, 28 insertions(+), 12 deletions(-) diff --git a/cubical/DefaultParset.cfg b/cubical/DefaultParset.cfg index 26824679..46d04f7c 100755 --- a/cubical/DefaultParset.cfg +++ b/cubical/DefaultParset.cfg @@ -99,11 +99,13 @@ beam-pattern = None # Apply beams if specified eg. 'beam_$(corr)_$(reim).fi 'beam_$(CORR)_$(REIM).fits' beam-l-axis = None beam-m-axis = None -feed-rotate = auto # Apply a feed angle rotation to the model visibilities. Use 'auto' to read angles +feed-rotate = 0 # Apply a feed angle rotation to the model visibilities. Use 'auto' to read angles from FEED subtable, or give an explicit value in degrees. + A value of 0 disables. This only matters for polarimetry. #metavar:DEG -pa-rotate = 1 # Apply parallactic angle rotation to model visibilities. Enable this for alt-az - mounts, unless your model visibilities are already rotated. #type:bool +pa-rotate = 0 # Apply parallactic angle rotation to model visibilities. Enable this for alt-az + mounts, unless your model visibilities are already rotated. This only + matters for polarimetry. #type:bool [montblanc] _Help = Montblanc simulation options diff --git a/cubical/machines/interval_gain_machine.py b/cubical/machines/interval_gain_machine.py index afaa7a88..edbb4695 100644 --- a/cubical/machines/interval_gain_machine.py +++ b/cubical/machines/interval_gain_machine.py @@ -339,6 +339,10 @@ def apply_gains(self, model_arr, full2x2=True, dd_only=False): def apply_inv_gains(self, obser_arr, corr_vis=None, full2x2=True, direction=None): if corr_vis is None: corr_vis = np.empty_like(obser_arr) + + # parset uses -1 for None, so may as well support it here + if direction < 0: + direction = None if self.dd_term and direction is None: corr_vis[:] = obser_arr diff --git a/cubical/main.py b/cubical/main.py index 1150ce19..038bf139 100644 --- a/cubical/main.py +++ b/cubical/main.py @@ -506,12 +506,6 @@ def prelog_print(level, message): single_chunk = GD["data"]["single-chunk"] single_tile = GD["data"]["single-tile"] - # setup worker process properties - - workers.setup_parallelism(GD["dist"]["ncpu"], GD["dist"]["nworker"], GD["dist"]["nthread"], - debugging or single_chunk, - GD["dist"]["pin"], GD["dist"]["pin-io"], GD["dist"]["pin-main"], - ms.use_montblanc, GD["montblanc"]["threads"]) # set up chunking @@ -538,6 +532,14 @@ def prelog_print(level, message): chunk_by=chunk_by, chunk_by_jump=jump, chunks_per_tile=chunks_per_tile, max_chunks_per_tile=max_chunks_per_tile) + # setup worker process properties + workers.setup_parallelism(GD["dist"]["ncpu"], GD["dist"]["nworker"], GD["dist"]["nthread"], + debugging or single_chunk, + GD["dist"]["pin"], GD["dist"]["pin-io"], GD["dist"]["pin-main"], + ms.use_montblanc, GD["montblanc"]["threads"], + max_workers=chunks_per_tile) + + # Estimate memory usage. This is still experimental. estimate_mem(ms, tile_list, GD["data"], GD["dist"]) diff --git a/cubical/workers.py b/cubical/workers.py index d9608f0d..d1fa604c 100644 --- a/cubical/workers.py +++ b/cubical/workers.py @@ -17,7 +17,7 @@ # number of worker processes that will be run num_workers = 0 -def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc_threads): +def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc_threads, max_workers): """ Internal helper -- determines how many workers and threads to allocate, based on defaults specified. See discussion in https://github.com/ratt-ru/CubiCal/pull/171#issuecomment-388334586 @@ -47,18 +47,26 @@ def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc if ncpu: cores = ncpu - (montblanc_threads or 1) if not nworkers and not nthreads: + if max_workers: + cores = min(cores, max_workers) print("multi-process mode: {}+1 workers, single thread{}".format(cores, montblanc), file=log(0, "blue")) return True, cores, 1 if nworkers: + if max_workers: + nworkers = min(nworkers, max_workers) nthreads = max(1, cores // nworkers) print("multi-process mode: --dist-nworker {} (+1), {} OMP threads{}".format(nworkers, nthreads, montblanc), file=log(0, "blue")) return True, nworkers, nthreads if nthreads: nworkers = max(1, cores // nthreads) + if max_workers: + nworkers = min(nworkers, max_workers) print("multi-process mode: {}+1 workers, --dist-nthread {}{}".format(nworkers, nthreads, montblanc), file=log(0, "blue")) return True, nworkers, nthreads else: # ncpu not set, and nworkers/nthreads not both set if nworkers: + if max_workers: + nworkers = min(nworkers, max_workers) print("multi-process mode: --dist-nworker {} (+1), single thread{}".format(nworkers, montblanc), file=log(0, "blue")) return True, nworkers, 1 if nthreads: @@ -69,7 +77,7 @@ def _setup_workers_and_threads(force_serial, ncpu, nworkers, nthreads, montblanc raise RuntimeError("can't be here -- this is a bug!") -def setup_parallelism(ncpu, nworker, nthread, force_serial, affinity, io_affinity, main_affinity, use_montblanc, montblanc_threads): +def setup_parallelism(ncpu, nworker, nthread, force_serial, affinity, io_affinity, main_affinity, use_montblanc, montblanc_threads, max_workers): """ Sets up parallelism, affinities and other properties of worker processes. @@ -103,7 +111,7 @@ def setup_parallelism(ncpu, nworker, nthread, force_serial, affinity, io_affinit """ global num_workers parallel, num_workers, nthread = _setup_workers_and_threads(force_serial, ncpu, nworker, nthread, - montblanc_threads if use_montblanc else None) + montblanc_threads if use_montblanc else None, max_workers) # in serial mode, simply set the Montblanc and/or worker thread count, and return if not parallel: