#include #include #include #include #include #include #include //using std::ofstream; using std::endl; using std::setw; using std::setprecision; void Cube::outputDetectionsKarma(std::ostream &stream) { /** * outputDetectionsKarma * 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. */ stream << "# Duchamp Source Finder results for cube " << this->par.getImageFile() << endl; stream << "COLOR RED" << endl; stream << "COORD W" << endl; for(int i=0;iobjectList.size();i++){ 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; } } void Cube::outputDetectionsVOTable(std::ostream &stream) { /** * outputDetectionsVOTable * 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... */ stream<<""<"<"<"<"<Detected sources and parameters from running the Duchamp source finder."<par.getImageFile() << "\"/>"<"<"<"<"<"<"<"<"<"<"<"<objectList.size();i++){ if(this->objectList[i].isWCS()){ stream<<" "<"<"; stream<<"" << setw(14) << this->objectList[i].getName() <<""; stream<" << setw(10) << this->objectList[i].getRA() <<""; stream<<"" << setw(10) << this->objectList[i].getDec() <<""; stream<" << setw(7) << this->objectList[i].getRAWidth() <<""; stream<<"" << setw(7) << this->objectList[i].getDecWidth() <<""; stream<" << setw(9) << this->objectList[i].getVel() <<""; stream<<"" << setw(8) << this->objectList[i].getVelWidth() <<""; stream<" << setw(10) << this->objectList[i].getIntegFlux() <<""; stream<"<"<"<"<"<"<par.getOutFile().c_str()); output<<"Results of the Duchamp source finder: "; output.close(); string syscall = "date >> " + this->par.getOutFile(); system(syscall.c_str()); output.open(this->par.getOutFile().c_str(),std::ios::app); this->showParam(output); output<<"Total number of detections = "<objectList.size()<wcs); outputDetectionTextWCSHeader(std::cout,this->wcs); for(int i=0;iobjectList.size();i++){ this->objectList[i].outputDetectionTextWCS(output); this->objectList[i].outputDetectionTextWCS(std::cout); } } 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); outputDetectionTextHeader(fout); 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,objCtr); delete obj; } fout.close(); } void Cube::logDetection(Detection obj, int counter) { /** * logDetection * A front-end to writing a detected object to the log file. * Does not assume WCS, so uses outputDetectionText. * obj is passed by value, as we want to potentially change positions etc, but not for * object in the calling function. * Corrects for changes to positions of pixels and removal of baselines. * Designed to be used by searching routines before returning their final list. */ 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,counter); fout.close(); }