#include #include #include #include #include #include #include #include #include #include using std::endl; using std::setw; using std::setprecision; using namespace Column; void Cube::outputDetectionsKarma(std::ostream &stream) { /** * Prints to a stream (provided) the list of detected objects in the cube * in the format of an annotation file for the Karma suite of programs. * Annotation file draws a box enclosing the detection, and writes the * ID number of the detection to the right of the box. */ string fname = this->par.getImageFile(); if(this->par.getFlagSubsection()) fname+=this->par.getSubsection(); stream << "# Duchamp Source Finder results for FITS file: " << fname << endl; if(this->par.getFlagFDR()) stream<<"# FDR Significance = " << this->par.getAlpha() << endl; else stream<<"# Threshold = " << this->par.getCut() << endl; if(this->par.getFlagATrous()){ stream<<"# The a trous reconstruction method was used, with the following parameters." << endl; stream<<"# ATrous Dimension = " << this->par.getReconDim() << endl; stream<<"# ATrous Threshold = " << this->par.getAtrousCut() << endl; stream<<"# ATrous Minimum Scale =" << this->par.getMinScale() << endl; stream<<"# ATrous Filter = " << this->par.getFilterName() << endl; } else stream << "# No ATrous reconstruction done." << endl; stream << "#\n"; stream << "COLOR RED" << endl; stream << "COORD W" << endl; for(int i=0;iobjectList.size();i++){ if(this->head.isWCS()){ float radius = this->objectList[i].getRAWidth()/120.; if(this->objectList[i].getDecWidth()/120.>radius) radius = this->objectList[i].getDecWidth()/120.; stream << "CIRCLE " << this->objectList[i].getRA() << " " << this->objectList[i].getDec() << " " << radius << endl; stream << "TEXT " << this->objectList[i].getRA() << " " << this->objectList[i].getDec() << " " << this->objectList[i].getID() << endl; } else{ float radius = this->objectList[i].getXmax() - this->objectList[i].getXmin() + 1; if(this->objectList[i].getYmax()-this->objectList[i].getYmin() + 1 > radius) radius = this->objectList[i].getYmax() - this->objectList[i].getYmin() + 1; stream << "CIRCLE " << this->objectList[i].getXcentre() << " " << this->objectList[i].getYcentre() << " " << radius << endl; stream << "TEXT " << this->objectList[i].getXcentre() << " " << this->objectList[i].getYcentre() << " " << this->objectList[i].getID() << endl; } } } void Cube::outputDetectionsVOTable(std::ostream &stream) { /** * Prints to a stream (provided) the list of detected objects in the cube * in a VOTable format. * Uses WCS information and assumes WCS parameters have been calculated for each * detected object. * If they have not (given by the isWCS() function), then those objects are not written... */ // Set up Column definitions here vector localCol; string posUCD[4]; localCol.push_back(this->fullCols[NUM]); // objID localCol.push_back(this->fullCols[NAME]); // name localCol.push_back(this->fullCols[RA]); // ra if(makelower(localCol[2].getName())=="ra"){ posUCD[0] = "pos.eq.ra;meta.main"; posUCD[2] = "phys.angSize;pos.eq.ra"; } else{ posUCD[0] = "pos.galactic.lat;meta.main"; posUCD[2] = "phys.angSize;pos.galactic.lat"; } localCol.push_back(this->fullCols[DEC]); // dec if(makelower(localCol[2].getName())=="dec"){ posUCD[1] = "pos.eq.dec;meta.main"; posUCD[3] = "phys.angSize;pos.eq.dec"; } else{ posUCD[1] = "pos.galactic.lon;meta.main"; posUCD[3] = "phys.angSize;pos.galactic.lon"; } localCol.push_back(this->fullCols[WRA]); // w_ra localCol.push_back(this->fullCols[WDEC]); // w_dec localCol.push_back(this->fullCols[VEL]); // vel localCol.push_back(this->fullCols[WVEL]); // w_vel localCol.push_back(this->fullCols[FINT]); // f_int localCol.push_back(this->fullCols[FPEAK]); // f_peak localCol.push_back(this->fullCols[FLAG]); // flag stream<<""<"<"<"<"<Detected sources and parameters from running the Duchamp source finder."<par.getImageFile(); if(this->par.getFlagSubsection()) fname+=this->par.getSubsection(); stream<<" "<par.getFlagFDR()) stream<<" par.getAlpha() << "\">" << endl; else stream<<" par.getCut() << "\">" << endl; if(this->par.getFlagATrous()){ stream<<" " << endl; stream<<" par.getReconDim() << "\">" << endl; stream<<" par.getAtrousCut() << "\">" << endl; stream<<" par.getMinScale() << "\">" << endl; stream<<" par.getFilterName() << "\">" << endl; } // FIELD section -- names, titles and info for each column. stream<<" "<"<"<"<"<"<"<"<"<"<"<"<"<objectList.size();i++){ if(this->objectList[i].isWCS()){ stream<<" "<"<"; stream<<"" << setw(localCol[1].getWidth()) << this->objectList[i].getName() <<""; stream<" << setw(localCol[2].getWidth()) << this->objectList[i].getRA() <<""; stream<<"" << setw(localCol[3].getWidth()) << this->objectList[i].getDec() <<""; stream<" << setw(localCol[4].getWidth()) << this->objectList[i].getRAWidth() <<""; stream<<"" << setw(localCol[5].getWidth()) << this->objectList[i].getDecWidth() <<""; stream<" << setw(localCol[6].getWidth()) << this->objectList[i].getVel() <<""; stream<<"" << setw(localCol[7].getWidth()) << this->objectList[i].getVelWidth() <<""; stream<" << setw(localCol[8].getWidth()) << this->objectList[i].getIntegFlux() <<""; stream<<"" << setw(localCol[9].getWidth()) << this->objectList[i].getPeakFlux() <<""; stream<<"" << setw(localCol[10].getWidth())<< this->objectList[i].getFlagText() <<""; stream<"<"<"<"<"<"<par.getOutFile().c_str()); output<<"Results of the Duchamp source finder: "; time_t now = time(NULL); output << asctime( localtime(&now) ); this->showParam(output); output<<"--------------------"<head.getFluxUnits(); if(this->par.getFlagFDR()) output<<" (or S/N=" << this->Stats.getThresholdSNR()<<")"; output<setupColumns(); this->objectList[0].outputDetectionTextHeader(output,this->fullCols); this->objectList[0].outputDetectionTextHeader(std::cout,this->fullCols); for(int i=0;iobjectList.size();i++){ this->objectList[i].outputDetectionTextWCS(output,this->fullCols); this->objectList[i].outputDetectionTextWCS(std::cout,this->fullCols); } } void Cube::logDetectionList() { /** * logDetectionList * A front-end to writing a list of detected objects to the log file. * Does not assume WCS, so uses outputDetectionText. * Designed to be used by searching routines before returning their final list. */ std::ofstream fout(this->par.getLogFile().c_str(),std::ios::app); this->setupColumns(); this->objectList[0].outputDetectionTextHeader(fout,this->logCols); long pos; bool baselineFlag = this->par.getFlagBaseline(); for(int objCtr=0;objCtrobjectList.size();objCtr++){ Detection *obj = new Detection; *obj = objectList[objCtr]; if(this->par.getFlagCubeTrimmed()){ for(int pix=0;pixgetSize();pix++){ // Need to correct the pixels first, as this hasn't been done yet. // Corrections needed for positions (to account for trimmed region) // and for the baseline removal, if it has happened. // Don't want to keep these changes, so just do it on a dummy variable. pos = obj->getX(pix) + obj->getY(pix)*this->axisDim[0] + obj->getZ(pix)*this->axisDim[0]*this->axisDim[1]; obj->setX(pix, obj->getX(pix) + this->par.getBorderLeft() ); obj->setY(pix, obj->getY(pix) + this->par.getBorderBottom() ); if(baselineFlag) obj->setF(pix, obj->getF(pix) + this->baseline[pos]); // add in baseline } obj->calcParams(); } obj->outputDetectionText(fout,this->logCols,objCtr+1); delete obj; } fout.close(); } void Cube::logDetection(Detection obj, int counter) { /** * A front-end to writing a detected object to the log file. * Does not assume WCS, so uses outputDetectionText. * Corrects for changes to positions of pixels and removal of baselines. * Designed to be used by searching routines before returning their final * list. * \param obj Detection object to be written : passed by value, as we want * to potentially change positions etc, but not for the object in the * calling function. * \param counter The number to assign to the object : ideally its number * in a list of some kind. */ std::ofstream fout(this->par.getLogFile().c_str(),std::ios::app); bool baselineFlag = this->par.getFlagBaseline(); if(this->par.getFlagCubeTrimmed()){ for(int pix=0;pixaxisDim[0] + obj.getZ(pix)*this->axisDim[0]*this->axisDim[1]; obj.setX(pix, obj.getX(pix) + this->par.getBorderLeft() ); obj.setY(pix, obj.getY(pix) + this->par.getBorderBottom() ); if(baselineFlag) obj.setF(pix, obj.getF(pix) + this->baseline[pos]); // add in baseline } obj.calcParams(); } obj.outputDetectionText(fout,this->logCols,counter); fout.close(); }