NASA - Jet Propulsion Laboratory
    + View the NASA Portal
Search JPL
Jet Propulsion Laboratory Home Earth Solar System Stars & Galaxies Technology
Introduction Background Software Links

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.jpl.nasa.gov
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, 2004 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   pix2xyf to_xyf = (scheme_==RING) ?
00044     &Healpix_Map::ring2xyf : &Healpix_Map::nest2xyf;
00045   xyf2pix from_xyf = (orig.scheme_==RING) ?
00046     &Healpix_Map::xyf2ring : &Healpix_Map::xyf2nest;
00047 
00048   int minhits = pessimistic ? fact : 1;
00049 #pragma omp parallel
00050 {
00051   int m;
00052 #pragma omp for schedule (static)
00053   for (m=0; m<npix_; ++m)
00054     {
00055     int x,y,f;
00056     (this->*to_xyf)(m,x,y,f);
00057     int hits = 0;
00058     double sum = 0;
00059     for (int j=fact*y; j<fact*(y+1); ++j)
00060       for (int i=fact*x; i<fact*(x+1); ++i)
00061         {
00062         int opix = (orig.*from_xyf)(i,j,f);
00063         if (!approx<double>(orig.map[opix],Healpix_undef))
00064           {
00065           ++hits;
00066           sum += orig.map[opix];
00067           }
00068         }
00069     map[m] = (hits<minhits) ? Healpix_undef : sum/hits;
00070     }
00071 }
00072   }
00073 
00074 template void Healpix_Map<float>::Import_degrade
00075   (const Healpix_Map<float> &orig, bool pessimistic);
00076 template void Healpix_Map<double>::Import_degrade
00077   (const Healpix_Map<double> &orig, bool pessimistic);
00078 
00079 template<typename T> void Healpix_Map<T>::minmax (T &Min, T &Max) const
00080   {
00081   Min = 1e30; Max = -1e30;
00082   for (int m=0; m<npix_; ++m)
00083     {
00084     T val = map[m];
00085     if (!approx<double>(val,Healpix_undef))
00086       {
00087       if (val>Max) Max=val;
00088       if (val<Min) Min=val;
00089       }
00090     }
00091   }
00092 
00093 template void Healpix_Map<float>::minmax (float &Min, float &Max) const;
00094 template void Healpix_Map<double>::minmax (double &Min, double &Max) const;

Generated on Fri Jun 18 16:12:30 2010 for Healpix C++
Privacy / Copyright
FIRST GOV Contact: NASA Home Page Site Manager:
Webmaster:

CL 03-2650