From 29669ee5b9be2b873423a3f1dd9f8300d058064d Mon Sep 17 00:00:00 2001 From: Simon Bonnefoy Date: Thu, 15 Nov 2018 17:17:56 +0100 Subject: [PATCH] create xml file with all sky direction with significance greater than the sig_threshold parameter --- src/ctfindvar/ctfindvar.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++------- src/ctfindvar/ctfindvar.hpp | 30 ++++++++++++++++-------------- 2 files changed, 66 insertions(+), 21 deletions(-) diff --git a/src/ctfindvar/ctfindvar.cpp b/src/ctfindvar/ctfindvar.cpp index 3c1e78f..c6ac648 100644 --- a/src/ctfindvar/ctfindvar.cpp +++ b/src/ctfindvar/ctfindvar.cpp @@ -314,17 +314,19 @@ void ctfindvar::run(void) //looping over all the pixels in the cube #pragma omp parallel for - for (int pix_number=0; pix_number m_sig_threshold) { + GSkyDir dir_pix = m_counts.inx2dir(pix_number); + fill_model_sig_pos(dir_pix); + } + + } + log_header1(NORMAL, "Analysis finished"); log_value(NORMAL, "Maximum sigma", max_sig); log_value(NORMAL, "Max pixel RA", m_max_sig_dir.ra_deg()); @@ -481,7 +491,34 @@ void ctfindvar::get_variability_sig(const int& pix_number, } } +/***********************************************************************//** + * @brief Save the current sky direction to model if significance > thr + * + * @param[in] dir_pix pixel sky direction + * @param[out] m_model_sig_above_thr model position with sig>thr + ***************************************************************************/ +void ctfindvar::fill_model_sig_pos(const GSkyDir& dir_pix) +{ + //Set spatial components + GModelSpatialPointSource spatial(dir_pix); + + //Set fake spectral component (powerlaw with 1% of Crab) + GModelSpectralPlaw spectral(5.7e-18, -2.48, GEnergy(0.3, "TeV")); + //Creat a sky model + GModelSky model(spatial, spectral); + + //Extracting the coordinate to name the model + double ra = dir_pix.ra_deg(); + double dec = dir_pix.dec_deg(); + std::stringstream name; + name << "Sky_direction_"<< ra << "_" << dec ; + model.name(name.str()); + + //Add the model for this pixel to the output mode + m_model_above_thr.append(model); + +} /***********************************************************************//** * @brief Get the map index associated with a given time * @@ -630,6 +667,12 @@ void ctfindvar::save(void) GFilename outfilename = prefix + "signifmap.fits"; m_outfile.saveto(outfilename, (*this)["clobber"].boolean()); + //Save the model file with position with significance + if (m_model_above_thr.size() > 2){ + GFilename model_filename = prefix + "model_significant_directions.xml"; + m_model_above_thr.save(model_filename); + } + // Return return; } diff --git a/src/ctfindvar/ctfindvar.hpp b/src/ctfindvar/ctfindvar.hpp index 7128bc3..1b26eee 100644 --- a/src/ctfindvar/ctfindvar.hpp +++ b/src/ctfindvar/ctfindvar.hpp @@ -69,6 +69,7 @@ public: protected: // Protected methods void init_cube(void); + void fill_model_sig_pos(const GSkyDir& dir_pix); void init_gtis(void); void init_members(void); void copy_members(const ctfindvar& app); @@ -90,20 +91,21 @@ protected: const GNdarray& src_info); // Protected members - GSkyMap m_counts; //!< Counts for each time interval - std::vector m_gti; //!< List of time intervals - GModels m_inmodel; //!< List of models for source positions - GSkyDir m_max_sig_dir; //!< Sky direction associated with maximum significance - double m_minoff; //!< Minimum counts for use in significance calculation - double m_sig_threshold; //!< Minimum significance required to set source as variable - GFits m_outfile; //!< FITS object to store output - GSkyMap m_peaksigmap; //!< Skymap holding the maximum significance - GNdarray m_pixsigsrc; //!< Store distributions of the source significances - GNdarray m_pixsigmax; //!< Store distribution for pixel with max significance - GTime m_tstart; //!< Start time for variability study - GTime m_tstop; //!< Stop time for variability study - GEnergy m_emin; //!< Minimum energy for events - GEnergy m_emax; //!< Maximum energy for events + GSkyMap m_counts; //!< Counts for each time interval + std::vector m_gti; //!< List of time intervals + GModels m_inmodel; //!< List of models for source positions + GSkyDir m_max_sig_dir; //!< Sky direction associated with maximum significance + double m_minoff; //!< Minimum counts for use in significance calculation + double m_sig_threshold; //!< Minimum significance required to set source as variable + GFits m_outfile; //!< FITS object to store output + GSkyMap m_peaksigmap; //!< Skymap holding the maximum significance + GNdarray m_pixsigsrc; //!< Store distributions of the source significances + GNdarray m_pixsigmax; //!< Store distribution for pixel with max significance + GTime m_tstart; //!< Start time for variability study + GTime m_tstop; //!< Stop time for variability study + GEnergy m_emin; //!< Minimum energy for events + GEnergy m_emax; //!< Maximum energy for events + GModels m_model_above_thr; //!< Model storing position with significance above thr }; -- libgit2 0.21.4