Changeset 15


Ignore:
Timestamp:
06/30/04 10:59:20 (21 years ago)
Author:
mmarquar
Message:

Added multiply function.

Location:
trunk/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMath.cc

    r13 r15  
    5555  ROScalarColumn<Double> mjd(t, "TIME");
    5656  ROScalarColumn<String> srcn(t, "SRCNAME");
     57  ROScalarColumn<Double> integr(t, "INTERVAL");
    5758  IPosition ip = in->rowAsMaskedArray(0).shape();
    5859  Array<Float> outarr(ip); outarr =0.0;
     
    6364  Array<Float> outtsarr(tsys.shape(0));
    6465  Double tme = 0.0;
     66  Double inttime = 0.0;
    6567
    6668  for (uInt i=0; i < t.nrow(); i++) {
     
    7678    mjd.get(i,tmp);
    7779    tme += tmp;// average time
     80    integr.get(i,tmp);
     81    inttime += tmp;
    7882  }
    7983  // averaging using mask
     
    8892  outtsarr /= Float(n/2);
    8993  sc.timestamp = tme/Double(n/2);
    90 
    91   String tstr; srcn.getScalar(n,tstr);// get sourcename of "mid" point
     94  sc.interval =inttime;
     95  String tstr; srcn.getScalar(0,tstr);// get sourcename of "mid" point
    9296  sc.sourcename = tstr;
    9397  sc.putSpectrum(outarr);
    9498  sc.putFlags(outflags); 
    95   SDMemTable* sdmt = new SDMemTable(*in);
     99  SDMemTable* sdmt = new SDMemTable(*in,True);
    96100  sdmt->putSDContainer(sc);
    97101  return CountedPtr<SDMemTable>(sdmt);
     
    104108  Table ton = on->table();
    105109  Table toff = off->table();
    106   ROArrayColumn<Float> tsys(toff, "TSYS");
    107  
     110  ROArrayColumn<Float> tsys(toff, "TSYS"); 
    108111  ROScalarColumn<Double> mjd(ton, "TIME");
     112  ROScalarColumn<Double> integr(ton, "INTERVAL");
    109113  ROScalarColumn<String> srcn(ton, "SRCNAME");
    110114  MaskedArray<Float> mon(on->rowAsMaskedArray(0));
     
    131135  Double tme; mjd.getScalar(0,tme);// get time of "on" scan
    132136  sc.timestamp = tme;
     137  integr.getScalar(0,tme);
     138  sc.interval = tme;
    133139  sc.putSpectrum(out);
    134140  sc.putFlags(outflags); 
    135   SDMemTable* sdmt = new SDMemTable(*on);
     141  SDMemTable* sdmt = new SDMemTable(*on, True);
    136142  sdmt->putSDContainer(sc);
    137143  return CountedPtr<SDMemTable>(sdmt);
    138144 
    139145}
     146static CountedPtr<SDMemTable>
     147SDMath::multiply(const CountedPtr<SDMemTable>& in, Float factor) {
     148  SDMemTable* sdmt = new SDMemTable(*in);
     149  Table t = sdmt->table();
     150  ArrayColumn<Float> spec(t,"SPECTRA");
    140151
    141 
     152  for (uInt i=0; i < t.nrow(); i++) {
     153    // data stuff
     154    MaskedArray<Float> marr(sdmt->rowAsMaskedArray(i));
     155    marr *= factor;
     156    spec.put(i, marr.getArray());
     157  }
     158  return CountedPtr<SDMemTable>(sdmt);
     159}
     160/*
     161static Float SDMath::rms(const SDMemTable& in, uInt whichRow) {
     162  Table t = in.table(); 
     163  MaskedArray<Float> marr(in.rowAsMaskedArray(whichRow,True));
     164 
     165}
     166*/
  • trunk/src/SDMath.h

    r9 r15  
    4343  static CountedPtr<SDMemTable> quotient(const CountedPtr<SDMemTable>& on,
    4444                                         const CountedPtr<SDMemTable>& off);
    45   //CountedPtr<SDMemTable> multiply(CountedPtr<SDMemTable>& in, Float factor);
     45  static CountedPtr<SDMemTable> multiply(const CountedPtr<SDMemTable>& in,
     46                                         Float factor);
     47 
    4648 
    4749};
  • trunk/src/python_SDMath.cc

    r12 r15  
    4242    .def("average", &SDMathWrapper::average)
    4343    .def("quotient", &SDMathWrapper::quotient)
     44    .def("multiply", &SDMathWrapper::multiply)
    4445    ;
    4546};
Note: See TracChangeset for help on using the changeset viewer.