Commit 29669ee5b9be2b873423a3f1dd9f8300d058064d

Authored by Simon Bonnefoy
Committed by Jürgen Knödlseder
1 parent 067e0e8e

create xml file with all sky direction with significance greater than the sig_threshold parameter

src/ctfindvar/ctfindvar.cpp
... ... @@ -314,17 +314,19 @@ void ctfindvar::run(void)
314 314  
315 315 //looping over all the pixels in the cube
316 316 #pragma omp parallel for
317   - for (int pix_number=0; pix_number<m_counts.npix(); pix_number++)
318   - {
  317 + for (int pix_number=0; pix_number<m_counts.npix(); pix_number++) {
  318 +
  319 + //Preparing array to store significance evolution of
  320 + //each pixel
319 321 GNdarray pixSig(nbins);
320 322 double total_counts=0;
321   - for (int k=0;k<m_counts.nmaps();k++)
322   - {
  323 +
  324 + //Checking the integrated count of each pixel
  325 + for (int k=0;k<m_counts.nmaps();k++) {
323 326 total_counts += m_counts(pix_number, k);
324 327 }
325 328 #ifdef G_DEBUG
326   - if(pix_number%20==0)
327   - {
  329 + if(pix_number%20==0) {
328 330 std::cout << "Pixel number " << pix_number ;
329 331 std::cout << " has a total number of counts of: ";
330 332 std::cout << total_counts << std::endl;
... ... @@ -379,8 +381,16 @@ void ctfindvar::run(void)
379 381 }
380 382 //storing sig in skymap
381 383 m_peaksigmap(pix_number) = max(pixSig);
382   - }
383 384  
  385 + //If the significance is greater than sig threshold, the position
  386 + //is stored in a model
  387 + if (max(pixSig)> m_sig_threshold) {
  388 + GSkyDir dir_pix = m_counts.inx2dir(pix_number);
  389 + fill_model_sig_pos(dir_pix);
  390 + }
  391 +
  392 + }
  393 +
384 394 log_header1(NORMAL, "Analysis finished");
385 395 log_value(NORMAL, "Maximum sigma", max_sig);
386 396 log_value(NORMAL, "Max pixel RA", m_max_sig_dir.ra_deg());
... ... @@ -481,7 +491,34 @@ void ctfindvar::get_variability_sig(const int&amp; pix_number,
481 491 }
482 492 }
483 493  
  494 +/***********************************************************************//**
  495 + * @brief Save the current sky direction to model if significance > thr
  496 + *
  497 + * @param[in] dir_pix pixel sky direction
  498 + * @param[out] m_model_sig_above_thr model position with sig>thr
  499 + ***************************************************************************/
  500 +void ctfindvar::fill_model_sig_pos(const GSkyDir& dir_pix)
  501 +{
  502 + //Set spatial components
  503 + GModelSpatialPointSource spatial(dir_pix);
  504 +
  505 + //Set fake spectral component (powerlaw with 1% of Crab)
  506 + GModelSpectralPlaw spectral(5.7e-18, -2.48, GEnergy(0.3, "TeV"));
484 507  
  508 + //Creat a sky model
  509 + GModelSky model(spatial, spectral);
  510 +
  511 + //Extracting the coordinate to name the model
  512 + double ra = dir_pix.ra_deg();
  513 + double dec = dir_pix.dec_deg();
  514 + std::stringstream name;
  515 + name << "Sky_direction_"<< ra << "_" << dec ;
  516 + model.name(name.str());
  517 +
  518 + //Add the model for this pixel to the output mode
  519 + m_model_above_thr.append(model);
  520 +
  521 +}
485 522 /***********************************************************************//**
486 523 * @brief Get the map index associated with a given time
487 524 *
... ... @@ -630,6 +667,12 @@ void ctfindvar::save(void)
630 667 GFilename outfilename = prefix + "signifmap.fits";
631 668 m_outfile.saveto(outfilename, (*this)["clobber"].boolean());
632 669  
  670 + //Save the model file with position with significance
  671 + if (m_model_above_thr.size() > 2){
  672 + GFilename model_filename = prefix + "model_significant_directions.xml";
  673 + m_model_above_thr.save(model_filename);
  674 + }
  675 +
633 676 // Return
634 677 return;
635 678 }
... ...
src/ctfindvar/ctfindvar.hpp
... ... @@ -69,6 +69,7 @@ public:
69 69 protected:
70 70 // Protected methods
71 71 void init_cube(void);
  72 + void fill_model_sig_pos(const GSkyDir& dir_pix);
72 73 void init_gtis(void);
73 74 void init_members(void);
74 75 void copy_members(const ctfindvar& app);
... ... @@ -90,20 +91,21 @@ protected:
90 91 const GNdarray& src_info);
91 92  
92 93 // Protected members
93   - GSkyMap m_counts; //!< Counts for each time interval
94   - std::vector<GGti> m_gti; //!< List of time intervals
95   - GModels m_inmodel; //!< List of models for source positions
96   - GSkyDir m_max_sig_dir; //!< Sky direction associated with maximum significance
97   - double m_minoff; //!< Minimum counts for use in significance calculation
98   - double m_sig_threshold; //!< Minimum significance required to set source as variable
99   - GFits m_outfile; //!< FITS object to store output
100   - GSkyMap m_peaksigmap; //!< Skymap holding the maximum significance
101   - GNdarray m_pixsigsrc; //!< Store distributions of the source significances
102   - GNdarray m_pixsigmax; //!< Store distribution for pixel with max significance
103   - GTime m_tstart; //!< Start time for variability study
104   - GTime m_tstop; //!< Stop time for variability study
105   - GEnergy m_emin; //!< Minimum energy for events
106   - GEnergy m_emax; //!< Maximum energy for events
  94 + GSkyMap m_counts; //!< Counts for each time interval
  95 + std::vector<GGti> m_gti; //!< List of time intervals
  96 + GModels m_inmodel; //!< List of models for source positions
  97 + GSkyDir m_max_sig_dir; //!< Sky direction associated with maximum significance
  98 + double m_minoff; //!< Minimum counts for use in significance calculation
  99 + double m_sig_threshold; //!< Minimum significance required to set source as variable
  100 + GFits m_outfile; //!< FITS object to store output
  101 + GSkyMap m_peaksigmap; //!< Skymap holding the maximum significance
  102 + GNdarray m_pixsigsrc; //!< Store distributions of the source significances
  103 + GNdarray m_pixsigmax; //!< Store distribution for pixel with max significance
  104 + GTime m_tstart; //!< Start time for variability study
  105 + GTime m_tstop; //!< Stop time for variability study
  106 + GEnergy m_emin; //!< Minimum energy for events
  107 + GEnergy m_emax; //!< Maximum energy for events
  108 + GModels m_model_above_thr; //!< Model storing position with significance above thr
107 109  
108 110 };
109 111  
... ...