Skip to content

Commit

Permalink
fixes #390. Fixes #392. Disables PA rotation by default (see #389)
Browse files Browse the repository at this point in the history
  • Loading branch information
o-smirnov committed Jul 9, 2020
1 parent a5815eb commit 0eac7d3
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
8 changes: 5 additions & 3 deletions cubical/DefaultParset.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions cubical/machines/interval_gain_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 8 additions & 6 deletions cubical/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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"])

Expand Down
14 changes: 11 additions & 3 deletions cubical/workers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -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.
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 0eac7d3

Please sign in to comment.