54 #define G_CONSTRUCT_HPX "GSkyMap::GSkyMap(std::string&, int&,"\
55 " std::string&, int&)"
56 #define G_CONSTRUCT_MAP "GSkyMap::GSkyMap(std::string&, std::string&,"\
57 " double&, double&, double& double&, int&, int&, int&)"
58 #define G_NMAPS "GSkyMap::nmaps(int&)"
59 #define G_SHAPE "GSkyMap::shape(std::vector<int>&)"
60 #define G_OP_UNARY_ADD "GSkyMap::operator+=(GSkyMap&)"
61 #define G_OP_UNARY_SUB "GSkyMap::operator-=(GSkyMap&)"
62 #define G_OP_UNARY_MUL "GSkyMap::operator-=(GSkyMap&)"
63 #define G_OP_UNARY_DIV "GSkyMap::operator/=(GSkyMap&)"
64 #define G_OP_UNARY_DIV2 "GSkyMap::operator/=(double&)"
65 #define G_OP_ACCESS_1D "GSkyMap::operator(int&, int&)"
66 #define G_OP_ACCESS_2D "GSkyMap::operator(GSkyPixel&, int&)"
67 #define G_OP_VALUE "GSkyMap::operator(GSkyDir&, int&)"
68 #define G_INX2DIR "GSkyMap::inx2dir(int&)"
69 #define G_PIX2DIR "GSkyMap::pix2dir(GSkyPixel&)"
70 #define G_DIR2INX "GSkyMap::dir2inx(GSkyDir&)"
71 #define G_DIR2PIX "GSkyMap::dir2pix(GSkyDir&)"
72 #define G_FLUX1 "GSkyMap::flux(int&)"
73 #define G_FLUX2 "GSkyMap::flux(GSkyPixel&)"
74 #define G_FLUX3 "GSkyMap::flux(GSkyRegion&, int&)"
75 #define G_FLUX4 "GSkyMap::flux(GSkyRegions&, int&)"
76 #define G_SOLIDANGLE1 "GSkyMap::solidangle(int&)"
77 #define G_SOLIDANGLE2 "GSkyMap::solidangle(GSkyPixel&)"
78 #define G_OVERLAPS "GSkyMap::overlaps(GSkyRegion&)"
79 #define G_EXTRACT "GSkyMap::extract(int&, int&)"
80 #define G_EXTRACT_INT "GSkyMap::extract(int&, int&, int&, int&)"
81 #define G_EXTRACT_REG "GSkyMap::extract(GSkyRegions&)"
82 #define G_READ "GSkyMap::read(GFitsHDU&)"
83 #define G_SET_WCS "GSkyMap::set_wcs(std::string&, std::string&, double&,"\
84 " double&, double&, double&, double&, double&)"
85 #define G_READ_HEALPIX "GSkyMap::read_healpix(GFitsTable*)"
86 #define G_READ_WCS "GSkyMap::read_wcs(GFitsImage*)"
87 #define G_ALLOC_WCS "GSkyMap::alloc_wcs(GFitsImage*)"
88 #define G_SQRT "GSkyMap sqrt(GSkyMap&)"
89 #define G_LOG "GSkyMap log(GSkyMap&)"
90 #define G_LOG10 "GSkyMap log10(GSkyMap&)"
91 #define G_CONVOLUTION_KERNEL "GSkyMap::convolution_kernel(std::string&, "\
184 const std::string& order,
192 std::string msg =
"Number of maps "+
gammalib::str(nmaps)+
" is smaller "
193 "than 1. Please specify at least one map.";
235 const std::string& coords,
249 std::string msg =
"Number of pixels "+
gammalib::str(nx)+
" in x "
250 "direction is smaller than 1. Please specify at "
251 "least one pixel in x direction.";
255 std::string msg =
"Number of pixels "+
gammalib::str(ny)+
" in y "
256 "direction is smaller than 1. Please specify at "
257 "least one pixel in y direction.";
261 std::string msg =
"Number of maps "+
gammalib::str(nmaps)+
" is smaller "
262 "than 1. Please specify at least one map.";
269 double crpix1 = double(nx+1)/2.0;
270 double crpix2 = double(ny+1)/2.0;
273 set_wcs(wcs, coords, crval1, crval2, crpix1, crpix2, cdelt1, cdelt2);
372 for (
int i = 0; i < num; ++i) {
402 std::string msg =
"Mismatch of number of maps in skymap object"
413 for (
int index = 0; index <
npix(); ++index) {
416 for (
int layer = 0; layer <
nmaps(); ++layer) {
419 (*this)(index, layer) += map(index, layer);
431 for (
int index = 0; index <
npix(); ++index) {
437 for (
int layer = 0; layer <
nmaps(); ++layer) {
440 (*this)(index, layer) += map(dir, layer);
492 std::string msg =
"Mismatch of number of maps in skymap object"
503 for (
int index = 0; index <
npix(); ++index) {
506 for (
int layer = 0; layer <
nmaps(); ++layer) {
509 (*this)(index, layer) -= map(index, layer);
521 for (
int index = 0; index <
npix(); ++index) {
527 for (
int layer = 0; layer <
nmaps(); ++layer) {
530 (*this)(index, layer) -= map(dir, layer);
582 std::string msg =
"Mismatch of number of maps in skymap object"
593 for (
int index = 0; index <
npix(); ++index) {
596 for (
int layer = 0; layer <
nmaps(); ++layer) {
599 (*this)(index, layer) *= map(index, layer);
611 for (
int index = 0; index <
npix(); ++index) {
617 for (
int layer = 0; layer <
nmaps(); ++layer) {
620 (*this)(index, layer) *= map(dir, layer);
676 std::string msg =
"Mismatch of number of maps in skymap object"
687 for (
int index = 0; index <
npix(); ++index) {
690 for (
int layer = 0; layer <
nmaps(); ++layer) {
694 double value = map(index, layer);
699 (*this)(index, layer) = 0.0;
702 (*this)(index, layer) /= value;
715 for (
int index = 0; index <
npix(); ++index) {
721 for (
int layer = 0; layer <
nmaps(); ++layer) {
727 double value = map(dir, layer);
732 (*this)(index, layer) = 0.0;
735 (*this)(index, layer) /= value;
764 std::string msg =
"Trying to divide sky map pixels by zero.";
792 #if defined(G_RANGE_CHECK)
795 "Sky map pixel index",
825 #if defined(G_RANGE_CHECK)
828 "Sky map pixel index",
860 #if defined(G_RANGE_CHECK)
866 "a valid sky pixel.";
900 #if defined(G_RANGE_CHECK)
906 "a valid sky pixel.";
945 #if defined(G_RANGE_CHECK)
954 double intensity = 0.0;
996 bool x_wrap = (x_size > 359.99);
1002 int inx_x = int(pixel.
x());
1003 int inx_y = int(pixel.
y());
1004 if (pixel.
x() < 0.0) {
1007 if (pixel.
y() < 0.0) {
1016 int inx_x_left = inx_x;
1017 int inx_y_left = inx_y;
1018 int inx_x_right = inx_x_left + 1;
1019 int inx_y_right = inx_y_left + 1;
1020 if (inx_x_left < 0) {
1036 if (inx_y_left < 0) {
1044 double wgt_x_right = (pixel.
x() - inx_x);
1045 double wgt_x_left = 1.0 - wgt_x_right;
1046 double wgt_y_right = (pixel.
y() - inx_y);
1047 double wgt_y_left = 1.0 - wgt_y_right;
1143 std::string msg =
"At least one map is required in an GSkyMap object."
1144 " Please specify an argument >=1.";
1158 for (
int i = 0; i < num_copy; ++i) {
1188 std::vector<int>
shape;
1191 shape.push_back(s1);
1210 std::vector<int>
shape;
1213 shape.push_back(s1);
1214 shape.push_back(s2);
1234 std::vector<int>
shape;
1237 shape.push_back(s1);
1238 shape.push_back(s2);
1239 shape.push_back(s3);
1264 if (shape.size() > 0) {
1266 for (
int i = 0; i < shape.size(); ++i) {
1274 std::string msg =
"Sky map shaping requires "+
gammalib::str(nmaps)+
1276 "are available. Please specify an appropriate "
1277 "factorisation or modify the number of available "
1309 pixel.
y(
double(index / m_num_x));
1335 std::string msg =
"Sky projection has not been defined.";
1364 std::string msg =
"Sky projection has not been defined.";
1386 std::string msg =
"A 2-dimensional sky map pixel "+pixel.
print()+
1387 " is used to determine the sky direction for"
1388 " the 1-dimensional sky projection \""+
1390 "Please specify a 1-dimensional sky map pixel.";
1413 if (pixel.
is_1D()) {
1418 else if (pixel.
is_2D()) {
1421 int ix = int(pixel.
x()+0.5);
1422 int iy = int(pixel.
y()+0.5);
1449 std::string msg =
"Sky projection has not been defined.";
1476 std::string msg =
"Sky projection has not been defined.";
1509 sum += (*this)(k,i);
1555 std::string msg =
"Sky projection has not been defined.";
1599 std::string msg =
"Sky projection has not been defined.";
1624 double i1 = this->
operator()(boundaries[0], map);
1625 double i2 = this->
operator()(boundaries[4], map);
1626 double i3 = this->
operator()(boundaries[8], map);
1627 double i4 = this->
operator()(boundaries[1], map);
1628 double i5 = this->
operator()(boundaries[5], map);
1629 double i6 = this->
operator()(boundaries[9], map);
1630 double i7 = this->
operator()(boundaries[2], map);
1631 double i8 = this->
operator()(boundaries[6], map);
1632 double i9 = this->
operator()(boundaries[10], map);
1633 double i10 = this->
operator()(boundaries[3], map);
1634 double i11 = this->
operator()(boundaries[7], map);
1635 double i12 = this->
operator()(boundaries[11], map);
1639 solidangle(centre, boundaries[0], boundaries[4]);
1641 solidangle(centre, boundaries[4], boundaries[8]);
1643 solidangle(centre, boundaries[8], boundaries[1]);
1645 solidangle(centre, boundaries[1], boundaries[5]);
1647 solidangle(centre, boundaries[5], boundaries[9]);
1649 solidangle(centre, boundaries[9], boundaries[2]);
1651 solidangle(centre, boundaries[2], boundaries[6]);
1653 solidangle(centre, boundaries[6], boundaries[10]);
1655 solidangle(centre, boundaries[10], boundaries[3]);
1657 solidangle(centre, boundaries[3], boundaries[7]);
1659 solidangle(centre, boundaries[7], boundaries[11]);
1661 solidangle(centre, boundaries[11], boundaries[0]);
1664 flux = (flux1 + flux2 + flux3 + flux4 +
1665 flux5 + flux6 + flux7 + flux8 +
1666 flux9 + flux10 + flux11 + flux12);
1682 const double up = 0.4999999;
1696 double i1 = this->
operator()(boundary1, map);
1697 double i2 = this->
operator()(boundary2, map);
1698 double i3 = this->
operator()(boundary3, map);
1699 double i4 = this->
operator()(boundary4, map);
1700 double i5 = this->
operator()(boundary5, map);
1701 double i6 = this->
operator()(boundary6, map);
1702 double i7 = this->
operator()(boundary7, map);
1703 double i8 = this->
operator()(boundary8, map);
1724 flux = (flux1 + flux2 + flux3 + flux4 +
1725 flux5 + flux6 + flux7 + flux8);
1826 for (
int i = 0, ipix = 0; i <
m_num_maps; ++i) {
1838 flux_array(i) =
flux;
1862 std::string msg =
"Sky projection has not been defined.";
1889 std::string msg =
"Sky projection has not been defined.";
1911 std::string msg =
"A 2-dimensional sky map pixel "+pixel.
print()+
1912 " is used to determine the solid angle for"
1913 " the 1-dimensional sky projection \""+
1915 "Please specify a 1-dimensional sky map pixel.";
2070 if (pixel.
is_1D()) {
2071 if (pixel.
index() >= -0.5 &&
2078 else if (pixel.
is_2D()) {
2081 if ((pixel.
x() >= -0.5 && pixel.
x() < double(
m_num_x)-0.5) &&
2082 (pixel.
y() >= -0.5 && pixel.
y() < double(
m_num_y)-0.5)) {
2105 bool overlap =
false;
2108 if (region.
type() ==
"Circle") {
2116 std::string msg =
"Method not implemented for non-circular regions.";
2149 std::string msg =
"The number of maps to extract cannot be negative "
2154 std::string msg =
"The number of maps to extract ("+
2156 "that are available ("+
2167 double *dst = extracted_pixels.
data();
2168 for (
int i = 0; i < n_size; ++i) {
2176 result.
m_pixels = extracted_pixels;
2183 result.
m_shape.push_back(nmaps);
2210 const int& starty,
const int& stopy)
const
2214 std::string msg =
"Method not valid for \"HPX\" projection. Please "
2215 "specify WCS projection.";
2218 else if ((startx > stopx) || (starty > stopy)) {
2220 "Invalid x,y range provided");
2224 int first_x = (startx < 0) ? 0 : startx;
2226 int first_y = (starty < 0) ? 0 : starty;
2228 int nxpix = last_x - first_x + 1;
2229 int nypix = last_y - first_y + 1;
2230 int npixels = nxpix * nypix;
2236 for (
int ix = 0; ix < nxpix; ++ix) {
2237 int ix_src = ix + first_x;
2238 for (
int iy = 0; iy < nypix; ++iy) {
2239 int iy_src = iy + first_y;
2240 for (
int imap = 0; imap <
m_num_maps; ++imap) {
2241 new_pixels(ix, iy, imap) =
m_pixels(ix_src, iy_src, imap);
2253 proj->
crpix(0) - first_x,
2254 proj->
crpix(1) - first_y,
2293 std::string msg =
"Method not valid for \"HPX\" projection. Please "
2294 "specify WCS projection.";
2299 int startx =
nx()+1;
2301 int starty =
ny()+1;
2305 for (
int i = 0; i <
npix(); ++i) {
2315 int pix_x = int(pixel.
x());
2316 int pix_y = int(pixel.
y());
2319 startx = (pix_x < startx) ? pix_x : startx;
2320 stopx = (pix_x > stopx) ? pix_x : stopx;
2321 starty = (pix_y < starty) ? pix_y : starty;
2322 stopy = (pix_y > stopy) ? pix_y : stopy;
2329 return (this->
extract(startx-1, stopx+1, starty-1, stopy+1));
2360 for (
int imap = 0; imap <
m_num_maps; ++imap) {
2361 sum += (*this)(i,imap);
2363 stacked_pixels(i) =
sum;
2415 double max_radius = 0.0;
2423 for (
int i = 0; i <
npix(); ++i) {
2425 if (radius > max_radius) {
2426 max_radius = radius;
2432 if (max_index != -1) {
2436 const double up = 0.4999999;
2452 double radius1 = boundary1.
dist_deg(centre);
2453 double radius2 = boundary2.dist_deg(centre);
2454 double radius3 = boundary3.dist_deg(centre);
2455 double radius4 = boundary4.dist_deg(centre);
2456 double radius5 = boundary5.
dist_deg(centre);
2457 double radius6 = boundary6.
dist_deg(centre);
2458 double radius7 = boundary7.
dist_deg(centre);
2459 double radius8 = boundary8.
dist_deg(centre);
2462 if (radius1 > max_radius) {
2463 max_radius = radius1;
2465 if (radius2 > max_radius) {
2466 max_radius = radius2;
2468 if (radius3 > max_radius) {
2469 max_radius = radius3;
2471 if (radius4 > max_radius) {
2472 max_radius = radius4;
2474 if (radius5 > max_radius) {
2475 max_radius = radius5;
2477 if (radius6 > max_radius) {
2478 max_radius = radius6;
2480 if (radius7 > max_radius) {
2481 max_radius = radius7;
2483 if (radius8 > max_radius) {
2484 max_radius = radius8;
2520 GFits fits(filename);
2531 read_wcs(static_cast<const GFitsImage&>(hdu));
2545 read_wcs(static_cast<const GFitsImage&>(hdu));
2555 int num = fits.
size();
2560 for (
int extno = 1; extno < num; ++extno) {
2577 for (
int extno = 0; extno < num; ++extno) {
2584 read_wcs(static_cast<const GFitsImage&>(hdu));
2677 read_wcs(static_cast<const GFitsImage&>(hdu));
2722 if (extname.length() > 0) {
2727 hdu_appended = file.
append(*hdu);
2737 return hdu_appended;
2764 if (!name.empty()) {
2796 result.append(
"=== GSkyMap ===");
2817 std::string
shape =
"(";
2818 for (
int i = 0; i <
m_shape.size(); ++i) {
2825 result.append(shape);
2828 result.append(
"not defined");
2838 result.append(
"not defined");
2947 const std::string& coords,
2948 const double& crval1,
2949 const double& crval2,
2950 const double& crpix1,
2951 const double& crpix2,
2952 const double& cdelt1,
2953 const double& cdelt2)
2959 if (uwcs ==
"HPX") {
2960 std::string msg =
"Method not valid for \"HPX\" projection. Please "
2961 "specify WCS projections.";
2975 if (projection == NULL) {
2976 std::string msg =
"WCS projection code \""+uwcs+
"\" not known. "
2977 "Please specify one of the following WCS "
2978 "projections: "+registry.
content()+
".";
2983 projection->
set(coords, crval1, crval2, crpix1, crpix2,
3011 int nrows = table.
nrows();
3012 int ncols = table.
ncols();
3013 #if defined(G_READ_HEALPIX_DEBUG)
3014 std::cout <<
"nrows=" << nrows <<
" ncols=" << ncols << std::endl;
3025 #if defined(G_READ_HEALPIX_DEBUG)
3026 std::cout <<
"m_num_pixels=" <<
m_num_pixels << std::endl;
3032 std::string msg =
"Number of "+
gammalib::str(nrows)+
" rows in FITS "
3033 "table must correspond to number of "+
3041 #if defined(G_READ_HEALPIX_DEBUG)
3042 std::cout <<
"nentry=" << nentry << std::endl;
3048 for (
int icol = 0; icol < ncols; ++icol) {
3050 if (col->
number() % nentry == 0) {
3054 #if defined(G_READ_HEALPIX_DEBUG)
3055 std::cout <<
"m_num_maps=" <<
m_num_maps << std::endl;
3069 for (
int icol = 0; icol < ncols; ++icol) {
3075 if (col->
number() % nentry == 0) {
3078 int num = col->
number() / nentry;
3082 int inx_end = nentry;
3083 for (
int i = 0; i < num; ++i) {
3087 for (
int row = 0; row < col->
nrows(); ++row) {
3088 for (
int inx = inx_start; inx < inx_end; ++inx) {
3089 *ptr++ = col->
real(row,inx);
3092 #if defined(G_READ_HEALPIX_DEBUG)
3093 std::cout <<
"Load map=" << imap <<
" index="
3094 << inx_start <<
"-" << inx_end << std::endl;
3098 inx_start = inx_end;
3143 if (image.
naxis() < 2) {
3145 " dimensions, which is less than the two dimensions"
3146 " that are required for a WCS image.";
3162 if (image.
naxis() == 2) {
3169 for (
int i = 3; i < image.
naxis(); ++i) {
3174 #if defined(G_READ_WCS_DEBUG)
3175 std::cout <<
"m_num_x=" <<
m_num_x << std::endl;
3176 std::cout <<
"m_num_y=" <<
m_num_y << std::endl;
3177 std::cout <<
"m_num_maps=" <<
m_num_maps << std::endl;
3182 #if defined(G_READ_WCS_DEBUG)
3183 std::cout <<
"m_num_pixels=" <<
m_num_pixels << std::endl;
3192 for (
int i = 0; i < size; ++i) {
3193 *ptr++ = (double)image.
pixel(i);
3198 double y_size =
std::abs(m_num_y * static_cast<GWcs*>(
m_proj)->cdelt(1));
3199 if (x_size > 360.001) {
3200 std::string msg =
"Skymap covers "+
gammalib::str(x_size)+
" degrees "
3201 "in the X axis which results in ambiguous "
3202 "coordinate transformations. Please provide a "
3203 "skymap that does not cover more than 360 degrees.";
3206 if (y_size > 180.001) {
3207 std::string msg =
"Skymap covers "+
gammalib::str(y_size)+
" degrees "
3208 "in the Y axis which results in ambiguous "
3209 "coordinate transformations. Please provide a "
3210 "skymap that does not cover more than 180 degrees.";
3231 std::string ctype1 = image.
string(
"CTYPE1");
3232 std::string ctype2 = image.
string(
"CTYPE2");
3235 std::string xproj = ctype1.substr(5,3);
3236 std::string yproj = ctype2.substr(5,3);
3239 if (xproj != yproj) {
3240 std::string msg =
"X axis projection \""+xproj+
"\" differs from Y "
3241 "axis projection \""+yproj+
"\". Please specify a "
3242 "FITS image with a valid WCS header.";
3254 std::string msg =
"WCS projection code \""+xproj+
"\" not known. Please "
3255 "specify a FITS image with one of the following "
3256 "WCS projections: "+registry.
content()+
".";
3291 for (
int inx = 0; inx <
number; ++inx) {
3292 for (
int row = 0; row < rows; ++row) {
3293 column(row,inx) = *ptr++;
3317 hdu->
card(
"NBRBINS", m_num_maps,
"Number of HEALPix maps");
3345 std::vector<int> naxes;
3348 if (m_num_maps > 1) {
3349 for (
int i = 0; i <
ndim(); ++i) {
3358 if (naxes.size() == 2) {
3360 for (
int iy = 0; iy <
m_num_y; ++iy) {
3361 for (
int ix = 0; ix <
m_num_x; ++ix) {
3362 (*hdu)(ix,iy) = *ptr++;
3368 for (
int imap = 0; imap <
m_num_maps; ++imap) {
3369 for (
int iy = 0; iy <
m_num_y; ++iy) {
3370 for (
int ix = 0; ix <
m_num_x; ++ix) {
3371 (*hdu)(ix,iy,imap) = *ptr++;
3437 double a12 = dir1.
dist(dir2);
3438 double a14 = dir1.
dist(dir4);
3439 double a23 = dir2.
dist(dir3);
3440 double a24 = dir2.
dist(dir4);
3441 double a34 = dir3.
dist(dir4);
3445 if (a12 <= 0.0 || a14 <= 0.0) {
3446 double s = 0.5 * (a23 + a34 + a24);
3455 else if (a23 <= 0.0 || a34 <= 0.0) {
3456 double s = 0.5 * (a12 + a24 + a14);
3467 double s1 = 0.5 * (a12 + a24 + a14);
3474 double s2 = 0.5 * (a23 + a34 + a24);
3481 solidangle = 4.0 * (excess1 + excess2);
3522 double a12 = dir1.
dist(dir2);
3523 double a13 = dir1.
dist(dir3);
3524 double a23 = dir2.
dist(dir3);
3527 double s = 0.5 * (a12 + a23 + a13);
3564 bool overlap =
false;
3581 pix2.
y(
double(
ny()));
3582 for (
double xbin = -1.0; xbin <=
nx(); xbin += 1.0) {
3596 pix2.
x(
double(
nx()));
3597 for (
double ybin = 0.0; ybin <
ny(); ybin += 1.0) {
3632 (hdu.
has_card(
"PIXTYPE") && (hdu.
string(
"PIXTYPE") ==
"HEALPIX"))) {
3706 if ((wcs1 != NULL) && (wcs2 != NULL)) {
3722 if ((healpix1 != NULL) && (healpix2 != NULL)) {
3723 if ((healpix1->
npix() != healpix2->
npix()) ||
3758 const bool& normalise)
3772 double *dst = array.
data();
3781 GFft fft_smooth = fft_array * fft_kernel;
3787 src = smooth.
data();
3815 const bool& normalise)
const
3820 std::string msg =
"Sky map is not a WCS projection. Method is only "
3821 "valid for WCS projections.";
3826 double dx = wcs->
cdelt(0);
3827 double dy = wcs->
cdelt(1);
3840 double x = ix1 * dx;
3843 double y = iy1 * dy;
3845 kern(ix1,iy1) += 1.0;
3847 if (ix2 < m_num_x) {
3848 kern(ix2,iy1) += 1.0;
3851 if (iy2 < m_num_y) {
3852 kern(ix1,iy2) += 1.0;
3855 if ((ix2 < m_num_x) && (iy2 < m_num_y)) {
3856 kern(ix2,iy2) += 1.0;
3869 double norm = -0.5 / (par * par);
3873 double x = ix1 * dx;
3876 double y = iy1 * dy;
3877 double value =
std::exp(norm * (xqs + y*y));
3878 kern(ix1,iy1) += value;
3880 if (ix2 < m_num_x) {
3881 kern(ix2,iy1) += value;
3884 if (iy2 < m_num_y) {
3885 kern(ix1,iy2) += value;
3888 if ((ix2 < m_num_x) && (iy2 < m_num_y)) {
3889 kern(ix2,iy2) += value;
3899 std::string msg =
"Invalid kernel type \""+kernel+
"\" specified. "
3900 "Please specify one of \"DISK\", \"GAUSSIAN\".";
3905 if ((normalise) && (sum > 0.0)) {
3906 for (
int ix = 0; ix <
m_num_x; ++ix) {
3907 for (
int iy = 0; iy <
m_num_y; ++iy) {
3936 for (
int i = 0; i < map.
nmaps(); ++i) {
3939 for (
int j = 0; j < map.
npix(); ++j) {
3942 double content = map(j,i);
3945 if (content < 0.0) {
3946 std::string msg =
"Negative value encountered. "
3947 "Cannot take the sqrt from a negative "
3976 for (
int i = 0; i < map.
nmaps(); ++i) {
3979 for (
int j = 0; j < map.
npix(); ++j) {
3982 double content = map(j,i);
3985 if (content <= 0.0) {
3986 std::string msg =
"Negative or zero value encountered. "
3987 "Cannot calculate the logarithm of a "
3988 "negative or zero value";
4016 for (
int i = 0; i < map.
nmaps(); ++i) {
4019 for (
int j = 0; j < map.
npix(); ++j) {
4022 double content = map(j,i);
4025 if (content <= 0.0) {
4026 std::string msg =
"Negative or zero value encountered. "
4027 "Cannot calculate the logarithm of a "
4028 "negative or zero value";
4056 for (
int i = 0; i < map.
nmaps(); ++i) {
4059 for (
int j = 0; j < map.
npix(); ++j) {
4062 double content = map(j,i);
4092 for (
int i = 0; i < map.
nmaps(); ++i) {
4095 for (
int j = 0; j < map.
npix(); ++j) {
4098 double content = map(j,i);
4101 if (content < 0.0) {
4104 else if (content > 0.0) {
4134 for (
int i = 0; i < map.
nmaps(); ++i) {
4137 for (
int j = 0; j < map.
npix(); ++j) {
4140 double content = map(j,i);
4143 if (content < thresh) {
4144 result(j,i) = thresh;
4149 result(j,i) = content;
GSkyDirs boundaries(const GSkyPixel &pixel, const int &step=1) const
Return pixel boundaries.
GFitsHDU * at(const int &extno)
Get pointer to HDU.
bool is_same(const GSkyMap &map) const
Check if map is the same.
GSkyMap(void)
Void constructor.
const int & ncols(void) const
Return number of columns in table.
void stack_maps(void)
Stack all maps into a single map.
std::string print(const GChatter &chatter=NORMAL) const
Print pixel.
GSkyMap & operator=(const GSkyMap &map)
Assignment operator.
Interface definition for the WCS registry class.
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
Double precision FITS image class definition.
FITS table double column class interface definition.
Abstract FITS image base class.
void number(const int &number)
Set number of elements in column.
int size(void) const
Return pixel dimension.
const int & naxis(void) const
Return dimension of image.
GSkyMap & operator*=(const GSkyMap &map)
Multiplication operator.
std::string number(const std::string &noun, const int &number)
Convert singular noun into number noun.
bool has_card(const int &cardno) const
Check existence of header card.
const int & ny(void) const
Returns number of pixels in y coordinate.
bool is_1D(void) const
Check if pixel is 1D.
GSkyPixel inx2pix(const int &index) const
Converts pixel index into sky map pixel.
double norm(const GVector &vector)
Computes vector norm.
int pix2inx(const GSkyPixel &pixel) const
Converts sky map pixel into pixel index.
const GSkyProjection * projection(void) const
Returns pointer to sky projection.
const int & nside(void) const
Returns number of divisions of the side of each base pixel.
GNdarray counts(void) const
Returns array with total number of counts for count maps.
GSkyMap * clone(void) const
Clone sky map.
void clear(void)
Clear array.
void x(const double &x)
Set x value of sky map pixel.
GSkyMap extract(const int &map, const int &nmaps=1) const
Extract maps into a new sky map object.
int m_num_maps
Number of maps (used for pixel allocation)
int m_num_pixels
Number of pixels (used for pixel allocation)
void read_healpix(const GFitsTable &table)
Read Healpix data from FITS table.
void publish(const GFitsHDU &hdu)
Publish FITS HDU.
bool has_extno(void) const
Signal if filename has an extension number.
Sky directions container class definition.
void set(const std::string &coords, const double &crval1, const double &crval2, const double &crpix1, const double &crpix2, const double &cdelt1, const double &cdelt2)
Set World Coordinate System parameters.
GVector abs(const GVector &vector)
Computes absolute of vector elements.
std::vector< int > m_shape
Shape of the maps.
Abstract FITS extension base class.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
int m_num_x
Number of pixels in x direction (only 2D)
int & index2(void)
Access index 2.
Generic matrix class definition.
Sky regions container class definition.
const std::string & type(void) const
Return region type.
void nrows(const int &nrows)
Set number of rows in column.
bool has_extname(void) const
Signal if filename has an extension name.
virtual HDUType exttype(void) const =0
GSkyProjection * m_proj
Pointer to sky projection.
double sum(const GVector &vector)
Computes vector sum.
std::string extname(const std::string &defaultname="") const
Return extension name.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
double crval(const int &inx) const
Return value of reference pixel.
int m_num_y
Number of pixels in y direction (only 2D)
double & weight2(void)
Access weight 2.
virtual void read(const GFitsHDU &hdu)=0
GSkyMap & operator+=(const GSkyMap &map)
Map addition operator.
void y(const double &y)
Set y value of sky map pixel.
void set_wcs(const std::string &wcs, const std::string &coords, const double &crval1, const double &crval2, const double &crpix1, const double &crpix2, const double &cdelt1, const double &cdelt2)
Set World Coordinate System.
GNdarray convolution_kernel(const std::string &kernel, const double &par, const bool &normalise) const
Return convolution kernel.
FITS file class interface definition.
Interface for the circular sky region class.
virtual int size(void) const =0
GNdarray backward(void) const
Backward Fast Fourier Transform.
virtual std::string name(void) const =0
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
HealPix projection class definition.
Sky map class definition.
GSkyMap & operator-=(const GSkyMap &map)
Map subtraction operator.
const std::vector< int > & shape(void) const
Returns shape of maps.
std::string centre(const std::string &s, const int &n, const char &c= ' ')
Centre string to achieve a length of n characters.
Abstract FITS image base class definition.
void publish(const std::string &name="") const
Publish sky map.
World Coordinate Projection registry class interface definition.
virtual std::string code(void) const =0
VO client class interface definition.
void index(const double &index)
Set sky map pixel index.
bool is_healpix(const GFitsHDU &hdu) const
Check if HDU contains HEALPix data.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
std::string content(void) const
Return list of names in registry.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
void clear(void)
Clear node array.
void copy_members(const GSkyMap &map)
Copy class members.
GVector sqrt(const GVector &vector)
Computes square root of vector elements.
GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
double & operator()(const int &index, const int &map=0)
Pixel index access operator.
double crpix(const int &inx) const
Return reference pixel.
virtual GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
HealPix projection class interface definition.
Abstract interface for the sky region class.
const int & nmaps(void) const
Returns number of maps.
GSkyDir inx2dir(const int &index) const
Returns sky direction of pixel.
GVector tan(const GVector &vector)
Computes tangens of vector elements.
virtual bool contains(const GSkyDir &dir) const =0
Double precision FITS image class.
GFitsImageDouble * create_wcs_hdu(void) const
Create FITS HDU containing WCS image.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
GWcs * alloc(const std::string &code) const
Allocate World Coordinate System of given code.
Abstract interface for FITS table column.
GNdarray m_pixels
Skymap pixels.
Fast Fourier Transformation class.
virtual double pixel(const int &ix) const =0
double cdelt(const int &inx) const
Return pixel size.
int & index1(void)
Access index 1.
GVector log(const GVector &vector)
Computes natural logarithm of vector elements.
bool m_contained
Sky direction is contained in map.
GNdarray sign(const GNdarray &array)
Computes sign of array elements.
int & index4(void)
Access index 4.
bool contains(const GSkyDir &dir) const
Checks if sky direction falls in map.
const double * data(void) const
Data access method (const version)
Abstract interface for FITS table.
int size(void) const
Return number of elements in array.
void alloc_wcs(const GFitsImage &image)
Allocate WCS class.
#define G_CONVOLUTION_KERNEL
int integer(const std::string &keyname) const
Return card value as integer.
virtual void write(GFitsHDU &hdu) const =0
void clear(void)
Clear instance.
const int & npix(void) const
Returns number of pixels.
void convolve(const std::string &kernel, const double &par, const bool &normalise)
Convolve sky map.
Vector class interface definition.
N-dimensional array class.
const std::string & extname(void) const
Return extension name.
double & weight3(void)
Access weight 3.
virtual std::string coordsys(void) const
Returns coordinate system.
int & index3(void)
Access index 3.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
const int & nrows(void) const
Return number of rows in table.
Sky region container class.
int naxes(const int &axis) const
Return dimension of an image axis.
Fast Fourier transformation class interface definition.
GSkyRegionCircle region_circle(void) const
Return sky region circle that encloses the sky map.
void free_members(void)
Delete class members.
bool m_hascache
Cache is valid.
Abstract world coordinate system base class.
double & weight4(void)
Access weight 4.
std::string url(void) const
Return Uniform Resource Locator (URL)
const GSkyDir & centre(void) const
Return circular region centre.
void clear(void)
Clear sky direction.
GSkyDir m_last_dir
Last sky direction.
GSkyMap & operator/=(const GSkyMap &map)
Division operator.
GSkyPixel dir2pix(const GSkyDir &dir) const
Returns sky map pixel for a given sky direction.
GBilinear m_interpol
Bilinear interpolator.
GFitsBinTable * create_healpix_hdu(void) const
Create FITS HDU containing Healpix data.
virtual double real(const int &row, const int &inx=0) const =0
int ndim(void) const
Returns dimension of maps.
virtual double solidangle(const GSkyPixel &pixel) const =0
double & weight1(void)
Access weight 1.
bool is_wcs(const GFitsHDU &hdu) const
Check if HDU contains WCS data.
void read_wcs(const GFitsImage &image)
Read WCS image from FITS HDU.
bool overlaps_circle(const GSkyRegionCircle ®ion) const
Checks whether a circular region overlaps with this map.
std::string ordering(void) const
Returns ordering parameter.
int size(void) const
Return number of HDUs in FITS file.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
GSkyMap clip(const GSkyMap &map, const double &thresh)
Clips map at given value.
bool contains(const GSkyDir &dir) const
Checks if sky direction lies within region.
int extno(const int &defaultno=-1) const
Return extension number.
std::string string(const std::string &keyname) const
Return card value as string.
Exception handler interface definition.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
std::string toupper(const std::string &s)
Convert string to upper case.
FITS binary table class definition.
const int & nx(void) const
Returns number of pixels in x coordinate.
GVector exp(const GVector &vector)
Computes exponential of vector elements.
void save(const GFilename &filename, const bool &clobber=false) const
Save sky map into FITS file.
void smooth(const std::string &kernel, const double &par)
Smooth sky map.
double solidangle(const int &index) const
Returns solid angle of pixel.
Abstract sky projection base class.
virtual GSkyDir pix2dir(const GSkyPixel &pixel) const =0
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
virtual ~GSkyMap(void)
Destructor.
bool is_2D(void) const
Check if pixel is 2D.
void load(const GFilename &filename)
Load skymap from FITS file.
const int & npix(void) const
Returns number of pixels.
GFitsHeaderCard & card(const int &cardno)
Return header card.
void init_members(void)
Initialise class members.
int dir2inx(const GSkyDir &dir) const
Returns pixel index for a given sky direction.
void close(void)
Close FITS file.
bool contains(const GSkyDir &dir) const
Check if direction is contained in one of the regions.
GVector atan(const GVector &vector)
Computes arctan of vector elements.
Circular sky region class interface definition.
Abstract sky region base class interface definition.
GNdarray flux(void) const
Returns array with total flux for sky maps.
FITS table double column.
Abstract world coordinate system base class definition.
virtual GSkyPixel dir2pix(const GSkyDir &dir) const =0
virtual GSkyProjection * clone(void) const =0
Clones object.
Mathematical function definitions.
GVector log10(const GVector &vector)
Computes base10 logarithm of vector elements.
Sky directions container class.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
FITS table abstract base class interface definition.