Changeset 1500 for trunk


Ignore:
Timestamp:
02/10/09 13:17:31 (16 years ago)
Author:
Malte Marquarding
Message:

Fix for ticket #110. Hopefully the last. Using the preferVelocity option in ImageToFITS, which will output a elocity axis if a restfrequency is given, otherwise it will set up a frequency axis hwich looks the same in CLASS and asap

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFITSImageWriter.cpp

    r1476 r1500  
    179179    latMask.putSlice(!bflag, where, stride);
    180180    tIm.attachMask(latMask);
     181    if (isClass_) {
     182      preferVelocity = True;
     183    }
    181184    Bool ok = ImageFITSConverter::ImageToFITS(errMsg, tIm, fileName,
    182185                                              maxMem, preferVelocity,
     
    188191    }
    189192    if (isClass_) {
    190       classHackHeader(fileName);
     193      // Add CLASS specific information
     194      // Apply hacks to fits file so it can be read by class
     195      // modifications are
     196      // CTYPE1 :  FREQ-XYZ -> FREQ
     197      // CRVAL1 :  -> CRVAL1-RESTFREQ
     198      int status = 0;
     199      fitsfile *fptr;     
     200      if( fits_open_file(&fptr, fileName.c_str(), READWRITE, &status) )
     201        throw AipsError("Coudn't open fits file for CLASS modification");
     202
     203      // Use preferVelocity which seems to work.
     204      // When no restfrequency is given this will set up the correct
     205      // frequency axis. Otherwise it uses a velocity axis
     206      //       if ( fits_update_key(fptr, TSTRING, "CTYPE1", (char *)"FREQ",
     207      //                            NULL, &status) )
     208      //         throw AipsError("Couldn't modify CTYPE1.");
     209      //       float restf,refval,newfreq;
     210      //       fits_read_key(fptr, TFLOAT, "CRVAL1",
     211      //                     &refval, NULL, &status);
     212      //       fits_read_key(fptr, TFLOAT, "RESTFREQ",
     213      //                     &restf, NULL, &status);
     214      //       newfreq = refval - restf;
     215      //       if ( fits_update_key(fptr, TFLOAT, "CRVAL1", &newfreq,  NULL, &status) )
     216      //         throw AipsError("Couldn't modify CRVAL1");
     217
     218
     219      Float tsys = stable.getTsys(row0);
     220      if ( fits_update_key(fptr, TFLOAT, "TSYS", &tsys,
     221                           "System temperature", &status) ) {
     222        throw AipsError("Couldn't modify TSYS");       
     223      }
     224      Float otime = Float(stable.getIntTime(row0));
     225      if ( fits_update_key(fptr, TFLOAT, "OBSTIME", &otime,
     226                           "Integration time", &status) ) {
     227        throw AipsError("Couldn't modify OBSTIME");       
     228      }
     229
     230      const char* oname = stable.getSourceName(row0).c_str();
     231      if ( fits_update_key(fptr, TSTRING, "OBJECT", (char *)oname,
     232                           NULL, &status) ) {
     233        throw AipsError("Couldn't modify OBJECT");       
     234      }
     235      fits_close_file(fptr, &status);
    191236    }
    192237    //pushLog(String(oss));
     
    216261}
    217262
    218 void STFITSImageWriter::classHackHeader(const String& filename) {
    219   int status = 0;
    220   fitsfile *fptr;     
    221   if( fits_open_file(&fptr, filename.c_str(), READWRITE, &status) )
    222     throw AipsError("FCoudn't open fits file for CLASS modification");
    223 
    224   if ( fits_update_key(fptr, TSTRING, "CTYPE1", (char *)"FREQ",
    225                        NULL, &status) )
    226     throw AipsError("Couldn't modify CTYPE1.");
    227   float restf,refval,newfreq;
    228   fits_read_key(fptr, TFLOAT, "CRVAL1",
    229                 &refval, NULL, &status);
    230   fits_read_key(fptr, TFLOAT, "RESTFREQ",
    231                 &restf, NULL, &status);
    232   newfreq = refval - restf;
    233   if ( fits_update_key(fptr, TFLOAT, "CRVAL1", &newfreq,  NULL, &status) )
    234     throw AipsError("Couldn't modify CRVAL1");
    235   fits_close_file(fptr, &status);
    236 
    237 }
  • trunk/src/STFITSImageWriter.h

    r1444 r1500  
    6161                                                   casa::Double lon,
    6262                                                   casa::Double lat);
    63   // Apply hacks to fits file so it can be read by class
    64   // modifications are
    65   // CTYPE1 :  FREQ-XYZ -> FREQ
    66   // CRVAL1 :  -> CRVAL1-RESTFREQ
    67   void classHackHeader(const casa::String& filename);
    6863
    6964  casa::Bool isClass_;
Note: See TracChangeset for help on using the changeset viewer.