@@ -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