Commit fe0597f604366217d1d31ecc5b8e106b9c3fcbcc
1 parent
e9f7fb0a
Integrate code
Showing
5 changed files
with
46 additions
and
33 deletions
ChangeLog
NEWS
| 1 | 1 | New Features and Important Changes in ctools 1.5.0 |
| 2 | 2 | |
| 3 | -8 August 2017 | |
| 3 | +11 October 2017 | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | Introduction |
| ... | ... | @@ -61,6 +61,11 @@ ctmodel - CTA counts cube modelling |
| 61 | 61 | Use t-type parameters for "tmin" and "tmax" to all specifying times in various |
| 62 | 62 | formats (#1864). |
| 63 | 63 | |
| 64 | +The tool now also checks which models actually overlap with the RoI of a given | |
| 65 | +observation and then only use these models to compute the model cube. The | |
| 66 | +parallelization of the tool has also been optimised so that diffuse models are | |
| 67 | +not loaded over and over again (#2189). | |
| 68 | + | |
| 64 | 69 | |
| 65 | 70 | ctexpcube - CTA exposure cube generation |
| 66 | 71 | ---------------------------------------- | ... | ... |
doc/source/admin/release_history/1.5.rst
src/ctmodel/ctmodel.cpp
| ... | ... | @@ -920,9 +920,9 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels& models) |
| 920 | 920 | /***********************************************************************//** |
| 921 | 921 | * @brief Find the models falling inside a defined region of interest. |
| 922 | 922 | * |
| 923 | - * @param[out] all_models Model container to be trimmed | |
| 924 | - * @param[in] roi Observation region of interest | |
| 925 | - * @return New model container contianing only models inside roi | |
| 923 | + * @param[in,out] all_models Model container to be trimmed. | |
| 924 | + * @param[in] roi Observation region of interest. | |
| 925 | + * @return New model container containing only models inside RoI. | |
| 926 | 926 | * |
| 927 | 927 | * Note that a buffer is added to the observation region to ensure that |
| 928 | 928 | * point sources (which have radius=0) are appropriately included if they |
| ... | ... | @@ -930,9 +930,9 @@ void ctmodel::fill_cube(const GCTAObservation* obs, GModels& models) |
| 930 | 930 | ***************************************************************************/ |
| 931 | 931 | GModels ctmodel::trim_models(GModels& all_models, const GCTARoi& roi) |
| 932 | 932 | { |
| 933 | - // Create the model object to be returned | |
| 933 | + // Create the model container containing only models in RoI | |
| 934 | 934 | GModels excluded_models; |
| 935 | - | |
| 935 | + | |
| 936 | 936 | // Do nothing if roi is not valid. This will be the case for binned data |
| 937 | 937 | // sets as they have the default roi radius of 0. In this case we would |
| 938 | 938 | // remove ALL models, which is obviously incorrect. So we keep all models |
| ... | ... | @@ -940,35 +940,41 @@ GModels ctmodel::trim_models(GModels& all_models, const GCTARoi& roi) |
| 940 | 940 | if (!roi.is_valid()) { |
| 941 | 941 | return excluded_models; |
| 942 | 942 | } |
| 943 | - | |
| 943 | + | |
| 944 | 944 | // Remove all models that dont overlap with the region of interest. Note |
| 945 | 945 | // that an extra factor is used since point sources have regions of |
| 946 | 946 | // radius 0, which is a problem when they fall just barely outside the |
| 947 | - // ROI. This ensures point sources are appropriately included. | |
| 947 | + // RoI. This ensures point sources are appropriately included. | |
| 948 | 948 | GSkyRegionCircle obsreg(roi.centre().dir(), roi.radius()+0.5); |
| 949 | - | |
| 949 | + | |
| 950 | 950 | // Loop over the models in the passed container |
| 951 | - for (int mod=0; mod<all_models.size(); mod++) { | |
| 951 | + for (int i = 0; i < all_models.size(); ++i) { | |
| 952 | + | |
| 952 | 953 | // Cast the model to a GModelSky object |
| 953 | - GModelSky* model = dynamic_cast<GModelSky*>(all_models.at(mod)->clone()); | |
| 954 | - | |
| 954 | + GModelSky* model = dynamic_cast<GModelSky*>(all_models[i]); | |
| 955 | + | |
| 956 | + // If model is not a GModelSky model than skip | |
| 955 | 957 | if (model == NULL) { |
| 956 | - // Model is most likely a background model and should be kept | |
| 957 | 958 | continue; |
| 958 | 959 | } |
| 960 | + | |
| 959 | 961 | // Otherwise, exclude the model if it isn't a diffuse cube and it |
| 960 | 962 | // doesn't overlap with the observation. |
| 961 | - else if (!(model->spatial()->code() == GMODEL_SPATIAL_DIFFUSE) && | |
| 963 | + if (!(model->spatial()->code() == GMODEL_SPATIAL_DIFFUSE) && | |
| 962 | 964 | (!model->spatial()->region()->overlaps(obsreg))) { |
| 963 | - // Model represents a source, that doesn't overlap the observation | |
| 964 | - // and should be removed for now. | |
| 965 | + | |
| 966 | + // Append model to the excluded models | |
| 965 | 967 | excluded_models.append(*model); |
| 966 | - all_models.remove(mod); | |
| 967 | - mod--; // decrement to prevent skipping models | |
| 968 | + | |
| 969 | + // Remove model | |
| 970 | + all_models.remove(i); | |
| 971 | + | |
| 972 | + // Decrement to prevent skipping models | |
| 973 | + i--; | |
| 968 | 974 | } |
| 969 | - | |
| 970 | - delete model; | |
| 971 | - } | |
| 972 | - | |
| 975 | + | |
| 976 | + } // endfor: looped over all models | |
| 977 | + | |
| 978 | + // Return excluded models | |
| 973 | 979 | return excluded_models; |
| 974 | 980 | } | ... | ... |
src/ctmodel/ctmodel.hpp
| ... | ... | @@ -74,16 +74,16 @@ public: |
| 74 | 74 | |
| 75 | 75 | protected: |
| 76 | 76 | // Protected methods |
| 77 | - void init_members(void); | |
| 78 | - void copy_members(const ctmodel& app); | |
| 79 | - void free_members(void); | |
| 80 | - void get_parameters(void); | |
| 81 | - void get_obs(void); | |
| 82 | - void extract_cube_properties(void); | |
| 83 | - void fill_cube(const GCTAObservation* obs, GModels& models); | |
| 84 | - bool has_cube(void) const; | |
| 77 | + void init_members(void); | |
| 78 | + void copy_members(const ctmodel& app); | |
| 79 | + void free_members(void); | |
| 80 | + void get_parameters(void); | |
| 81 | + void get_obs(void); | |
| 82 | + void extract_cube_properties(void); | |
| 83 | + void fill_cube(const GCTAObservation* obs, GModels& models); | |
| 84 | + bool has_cube(void) const; | |
| 85 | 85 | GModels trim_models(GModels& all_models, const GCTARoi& roi); |
| 86 | - | |
| 86 | + | |
| 87 | 87 | // User parameters |
| 88 | 88 | GFilename m_outcube; //!< Output model cube |
| 89 | 89 | bool m_apply_edisp; //!< Apply energy dispersion? | ... | ... |