[Kst] extragear/graphics/kst/kst/datasources/healpix

Ted Kisner tskisner.public at gmail.com
Tue Oct 25 08:28:45 CEST 2005


SVN commit 473965 by tskisner:

Remove all projection and gridline stuff from the healpix datasource.  This will be supported (eventually) by a renderer.

 M  +48 -57    healpix.cpp  
 M  +7 -19     healpix_source.h  
 M  +2 -2      healpix_tools_pix.cpp  


--- trunk/extragear/graphics/kst/kst/datasources/healpix/healpix.cpp #473964:473965
@@ -22,6 +22,7 @@
 
 #include <ctype.h>
 #include <stdlib.h>
+#include <kstmath.h>
  
 HealpixSource::HealpixSource(KConfig *cfg, const QString& filename, const QString& type)
 : KstDataSource(cfg, filename, type) {
@@ -46,18 +47,12 @@
     if (ret) {
       _valid = true;
       _mapNpix = 12 * _mapNside * _mapNside;
-      _projNX = 640;
-      _projNY = 480;
-      _projType = HEALPIX_PROJ_SIN;
-      //_projPhiMin = 0.69;
-      //_projThetaMin = 2.05;
-      //_projPhiMax = 2.1;
-      //_projThetaMax = 2.65;
-      _projPhiMin = 0.01;
-      _projThetaMin = 0.0;
-      _projPhiMax = 2*HEALPIX_PI;
-      _projThetaMax = HEALPIX_PI;
-      _projUnits = 0;
+      _nX = 640;
+      _nY = 480;
+      _phiMin = HEALPIX_PI+0.01;
+      _thetaMin = 0.0;
+      _phiMax = HEALPIX_PI-0.01;
+      _thetaMax = HEALPIX_PI;
       
       // populate the metadata
       QString metaVal;
@@ -128,8 +123,10 @@
         }
         _matrixList.append(mapName);
       }
