[Kst] kdeextragear-2/kst/kst/datasources/lfiio

Andrew Walker arwalker at sumusltd.com
Sat Nov 20 00:08:25 CET 2004


CVS commit by arwalker: 

Modified so that we can understand an implicitly defined time vector within an LFI FITS file.

Please let me know if anyone has any concerns with these changes, but I think its important to get this in for 1.0


  M +40 -1     lfiio.cpp   1.14
  M +3 -0      lfiio.h   1.8


--- kdeextragear-2/kst/kst/datasources/lfiio/lfiio.cpp  #1.13:1.14
@@ -24,4 +24,6 @@
 #include <stdlib.h>
 
+#define TIME_FIELD  "TIME"
+
 LFIIOSource::LFIIOSource( KConfig *cfg, const QString& filename, const QString& type )
 : KstDataSource( cfg, filename, type )
@@ -99,4 +101,5 @@ KstObject::UpdateType LFIIOSource::updat
 
           _valid = true;
+          _bHasTime = false;
 
           //
@@ -131,4 +134,28 @@ KstObject::UpdateType LFIIOSource::updat
           }
 
+          //
+          // check if we have a time field defined by the header keys TIMEZERO and DELTA_T.
+          //  If so then we create a new field called $TIME_FIELD, unless such a field already
+          //  exists, in which case we do nothing...
+          //
+          char charTimeZero[] = "TIMEZERO";
+
+          iStatus = 0;
+          iResult = fits_read_key( ffits, TDOUBLE, charTimeZero, &_dTimeZero, 0L, &iStatus );
+          if( iResult == 0 )
+          {
+            char charTimeDelta[] = "DELTA_T";
+
+            iResult = fits_read_key( ffits, TDOUBLE, charTimeDelta, &_dTimeDelta, 0L, &iStatus );
+            if( iResult == 0 )
+            {
+              if( _fieldList.find( QString( TIME_FIELD ) ) == _fieldList.end( ) )
+              {
+                _bHasTime = true;
+                _fieldList.append( TIME_FIELD );
+              }
+            }
+          }
+          
           if( lNumFrames * lMaxRepeat != _numFrames )
           {
@@ -175,4 +202,12 @@ int LFIIOSource::readField( double *v, c
     iRead =  n;
   }
+  else if( _bHasTime && field == TIME_FIELD )
+  {
+    for( i = 0; i < n; i++ )
+    {
+      v[i] = _dTimeZero + ( (double)( s + i ) * _dTimeDelta );
+    }
+    iRead =  n;    
+  }
   else
   {
@@ -268,4 +303,8 @@ bool LFIIOSource::isValidField( const QS
     bRetVal = true;
   }
+  else if( field == TIME_FIELD && _bHasTime )
+  {
+    bRetVal = true;
+  }
   else
   {

--- kdeextragear-2/kst/kst/datasources/lfiio/lfiio.h  #1.7:1.8
@@ -40,4 +40,7 @@ class LFIIOSource : public KstDataSource
     bool getColNumber(const QString& field, int* piColNumber) const;
 
+    double _dTimeZero;
+    double _dTimeDelta;
+    bool _bHasTime;
     int _numFrames;
     int _numCols;





More information about the Kst mailing list