Ignore:
Timestamp:
02/10/10 19:39:06 (14 years ago)
Author:
Takeshi Nakazato
Message:

New Development: No

JIRA Issue: Yes CAS-1908

Ready to Release: Yes

Interface Changes: No

What Interface Changed: Please list interface changes

Test Programs: List test programs

Put in Release Notes: Yes

Module(s): Module Names change impacts.

Description: Describe your changes here...

Changed a tagging as the source type is tagged by using SRCTYPE, not
an extra string in SRCNAME. To do this, I have defined a selection method
by SRCTYPE in STSelector class. I have newly added python_SrcType.cpp
that defines a Python interface of SrcType? enums which is defined
in atnf/PKSIO/SrcType.h.

Since I have added new file in the src directory, I have modified src/Makefile
to compile new file.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/alma/python/asapmath.py

    r1686 r1693  
    184184    varlist = vars()
    185185    # check for the appropriate data
    186     s = scantab.get_scan('*_ps*')
    187     if s is None:
     186##    s = scantab.get_scan('*_ps*')
     187##     if s is None:
     188##         msg = "The input data appear to contain no position-switch mode data."
     189##         if rcParams['verbose']:
     190##             #print msg
     191##             asaplog.push(msg)
     192##             print_log('ERROR')
     193##             return
     194##         else:
     195##             raise TypeError(msg)
     196    s = scantab.copy()
     197    from asap._asap import srctype
     198    sel = selector()
     199    sel.set_types( srctype.pson )
     200    try:
     201        scantab.set_selection( sel )
     202    except Exception, e:
    188203        msg = "The input data appear to contain no position-switch mode data."
    189204        if rcParams['verbose']:
     
    194209        else:
    195210            raise TypeError(msg)
     211    s.set_selection()
     212    sel.reset()
    196213    ssub = s.get_scan(scannos)
    197214    if ssub is None:
     
    204221        else:
    205222            raise TypeError(msg)
    206     ssubon = ssub.get_scan('*calon')
    207     ssuboff = ssub.get_scan('*[^calon]')
     223    #ssubon = ssub.get_scan('*calon')
     224    #ssuboff = ssub.get_scan('*[^calon]')
     225    sel.set_types( [srctype.poncal,srctype.poffcal] )
     226    ssub.set_selection( sel )
     227    ssubon = ssub.copy()
     228    ssub.set_selection()
     229    sel.reset()
     230    sel.set_types( [srctype.pson,srctype.psoff] )
     231    ssub.set_selection( sel )
     232    ssuboff = ssub.copy()
     233    ssub.set_selection()
     234    sel.reset()
    208235    if ssubon.nrow() != ssuboff.nrow():
    209236        msg = "mismatch in numbers of CAL on/off scans. Cannot calibrate. Check the scan numbers."
     
    216243            raise TypeError(msg)
    217244    cals = dototalpower(ssubon, ssuboff, tcalval)
    218     sig = cals.get_scan('*ps')
    219     ref = cals.get_scan('*psr')
     245    #sig = cals.get_scan('*ps')
     246    #ref = cals.get_scan('*psr')
     247    sel.set_types( srctype.pson )
     248    cals.set_selection( sel )
     249    sig = cals.copy()
     250    cals.set_selection()
     251    sel.reset()
     252    sel.set_types( srctype.psoff )
     253    cals.set_selection( sel )
     254    ref = cals.copy()
     255    cals.set_selection()
     256    sel.reset()
    220257    if sig.nscan() != ref.nscan():
    221258        msg = "mismatch in numbers of on/off scans. Cannot calibrate. Check the scan numbers."
     
    261298        postcal=[]
    262299        keys=['ps','ps_calon','psr','psr_calon']
     300        types=[srctype.pson,srctype.poncal,srctype.psoff,srctype.poffcal]
    263301        ifnos=list(ssub.getifnos())
    264302        polnos=list(ssub.getpolnos())
    265303        sel=selector()
    266304        for i in range(2):
    267             ss=ssuboff.get_scan('*'+keys[2*i])
     305            #ss=ssuboff.get_scan('*'+keys[2*i])
    268306            ll=[]
    269307            for j in range(len(ifnos)):
     
    271309                    sel.set_ifs(ifnos[j])
    272310                    sel.set_polarizations(polnos[k])
     311                    sel.set_types(types[2*i])
    273312                    try:
    274                         ss.set_selection(sel)
     313                        #ss.set_selection(sel)
     314                        ssuboff.set_selection(sel)
    275315                    except:
    276316                        continue
    277                     ll.append(numpy.array(ss._getspectrum(0)))
     317                    #ll.append(numpy.array(ss._getspectrum(0)))
     318                    ll.append(numpy.array(ssuboff._getspectrum(0)))
    278319                    sel.reset()
    279                     ss.set_selection()
     320                    ssuboff.set_selection()
    280321            precal[keys[2*i]]=ll
    281             del ss
    282             ss=ssubon.get_scan('*'+keys[2*i+1])
     322            #del ss
     323            #ss=ssubon.get_scan('*'+keys[2*i+1])
    283324            ll=[]
    284325            for j in range(len(ifnos)):
     
    286327                    sel.set_ifs(ifnos[j])
    287328                    sel.set_polarizations(polnos[k])
     329                    sel.set_types(types[2*i+1])
    288330                    try:
    289                         ss.set_selection(sel)
     331                        #ss.set_selection(sel)
     332                        ssubon.set_selection(sel)
    290333                    except:
    291334                        continue
    292                     ll.append(numpy.array(ss._getspectrum(0)))
     335                    #ll.append(numpy.array(ss._getspectrum(0)))
     336                    ll.append(numpy.array(ssubon._getspectrum(0)))
    293337                    sel.reset()
    294                     ss.set_selection()
     338                    ssubon.set_selection()
    295339            precal[keys[2*i+1]]=ll
    296             del ss
     340            #del ss
    297341        for j in range(len(ifnos)):
    298342            for k in range(len(polnos)):
     
    413457    varlist = vars()
    414458    from asap._asap import stmath
     459    from asap._asap import srctype
    415460    stm = stmath()
    416461    stm._setinsitu(False)
    417462
    418463    # check for the appropriate data
    419     s = scantab.get_scan('*_nod*')
    420     if s is None:
     464##     s = scantab.get_scan('*_nod*')
     465##     if s is None:
     466##         msg = "The input data appear to contain no Nod observing mode data."
     467##         if rcParams['verbose']:
     468##             #print msg
     469##             asaplog.push(msg)
     470##             print_log('ERROR')
     471##             return
     472##         else:
     473##             raise TypeError(msg)
     474    s = scantab.copy()
     475    sel = selector()
     476    sel.set_types( srctype.nod )
     477    try:
     478        s.set_selection( sel )
     479    except Exception, e:
    421480        msg = "The input data appear to contain no Nod observing mode data."
    422481        if rcParams['verbose']:
     
    427486        else:
    428487            raise TypeError(msg)
     488    sel.reset()
     489    del sel
     490    del s
    429491
    430492    # need check correspondance of each beam with sig-ref ...
     
    475537        precal={}
    476538        postcal=[]
    477         keys=['nod','nod_calon']
     539        keys=['','_calon']
     540        types=[srctype.nod,srctype.nodcal]
    478541        ifnos=list(scantab.getifnos())
    479542        polnos=list(scantab.getpolnos())
    480543        sel=selector()
     544        ss = scantab.copy()
    481545        for i in range(2):
    482             ss=scantab.get_scan('*'+keys[i])
     546            #ss=scantab.get_scan('*'+keys[i])
    483547            ll=[]
    484548            ll2=[]
     
    488552                    sel.set_polarizations(polnos[k])
    489553                    sel.set_scans(pairScans[0])
     554                    sel.set_types(types[i])
    490555                    try:
    491556                        ss.set_selection(sel)
     
    498563                    sel.set_polarizations(polnos[k])
    499564                    sel.set_scans(pairScans[1])
     565                    sel.set_types(types[i])
    500566                    try:
    501567                        ss.set_selection(sel)
     
    506572                    sel.reset()
    507573                    ss.set_selection()
    508             key='%s%s' %(pairScans[0],keys[i].lstrip('nod'))
     574            key='%s%s' %(pairScans[0],keys[i])
    509575            precal[key]=ll
    510             key='%s%s' %(pairScans[1],keys[i].lstrip('nod'))
     576            key='%s%s' %(pairScans[1],keys[i])
    511577            precal[key]=ll2
    512             del ss
     578            #del ss
    513579        keys=precal.keys()
    514580        for j in range(len(ifnos)):
     
    638704    varlist = vars()
    639705    from asap._asap import stmath
     706    from asap._asap import srctype
    640707    stm = stmath()
    641708    stm._setinsitu(False)
     
    657724        # get data
    658725        ssub = s.get_scan(scannos)
    659         ssubon = ssub.get_scan('*calon')
    660         ssuboff = ssub.get_scan('*[^calon]')
     726        #ssubon = ssub.get_scan('*calon')
     727        #ssuboff = ssub.get_scan('*[^calon]')
     728        sel = selector()
     729        sel.set_types( [srctype.foncal,srctype.foffcal] )
     730        ssub.set_selection( sel )
     731        ssubon = ssub.copy()
     732        ssub.set_selection()
     733        sel.reset()
     734        sel.set_types( [srctype.fson,srctype.fsoff] )
     735        ssub.set_selection( sel )
     736        ssuboff = ssub.copy()
     737        ssub.set_selection()
     738        sel.reset()
    661739        import numpy
    662740        precal={}
    663741        postcal=[]
    664742        keys=['fs','fs_calon','fsr','fsr_calon']
     743        types=[srctype.fson,srctype.foncal,srctype.fsoff,srctype.foffcal]
    665744        ifnos=list(ssub.getifnos())
    666745        polnos=list(ssub.getpolnos())
    667         sel=selector()
    668746        for i in range(2):
    669             ss=ssuboff.get_scan('*'+keys[2*i])
     747            #ss=ssuboff.get_scan('*'+keys[2*i])
    670748            ll=[]
    671749            for j in range(len(ifnos)):
     
    673751                    sel.set_ifs(ifnos[j])
    674752                    sel.set_polarizations(polnos[k])
     753                    sel.set_types(types[2*i])
    675754                    try:
    676                         ss.set_selection(sel)
     755                        #ss.set_selection(sel)
     756                        ssuboff.set_selection(sel)
    677757                    except:
    678758                        continue
    679759                    ll.append(numpy.array(ss._getspectrum(0)))
    680760                    sel.reset()
    681                     ss.set_selection()
     761                    #ss.set_selection()
     762                    ssuboff.set_selection()
    682763            precal[keys[2*i]]=ll
    683             del ss
    684             ss=ssubon.get_scan('*'+keys[2*i+1])
     764            #del ss
     765            #ss=ssubon.get_scan('*'+keys[2*i+1])
    685766            ll=[]
    686767            for j in range(len(ifnos)):
     
    688769                    sel.set_ifs(ifnos[j])
    689770                    sel.set_polarizations(polnos[k])
     771                    sel.set_types(types[2*i+1])
    690772                    try:
    691                         ss.set_selection(sel)
     773                        #ss.set_selection(sel)
     774                        ssubon.set_selection(sel)
    692775                    except:
    693776                        continue
    694777                    ll.append(numpy.array(ss._getspectrum(0)))
    695778                    sel.reset()
    696                     ss.set_selection()
     779                    #ss.set_selection()
     780                    ssubon.set_selection()
    697781            precal[keys[2*i+1]]=ll
    698             del ss
    699         sig=resspec.get_scan('*_fs')
    700         ref=resspec.get_scan('*_fsr')
     782            #del ss
     783        #sig=resspec.get_scan('*_fs')
     784        #ref=resspec.get_scan('*_fsr')
     785        sel.set_types( srctype.fson )
     786        resspec.set_selection( sel )
     787        sig=resspec.copy()
     788        resspec.set_selection()
     789        sel.reset()
     790        sel.set_type( srctype.fsoff )
     791        resspec.set_selection( sel )
     792        ref=resspec.copy()
     793        resspec.set_selection()
     794        sel.reset()
    701795        for k in range(len(polnos)):
    702796            for j in range(len(ifnos)):
Note: See TracChangeset for help on using the changeset viewer.