A set of functions for manipulating spw:chan selection strings.
If this is run from a shell (i.e. not in casapy), doctest will be used to run
several unit tests from the doc strings, including the one below:
>>> from update_spw import update_spw
>>> update_spw('0~2,5', None)[0]
>>> update_spw('0~2,5', None)[1]['5'] # doctest warning! dicts don't always print out in the same order!
from __future__ import absolute_import
from casatasks.private.casa_transition import is_CASA6
from casatools import table as tbtool
from taskinit import ms as _ms
def update_spw(spw, spwmap=None):
Given an spw:chan selection string, return what it should be after the spws
have been remapped (i.e. by split), and a map from input to output spws
(spwmap). It does not change spw OR the *channels* part of the output spw
string! (See update_spwchan)
If given, spwmap will be used as a dictionary from (string) input spw to
(string) output spws. Otherwise it will be freshly calculated. Supplying
spwmap doesn't just save work: it is also necessary for chaining
update_spw() calls when the first selection includes more spws than the
subsequent one(s). HOWEVER, if given, spwmap must have slots for all the
spws that will appear in the output MS, i.e. it can't be grown once made.
>>> from update_spw import update_spw
>>> myfitspw, spws = update_spw('0~3,5;6:1~7;11~13', None)
>>> myspw = update_spw('1,5;6:8~10', spws)[0]
>>> myspw # not '0,1,2:8~10'
>>> update_spw('0~3,5;6:1~7;11~13,7~9:0~3,11,7~8:6~8', None)[0]
'0~3,4;5:1~7;11~13,6~8:0~3,9,6~7:6~8'
# Let's say we want updates of both fitspw and spw, but fitspw and spw
# are disjoint (in spws).
>>> fitspw = '1~10:5~122,15~22:5~122'