healpixmap.cpp

Go to the documentation of this file.
00001 /* ============================================================================
00002 'healpixmap.cpp' extends the Skymap class to support HEALPIX maps.  The class
00003 is defined in 'healpixmap.h'.
00004 
00005 Written by Michael R. Greason, ADNET, 29 December 2006.
00006 ============================================================================ */
00007 /*
00008                         Fetch header files.  Wrap the call to chealpix.h in an 
00009                         'extern "C"' construct to ensure that name mangling is turned off;
00010                         the Gnu C++ compiler wouldn't link these functions in correctly
00011                         without it.
00012 */
00013 #include <iostream>
00014 #include <string.h>
00015 #include <stdio.h>
00016 extern "C"
00017 {
00018 #include <chealpix.h>
00019 };
00020 #include "healpixmap.h"
00021 #include "controldialog.h"
00022 #include "str_funcs.h"
00023 
00024 using namespace std;
00025 /*
00026                         Constants.
00027 */
00028 static double pi      = 3.141592653589793;
00029 static double deg2rad = pi / 360.0;
00030 /* =============================================================================
00031 The HealpixMap class defines a skymap that uses the HEALPIX pixelization scheme.
00032 ============================================================================= */
00033 /* ----------------------------------------------------------------------------
00034 'readFITSPrimaryHeader' reads information from the primary FITS header.
00035 
00036 This routine assumes that the current HDU is the primary HDU.
00037 
00038 An exception is thrown in the event of a FITS error.
00039 
00040 Arguments:
00041         fitsfile - The handle to the currently open FITS file.
00042 
00043 Returned:
00044         Nothing.
00045 ---------------------------------------------------------------------------- */
00046 void HealpixMap::readFITSPrimaryHeader (fitsfile* fptr)
00047 {
00048         char tmp[24], comm[80];
00049         int  status = 0;
00050         Skymap::readFITSPrimaryHeader(fptr);
00051         if (fits_read_keyword(fptr, "ORDERING", tmp, comm, &status) != 0)
00052                 return;
00053         fits_str_cull(tmp);
00054         if (strncmp(tmp, "RING", 4) == 0) ordering_ = Ring;
00055                                      else ordering_ = Nested;
00056         return;
00057 }
00058 /* ----------------------------------------------------------------------------
00059 'writeFITSPrimaryHeader' writes information to the primary FITS header.
00060 
00061 This routine assumes that the current HDU is the primary HDU.
00062 
00063 An exception is thrown in the event of a FITS error or if the ordering
00064 scheme is undefined.
00065 
00066 Arguments:
00067         fitsfile - The handle to the currently open FITS file.
00068 
00069 Returned:
00070         Nothing.
00071 ---------------------------------------------------------------------------- */
00072 void HealpixMap::writeFITSPrimaryHeader (fitsfile* fptr)
00073 {
00074         char         stmp[80], comm[80];
00075         unsigned int itmp;
00076         int          status = 0;
00077 
00078         if (ordering_ == Undefined) throw MapException(MapException::Undefined);
00079 
00080         Skymap::writeFITSPrimaryHeader(fptr);
00081 
00082         strcpy(comm, "Pixel algorithm");
00083         strcpy(stmp, "HEALPIX");
00084         fits_write_key(fptr, TSTRING, "PIXTYPE", stmp, comm, &status);
00085 
00086         strcpy(comm, "Ordering scheme");
00087         strcpy(stmp, ordering());
00088         fits_write_key(fptr, TSTRING, "ORDERING", stmp, comm, &status);
00089 
00090         strcpy(comm, "Resolution index");
00091         itmp = NSide2Res(nside());
00092         fits_write_key(fptr, TUINT, "RESOLUTN", &itmp, comm, &status);
00093 
00094         strcpy(comm, "Resolution parameter");
00095         itmp = nside();
00096         fits_write_key(fptr, TUINT, "NSIDE", &itmp, comm, &status);
00097 
00098         strcpy(comm, "First pixel index (0 based)");
00099         itmp = 0;
00100         fits_write_key(fptr, TUINT, "FIRSTPIX", &itmp, comm, &status);
00101 
00102         strcpy(comm, "Last pixel index (0 based)");
00103         itmp = size() - 1;
00104         fits_write_key(fptr, TUINT, "LASTPIX", &itmp, comm, &status);
00105 
00106         return;
00107 }
00108 /* ----------------------------------------------------------------------------
00109 'readFITSExtensionHeader' reads information from the extension FITS header.
00110 
00111 This routine assumes that the current HDU is the correct extension HDU.
00112 
00113 An exception is thrown in the event of a FITS error.
00114 
00115 Arguments:
00116         fitsfile - The handle to the currently open FITS file.
00117 
00118 Returned:
00119         Nothing.
00120 ---------------------------------------------------------------------------- */
00121 void HealpixMap::readFITSExtensionHeader (fitsfile* fptr)
00122 {
00123         char tmp[24], comm[80];
00124         int  status = 0;
00125         Skymap::readFITSExtensionHeader(fptr);
00126         if (fits_read_keyword(fptr, "ORDERING", tmp, comm, &status) != 0)
00127                 return;
00128         fits_str_cull(tmp);
00129         if (strncmp(tmp, "RING", 4) == 0) ordering_ = Ring;
00130                                      else ordering_ = Nested;
00131 }
00132 /* ----------------------------------------------------------------------------
00133 'writeFITSExtensionHeader' writes information to the primary FITS header.
00134 
00135 This routine assumes that the current HDU is the correct extension HDU.
00136 
00137 An exception is thrown in the event of a FITS error.
00138 
00139 Arguments:
00140         fitsfile - The handle to the currently open FITS file.
00141 
00142 Returned:
00143         Nothing.
00144 ---------------------------------------------------------------------------- */
00145 void HealpixMap::writeFITSExtensionHeader (fitsfile* fptr)
00146 {
00147         char         stmp[80], comm[80];
00148         unsigned int itmp;
00149         int          status = 0;
00150 
00151         Skymap::writeFITSExtensionHeader(fptr);
00152 
00153         strcpy(comm, "Pixel algorithm");
00154         strcpy(stmp, "HEALPIX");
00155         fits_write_key(fptr, TSTRING, "PIXTYPE", stmp, comm, &status);
00156 
00157         strcpy(comm, "Ordering scheme");
00158         strcpy(stmp, ordering());
00159         fits_write_key(fptr, TSTRING, "ORDERING", stmp, comm, &status);
00160 
00161         strcpy(comm, "Resolution index");
00162         itmp = NSide2Res(nside());
00163         fits_write_key(fptr, TUINT, "RESOLUTN", &itmp, comm, &status);
00164 
00165         strcpy(comm, "Resolution parameter");
00166         itmp = nside();
00167         fits_write_key(fptr, TUINT, "NSIDE", &itmp, comm, &status);
00168 
00169         strcpy(comm, "First pixel index (0 based)");
00170         itmp = 0;
00171         fits_write_key(fptr, TUINT, "FIRSTPIX", &itmp, comm, &status);
00172 
00173         strcpy(comm, "Last pixel index (0 based)");
00174         itmp = size() - 1;
00175         fits_write_key(fptr, TUINT, "LASTPIX", &itmp, comm, &status);
00176 
00177         return;
00178 }
00179 /* ----------------------------------------------------------------------------
00180 'degrade_pixindex' computes a degraded pixel index for the current map type.
00181 This calculation should always go from the higher to the lower resolution
00182 direction because this results in a unique calculation; therefore there is
00183 no 'upgrade_pixindex' function.
00184 
00185 If an error occurs, a MapException will be thrown.
00186 
00187 Arguments:
00188         i   - The pixel index to convert.
00189         nsi - The nside of the [high resolution] map corresponding to i.
00190         nso - The nside of the [low resolution] map to be computed to.
00191 
00192 Returned:
00193         The converted pixel index.
00194 ---------------------------------------------------------------------------- */
00195 unsigned int HealpixMap::degrade_pixindex (unsigned int i, unsigned int nsi,
00196         unsigned int nso)
00197 {
00198         long ti, tj;
00199         double scl;
00200         if (ordering_ == Undefined) throw MapException(MapException::Undefined);
00201         if (ordering_ == Ring) ::ring2nest(long(nsi), long(i), &ti);
00202                           else ti = long(i);
00203         scl = double(nso) / double(nsi);
00204         tj = long(double(ti) * scl * scl);
00205         if (ordering_ == Ring) ::nest2ring(long(nso), tj, &tj);
00206         return ((unsigned int) tj);
00207 }
00208 /* ----------------------------------------------------------------------------
00209 'degrade_map' reduces the size of the map.
00210 
00211 If an error occurs, a MapException will be thrown.
00212 
00213 Arguments:
00214         ns - The new nsize.
00215 
00216 Returned:
00217         Nothing.
00218 ---------------------------------------------------------------------------- */
00219 void HealpixMap::degrade_map (unsigned int ns) 
00220 {
00221         BasePixel *arr;
00222         unsigned int i, j;
00223         unsigned int nnew = NSide2NPix(ns);
00224         unsigned int *cnt;
00225 /*
00226                         Allocate space for the new array.
00227 */
00228         switch (type())
00229         {
00230                 case TPix:
00231                         arr = new TPixel[nnew];
00232                         if (arr == NULL) throw MapException(MapException::Memory);
00233                         break;
00234                 case PPix:
00235                         arr = new TPPixel[nnew];
00236                         if (arr == NULL) throw MapException(MapException::Memory);
00237                         break;
00238                 case TnobsPix:
00239                         arr = new TnobsPixel[nnew];
00240                         if (arr == NULL) throw MapException(MapException::Memory);
00241                         break;
00242                 case TPnobsPix:
00243                         arr = new TPnobsPixel[nnew];
00244                         if (arr == NULL) throw MapException(MapException::Memory);
00245                         break;
00246                 default:
00247                         throw MapException(MapException::InvalidType);
00248                         break;
00249         }
00250         if ((cnt = new unsigned int[nnew]) == NULL)
00251                 throw MapException(MapException::InvalidType);
00252         for (i = 0; i < nnew; i++) cnt[i] = 0;
00253 /*
00254                         Accumulate data into the new map.
00255 */
00256         for (j = 0; j < size(); j++)
00257         {
00258                 i = degrade_pixindex(j, nside_, ns);
00259                 if (i >= nnew) break;
00260                 cnt[i] += 1;
00261                 try { arr[i].T()    += (*this)[j].T();    } catch (MapException &exc) { ; }
00262                 try { arr[i].Nobs() += (*this)[j].Nobs(); } catch (MapException &exc) { ; }
00263                 try { arr[i].Q()    += (*this)[j].Q();    } catch (MapException &exc) { ; }
00264                 try { arr[i].U()    += (*this)[j].U();    } catch (MapException &exc) { ; }
00265         }
00266 /*
00267                         Compute the mean temperature measurements.
00268 */
00269         for (i = 0; i < nnew; i++)
00270         {
00271                 try { arr[i].T() /= double(cnt[i]); } catch (MapException &exc) { ; }
00272                 try { arr[i].Q() /= double(cnt[i]); } catch (MapException &exc) { ; }
00273                 try { arr[i].U() /= double(cnt[i]); } catch (MapException &exc) { ; }
00274         }
00275 /*
00276                         Destroy the old map array, assign the new one to the map,
00277                         and update bookkeeping parameters.
00278 */
00279         delete [] cnt;
00280         switch (type())
00281         {
00282                 case TPix:
00283                         if (tpix != 0) delete [] tpix;
00284                         tpix = (TPixel*) arr;
00285                         break;
00286                 case PPix:
00287                         if (tppix != 0) delete [] tppix;
00288                         tppix = (TPPixel*) arr;
00289                         break;
00290                 case TnobsPix:
00291                         if (tnobspix != 0) delete [] tnobspix;
00292                         tnobspix = (TnobsPixel*) arr;
00293                         break;
00294                 case TPnobsPix:
00295                         if (tpnobspix != 0) delete [] tpnobspix;
00296                         tpnobspix = (TPnobsPixel*) arr;
00297                         break;
00298                 default:
00299                         throw MapException(MapException::InvalidType);
00300                         break;
00301         }
00302         nside_ = ns;
00303         n_     = nnew;
00304         return;
00305 }
00306 /* ----------------------------------------------------------------------------
00307 'upgrade_map' increases the size of the map.
00308 
00309 If an error occurs, a MapException will be thrown.
00310 
00311 Arguments:
00312         ns - The new nsize.
00313 
00314 Returned:
00315         Nothing.
00316 ---------------------------------------------------------------------------- */
00317 void HealpixMap::upgrade_map (unsigned int ns) 
00318 {
00319         BasePixel *arr;
00320         unsigned int i, j;
00321         unsigned int nnew = NSide2NPix(ns);
00322         double       scl;
00323 /*
00324                         Allocate space for the new array.
00325 */
00326         switch (type())
00327         {
00328                 case TPix:
00329                         arr = new TPixel[nnew];
00330                         if (arr == NULL) throw MapException(MapException::Memory);
00331                         break;
00332                 case PPix:
00333                         arr = new TPPixel[nnew];
00334                         if (arr == NULL) throw MapException(MapException::Memory);
00335                         break;
00336                 case TnobsPix:
00337                         arr = new TnobsPixel[nnew];
00338                         if (arr == NULL) throw MapException(MapException::Memory);
00339                         break;
00340                 case TPnobsPix:
00341                         arr = new TPnobsPixel[nnew];
00342                         if (arr == NULL) throw MapException(MapException::Memory);
00343                         break;
00344                 default:
00345                         throw MapException(MapException::InvalidType);
00346                         break;
00347         }
00348 /*
00349                         Accumulate data into the new map.
00350 */
00351         scl = double(nnew) / double(size());
00352         for (j = 0; j < nnew; j++)
00353         {
00354                 i = degrade_pixindex(j, ns, nside_);
00355                 i  = (unsigned int)(double(j) / scl);
00356                 if (i >= size()) break;
00357                 try { arr[j].T()        = (*this)[i].T();        } catch (MapException &exc) { ; }
00358                 try { arr[j].Nobs() = (*this)[i].Nobs(); } catch (MapException &exc) { ; }
00359                 try { arr[j].Q()        = (*this)[i].Q();        } catch (MapException &exc) { ; }
00360                 try { arr[j].U()        = (*this)[i].U();        } catch (MapException &exc) { ; }
00361         }
00362 /*
00363                         Destroy the old map array, assign the new one to the map,
00364                         and update bookkeeping parameters.
00365 */
00366         switch (type())
00367         {
00368                 case TPix:
00369                         if (tpix != 0) delete [] tpix;
00370                         tpix = (TPixel*) arr;
00371                         break;
00372                 case PPix:
00373                         if (tppix != 0) delete [] tppix;
00374                         tppix = (TPPixel*) arr;
00375                         break;
00376                 case TnobsPix:
00377                         if (tnobspix != 0) delete [] tnobspix;
00378                         tnobspix = (TnobsPixel*) arr;
00379                         break;
00380                 case TPnobsPix:
00381                         if (tpnobspix != 0) delete [] tpnobspix;
00382                         tpnobspix = (TPnobsPixel*) arr;
00383                         break;
00384                 default:
00385                         throw MapException(MapException::InvalidType);
00386                         break;
00387         }
00388         nside_ = ns;
00389         n_     = nnew;
00390         return;
00391 }
00392 /* ----------------------------------------------------------------------------
00393 'HealpixMap' creates an empty instance of the class.
00394 
00395 Arguments:
00396         None.
00397 
00398 Returned:
00399         N/A.
00400 ---------------------------------------------------------------------------- */
00401 HealpixMap::HealpixMap () : Skymap()
00402 {
00403         nside_    = 0;
00404         ordering_ = Undefined;
00405 }
00406 /* ----------------------------------------------------------------------------
00407 'HealpixMap' creates a blank map given descriptive information.
00408 
00409 Arguments:
00410         n_in    - The number of pixels in the map.
00411         type_in - The type of map.
00412         ord     - The pixel ordering.  Defaults to Nested.
00413 
00414 Returned:
00415         N/A.
00416 ---------------------------------------------------------------------------- */
00417 HealpixMap::HealpixMap (unsigned int n_in, Type type_in, PixOrder ord) : 
00418         Skymap(n_in, type_in)
00419 {
00420         nside_    = NPix2NSide(n_in);
00421         ordering_ = ord;
00422 }
00423 /* ----------------------------------------------------------------------------
00424 '~HealpixMap' is the class destructor.
00425 
00426 Arguments:
00427         None.
00428 
00429 Returned:
00430         N/A.
00431 ---------------------------------------------------------------------------- */
00432 HealpixMap::~HealpixMap ()
00433 {
00434         ;
00435 }
00436 /* ----------------------------------------------------------------------------
00437 'copy' copies the contents of another map into this one.
00438 
00439 Arguments:
00440         imap - The source map.
00441 
00442 Returned:
00443         Nothing.
00444 ---------------------------------------------------------------------------- */
00445 void HealpixMap::copy(HealpixMap &imap)
00446 {
00447         Skymap::copy(imap);
00448         nside_    = imap.nside_;
00449         ordering_ = imap.ordering_;
00450         
00451 }
00452 /* ----------------------------------------------------------------------------
00453 'ordering' reports the ordering scheme as a descriptive string.  Static
00454 internal storage is used, so use the string before calling this routine
00455 again.
00456 
00457 Arguments:
00458         None.
00459 
00460 Returned:
00461         The string:  NESTED or RING.
00462 ---------------------------------------------------------------------------- */
00463 const char* HealpixMap::ordering () const
00464 {
00465         static char str[12];
00466         if (ordering_ == Ring  ) strcpy(str, "RING");
00467         if (ordering_ == Nested) strcpy(str, "NESTED");
00468                             else strcpy(str, "UNDEFINED");
00469         return str;
00470 }
00471 /* ----------------------------------------------------------------------------
00472 'pixel2vector' converts a pixel number into a cartesian pointing vector.
00473 
00474 If the pixel ordering of the map is undefined, then an Undefined MapException
00475 is thrown.
00476 
00477 Arguments:
00478         pix    - The pixel number.
00479         vector - The three-element cartesian pointing vector.
00480 
00481 Returned:
00482         Nothing.
00483 ---------------------------------------------------------------------------- */
00484 void HealpixMap::pixel2vector (long pix, double *vector)
00485 {
00486         switch (ordering_)
00487         {
00488                 case Nested:
00489                         ::pix2vec_nest(long(nside_), pix, vector);
00490                         break;
00491                 case Ring:
00492                         ::pix2vec_ring(long(nside_), pix, vector);
00493                         break;
00494                 default:
00495                         throw MapException(MapException::Undefined);
00496                         break;
00497         }
00498         return;
00499 }
00500 /* ----------------------------------------------------------------------------
00501 'vector2pixel' converts a cartesian pointing vector into a pixel number.
00502 
00503 If the pixel ordering of the map is undefined, then an Undefined MapException
00504 is thrown.
00505 
00506 Arguments:
00507         vector - The three-element cartesian pointing vector.
00508         pix    - The pixel number.
00509 
00510 Returned:
00511         Nothing.
00512 ---------------------------------------------------------------------------- */
00513 void HealpixMap::vector2pixel (double *vector, long &pix)
00514 {
00515         pix = 0;
00516         switch (ordering_)
00517         {
00518                 case Nested:
00519                         ::vec2pix_nest(long(nside_), vector, &pix);
00520                         break;
00521                 case Ring:
00522                         ::vec2pix_ring(long(nside_), vector, &pix);
00523                         break;
00524                 default:
00525                         throw MapException(MapException::Undefined);
00526                         break;
00527         }
00528         return;
00529 }
00530 /* ----------------------------------------------------------------------------
00531 'pixel2angles' converts a pixel number into position angles on the sphere.
00532 
00533 If the pixel ordering of the map is undefined, then an Undefined MapException
00534 is thrown.
00535 
00536 Arguments:
00537         pix   - The pixel number.
00538         theta - The colatitude in radians measured southward from the north pole
00539                         (0--PI).
00540         phi   - The longitude in radians measured eastward from the X-axis
00541                         (0--2PI).
00542         deg   - If nonzero return the angles in degrees instead of radians.
00543                 Defaults to 0.
00544 
00545 Returned:
00546         Nothing.
00547 ---------------------------------------------------------------------------- */
00548 void HealpixMap::pixel2angles (long pix, double &theta, double &phi, int deg)
00549 {
00550         theta = phi = 0.0;
00551         switch (ordering_)
00552         {
00553                 case Nested:
00554                         ::pix2ang_nest(long(nside_), pix, &theta, &phi);
00555                         break;
00556                 case Ring:
00557                         ::pix2ang_ring(long(nside_), pix, &theta, &phi);
00558                         break;
00559                 default:
00560                         throw MapException(MapException::Undefined);
00561                         break;
00562         }
00563         if (deg != 0)
00564         {
00565                 theta /= deg2rad;
00566                 phi   /= deg2rad;
00567         }
00568         return;
00569 }
00570 /* ----------------------------------------------------------------------------
00571 'angles2pixel' converts position angles on the sphere into a pixel number.
00572 
00573 If the pixel ordering of the map is undefined, then an Undefined MapException
00574 is thrown.
00575 
00576 Arguments:
00577         theta - The colatitude in radians measured southward from the north pole
00578                         (0--PI).
00579         phi   - The longitude in radians measured eastward from the X-axis
00580                         (0--2PI).
00581         pix   - The pixel number.
00582         deg   - If nonzero the angles are in degrees instead of radians.
00583                 Defaults to 0.
00584 
00585 Returned:
00586         Nothing.
00587 ---------------------------------------------------------------------------- */
00588 void HealpixMap::angles2pixel (double theta, double phi, long &pix, int deg)
00589 {
00590         pix = 0;
00591         if (deg != 0)
00592         {
00593                 theta *= deg2rad;
00594                 phi   *= deg2rad;
00595         }
00596         switch (ordering_)
00597         {
00598                 case Nested:
00599                         ::ang2pix_nest(long(nside_), theta, phi, &pix);
00600                         break;
00601                 case Ring:
00602                         ::ang2pix_ring(long(nside_), theta, phi, &pix);
00603                         break;
00604                 default:
00605                         throw MapException(MapException::Undefined);
00606                         break;
00607         }
00608         return;
00609 }
00610 /* ----------------------------------------------------------------------------
00611 'pix2ordering' converts a pixel number for this map into a specified ordering 
00612 scheme.
00613 
00614 If either the pixel ordering of the map or the requested pixel ordering scheme
00615 is undefined, then an Undefined MapException is thrown.
00616 
00617 Arguments:
00618         ipix - The pixel number in this map's ordering scheme.
00619         dord - The desired ordering scheme.
00620 
00621 Returned:
00622         The converted pixel number.
00623 ---------------------------------------------------------------------------- */
00624 long HealpixMap::pix2ordering (long ipix, PixOrder dord)
00625 {
00626         long opix = 0;
00627         if ((dord == Undefined) || (ordering_ == Undefined))
00628                 throw MapException(MapException::Undefined);
00629         if (dord == ordering_) return ipix;
00630         switch (ordering_)
00631         {
00632                 case Nested:
00633                         ::nest2ring(long(nside_), ipix, &opix);
00634                         break;
00635                 case Ring:
00636                         ::ring2nest(long(nside_), ipix, &opix);
00637                         break;
00638                 default:
00639                         throw MapException(MapException::Undefined);
00640                         break;
00641         }
00642         return opix;
00643 }
00644 /* ----------------------------------------------------------------------------
00645 'resize' scales the map to a new nsize.
00646 
00647 If an error occurs, a MapException will be thrown.
00648 
00649 Arguments:
00650         ns - The new nsize.
00651 
00652 Returned:
00653         Nothing.
00654 ---------------------------------------------------------------------------- */
00655 void HealpixMap::resize (unsigned int ns) 
00656 {
00657         if (ordering_ == Undefined) throw MapException(MapException::Undefined);
00658         if (ns == nside_) return;
00659         if (ns > nside_) upgrade_map(ns);
00660                     else degrade_map(ns);
00661         return;
00662 }
00663 /* ----------------------------------------------------------------------------
00664 'pix2ordering' converts a pixel number for this map into a specified ordering 
00665 scheme.
00666 
00667 If either the pixel ordering of the map or the requested pixel ordering scheme
00668 is undefined, then an Undefined MapException is thrown.
00669 
00670 Arguments:
00671         ipix - The pixel number in this map's ordering scheme.
00672         dord - The desired ordering scheme.
00673 
00674 Returned:
00675         The converted pixel number.
00676 ---------------------------------------------------------------------------- */
00677 /* ----------------------------------------------------------------------------
00678 'getPixel' retrieves a pixel based upon its position angles.
00679 
00680 If the pixel ordering of the map is undefined, then an Undefined MapException
00681 is thrown or if the resultant pixel number is out of bounds.
00682 
00683 Arguments:
00684         theta - The colatitude in radians measured southward from the north pole
00685                         (0--PI).
00686         phi   - The longitude in radians measured eastward from the X-axis
00687                         (0--2PI).
00688         deg   - If nonzero the angles are in degrees instead of radians.
00689                 Defaults to 0.
00690 
00691 Returned:
00692         The pixel is returned.
00693 ---------------------------------------------------------------------------- */
00694 BasePixel& HealpixMap::getPixel (double theta, double phi, int deg)
00695 {
00696         long pix;
00697         angles2pixel(theta, phi, pix, deg);
00698         return (*this)[pix];
00699 }
00700 /* ----------------------------------------------------------------------------
00701 'getPixel' retrieves a pixel based upon its cartesian pointing vector.
00702 
00703 If the pixel ordering of the map is undefined, then an Undefined MapException
00704 is thrown or if the resultant pixel number is out of bounds.
00705 
00706 Arguments:
00707         vector - The three-element cartesian pointing vector.
00708 
00709 Returned:
00710         The pixel is returned.
00711 ---------------------------------------------------------------------------- */
00712 BasePixel& HealpixMap::getPixel (double *vector)
00713 {
00714         long pix;
00715         vector2pixel(vector, pix);
00716         return (*this)[pix];
00717 }
00718 /* ----------------------------------------------------------------------------
00719 'readFITS' fills the map from a FITS file. An exception is thrown in the event
00720 of a FITS error or if the appropriate FITS table cannot be found.  There must
00721 be a temperature column!
00722 
00723 Arguments:
00724         filename - The name of the FITS file.
00725         progwin  - A pointer to the file load progress window.
00726 
00727 Returned:
00728         Nothing.
00729 ---------------------------------------------------------------------------- */
00730 /*
00731 void HealpixMap::readFITS(const char* filename, fileProgress *progwin)
00732 {
00733         Skymap::readFITS(filename, progwin);
00734         nside_ = NPix2NSide(size());
00735         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00736 }
00737 void HealpixMap::readFITS(string filename, fileProgress *progwin)
00738 {
00739         readFITS(filename.c_str(), progwin);
00740         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00741 }
00742 void HealpixMap::readFITS(QString filename, fileProgress *progwin)
00743 {
00744         readFITS(filename.toStdString(), progwin);
00745         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00746 }
00747 */
00748 /* ----------------------------------------------------------------------------
00749 'readFITS' fills the map from a FITS file. An exception is thrown in the event
00750 of a FITS error or if the appropriate FITS table cannot be found.  There must
00751 be a temperature column!
00752 
00753 Arguments:
00754         filename - The name of the FITS file.
00755         progwin  - A pointer to the file load progress window.
00756 
00757 Returned:
00758         Nothing.
00759 ---------------------------------------------------------------------------- */
00760 void HealpixMap::readFITS(const char* filename, ControlDialog *progwin)
00761 {
00762         Skymap::readFITS(filename, progwin);
00763         nside_ = NPix2NSide(size());
00764         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00765 }
00766 void HealpixMap::readFITS(string filename, ControlDialog *progwin)
00767 {
00768         readFITS(filename.c_str(), progwin);
00769         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00770 }
00771 void HealpixMap::readFITS(QString filename, ControlDialog *progwin)
00772 {
00773         readFITS(filename.toStdString(), progwin);
00774         if (progwin != NULL) progwin->loadNSide(nside_, ordering_);
00775 }

Generated on Fri Feb 6 15:32:42 2009 for Skyviewer by  doxygen 1.4.7