Ignore:
Timestamp:
02/17/05 14:46:17 (19 years ago)
Author:
mar637
Message:

Added SDFitTable to handle fits and expose them to python vi the sdfit class.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/SDMemTable.cc

    r464 r465  
    6060
    6161#include "SDDefs.h"
    62 #include "SDMemTable.h"
    6362#include "SDContainer.h"
    6463#include "MathUtils.h"
    6564#include "SDPol.h"
    6665
    67 
     66#include "SDMemTable.h"
    6867
    6968using namespace casa;
     
    206205  tdf.addColumn(ArrayColumnDesc<Double>("PARAMETERS"));
    207206  tdf.addColumn(ArrayColumnDesc<Bool>("PARMASK"));
     207  tdf.addColumn(ArrayColumnDesc<String>("FRAMEINFO"));
    208208  SetupNewTable fittab("fits", tdf, Table::New);
    209209  Table fitTable(fittab, Table::Memory);
     
    948948  td.addColumn(ArrayColumnDesc<Double>("PARAMETERS"));
    949949  td.addColumn(ArrayColumnDesc<Bool>("PARMASK"));
     950  td.addColumn(ArrayColumnDesc<String>("FRAMEINFO"));
    950951  SetupNewTable aNewTab("fits", td, Table::New);
    951952  Table aTable(aNewTab, Table::Memory);
     
    954955  ArrayColumn<Double> sc2(aTable, "PARAMETERS");
    955956  ArrayColumn<Bool> sc3(aTable, "PARMASK");
     957  ArrayColumn<String> sc4(aTable, "FRAMEINFO");
    956958  for (uInt i; i<sdft.length(); ++i) {
    957     const Vector<Double>& parms = sdft.getFitParameters(i);
    958     const Vector<Bool>& parmask = sdft.getFitParameterMask(i);
    959     const Vector<String>& funcs = sdft.getFitFunctions(i);
    960     const Vector<Int>& comps = sdft.getFitComponents(i);
     959    const Vector<Double>& parms = sdft.getParameters(i);
     960    const Vector<Bool>& parmask = sdft.getParameterMask(i);
     961    const Vector<String>& funcs = sdft.getFunctions(i);
     962    const Vector<Int>& comps = sdft.getComponents(i);
     963    const Vector<String>& finfo = sdft.getFrameInfo(i);
    961964    sc0.put(i,funcs);
    962965    sc1.put(i,comps);
    963966    sc3.put(i,parmask);
    964967    sc2.put(i,parms);
     968    sc4.put(i,finfo);
    965969  }
    966970  table_.rwKeywordSet().defineTable("FITS", aTable);
     
    974978  Vector<Bool> parmask;
    975979  Vector<String> funcs;
     980  Vector<String> finfo;
    976981  Vector<Int> comps; 
    977982  ROArrayColumn<Double> parmsCol(t, "PARAMETERS");
     
    979984  ROArrayColumn<Int> compsCol(t, "COMPONENTS");
    980985  ROArrayColumn<String> funcsCol(t, "FUNCTIONS");
     986  ROArrayColumn<String> finfoCol(t, "FRAMEINFO");
    981987  uInt n = t.nrow();
    982   SDFitTable sdft(n);
     988  SDFitTable sdft;
    983989  for (uInt i=0; i<n; ++i) {
    984990    parmaskCol.get(i, parmask);
    985     sdft.putFitParameterMask(i, parmask);
    986991    parmsCol.get(i, parms);
    987     sdft.putFitParameters(i, parms);
    988992    funcsCol.get(i, funcs);
    989     sdft.putFitFunctions(i, funcs);
    990993    compsCol.get(i, comps);
    991     sdft.putFitComponents(i, comps);
     994    finfoCol.get(i, finfo);
     995    sdft.addFit(parms, parmask, funcs, comps, finfo);
    992996  }
    993997  return sdft;
    994998}
    995999
     1000SDFitTable SDMemTable::getSDFitTable(uInt whichRow) const {
     1001  Array<Int> fitid;
     1002  fitCol_.get(whichRow, fitid);
     1003  if (fitid.nelements() == 0) return SDFitTable();
     1004
     1005  IPosition shp = fitid.shape();
     1006  IPosition start(4, beamSel_, IFSel_, polSel_,0);
     1007  IPosition end(4, beamSel_, IFSel_, polSel_, shp[3]-1);
     1008
     1009  // reform the output array slice to be of dim=1
     1010  Vector<Int> tmp = (fitid(start, end)).reform(IPosition(1,shp[3]));
     1011
     1012  const Table& t = table_.keywordSet().asTable("FITS");
     1013  Vector<Double> parms;
     1014  Vector<Bool> parmask;
     1015  Vector<String> funcs;
     1016  Vector<String> finfo;
     1017  Vector<Int> comps;   
     1018  ROArrayColumn<Double> parmsCol(t, "PARAMETERS");
     1019  ROArrayColumn<Bool> parmaskCol(t, "PARMASK");
     1020  ROArrayColumn<Int> compsCol(t, "COMPONENTS");
     1021  ROArrayColumn<String> funcsCol(t, "FUNCTIONS");
     1022  ROArrayColumn<String> finfoCol(t, "FRAMEINFO");
     1023  if (t.nrow() == 0) return SDFitTable();
     1024  SDFitTable sdft;
     1025  Int k=-1;
     1026  for (uInt i=0; i< tmp.nelements(); ++i) {
     1027    k = tmp[i];
     1028    if ( k > -1 && k < t.nrow() ) {
     1029      parms.resize();
     1030      parmsCol.get(k, parms);
     1031      parmask.resize();
     1032      parmaskCol.get(k, parmask);
     1033      funcs.resize();
     1034      funcsCol.get(k, funcs);
     1035      comps.resize();
     1036      compsCol.get(k, comps);
     1037      finfo.resize();
     1038      finfoCol.get(k, finfo);
     1039      sdft.addFit(parms, parmask, funcs, comps, finfo);
     1040    }
     1041  }
     1042  return sdft;
     1043}
    9961044
    9971045void SDMemTable::addFit(uInt whichRow,
     
    10091057  ArrayColumn<Int> compsCol(t, "COMPONENTS");
    10101058  ArrayColumn<String> funcsCol(t, "FUNCTIONS");
     1059  ArrayColumn<String> finfoCol(t, "FRAMEINFO");
    10111060  parmsCol.put(nrow, p);
    10121061  parmaskCol.put(nrow, m);
    10131062  compsCol.put(nrow, c);
    10141063  funcsCol.put(nrow, f);
     1064  Vector<String> fi = mathutil::toVectorString(getCoordInfo());
     1065  finfoCol.put(nrow, fi);
    10151066
    10161067  Array<Int> fitarr;
     
    14321483  Vector<String> history;
    14331484  histCol_.get(whichRow, history);
    1434   std::vector<std::string> stlout;
    1435   // there is no Array<String>.tovector(std::vector<std::string>), so
    1436   // do it by hand
    1437   for (uInt i=0; i<history.nelements(); ++i) {
    1438     stlout.push_back(history[i]);
    1439   }
     1485  std::vector<std::string> stlout = mathutil::tovectorstring(history);
    14401486  return stlout;
    14411487}
Note: See TracChangeset for help on using the changeset viewer.