Changeset 829


Ignore:
Timestamp:
02/17/06 15:04:14 (18 years ago)
Author:
mar637
Message:

asap2 integration

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/MathUtils.cc

    r465 r829  
    4141using namespace casa;
    4242
    43 float mathutil::statistics(const String& which, 
     43float mathutil::statistics(const String& which,
    4444                           const MaskedArray<Float>& data)
    4545{
     
    4747   str.upcase();
    4848   if (str.contains(String("MIN"))) {
    49       return min(data); 
     49      return min(data);
    5050   } else if (str.contains(String("MAX"))) {
    5151      return max(data);
     
    5757      return mean(data);
    5858   } else if (str.contains(String("VAR"))) {
    59       return variance(data); 
     59      return variance(data);
    6060   } else if (str.contains(String("STDDEV"))) {
    6161      return stddev(data);
     
    6969   }
    7070}
    71  
     71
    7272
    7373void mathutil::replaceMaskByZero(Vector<Float>& data, const Vector<Bool>& mask)
     
    7979
    8080
    81 void mathutil::scanBoundaries(Vector<uInt>& startInt,
    82                               Vector<uInt>& endInt,
    83                               const Vector<Int>& scanIDs)
    84   // Find integrations start and end for each Scan
    85 {
    86   uInt nInt = scanIDs.nelements();
    87   startInt.resize(nInt);
    88   endInt.resize(nInt);
    89 
    90   startInt(0) = 0;
    91   uInt j = 0;
    92   Int currScanID = scanIDs(0);
    93   for (uInt i=0; i<nInt; i++) {
    94     if (scanIDs(i) != currScanID) { 
    95       endInt(j) = i-1;
    96       currScanID = scanIDs(i);
    97 
    98       j += 1;
    99       startInt(j) = i;
    100       if (i==nInt-1) {
    101         endInt(j) = i;
    102       }   
    103     } else {
    104       if (i==nInt-1) endInt(j) = i;
    105     }
    106   }
    107   startInt.resize(j+1,True);
    108   endInt.resize(j+1,True);
    109 }
    110 
    111 std::vector<std::string> mathutil::tovectorstring(const Vector<String>& in)
     81std::vector<std::string> mathutil::tovectorstring(const Vector<String>& in)
    11282{
    11383  std::vector<std::string> out;
     
    11989}
    12090
    121 Vector<String> mathutil::toVectorString(const std::vector<std::string>& in) 
     91Vector<String> mathutil::toVectorString(const std::vector<std::string>& in)
    12292{
    12393  Vector<String> out(in.size());
  • trunk/src/MathUtils.h

    r465 r829  
    4040namespace mathutil {
    4141
    42 // Add new entry to list
    43 template <class T>
    44 casa::uInt addEntry(casa::Vector<T>& list, T val);
    45 
    46 // Find the scan boundaries from a list of ScanIDs
    47 void scanBoundaries(casa::Vector<casa::uInt>& startInt, 
    48                     casa::Vector<casa::uInt>& endInt,
    49                     const casa::Vector<casa::Int>& scanIDs);
    50 
    5142// Hanning smoothing
    5243template <class T>
    53 void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask, 
    54              const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask, 
    55              casa::Bool relaxed=casa::False, 
     44void hanning(casa::Vector<T>& out, casa::Vector<casa::Bool>& outmask,
     45             const casa::Vector<T>& in, const casa::Vector<casa::Bool>& mask,
     46             casa::Bool relaxed=casa::False,
    5647             casa::Bool ignoreOther=casa::False);
    5748
    5849// Generate specified statistic
    59 float statistics(const casa::String& which, 
     50float statistics(const casa::String& which,
    6051                 const casa::MaskedArray<casa::Float>& data);
    6152
    6253// Replace masked value by zero
    63 void replaceMaskByZero(casa::Vector<casa::Float>& data, 
     54void replaceMaskByZero(casa::Vector<casa::Float>& data,
    6455                       const casa::Vector<casa::Bool>& mask);
    6556
    66 // Extend the
    67 template <class T>
    68 void extendLastArrayAxis(casa::Array<T>& out, const casa::Array<T>& in,
    69                          const T& initVal);
    70  
    7157std::vector<std::string> tovectorstring(const casa::Vector<casa::String>& in);
    7258
  • trunk/src/MathUtils2.cc

    r452 r829  
    4141
    4242template <class T>
    43 void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask, 
    44                        const Vector<T>& in, const Vector<Bool>& mask, 
     43void mathutil::hanning(Vector<T>& out, Vector<Bool>& outmask,
     44                       const Vector<T>& in, const Vector<Bool>& mask,
    4545                       Bool relaxed, Bool ignoreOther) {
    4646
     
    5454  vals[0] = 0.5; vals[1] = 0.0; vals[2] = 0.5; weights[5] = vals;// TFT
    5555  vals[0] = 0.0; vals[1] = 2.0/3.0; vals[2] = 1.0/3.0; weights[6] = vals;// FTT
    56   vals[0] = 0.25; vals[1] = 0.5; vals[2] = 0.25; weights[7] = vals;// TTT 
     56  vals[0] = 0.25; vals[1] = 0.5; vals[2] = 0.25; weights[7] = vals;// TTT
    5757  // Chris' case
    58   Vector<Bool> weighted(8); 
     58  Vector<Bool> weighted(8);
    5959  if (relaxed) {
    6060    weighted = False;
     
    6565    weighted[0] = False;
    6666  }
    67  
     67
    6868  out.resize(in.nelements());
    6969  outmask.resize(mask.nelements());
     
    9191  }
    9292}
    93 
    94 template <class T>
    95 uInt mathutil::addEntry (Vector<T>& list, T val)
    96 {
    97    uInt n = list.nelements();
    98    if (n>0) {
    99       for (uInt i=0; i<n; i++) {
    100          if (near(list[i],val)) {
    101             return i;
    102          }
    103       }
    104    }
    105 //
    106    n++;
    107    list.resize(n,True);
    108    list(n-1) = val;
    109    return n-1;
    110 }
    111 
    112 template <class T>
    113 void mathutil::extendLastArrayAxis(casa::Array<T>& out,
    114                                    const casa::Array<T>& in,
    115                                    const T& initVal)
    116 {
    117  
    118   IPosition ipin = in.shape();
    119   IPosition ipout = ipin; // copy?
    120   // extend the axis by 1
    121   uInt axis = in.ndim()-1;
    122   ipout[axis] = ipin[axis]+1;
    123   out.resize(ipout);
    124   out = initVal;
    125   ArrayIterator<T> itout(out,axis);
    126   ReadOnlyArrayIterator<T> itin(in,axis);
    127   while ( !itin.pastEnd() ) {
    128     itout.array() = itin.array();  // copy vector by vector
    129     itin.next(); itout.next();
    130   }
    131 }
Note: See TracChangeset for help on using the changeset viewer.