-      _fieldList.append("GRID - X Coordinates");
-      _fieldList.append("GRID - Y Coordinates");
+      _fieldList.append("Vector Field Head X");
+      _fieldList.append("Vector Field Head Y");
+      _fieldList.append("Vector Field Tail X");
+      _fieldList.append("Vector Field Tail Y");
     } else {
       healpix_keys_free(_keys);
       healpix_strarr_free(_names, HEALPIX_FITS_MAXCOL);
@@ -200,22 +197,22 @@
     int nnull;
 
     // check range
-    if ((xStart >= _projNX) || (yStart >= _projNY)) {
+    if ((xStart >= _nX) || (yStart >= _nY)) {
       return -1;
     }
     int nxread = xNumSteps;
     if (nxread < 0) {
       nxread = 1;
     }
-    if (xStart + nxread > _projNX) {
-      nxread = _projNX - xStart;
+    if (xStart + nxread > _nX) {
+      nxread = _nX - xStart;
     } 
     int nyread = yNumSteps;
     if (nyread < 0) {
       nyread = 1;
     }
-    if (yStart + nyread > _projNY) {
-      nyread = _projNY - yStart;
+    if (yStart + nyread > _nY) {
+      nyread = _nY - yStart;
     } 
     
     if (_mapType == HEALPIX_FITS_CUT) {
@@ -242,6 +239,7 @@
       fits_close_file(fp, &ret);
       return -1;
     }
+    //kstdDebug() << "HEALPIX readMatrix nrows = " << nrows << endl;
     
     mapdata = (float*)calloc(_mapNpix, sizeof(float));
     //initialize data to HEALPIX_NULL
@@ -295,52 +293,43 @@
       
     }
     
-    // Project sphere data onto matrix, given the projection
-    // parameters.
+    // copy sphere data to matrix.
     
-    data->xMin = _projPhiMin;
-    data->yMin = _projThetaMax;
-    
-    if (_projUnits == 0) { // radians
-      data->yStepSize = (_projThetaMax - _projThetaMin)/(double)_projNY;
+    //data->xMin = _phiMin;
+    //data->yMin = _thetaMax;
+    //FIXME
+    // temporarily return data in bastardized RA/DEC, 
+    // since kst cannot yet handle max < min.  Change this
+    // once kst2drenderer is implemented
+    if (_phiMin > _phiMax) {
+      data->xMin = -((2.0*HEALPIX_PI - _phiMin)/HEALPIX_PI) * 180.0;
+      data->xStepSize = ((_phiMax + (2.0*HEALPIX_PI-_phiMin))/HEALPIX_PI) * 180.0/(double)_nX;
+    } else {
+      data->xMin = (_phiMin/HEALPIX_PI) * 180.0;
+      data->xStepSize = ((_phiMax - _phiMin)/HEALPIX_PI) * 180.0/(double)_nX;
     }
-    data->xStepSize = 1.0;
+    data->yMin = 90.0 - (_thetaMax/HEALPIX_PI) * 180.0;
+    data->yStepSize = ((_thetaMax - _thetaMin)/HEALPIX_PI) * 180.0/(double)_nY;
     
     
-    
-    
     double theta, phi;
     size_t ppix;
     
     // set the matrix to NULL
     for (int i = 0; i < nxread*nyread; i++) {
-      data->z[i] = HEALPIX_NULL;
+      data->z[i] = NAN;
     }
     
-    if (_projType == HEALPIX_PROJ_CAR) {
-      for (int i = xStart; i < nxread; i++) {
-        for (int j = yStart; j < nyread; j++) {
-          healpix_proj_rev_car(_projThetaMin, _projThetaMax, _projPhiMin, _projPhiMax, (double)_projNX, (double)_projNY, (double)i, (double)j, &theta, &phi);
-          if ((!healpix_is_dnull(theta)) && (!healpix_is_dnull(phi))) { 
-            if (_mapOrder == HEALPIX_RING) {
-              healpix_ang2pix_ring(_mapNside, theta, phi, &ppix);
-            } else {
-              healpix_ang2pix_nest(_mapNside, theta, phi, &ppix);
-            }
-            data->z[i*nyread+j] = mapdata[ppix];
+    for (int i = xStart; i < nxread; i++) {
+      for (int j = yStart; j < nyread; j++) {
+        healpix_proj_rev_car(_thetaMin, _thetaMax, _phiMin, _phiMax, (double)_nX, (double)_nY, (double)i, (double)j, &theta, &phi);
+        if ((!healpix_is_dnull(theta)) && (!healpix_is_dnull(phi))) { 
+          if (_mapOrder == HEALPIX_RING) {
+            healpix_ang2pix_ring(_mapNside, theta, phi, &ppix);
+          } else {
+            healpix_ang2pix_nest(_mapNside, theta, phi, &ppix);
           }
-        }
-      }
-    } else {
-      for (int i = xStart; i < nxread; i++) {
-        for (int j = yStart; j < nyread; j++) {
-          healpix_proj_rev_sin(_projThetaMin, _projThetaMax, _projPhiMin, _projPhiMax, (double)_projNX, (double)_projNY, (double)i, (double)j, &theta, &phi);
-          if ((!healpix_is_dnull(theta)) && (!healpix_is_dnull(phi))) { 
-            if (_mapOrder == HEALPIX_RING) {
-              healpix_ang2pix_ring(_mapNside, theta, phi, &ppix);
-            } else {
-              healpix_ang2pix_nest(_mapNside, theta, phi, &ppix);
-            }
+          if (!healpix_is_fnull(mapdata[ppix])) {
             data->z[i*nyread+j] = mapdata[ppix];
           }
         }
@@ -384,8 +373,8 @@
 {
   Q_UNUSED(matrix)
   if (_valid) {
-    (*xDim) = _projNX;
-    (*yDim) = _projNY;
+    (*xDim) = _nX;
+    (*yDim) = _nY;
     return true;
   }
   return false;
@@ -550,8 +539,10 @@
   ret = healpix_fits_map_test(thealpixfile, &tNside, &tOrder, &tCoord, &tType, &tMaps);
   
   if (ret) {
-    fields.append("GRID - X Coordinates");
-    fields.append("GRID - Y Coordinates");
+    fields.append("Vector Field Head X");
+    fields.append("Vector Field Head Y");
+    fields.append("Vector Field Tail X");
+    fields.append("Vector Field Tail Y");
   } else {
     return QStringList();
   }
--- trunk/extragear/graphics/kst/kst/datasources/healpix/healpix_source.h #473964:473965
@@ -64,27 +64,15 @@
     char **_names;
     char **_units;
     
-    /* projection options */
-    int _projType;
-    int _projNX;
-    int _projNY;
-    double _projThetaMin;
-    double _projPhiMin;
-    double _projThetaMax;
-    double _projPhiMax;
-    // Units choices are:
-    // 0 : (theta, phi) in Radians
-    // 1 : (theta, phi) in Degrees
-    // 2 : (lat, long) in Degrees
-    // 3 : (RA, DEC) in Degrees
-    int _projUnits;
+    /* data range */
+    int _nX;
+    int _nY;
+    double _thetaMin;
+    double _phiMin;
+    double _thetaMax;
+    double _phiMax;
     
-    /* grid lines */
-    double _gridXspace;
-    double _gridYspace;
-    
     /* vector field */
-    int _vecType;
     int _vecDegrade;
     int _vecComp1;
     int _vecComp2;
--- trunk/extragear/graphics/kst/kst/datasources/healpix/healpix_tools_pix.cpp #473964:473965
@@ -764,12 +764,12 @@
   if ((ix > 0)&&(ix < (int)nsm1)&&(iy > 0)&&(iy < (int)nsm1)) {
     if (ordering == HEALPIX_RING) {
       for (i = 0; i < 8; i++) {
-        err = healpix_xyf2ring(nside, (size_t)(ix + xoffset[i]), (size_t)(iy+xoffset[i]), face, &ptemp);
+        err = healpix_xyf2ring(nside, (size_t)(ix + xoffset[i]), (size_t)(iy+yoffset[i]), face, &ptemp);
         parray[i] = ptemp;
       }
     } else {
       for (i = 0; i < 8; i++) {
-        err = healpix_xyf2nest(nside, (size_t)(ix + xoffset[i]), (size_t)(iy+xoffset[i]), face, &ptemp);
+        err = healpix_xyf2nest(nside, (size_t)(ix + xoffset[i]), (size_t)(iy+yoffset[i]), face, &ptemp);
         parray[i] = ptemp;
       }
     }


More information about the Kst mailing list