165 this->GApplication::clear();
197 log_header1(NORMAL,
"Map cube");
218 log_header1(TERSE,
"Save map cube");
221 if ((*
this)[
"outcube"].is_valid() && !
m_cube.cube().is_empty()) {
224 m_outcube = (*this)[
"outcube"].filename();
235 if (
m_cube.cube().is_empty()) {
236 fname.append(
" (cube is empty, no file created)");
238 log_value(NORMAL,
"Map cube file", fname);
255 log_header1(TERSE,
"Publish map cube");
258 std::string user_name(name);
259 if (user_name.empty()) {
264 log_value(NORMAL,
"Map cube name", user_name);
267 m_cube.cube().publish(user_name);
344 GFilename inmodel = (*this)[
"inmodel"].filename();
355 double xref = (*this)[
"xref"].real();
356 double yref = (*this)[
"yref"].real();
357 std::string proj = (*this)[
"proj"].string();
358 std::string coordsys = (*this)[
"coordsys"].string();
359 double binsz = (*this)[
"binsz"].real();
360 int nxpix = (*this)[
"nxpix"].integer();
361 int nypix = (*this)[
"nypix"].integer();
365 m_publish = (*this)[
"publish"].boolean();
366 m_chatter =
static_cast<GChatter
>((*this)[
"chatter"].integer());
370 (*this)[
"outcube"].query();
374 GSkyMap cube(proj, coordsys, xref, yref, -binsz, binsz, nxpix, nypix,
378 m_cube = GModelSpatialDiffuseCube(cube, energies);
396 log_header1(TERSE,
"Generate map cube");
399 for (
int i = 0; i <
m_models.size(); ++i) {
402 GModelSky* model =
dynamic_cast<GModelSky*
>(
m_models[i]);
408 log_value(NORMAL,
"Skip model",
m_models[i]->name());
416 log_value(NORMAL,
"Use model",
m_models[i]->name());
419 if (
dynamic_cast<GModelSpatialPointSource*
>(model->spatial()) != NULL) {
443 GEnergies energies =
m_cube.energies();
446 GSkyMap* map =
const_cast<GSkyMap*
>(&
m_cube.cube());
457 for (
int ipixel = 0; ipixel < map->npix(); ++ipixel) {
460 GSkyDir dir = map->inx2dir(ipixel);
463 if (centre.dist_deg(dir) > radius) {
468 for (
int iebin = 0; iebin < energies.size(); ++iebin) {
471 GPhoton photon(dir, energies[iebin], GTime());
474 map->operator()(ipixel, iebin) += model->value(photon);
495 GSkyMap* map =
const_cast<GSkyMap*
>(&
m_cube.cube());
510 GModelSpatialRadialGauss spatial(centre, sigma);
514 GModelSky skymodel(spatial, *(model->spectral()), *(model->temporal()));
525 GModelSpatialPointSource* ptsrc =
526 static_cast<GModelSpatialPointSource*
>(model->spatial());
529 GSkyDir dir = ptsrc->dir();
532 GEnergies energies =
m_cube.energies();
535 GSkyMap test_map(*map);
538 if (map->contains(dir)) {
541 int ipixel = map->dir2inx(dir);
544 for (
int iebin = 0; iebin < energies.size(); ++iebin) {
547 GPhoton photon(dir, energies[iebin], GTime());
550 double value = model->value(photon);
553 test_map(ipixel, iebin) = value;
554 double flux = test_map.flux(ipixel, iebin);
555 double norm = (flux > 0.0) ? value / flux : 0.0;
558 map->operator()(ipixel, iebin) += norm * value;
585 double* radius)
const
589 GModelSpatialPointSource* ptsrc =
590 dynamic_cast<GModelSpatialPointSource*
>(model->spatial());
591 GModelSpatialRadial* radial =
592 dynamic_cast<GModelSpatialRadial*
>(model->spatial());
593 GModelSpatialElliptical* elliptical =
594 dynamic_cast<GModelSpatialElliptical*
>(model->spatial());
606 else if (radial != NULL) {
607 *dir = radial->dir();
608 *radius = radial->theta_max() * gammalib::rad2deg;
614 else if (elliptical != NULL) {
615 *dir = elliptical->dir();
616 *radius = elliptical->theta_max() * gammalib::rad2deg;
Map cube generation tool.
void save(void)
Save map cube.
void init_members(void)
Initialise class members.
void get_bounding_circle(GModelSky *model, GSkyDir *dir, double *radius) const
Get bounding circle for a sky model.
ctmapcube(void)
Void constructor.
void create_cube(void)
Generate map cube.
GChatter m_chatter
Chattiness.
GFilename m_outcube
Output map cube filename.
void clear(void)
Clear ctmapcube tool.
void add_ptsrc_model(GModelSky *model)
Add one point source model to map cube.
void publish(const std::string &name="")
Publish map cube.
ctmapcube & operator=(const ctmapcube &app)
Assignment operator.
void copy_members(const ctmapcube &app)
Copy class members.
GModels m_models
Model container.
double m_ptsrcsig
Point source sigma (arcmin)
GModelSpatialDiffuseCube m_cube
Map cube.
void add_model(GModelSky *model)
Add one model to map cube.
void process(void)
Generate map cube.
bool m_publish
Publish map cube?
void get_parameters(void)
Get application parameters.
virtual ~ctmapcube(void)
Destructor.
void free_members(void)
Delete class members.
Map cube generation tool definition.