Changeset 9 for trunk/src


Ignore:
Timestamp:
06/24/04 11:44:08 (20 years ago)
Author:
mmarquar
Message:

Added flags to the computation. Also added function 'quotient' with flag support.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r2 r9  
    7878  }
    7979  // averaging using mask
    80   MaskedArray<Float> nma (narr,(narr > Float(0)));
     80  MaskedArray<Float> nma(narr,(narr > Float(0)));
    8181  outarr /= nma;
    82 
     82  Array<Bool> outflagsb = !(nma.getMask());
     83  Array<uChar> outflags(outflagsb.shape());
     84  convertArray(outflags,outflagsb);
    8385  SDContainer sc(ip(0),ip(1),ip(2),ip(3));
    8486
     
    9092  sc.sourcename = tstr;
    9193  sc.putSpectrum(outarr);
    92   //sc.putFlags(outflags); 
     94  sc.putFlags(outflags); 
    9395  SDMemTable* sdmt = new SDMemTable(*in);
    9496  sdmt->putSDContainer(sc);
    9597  return CountedPtr<SDMemTable>(sdmt);
    9698}
     99
     100static CountedPtr<SDMemTable>
     101SDMath::quotient(const CountedPtr<SDMemTable>& on,
     102                 const CountedPtr<SDMemTable>& off) {
     103 
     104  Table ton = on->table();
     105  Table toff = off->table();
     106  ROArrayColumn<Float> tsys(ton, "TSYS");
     107 
     108  ROScalarColumn<Double> mjd(ton, "TIME");
     109  ROScalarColumn<String> srcn(ton, "SRCNAME");
     110  MaskedArray<Float> mon(on->rowAsMaskedArray(0));
     111  MaskedArray<Float> moff(off->rowAsMaskedArray(0));
     112  IPosition ipon = mon.shape();
     113  IPosition ipoff = moff.shape();
     114  Array<Float> tsarr(tsys.shape(0));
     115
     116  if (ipon != ipoff && ipon != tsarr.shape())
     117    cerr << "on/off not conformant" << endl;
     118 
     119  //IPosition test = mon.shape()/2;
     120  MaskedArray<Float> tmp = (mon-moff);
     121  Array<Float> out(tmp.getArray());
     122  out /= moff;
     123  out *= tsarr;
     124  Array<Bool> outflagsb = !(mon.getMask() && moff.getMask());
     125  Array<uChar> outflags(outflagsb.shape());
     126  convertArray(outflags,outflagsb);
     127
     128  SDContainer sc(ipon(0),ipon(1),ipon(2),ipon(3));
     129  String tstr; srcn.getScalar(0,tstr);// get sourcename of "on" scan
     130  sc.sourcename = tstr;
     131  Double tme; mjd.getScalar(0,tme);// get time of "on" scan
     132  sc.timestamp = tme;
     133  sc.putSpectrum(out);
     134  sc.putFlags(outflags); 
     135  SDMemTable* sdmt = new SDMemTable(*on);
     136  sdmt->putSDContainer(sc);
     137  return CountedPtr<SDMemTable>(sdmt);
     138 
     139}
     140
     141
  • trunk/src/SDMath.h

    r2 r9  
    4141public:
    4242  static CountedPtr<SDMemTable> average(const CountedPtr<SDMemTable>& in);
    43   //SDMemTable quotient(const SDMemTable& on, const SDMemTable& off);
    44   //SDMemTable multiply(SDMemTable& in, Float factor);
     43  static CountedPtr<SDMemTable> quotient(const CountedPtr<SDMemTable>& on,
     44                                         const CountedPtr<SDMemTable>& off);
     45  //CountedPtr<SDMemTable> multiply(CountedPtr<SDMemTable>& in, Float factor);
    4546 
    4647};
Note: See TracChangeset for help on using the changeset viewer.