[Kst] extragear/graphics/kst/kst/datasources/healpix
Ted Kisner
tskisner.public at gmail.com
Wed Nov 2 02:18:16 CET 2005
SVN commit 476780 by tskisner:
Modify slightly the numbering of fields. Also allow using fields named 1, 2, 3, etc that specify the field number. This is required for supporting commandline loading of healpix FITS files. You can now do things like: kst -M 1 healpix.fits.
M +56 -16 healpix.cpp
--- trunk/extragear/graphics/kst/kst/datasources/healpix/healpix.cpp #476779:476780
@@ -123,9 +123,9 @@
QString mapName;
for (size_t i = 0; i < _nMaps; i++) {
if (strlen(_names[i+poff]) == 0) {
- mapName.sprintf("%d - %s",(int)i,"MAP");
+ mapName.sprintf("%d - %s",(int)(i+1),"MAP");
} else {
- mapName.sprintf("%d - %s",(int)i,_names[i+poff]);
+ mapName.sprintf("%d - %s",(int)(i+1),_names[i+poff]);
}
if (strlen(_units[i+poff]) == 0) {
mapName.sprintf("%s (%s)",mapName.ascii(),"Unknown Units");
@@ -153,10 +153,10 @@
}
_matrixList.append(mapName);
}
- _fieldList.append("Vector Field Head Theta");
- _fieldList.append("Vector Field Head Phi");
- _fieldList.append("Vector Field Tail Theta");
- _fieldList.append("Vector Field Tail Phi");
+ _fieldList.append("1 - Vector Field Head Theta");
+ _fieldList.append("2 - Vector Field Head Phi");
+ _fieldList.append("3 - Vector Field Tail Theta");
+ _fieldList.append("4 - Vector Field Tail Phi");
} else {
healpix_keys_free(_keys);
healpix_strarr_free(_names, HEALPIX_FITS_MAXCOL);
@@ -194,7 +194,7 @@
int HealpixSource::readField(double *v, const QString& field, int s, int n) {
Q_UNUSED(s)
- if (_valid && _fieldList.contains(field)) {
+ if (_valid && isValidField(field)) {
fitsfile *fp;
int coltheta;
int colphi;
@@ -215,9 +215,16 @@
int nnull;
size_t vecNside;
size_t temppix;
- int fieldnum = _fieldList.findIndex(field);
+ int fieldnum;
double theta, phi;
long nearest[8];
+
+ if (_fieldList.contains(field)) {
+ fieldnum = _fieldList.findIndex(field);
+ } else {
+ fieldnum = field.toInt();
+ fieldnum--;
+ }
// check range
if (n <= 0) {
@@ -516,7 +523,7 @@
// have all the header information- no need to read it again.
// We also know that the matrix index is not out-of-range.
- if (_valid && _matrixList.contains(matrix)) {
+ if (_valid && isValidMatrix(matrix)) {
fitsfile *fp;
int colnum;
int fieldnum = _matrixList.findIndex(matrix);
@@ -532,6 +539,13 @@
float *mapdata;
float nullval;
int nnull;
+
+ if (_matrixList.contains(matrix)) {
+ fieldnum = _matrixList.findIndex(matrix);
+ } else {
+ fieldnum = matrix.toInt();
+ fieldnum--;
+ }
// check range
if ((xStart >= _nX) || (yStart >= _nY)) {
@@ -800,11 +814,37 @@
}
bool HealpixSource::isValidField(const QString& field) const {
+ // need to allow for referencing fields by number, so
+ // that command line options work.
+ if (_fieldList.contains(field)) {
+ return true;
+ } else {
+ bool ok = false;
+ int num = field.toInt(&ok);
+ if (ok && num <= (int)_fieldList.count() && num != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
return _fieldList.contains(field);
}
bool HealpixSource::isValidMatrix(const QString& field) const {
- return _matrixList.contains(field);
+ // need to allow for referencing fields by number, so
+ // that command line options work.
+ if (_matrixList.contains(field)) {
+ return true;
+ } else {
+ bool ok = false;
+ int num = field.toInt(&ok);
+ if (ok && num <= (int)_matrixList.count() && num != 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }
}
int HealpixSource::samplesPerFrame(const QString &field) {
@@ -1297,9 +1337,9 @@
if (ret) {
for (size_t i = 0; i < tMaps; i++) {
if (strlen(names[i+poff]) == 0) {
- mapName.sprintf("%d - %s",(int)i,"MAP");
+ mapName.sprintf("%d - %s",(int)(i+1),"MAP");
} else {
- mapName.sprintf("%d - %s",(int)i,names[i+poff]);
+ mapName.sprintf("%d - %s",(int)(i+1),names[i+poff]);
}
if (strlen(units[i+poff]) == 0) {
mapName.sprintf("%s (%s)",mapName.ascii(),"Unknown Units");
@@ -1365,10 +1405,10 @@
ret = healpix_fits_map_test(thealpixfile, &tNside, &tOrder, &tCoord, &tType, &tMaps);
if (ret) {
- fields.append("Vector Field Head Theta");
- fields.append("Vector Field Head Phi");
- fields.append("Vector Field Tail Theta");
- fields.append("Vector Field Tail Phi");
+ fields.append("1 - Vector Field Head Theta");
+ fields.append("2 - Vector Field Head Phi");
+ fields.append("3 - Vector Field Tail Theta");
+ fields.append("4 - Vector Field Tail Phi");
} else {
return QStringList();
}
More information about the Kst
mailing list