healpix_map.cc

00001 /*
00002  *  This file is part of Healpix_cxx.
00003  *
00004  *  Healpix_cxx is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  Healpix_cxx is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with Healpix_cxx; if not, write to the Free Software
00016  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00017  *
00018  *  For more information about HEALPix, see http://healpix.sourceforge.net
00019  */
00020 
00021 /*
00022  *  Healpix_cxx is being developed at the Max-Planck-Institut fuer Astrophysik
00023  *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
00024  *  (DLR).
00025  */
00026 
00027 /*
00028  *  Copyright (C) 2003-2013 Max-Planck-Society
00029  *  Author: Martin Reinecke
00030  */
00031 
00032 #include "healpix_map.h"
00033 
00034 using namespace std;
00035 
00036 template<typename T> void Healpix_Map<T>::Import_degrade
00037   (const Healpix_Map<T> &orig, bool pessimistic)
00038   {
00039   planck_assert(nside_<orig.nside_,"Import_degrade: this is no degrade");
00040   int fact = orig.nside_/nside_;
00041   planck_assert (orig.nside_==nside_*fact,
00042     "the larger Nside must be a multiple of the smaller one");
00043 
00044   int minhits = pessimistic ? fact*fact : 1;
00045 #pragma omp parallel
00046 {
00047   int m;
00048 #pragma omp for schedule (static)
00049   for (m=0; m<npix_; ++m)
00050     {
00051     int x,y,f;
00052     pix2xyf(m,x,y,f);
00053     int hits = 0;
00054     kahan_adder<double> adder;
00055     for (int j=fact*y; j<fact*(y+1); ++j)
00056       for (int i=fact*x; i<fact*(x+1); ++i)
00057         {
00058         int opix = orig.xyf2pix(i,j,f);
00059         if (!approx<double>(orig.map[opix],Healpix_undef))
00060           {
00061           ++hits;
00062           adder.add(orig.map[opix]);
00063           }
00064         }
00065     map[m] = T((hits<minhits) ? Healpix_undef : adder.result()/hits);
00066     }
00067 }
00068   }
00069 
00070 template void Healpix_Map<float>::Import_degrade
00071   (const Healpix_Map<float> &orig, bool pessimistic);
00072 template void Healpix_Map<double>::Import_degrade
00073   (const Healpix_Map<double> &orig, bool pessimistic);
00074 
00075 template<typename T> void Healpix_Map<T>::minmax (T &Min, T &Max) const
00076   {
00077   Min = T(1e30); Max = T(-1e30);
00078   for (int m=0; m<npix_; ++m)
00079     {
00080     T val = map[m];
00081     if (!approx<double>(val,Healpix_undef))
00082       {
00083       if (val>Max) Max=val;
00084       if (val<Min) Min=val;
00085       }
00086     }
00087   }
00088 
00089 template void Healpix_Map<float>::minmax (float &Min, float &Max) const;
00090 template void Healpix_Map<double>::minmax (double &Min, double &Max) const;

Generated on Thu Oct 8 14:48:52 2015 for Healpix C++