Healpix C++  3.83
healpix_map.cc
1 /*
2  * This file is part of Healpix_cxx.
3  *
4  * Healpix_cxx is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * Healpix_cxx is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with Healpix_cxx; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  *
18  * For more information about HEALPix, see http://healpix.sourceforge.net
19  */
20 
21 /*
22  * Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
23  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
24  * (DLR).
25  */
26 
27 /*
28  * Copyright (C) 2003-2013 Max-Planck-Society
29  * Author: Martin Reinecke
30  */
31 
32 #include "healpix_map.h"
33 
34 using namespace std;
35 
36 template<typename T> void Healpix_Map<T>::Import_degrade
37  (const Healpix_Map<T> &orig, bool pessimistic)
38  {
39  planck_assert(nside_<orig.nside_,"Import_degrade: this is no degrade");
40  int fact = orig.nside_/nside_;
41  planck_assert (orig.nside_==nside_*fact,
42  "the larger Nside must be a multiple of the smaller one");
43 
44  int minhits = pessimistic ? fact*fact : 1;
45 #pragma omp parallel
46 {
47  int m;
48 #pragma omp for schedule (static)
49  for (m=0; m<npix_; ++m)
50  {
51  int x,y,f;
52  pix2xyf(m,x,y,f);
53  int hits = 0;
54  kahan_adder<double> adder;
55  for (int j=fact*y; j<fact*(y+1); ++j)
56  for (int i=fact*x; i<fact*(x+1); ++i)
57  {
58  int opix = orig.xyf2pix(i,j,f);
59  if (!approx<double>(orig.map[opix],Healpix_undef))
60  {
61  ++hits;
62  adder.add(orig.map[opix]);
63  }
64  }
65  map[m] = T((hits<minhits) ? Healpix_undef : adder.result()/hits);
66  }
67 }
68  }
69 
71  (const Healpix_Map<float> &orig, bool pessimistic);
73  (const Healpix_Map<double> &orig, bool pessimistic);
74 
75 template<typename T> void Healpix_Map<T>::minmax (T &Min, T &Max) const
76  {
77  Min = T(1e30); Max = T(-1e30);
78  for (int m=0; m<npix_; ++m)
79  {
80  T val = map[m];
81  if (!approx<double>(val,Healpix_undef))
82  {
83  if (val>Max) Max=val;
84  if (val<Min) Min=val;
85  }
86  }
87  }
88 
89 template void Healpix_Map<float>::minmax (float &Min, float &Max) const;
90 template void Healpix_Map<double>::minmax (double &Min, double &Max) const;
void minmax(T &Min, T &Max) const
Definition: healpix_map.cc:75
const double Healpix_undef
Healpix value representing "undefined".
Definition: healpix_map.h:39
void Import_degrade(const Healpix_Map< T > &orig, bool pessimistic=false)
Definition: healpix_map.cc:37

Generated on Wed Nov 13 2024 12:18:30 for Healpix C++