Changeset 1689


Ignore:
Timestamp:
02/10/10 11:59:23 (14 years ago)
Author:
Malte Marquarding
Message:

Ticket #177: added skydip function to determine opacities. This resulted in a slight interface change to accept lists of opacities in the scantable.opacity function

Location:
trunk
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/python/__init__.py

    r1645 r1689  
    389389from simplelinefinder import simplelinefinder
    390390from linecatalog import linecatalog
     391from opacity import skydip
    391392
    392393if rcParams['useplotter']:
  • trunk/python/asapfitter.py

    r1589 r1689  
    485485
    486486    @print_log_dec
    487     def plot(self, residual=False, components=None, plotparms=False, filename=None):
     487    def plot(self, residual=False, components=None, plotparms=False,
     488             filename=None):
    488489        """
    489490        Plot the last fit.
  • trunk/python/scantable.py

    r1617 r1689  
     1import functools
    12from asap._asap import Scantable
    23from asap import rcParams
     
    78from asap.coordinate import coordinate
    89from asap import _n_bools, mask_not, mask_and, mask_or
     10
     11
     12def preserve_selection(func):
     13    @functools.wraps(func)
     14    def wrap(obj, *args, **kw):
     15        basesel = obj.get_selection()
     16        val = func(obj, *args, **kw)
     17        obj.set_selection(basesel)
     18        return val
     19    return wrap
     20
    921
    1022class scantable(Scantable):
     
    11041116        and Tsys are multiplied by the correction factor.
    11051117        Parameters:
    1106             tau:         Opacity from which the correction factor is
     1118            tau:         (list of) opacity from which the correction factor is
    11071119                         exp(tau*ZD)
    1108                          where ZD is the zenith-distance
     1120                         where ZD is the zenith-distance.
     1121                         If a list is provided, it has to be of length nIF,
     1122                         nIF*nPol or 1 and in order of IF/POL, e.g.
     1123                         [opif0pol0, opif0pol1, opif1pol0 ...]
    11091124            insitu:      if False a new scantable is returned.
    11101125                         Otherwise, the scaling is done in-situ
     
    11141129        self._math._setinsitu(insitu)
    11151130        varlist = vars()
     1131        if not hasattr(tau, "__len__"):
     1132            tau = [tau]
    11161133        s = scantable(self._math._opacity(self, tau))
    11171134        s._add_history("opacity", varlist)
  • trunk/src/STMath.cpp

    r1618 r1689  
    14311431
    14321432CountedPtr< Scantable > STMath::opacity( const CountedPtr< Scantable > & in,
    1433                                          float tau )
     1433                                         const std::vector<float>& tau )
    14341434{
    14351435  CountedPtr< Scantable > out = getScantable(in, false);
    14361436
    1437   Table tab = out->table();
    1438   ROScalarColumn<Float> elev(tab, "ELEVATION");
    1439   ArrayColumn<Float> specCol(tab, "SPECTRA");
    1440   ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
    1441   ArrayColumn<Float> tsysCol(tab, "TSYS");
    1442   for ( uInt i=0; i<tab.nrow(); ++i) {
    1443     Float zdist = Float(C::pi_2) - elev(i);
    1444     Float factor = exp(tau/cos(zdist));
    1445     MaskedArray<Float> ma = maskedArray(specCol(i), flagCol(i));
    1446     ma *= factor;
    1447     specCol.put(i, ma.getArray());
    1448     flagCol.put(i, flagsFromMA(ma));
    1449     Vector<Float> tsys;
    1450     tsysCol.get(i, tsys);
    1451     tsys *= factor;
    1452     tsysCol.put(i, tsys);
     1437  Table outtab = out->table();
     1438
     1439  const uInt ntau = uInt(tau.size());
     1440  std::vector<float>::const_iterator tauit = tau.begin();
     1441  AlwaysAssert((ntau == 1 || ntau == in->nif() || ntau == in->nif() * in->npol()),
     1442               AipsError);
     1443  TableIterator iiter(outtab, "IFNO");
     1444  while ( !iiter.pastEnd() ) {
     1445    Table itab = iiter.table();
     1446    TableIterator piter(outtab, "POLNO");
     1447    while ( !piter.pastEnd() ) {
     1448      Table tab = piter.table();
     1449      ROScalarColumn<Float> elev(tab, "ELEVATION");
     1450      ArrayColumn<Float> specCol(tab, "SPECTRA");
     1451      ArrayColumn<uChar> flagCol(tab, "FLAGTRA");
     1452      ArrayColumn<Float> tsysCol(tab, "TSYS");
     1453      for ( uInt i=0; i<tab.nrow(); ++i) {
     1454        Float zdist = Float(C::pi_2) - elev(i);
     1455        Float factor = exp(*tauit/cos(zdist));
     1456        MaskedArray<Float> ma = maskedArray(specCol(i), flagCol(i));
     1457        ma *= factor;
     1458        specCol.put(i, ma.getArray());
     1459        flagCol.put(i, flagsFromMA(ma));
     1460        Vector<Float> tsys;
     1461        tsysCol.get(i, tsys);
     1462        tsys *= factor;
     1463        tsysCol.put(i, tsys);
     1464      }
     1465      if (ntau == in->nif()*in->npol() ) {
     1466        tauit++;
     1467      }
     1468      piter++;
     1469    }
     1470    if (ntau >= in->nif() ) {
     1471      tauit++;
     1472    }
     1473    iiter++;
    14531474  }
    14541475  return out;
  • trunk/src/STMath.h

    r1570 r1689  
    227227
    228228  casa::CountedPtr<Scantable> opacity(const casa::CountedPtr<Scantable>& in,
    229                                       float tau);
     229                                      const std::vector<float>& tau);
    230230
    231231  casa::CountedPtr<Scantable>
  • trunk/src/STMathWrapper.h

    r1570 r1689  
    149149
    150150  ScantableWrapper opacity(const ScantableWrapper& in,
    151                                       float tau)
     151                          const std::vector<float>& tau)
    152152  { return ScantableWrapper(STMath::opacity(in.getCP(), tau)); }
    153153
Note: See TracChangeset for help on using the changeset viewer.