Skip to content

Commit 1dd0c3b

Browse files
author
Nithyanandan Thyagarajan
committed
Add scripts/replicate_sim.py to repo
From 8696533 (master): ===================== (*) Add prisim/examples/simparms/replicatesim.yaml to repo (*) Add scripts/replicate_sim.py to repo In prisim/interferometry.py, (*) Add input datakeys in __init__() member function of class InterferometerData. Update member function docstring accordingly (*) In __init__() member function of class InterferometerData, only set arrays for specified keys in input datakeys (*) In member function write_uvfits() of class InterferometerArray, add key 'datapool' to write only specified portions of the simulated data to UVFITS file. Update member function docstring accordingly. (*) In member function write_uvfits() of class InterferometerArray, write only specified portions of the simulated data to UVFITS file. In scripts/run_prisim.py, (*) Pass datapool info in uvfits_parms before calling write_uvfits() member function of class InterferometerArray
1 parent 8696533 commit 1dd0c3b

6 files changed

Lines changed: 346 additions & 46 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
/prisim/*.pyc
1515
/prisim/*.tar.gz
1616
/prisim/interferometry.py.rej
17+
/prisim/examples/simparms/replicatesim.yaml~

changelog.txt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
From 8696533 (master):
2+
=====================
3+
4+
(*) Add prisim/examples/simparms/replicatesim.yaml to repo
5+
(*) Add scripts/replicate_sim.py to repo
6+
7+
In prisim/interferometry.py,
8+
9+
(*) Add input datakeys in __init__() member function of class
10+
InterferometerData. Update member function docstring accordingly
11+
(*) In __init__() member function of class InterferometerData, only
12+
set arrays for specified keys in input datakeys
13+
(*) In member function write_uvfits() of class InterferometerArray,
14+
add key 'datapool' to write only specified portions of the simulated
15+
data to UVFITS file. Update member function docstring accordingly.
16+
(*) In member function write_uvfits() of class InterferometerArray,
17+
write only specified portions of the simulated data to UVFITS file.
18+
19+
In scripts/run_prisim.py,
20+
21+
(*) Pass datapool info in uvfits_parms before calling write_uvfits()
22+
member function of class InterferometerArray
23+
124
From 31aeae9 (fov):
225
==================
326

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
##### IMPORTANT INFORMATION #####
2+
##### DO NOT MODIFY THIS FILE #####
3+
##### MAKE A COPY OF THIS FILE AND CUSTOMIZE #####
4+
5+
########## Directory Structure information #########
6+
7+
dirstruct :
8+
# Directory information
9+
10+
indir : '/path/to/simulation/directory/'
11+
# Directory containing simulations
12+
13+
infile : null
14+
# Filename (without extension) of
15+
# the simulation in indir. If set
16+
# to null, only noise will be
17+
# realized multiple time as requested
18+
# with no sky signal
19+
20+
infmt : 'hdf5'
21+
# Simulation formats. Accepted values
22+
# are 'hdf5' (default) and 'uvfits'
23+
24+
outdir : '/path/to/output/'
25+
# Path to output
26+
27+
outfile : 'simvis'
28+
# Outfile prefix. The files will be
29+
# appended with a number corresponding
30+
# to the realization and an extension
31+
# given by outfmt
32+
33+
outfmt : 'npz'
34+
# Output format. Accepted values are
35+
# 'npz' (default) and 'uvfits'.
36+
# 'npz' will only work if infmt is
37+
# set to 'hdf5', otherwise will
38+
# automatically change to 'uvfits'
39+
40+
######## Telescope information #########
41+
42+
telescope :
43+
44+
A_eff : 154
45+
# Effective area of antenna element
46+
# in m^2
47+
48+
eff_Q : 0.89
49+
# Interferometer efficiency. Value
50+
# must lie in [0,1]. Default=0.89
51+
52+
Trx : 50.0
53+
# Receiver temperature (in K)
54+
55+
Tant_freqref : 150000000.0
56+
# Reference frequency (in Hz) for
57+
# antenna temperature
58+
59+
Tant_spindex : -2.55
60+
# Spectral index for antenna
61+
# temperature
62+
63+
Tant_ref : 200.0
64+
# Antenna temperature at reference
65+
# frequency
66+
# Tsys = Trx + Tant * (f/f0)^alpha
67+
68+
Tsys : null
69+
# System temperature (in K)
70+
71+
######### Replicate information ############
72+
73+
replicate :
74+
# Replication parameters
75+
76+
n_avg : 1
77+
# Number of averages in determining
78+
# final noise RMS that is to be made
79+
# multiple realizations of. Default=1
80+
# The original noise RMS will be
81+
# reduced by a factor sqrt(n_avg)
82+
83+
n_realize : 1
84+
# Number of random realizations of
85+
# noise. Must be greater than 0.
86+
# Default=1
87+
88+
seed : 100
89+
# Use a fixed seed for reproducibility
90+
# else set it to null and a random
91+
# seed will be used
92+
93+
########## Diagnosis parameters ###########
94+
95+
diagnosis :
96+
97+
wait_after_run : true
98+
# If true, keep python shell open
99+
# after completing the run using
100+
# set_trace() of python debugger.
101+
# If false, close python shell
102+
# and return to command prompt
103+
# after successful completion

prisim/interferometry.py

Lines changed: 87 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8647,46 +8647,57 @@ def write_uvfits(self, outfile, uvfits_parms=None, overwrite=False,
86478647

86488648
Keyword Input(s):
86498649

8650-
uvfits_parms [dictionary] specifies basic parameters required for
8651-
saving in UVFITS format. If set to None (default), the
8652-
data will not be saved in UVFITS format. To save in UVFITS
8653-
format, the following keys and values are required:
8654-
'ref_point' [dictionary] Contains information about the
8655-
reference position to which projected
8656-
baselines and rotated visibilities are to
8657-
be computed. Default=None (no additional
8658-
phasing will be performed). It must be
8659-
contain the following keys with the
8660-
following values:
8661-
'coords' [string] Refers to the
8662-
coordinate system in which value
8663-
in key 'location' is specified
8664-
in. Accepted values are 'radec',
8665-
'hadec', 'altaz' and 'dircos'
8666-
'location' [numpy array] Must be a Mx2 (if
8667-
value in key 'coords' is set to
8668-
'radec', 'hadec', 'altaz' or
8669-
'dircos') or Mx3 (if value in
8670-
key 'coords' is set to
8671-
'dircos'). M can be 1 or equal
8672-
to number of timestamps. If M=1,
8673-
the same reference point in the
8674-
same coordinate system will be
8675-
repeated for all tiemstamps. If
8676-
value under key 'coords' is set
8677-
to 'radec', 'hadec' or 'altaz',
8678-
the value under this key
8679-
'location' must be in units of
8680-
degrees.
8681-
'method' [string] specifies method to be used in
8682-
saving in UVFITS format. Accepted values are
8683-
'uvdata', 'uvfits' or None (default). If set
8684-
to 'uvdata', the UVFITS writer in uvdata
8685-
module is used. If set to 'uvfits', the
8686-
in-house UVFITS writer is used. If set to
8687-
None, first uvdata module will be attempted
8688-
but if it fails then the in-house UVFITS
8689-
writer will be tried.
8650+
uvfits_parms
8651+
[dictionary] specifies basic parameters required for
8652+
saving in UVFITS format. If set to None (default), the
8653+
data will not be saved in UVFITS format. To save in UVFITS
8654+
format, the following keys and values are required:
8655+
'ref_point' [dictionary] Contains information about the
8656+
reference position to which projected
8657+
baselines and rotated visibilities are to
8658+
be computed. Default=None (no additional
8659+
phasing will be performed). It must be
8660+
contain the following keys with the
8661+
following values:
8662+
'coords' [string] Refers to the
8663+
coordinate system in which value
8664+
in key 'location' is specified
8665+
in. Accepted values are 'radec',
8666+
'hadec', 'altaz' and 'dircos'
8667+
'location' [numpy array] Must be a Mx2 (if
8668+
value in key 'coords' is set to
8669+
'radec', 'hadec', 'altaz' or
8670+
'dircos') or Mx3 (if value in
8671+
key 'coords' is set to
8672+
'dircos'). M can be 1 or equal
8673+
to number of timestamps. If M=1,
8674+
the same reference point in the
8675+
same coordinate system will be
8676+
repeated for all tiemstamps. If
8677+
value under key 'coords' is set
8678+
to 'radec', 'hadec' or 'altaz',
8679+
the value under this key
8680+
'location' must be in units of
8681+
degrees.
8682+
'method' [string] specifies method to be used in
8683+
saving in UVFITS format. Accepted values are
8684+
'uvdata', 'uvfits' or None (default). If set
8685+
to 'uvdata', the UVFITS writer in uvdata
8686+
module is used. If set to 'uvfits', the
8687+
in-house UVFITS writer is used. If set to
8688+
None, first uvdata module will be attempted
8689+
but if it fails then the in-house UVFITS
8690+
writer will be tried.
8691+
8692+
'datapool' [NoneType or list] Indicates which portion
8693+
of the data is to be written to the UVFITS
8694+
file. If set to None (default), all of
8695+
skyvis_freq, vis_freq, and vis_noise_freq
8696+
attributes will be written. Otherwise,
8697+
accepted values are a list of strings that
8698+
can include 'noiseless' (skyvis_freq
8699+
attribute), 'noisy' (vis_freq attribute),
8700+
and 'noise' (vis_nosie_freq attribute).
86908701

86918702
overwrite [boolean] True indicates overwrite even if a file already
86928703
exists. Default = False (does not overwrite). Beware this
@@ -8706,9 +8717,22 @@ def write_uvfits(self, outfile, uvfits_parms=None, overwrite=False,
87068717
uvfits_parms['ref_point'] = None
87078718
if 'method' not in uvfits_parms:
87088719
uvfits_parms['method'] = None
8709-
dataobj = InterferometerData(self, ref_point=uvfits_parms['ref_point'])
8720+
if 'datapool' not in uvfits_parms:
8721+
uvfits_parms['datapool'] = ['noiseless', 'noisy', 'noise']
8722+
if uvfits_parms['datapool'] is None:
8723+
uvfits_parms['datapool'] = ['noiseless', 'noisy', 'noise']
8724+
if not isinstance(uvfits_parms['datapool'], list):
8725+
raise TypeError('Key datapool in input uvfits_parms must be a list')
8726+
else:
8727+
datapool_list = [dpool.lower() for dpool in uvfits_parms['datapool'] if (isinstance(dpool, str) and dpool.lower() in ['noiseless', 'noise', 'noisy'])]
8728+
if len(datapool_list) == 0:
8729+
raise ValueError('No valid datapool string found in input uvfits_parms')
8730+
uvfits_parms['datapool'] = datapool_list
8731+
8732+
dataobj = InterferometerData(self, ref_point=uvfits_parms['ref_point'], datakeys=uvfits_parms['datapool'])
87108733
for datakey in dataobj.infodict['data_array']:
8711-
dataobj.write(outfile+'-{0}.uvfits'.format(datakey), datatype=datakey, fmt='UVFITS', uvfits_method=uvfits_parms['method'], overwrite=overwrite)
8734+
if dataobj.infodict['data_array'][datakey] is not None:
8735+
dataobj.write(outfile+'-{0}.uvfits'.format(datakey), datatype=datakey, fmt='UVFITS', uvfits_method=uvfits_parms['method'], overwrite=overwrite)
87128736

87138737
#################################################################################
87148738

@@ -9006,7 +9030,7 @@ class InterferometerData(object):
90069030
----------------------------------------------------------------------------
90079031
"""
90089032

9009-
def __init__(self, prisim_object, ref_point=None):
9033+
def __init__(self, prisim_object, ref_point=None, datakeys=None):
90109034

90119035
"""
90129036
------------------------------------------------------------------------
@@ -9041,6 +9065,14 @@ class InterferometerArray used to initialize an
90419065
is set to 'radec', 'hadec' or 'altaz', the
90429066
value under this key 'location' must be in
90439067
units of degrees.
9068+
9069+
datakeys [NoneType or list] Indicates which portion of the data
9070+
is to be written to the UVFITS file. If set to None
9071+
(default), all of skyvis_freq, vis_freq, and
9072+
vis_noise_freq attributes will be written. Otherwise,
9073+
accepted values are a list of strings that can include
9074+
'noiseless' (skyvis_freq attribute), 'noisy' (vis_freq
9075+
attribute), and 'noise' (vis_nosie_freq attribute).
90449076
------------------------------------------------------------------------
90459077
"""
90469078

@@ -9052,8 +9084,18 @@ class InterferometerArray used to initialize an
90529084
prisim_object.rotate_visibilities(ref_point)
90539085
if not isinstance(prisim_object, InterferometerArray):
90549086
raise TypeError('Inout prisim_object must be an instance of class InterferometerArray')
9055-
datatypes = ['noiseless', 'noisy', 'noise']
9056-
visibilities = {key: None for key in datatypes}
9087+
if datakeys is None:
9088+
datakeys = ['noiseless', 'noisy', 'noise']
9089+
if not isinstance(datakeys, list):
9090+
raise TypeError('Input datakeys must be a list')
9091+
else:
9092+
datapool_list = [dpool.lower() for dpool in datakeys if (isinstance(dpool, str) and dpool.lower() in ['noiseless', 'noise', 'noisy'])]
9093+
if len(datapool_list) == 0:
9094+
raise ValueError('No valid datapool string found in input uvfits_parms')
9095+
datakeys = datapool_list
9096+
9097+
# datatypes = ['noiseless', 'noisy', 'noise']
9098+
visibilities = {key: None for key in datakeys}
90579099
for key in visibilities:
90589100
# Conjugate visibilities for compatibility with UVFITS and CASA imager
90599101
if key == 'noiseless':

0 commit comments

Comments
 (0)