Changeset 15 for trunk/src/SDMath.cc


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

Added multiply function.

File:
1 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*/
Note: See TracChangeset for help on using the changeset viewer.