Changeset 1510 for trunk/src


Ignore:
Timestamp:
02/18/09 15:15:57 (16 years ago)
Author:
Malte Marquarding
Message:

Ticket #110: export velocity if restfreq is given otherwise frequency. add elevattion,azimuth etc to FITS header

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/STFITSImageWriter.cpp

    r1500 r1510  
    190190      throw(AipsError(errMsg));
    191191    }
     192   
     193    int status = 0;
     194    fitsfile *fptr;     
     195    if( fits_open_file(&fptr, fileName.c_str(), READWRITE, &status) )
     196      throw AipsError("Coudn't open fits file for modification");
     197
    192198    if (isClass_) {
    193199      // Add CLASS specific information
     
    196202      // CTYPE1 :  FREQ-XYZ -> FREQ
    197203      // 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 
     204     
    203205      // Use preferVelocity which seems to work.
    204206      // When no restfrequency is given this will set up the correct
    205207      // 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");       
     208      char ctyp[84];
     209      fits_read_key(fptr, TSTRING, "CTYPE1", ctyp, NULL, &status);
     210      if (String(ctyp).contains("FREQ", 0)) {
     211        float restf,refval;
     212        fits_read_key(fptr, TFLOAT, "CRVAL1",
     213                      &refval, NULL, &status);
     214        restf = 0.0;
     215        if ( fits_update_key(fptr, TFLOAT, "CRVAL1", &restf,
     216                             NULL, &status) ) {
     217          throw AipsError("Couldn't modify CRVAL1");       
     218        }
     219        if ( fits_update_key(fptr, TFLOAT, "RESTFREQ", &refval,
     220                             NULL, &status) ) {
     221          throw AipsError("Couldn't modify RESTFREQ");       
     222        }
     223      } else {
     224        float refval = sC.referenceValue()[0];
     225        if ( fits_update_key(fptr, TFLOAT, "RESTFREQ", &refval,
     226                             NULL, &status) ) {
     227          throw AipsError("Couldn't modify RESTFREQ");       
     228        }
     229       
    223230      }
    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);
    236     }
     231    }
     232
     233    Float tsys = stable.getTsys(row0);
     234    if ( fits_update_key(fptr, TFLOAT, "TSYS", &tsys,
     235                         "System temperature", &status) ) {
     236      throw AipsError("Couldn't modify TSYS");       
     237    }
     238    Float otime = Float(stable.getIntTime(row0));
     239    if ( fits_update_key(fptr, TFLOAT, "OBSTIME", &otime,
     240                         "Integration time", &status) ) {
     241      throw AipsError("Couldn't modify OBSTIME");       
     242    }
     243   
     244    const char* oname = stable.getSourceName(row0).c_str();
     245    if ( fits_update_key(fptr, TSTRING, "OBJECT", (char *)oname,
     246                         NULL, &status) ) {
     247      throw AipsError("Couldn't modify OBJECT");       
     248    }
     249    Float elev = stable.getElevation(row0)/C::pi*180.0;
     250    if ( fits_update_key(fptr, TFLOAT, "ELEVATIO", &elev,
     251                         "Telescope elevation (degrees)", &status) ) {
     252      throw AipsError("Couldn't modify ELEVATIO");       
     253    }
     254    Float azi = stable.getAzimuth(row0)/C::pi*180.0;
     255    if ( fits_update_key(fptr, TFLOAT, "AZIMUTH", &azi,
     256                         "Telescope azimuth (degrees)", &status) ) {
     257      throw AipsError("Couldn't modify AZIMUTH");       
     258    }
     259    fits_close_file(fptr, &status);
     260 
    237261    //pushLog(String(oss));
    238262    ++iter;
Note: See TracChangeset for help on using the changeset viewer.