From 42ccfdb30c4258e667436f0ae3fd3a369c6e15f7 Mon Sep 17 00:00:00 2001 From: Josh Cardenzana Date: Thu, 8 Nov 2018 10:11:10 +0100 Subject: [PATCH] Add output for significance distribution of pixel with maximum significance (#2713) --- src/ctfindvar/ctfindvar.cpp | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------- src/ctfindvar/ctfindvar.hpp | 3 +++ 2 files changed, 67 insertions(+), 27 deletions(-) diff --git a/src/ctfindvar/ctfindvar.cpp b/src/ctfindvar/ctfindvar.cpp index 72fb7d3..5d0dcff 100644 --- a/src/ctfindvar/ctfindvar.cpp +++ b/src/ctfindvar/ctfindvar.cpp @@ -303,11 +303,10 @@ void ctfindvar::run(void) //preparing the histogram with significance evolution for the source center and the highest sig-pix m_pixsigsrc = GNdarray(srcInxPix.size(), nbins); - m_pixsigmax = GNdarray(1,nbins); + m_pixsigmax = GNdarray(nbins); //Prepare the final skymap with the max significance of each pixel double max_sig=0; - GSkyDir max_sig_dir; //looping over all the pixels in the cube #pragma omp parallel for @@ -365,15 +364,10 @@ void ctfindvar::run(void) { if (max(pixSig) > max_sig) { - max_sig = max(pixSig); - // Store information for pixel with the maximum significance - for (int i=0; i= 0) { + max_pixel_info(i) = m_pixsigmax(index); + } } // Call the appropriate method for writing the data if ((*this)["histtype"].string() == "CSV") { - write_srchist_csv(time_info, src_info); + write_srchist_csv(time_info, max_pixel_info, src_info); } else { - write_srchist_fits(time_info, src_info); + write_srchist_fits(time_info, max_pixel_info, src_info); } } @@ -963,6 +963,7 @@ void ctfindvar::write_srchist(void) * @brief Write individual histograms in CSV format ***************************************************************************/ void ctfindvar::write_srchist_csv(const GNdarray& time_info, + const GNdarray& max_pixel_info, const GNdarray& src_info) { log_string(NORMAL,"Storing histograms in CSV format is not currently supported."); @@ -981,47 +982,83 @@ void ctfindvar::write_srchist_csv(const GNdarray& time_info, * significance of the source in that time bin. ***************************************************************************/ void ctfindvar::write_srchist_fits(const GNdarray& time_info, + const GNdarray& max_pixel_info, const GNdarray& src_info) { log_string(NORMAL, "Storing histograms in FITS format"); // Create the table int nrows = time_info.shape()[1]; - GFitsBinTable table(nrows); - table.extname("SRCSIGNIF"); + GFitsBinTable table_signif(nrows); + GFitsBinTable table_dir(2); + table_signif.extname("SRCSIGNIF"); + table_dir.extname("SRCPOSITION"); - // Append the start and stop time columns + // Append the start/stop time and max pixel columns GFitsTableFloatCol start_mjd("TSTART", nrows); GFitsTableFloatCol stop_mjd("TSTOP", nrows); - + GFitsTableFloatCol max_pix("MAXSIGPIXEL", nrows); for (int i=0; i 0) { src_name = m_inmodel[src]->name(); + + // Get source position + GModelSky* model = dynamic_cast(m_inmodel[src]); + GModelSpatial* model_spatial = model->spatial(); + GSkyRegion* model_region = model_spatial->region(); + src_dir = dynamic_cast(model_region)->centre(); + } + // ... otherwise set the position from xsrc,ysrc + else { + if ((*this)["coordsys"].string() == "CEL") { + src_dir.radec_deg((*this)["xsrc"].real(), (*this)["yref"].real()); + } else { + src_dir.lb_deg((*this)["xsrc"].real(), (*this)["yref"].real()); + } } - GFitsTableFloatCol src_sig(src_name, nrows); - + // Create and fill a new column + GFitsTableFloatCol src_sig_col(src_name, nrows); for (int i=0; i