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,
193 "than 1. Please specify at least one map.";
235 const std::string& coords,
250 "direction is smaller than 1. Please specify at "
251 "least one pixel in x direction.";
256 "direction is smaller than 1. Please specify at "
257 "least one pixel in y direction.";
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) {
1276 "are available. Please specify an appropriate "
1277 "factorisation or modify the number of available "
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;
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);
2555 int num = fits.
size();
2560 for (
int extno = 1; extno < num; ++extno) {
2577 for (
int extno = 0; extno < num; ++extno) {
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.";
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);
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++;
3345 std::vector<int> naxes;
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);
3447 solidangle = 4.0 * std::atan(std::sqrt(std::tan(0.5*s) *
3448 std::tan(0.5*(s-a23)) *
3449 std::tan(0.5*(s-a34)) *
3450 std::tan(0.5*(s-a24))));
3455 else if (a23 <= 0.0 || a34 <= 0.0) {
3456 double s = 0.5 * (a12 + a24 + a14);
3457 solidangle = 4.0 * std::atan(std::sqrt(std::tan(0.5*s) *
3458 std::tan(0.5*(s-a12)) *
3459 std::tan(0.5*(s-a24)) *
3460 std::tan(0.5*(s-a14))));
3467 double s1 = 0.5 * (a12 + a24 + a14);
3468 double excess1 = std::atan(std::sqrt(std::tan(0.5*s1) *
3469 std::tan(0.5*(s1-a12)) *
3470 std::tan(0.5*(s1-a24)) *
3471 std::tan(0.5*(s1-a14))));
3474 double s2 = 0.5 * (a23 + a34 + a24);
3475 double excess2 = std::atan(std::sqrt(std::tan(0.5*s2) *
3476 std::tan(0.5*(s2-a23)) *
3477 std::tan(0.5*(s2-a34)) *
3478 std::tan(0.5*(s2-a24))));
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);
3528 double solidangle = 4.0 * std::atan(std::sqrt(std::tan(0.5*s) *
3529 std::tan(0.5*(s-a12)) *
3530 std::tan(0.5*(s-a23)) *
3531 std::tan(0.5*(s-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;
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;
3844 if (std::sqrt(xqs + y*y) <= par) {
3845 kern(ix1,iy1) += 1.0;
3848 kern(ix2,iy1) += 1.0;
3852 kern(ix1,iy2) += 1.0;
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;
3881 kern(ix2,iy1) += value;
3885 kern(ix1,iy2) += value;
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 "
3953 result(j,i) = std::sqrt(content);
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";
3993 result(j,i) = std::log(content);
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";
4033 result(j,i) = std::log10(content);
4056 for (
int i = 0; i < map.
nmaps(); ++i) {
4059 for (
int j = 0; j < map.
npix(); ++j) {
4062 double content = map(j,i);
4065 result(j,i) = std::abs(content);
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;
Exception handler interface definition.
Fast Fourier transformation class interface definition.
FITS binary table class definition.
Double precision FITS image class definition.
Abstract FITS image base class definition.
FITS table double column class interface definition.
FITS table abstract base class interface definition.
FITS file class interface definition.
HealPix projection class definition.
Mathematical function definitions.
Generic matrix class definition.
Sky directions container class definition.
GSkyMap sqrt(const GSkyMap &map)
Computes square root of sky map elements.
GSkyMap clip(const GSkyMap &map, const double &thresh)
Clips map at given value.
#define G_CONVOLUTION_KERNEL
GSkyMap log(const GSkyMap &map)
Computes the natural logarithm of sky map elements.
GSkyMap log10(const GSkyMap &map)
Computes the base 10 logarithm of sky map elements.
GSkyMap sign(const GSkyMap &map)
Computes the sign value of sky map elements.
GSkyMap abs(const GSkyMap &map)
Computes the absolute value of sky map elements.
Sky map class definition.
Circular sky region class interface definition.
Abstract sky region base class interface definition.
Sky regions container class definition.
VO client class interface definition.
double norm(const GVector &vector)
Computes vector norm.
double sum(const GVector &vector)
Computes vector sum.
Vector class interface definition.
World Coordinate Projection registry class interface definition.
Abstract world coordinate system base class definition.
int & index4(void)
Access index 4.
int & index2(void)
Access index 2.
int & index3(void)
Access index 3.
double & weight1(void)
Access weight 1.
void clear(void)
Clear node array.
double & weight3(void)
Access weight 3.
double & weight4(void)
Access weight 4.
double & weight2(void)
Access weight 2.
int & index1(void)
Access index 1.
Fast Fourier Transformation class.
GNdarray backward(void) const
Backward Fast Fourier Transform.
bool has_extname(void) const
Signal if filename has an extension name.
bool has_extno(void) const
Signal if filename has an extension number.
std::string url(void) const
Return Uniform Resource Locator (URL)
std::string extname(const std::string &defaultname="") const
Return extension name.
int extno(const int &defaultno=-1) const
Return extension number.
Abstract FITS extension base class.
virtual HDUType exttype(void) const =0
bool has_card(const int &cardno) const
Check existence of header card.
const std::string & extname(void) const
Return extension name.
std::string string(const std::string &keyname) const
Return card value as string.
GFitsHeaderCard & card(const int &cardno)
Return header card.
int integer(const std::string &keyname) const
Return card value as integer.
Double precision FITS image class.
Abstract FITS image base class.
virtual double pixel(const int &ix) const =0
int naxes(const int &axis) const
Return dimension of an image axis.
const int & naxis(void) const
Return dimension of image.
Abstract interface for FITS table column.
void number(const int &number)
Set number of elements in column.
virtual double real(const int &row, const int &inx=0) const =0
void nrows(const int &nrows)
Set number of rows in column.
FITS table double column.
Abstract interface for FITS table.
GFitsTableCol * append(const GFitsTableCol &column)
Append column to the table.
const int & nrows(void) const
Return number of rows in table.
const int & ncols(void) const
Return number of columns in table.
void saveto(const GFilename &filename, const bool &clobber=false)
Saves to specified FITS file.
int size(void) const
Return number of HDUs in FITS file.
GFitsHDU * append(const GFitsHDU &hdu)
Append HDU to FITS file.
void close(void)
Close FITS file.
GFitsHDU * at(const int &extno)
Get pointer to HDU.
HealPix projection class interface definition.
GSkyDirs boundaries(const GSkyPixel &pixel, const int &step=1) const
Return pixel boundaries.
std::string ordering(void) const
Returns ordering parameter.
const int & nside(void) const
Returns number of divisions of the side of each base pixel.
const int & npix(void) const
Returns number of pixels.
virtual GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
N-dimensional array class.
const double * data(void) const
Data access method (const version)
int size(void) const
Return number of elements in array.
void clear(void)
Clear array.
std::string content(void) const
Return list of names in registry.
double dist_deg(const GSkyDir &dir) const
Compute angular distance between sky directions in degrees.
void clear(void)
Clear sky direction.
double dist(const GSkyDir &dir) const
Compute angular distance between sky directions in radians.
Sky directions container class.
GSkyMap & operator*=(const GSkyMap &map)
Multiplication operator.
void smooth(const std::string &kernel, const double &par)
Smooth sky map.
GSkyDir m_last_dir
Last sky direction.
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.
double solidangle(const int &index) const
Returns solid angle of pixel.
int ndim(void) const
Returns dimension of maps.
const int & nmaps(void) const
Returns number of maps.
void read_healpix(const GFitsTable &table)
Read Healpix data from FITS table.
GSkyMap & operator+=(const GSkyMap &map)
Map addition operator.
int m_num_maps
Number of maps (used for pixel allocation)
void clear(void)
Clear instance.
void stack_maps(void)
Stack all maps into a single map.
bool is_same(const GSkyMap &map) const
Check if map is the same.
GBilinear m_interpol
Bilinear interpolator.
GSkyRegionCircle region_circle(void) const
Return sky region circle that encloses the sky map.
GSkyDir inx2dir(const int &index) const
Returns sky direction of pixel.
void alloc_wcs(const GFitsImage &image)
Allocate WCS class.
GSkyProjection * m_proj
Pointer to sky projection.
GNdarray convolution_kernel(const std::string &kernel, const double &par, const bool &normalise) const
Return convolution kernel.
void read_wcs(const GFitsImage &image)
Read WCS image from FITS HDU.
int m_num_y
Number of pixels in y direction (only 2D)
double & operator()(const int &index, const int &map=0)
Pixel index access operator.
void save(const GFilename &filename, const bool &clobber=false) const
Save sky map into FITS file.
int dir2inx(const GSkyDir &dir) const
Returns pixel index for a given sky direction.
GSkyMap extract(const int &map, const int &nmaps=1) const
Extract maps into a new sky map object.
bool is_healpix(const GFitsHDU &hdu) const
Check if HDU contains HEALPix data.
const int & nx(void) const
Returns number of pixels in x coordinate.
void read(const GFitsHDU &hdu)
Read skymap from FITS HDU.
void copy_members(const GSkyMap &map)
Copy class members.
void convolve(const std::string &kernel, const double &par, const bool &normalise)
Convolve sky map.
const int & npix(void) const
Returns number of pixels.
GSkyMap & operator/=(const GSkyMap &map)
Division operator.
GNdarray counts(void) const
Returns array with total number of counts for count maps.
GSkyMap * clone(void) const
Clone sky map.
GNdarray flux(void) const
Returns array with total flux for sky maps.
const int & ny(void) const
Returns number of pixels in y coordinate.
int m_num_x
Number of pixels in x direction (only 2D)
const GSkyProjection * projection(void) const
Returns pointer to sky projection.
GFitsHDU * write(GFits &file, const std::string &extname="") const
Write sky map into FITS file.
int m_num_pixels
Number of pixels (used for pixel allocation)
bool m_contained
Sky direction is contained in map.
GSkyDir pix2dir(const GSkyPixel &pixel) const
Returns sky direction of pixel.
GSkyMap(void)
Void constructor.
const std::vector< int > & shape(void) const
Returns shape of maps.
void free_members(void)
Delete class members.
GSkyMap & operator-=(const GSkyMap &map)
Map subtraction operator.
bool is_wcs(const GFitsHDU &hdu) const
Check if HDU contains WCS data.
GSkyMap & operator=(const GSkyMap &map)
Assignment operator.
void publish(const std::string &name="") const
Publish sky map.
virtual ~GSkyMap(void)
Destructor.
void load(const GFilename &filename)
Load skymap from FITS file.
GFitsImageDouble * create_wcs_hdu(void) const
Create FITS HDU containing WCS image.
bool overlaps_circle(const GSkyRegionCircle ®ion) const
Checks whether a circular region overlaps with this map.
std::vector< int > m_shape
Shape of the maps.
bool contains(const GSkyDir &dir) const
Checks if sky direction falls in map.
bool m_hascache
Cache is valid.
GFitsBinTable * create_healpix_hdu(void) const
Create FITS HDU containing Healpix data.
GSkyPixel inx2pix(const int &index) const
Converts pixel index into sky map pixel.
int pix2inx(const GSkyPixel &pixel) const
Converts sky map pixel into pixel index.
GNdarray m_pixels
Skymap pixels.
void init_members(void)
Initialise class members.
GSkyPixel dir2pix(const GSkyDir &dir) const
Returns sky map pixel for a given sky direction.
bool overlaps(const GSkyRegion ®ion) const
Checks whether a region overlaps with this map.
std::string print(const GChatter &chatter=NORMAL) const
Print sky map.
std::string print(const GChatter &chatter=NORMAL) const
Print pixel.
int size(void) const
Return pixel dimension.
void index(const double &index)
Set sky map pixel index.
bool is_1D(void) const
Check if pixel is 1D.
bool is_2D(void) const
Check if pixel is 2D.
void y(const double &y)
Set y value of sky map pixel.
void x(const double &x)
Set x value of sky map pixel.
Abstract sky projection base class.
virtual std::string print(const GChatter &chatter=NORMAL) const =0
Print content of object.
virtual std::string coordsys(void) const
Returns coordinate system.
virtual std::string code(void) const =0
virtual void read(const GFitsHDU &hdu)=0
virtual double solidangle(const GSkyPixel &pixel) const =0
virtual GSkyProjection * clone(void) const =0
Clones object.
virtual int size(void) const =0
virtual GSkyPixel dir2pix(const GSkyDir &dir) const =0
virtual std::string name(void) const =0
virtual void write(GFitsHDU &hdu) const =0
virtual GSkyDir pix2dir(const GSkyPixel &pixel) const =0
Interface for the circular sky region class.
bool contains(const GSkyDir &dir) const
Checks if sky direction lies within region.
const GSkyDir & centre(void) const
Return circular region centre.
Abstract interface for the sky region class.
const std::string & type(void) const
Return region type.
virtual bool contains(const GSkyDir &dir) const =0
Sky region container class.
bool contains(const GSkyDir &dir) const
Check if direction is contained in one of the regions.
void publish(const GFitsHDU &hdu)
Publish FITS HDU.
Interface definition for the WCS registry class.
GWcs * alloc(const std::string &code) const
Allocate World Coordinate System of given code.
Abstract world coordinate system base class.
double cdelt(const int &inx) const
Return pixel size.
double crpix(const int &inx) const
Return reference pixel.
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.
double crval(const int &inx) const
Return value of reference pixel.
std::string parformat(const std::string &s, const int &indent=0)
Convert string in parameter format.
std::string str(const unsigned short int &value)
Convert unsigned short integer value into string.
GChatter reduce(const GChatter &chatter)
Reduce chattiness by one level.
std::string toupper(const std::string &s)
Convert string to upper case.