示例#1
0
    def commandLine (self):
        cmd = [_mirBinPath (self._name)]

        # Options
        
        options = []

        for opt in self._options or []:
            val = getattr (self, opt)

            # I think it'd be really confusing to set options based on
            # the Python truthiness of option fields -- e.g., task.foo = 'hello'
            # causing "task options=foo" to be run, if "foo" is an option.
            # So the only valid values for an option are True, False, and None.
            # I have a dim memory of there being a task or two that actually
            # accept nonboolean inputs through the options keyword in some
            # evil way, but if I ever run into that again that can be dealt
            # with.

            if val is None:
                continue

            if not isinstance (val, bool):
                raise ValueError ('Option %s set to non-bool, non-None value %s' \
                                      % (opt, val))

            if val:
                options.append (opt)

        if len (options) > 0:
            cmd.append ('options=' + ','.join (options))

        # Keywords
        
        for name in self._keywords or []:
            key = name

            if key[-1] == '_':
                key = key[:-1]
            
            val = getattr (self, name)

            if val is None:
                continue

            cmd.append ("%s=%s" % (key, miriad.commasplice (val)))

        return cmd
示例#2
0
    def commandLine (self):
        cmd = [_mirBinPath (self._name)]

        ostr = self.options
        if len (ostr):
            cmd.append ('options=' + ostr)

        for name in self._keywords or []:
            key = name

            if key[-1] == '_':
                key = key[:-1]

            val = getattr (self, name)

            if val is None:
                continue

            cmd.append ("%s=%s" % (key, miriad.commasplice (val)))

        return cmd
示例#3
0
    def commandLine(self):
        cmd = [_mirBinPath(self._name)]

        ostr = self.options
        if len(ostr):
            cmd.append('options=' + ostr)

        for name in self._keywords or []:
            key = name

            if key[-1] == '_':
                key = key[:-1]

            val = getattr(self, name)

            if val is None:
                continue

            cmd.append("%s=%s" % (key, miriad.commasplice(val)))

        return cmd
示例#4
0
def setupAndRead (toread, uvdOptions, saveFlags, nopass=False, nocal=False,
                  nopol=False, select=None, line=None, stokes=None, ref=None,
                  maxchan=default_maxchan):
    """Set up the UVDAT subsystem manually and read in the data.

:arg toread: the name(s) of the dataset or datasets to read
:type toread: stringable or iterable of stringable
:arg uvdOptions: extra options controlling the behavior of the UVDAT subsytem
:type uvdOptions: :class:`str`
:arg saveFlags: whether to rewrite the flags of the dataset(s) as it/they are
                being read
:type saveFlags: :class:`bool`
:arg nopass: whether to avoid applying bandpass calibration even if possible
:type nopass: :class:`bool`
:arg nocal: whether to avoid applying gain calibration even if possible
:type nocal: :class:`bool`
:arg nopol: whether to avoid applying polarization calibration even if possible
:type nopol: :class:`bool`
:arg select: standard UV data selection string
:type select: :class:`str` or :const:`None`
:arg line: standard channel processing string
:type line: :class:`str` or :const:`None`
:arg stokes: standard Stokes parameter processing string
:type stokes: :class:`str` or :const:`None`
:arg ref: standard reference line specification string
:type ref: :class:`str` or :const:`None`
:arg maxchan: the maximum number of spectral channels that can be read in at once
:type maxchan: :class:`int`
:rtype: generator of ``(handle, preamble, data, flags)``
:returns: generator yielding UV data records

Set up the UVDAT subsytem with explicitly-specified parameters and
read in the data.

The argument *toread* specifies which dataset or datasets to read. If
it is a non-string iterable, the stringification of each of its values
is treated as a dataset to read. Otherwise, its stringification is
treated as the dataset to read. Escaping is not supported by MIRIAD,
so if ``toread = 'a,b'``, MIRIAD will interpret this as a direction to
read two datasets named "a" and "b".

The return value is a generator that yields tuples of ``(handle,
preamble, data, flags)``, where *handle* is a :class:`UVDatDataSet`
corresponding to the dataset being read, and *preamble*, *data*, and
*flags* are the usual UV data arrays. For speed, the identities of the
arrays do not change from iteration to iteration, but their contents do.

Optional features of the UVDAT subsystem may be enabled by including
their control characters in the contents of *uvdOptions*:

==========      ==================
Character       Feature behavior
==========      ==================
*p*             Planet rotation and scaling corrections should be applied.
*w*             UVW coordinates should be returned in wavelength units, not
                nanoseconds. (Beware when writing these data to new UV
                datasets, as the output routines expect the values to
                be in nanoseconds.)
*1*             (The character is the number one.) Average the data
                down to one channel.
*x*             The input data must be cross-correlations.
*a*             The input data must be autocorrelations.
*b*             The input must be exactly one UV dataset (not multiple).
*3*             The "preamble" returned while reading data will always have 5
                elements and include the *w* coordinate.
==========      ==================
"""
    args = ['vis=' + commasplice (toread)]
    flags = uvdOptions + 'dslr'
    options = set ()

    if select is not None:
        args.append ('select=' + select)
    if line is not None:
        args.append ('line=' + line)
    if stokes is not None:
        args.append ('stokes=' + stokes)
    if ref is not None:
        args.append ('ref=' + ref)

    if nopass:
        options.add ('nopass')
    if nocal:
        options.add ('nocal')
    if nopol:
        options.add ('nopol')
    if len (options) > 0:
        args.append ('options=' + ','.join (options))

    from keys import KeySpec
    KeySpec ().uvdat (flags).process (args)
    return _read_gen (saveFlags, UVDatDataSet, maxchan)