IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 5, 2006, 5:44:26 PM (20 years ago)
Author:
eugene
Message:

big move: fits_ to gfits_; minor updates to relphot

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/libdvo/src/coordops.c

    r6678 r7080  
    312312 
    313313  status = FALSE;
    314   if (fits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
    315     status  = fits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
    316     status &= fits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);
    317     status &= fits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
    318     status &= fits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);
    319 
    320     if (fits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {
    321       status &= fits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
    322       if (fits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
     314  if (gfits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
     315    status  = gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
     316    status &= gfits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);
     317    status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
     318    status &= gfits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);
     319
     320    if (gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {
     321      status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
     322      if (gfits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
    323323        Lambda = coords[0].cdelt2 / coords[0].cdelt1;
    324324        coords[0].pc1_1 =  cos(rotate*RAD_DEG);
     
    327327        coords[0].pc2_2 =  cos(rotate*RAD_DEG);
    328328      }
    329       if (fits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {
    330         status &= fits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);
    331         status &= fits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);
    332         status &= fits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);
     329      if (gfits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {
     330        status &= gfits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);
     331        status &= gfits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);
     332        status &= gfits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);
    333333      }
    334334
     
    337337
    338338      if (Polynomial) {
    339         if (fits_scan (header, "NPLYTERM", "%d", 1, &itmp)) {
     339        if (gfits_scan (header, "NPLYTERM", "%d", 1, &itmp)) {
    340340          coords[0].Npolyterms = itmp;
    341341        } else {
     
    344344        switch (coords[0].Npolyterms) {
    345345          case 3:
    346             status &= fits_scan (header, "PCA1X3Y0", "%f", 1, &coords[0].polyterms[3][0]);
    347             status &= fits_scan (header, "PCA1X2Y1", "%f", 1, &coords[0].polyterms[4][0]);
    348             status &= fits_scan (header, "PCA1X1Y2", "%f", 1, &coords[0].polyterms[5][0]);
    349             status &= fits_scan (header, "PCA1X0Y3", "%f", 1, &coords[0].polyterms[6][0]);
    350             status &= fits_scan (header, "PCA2X3Y0", "%f", 1, &coords[0].polyterms[3][1]);
    351             status &= fits_scan (header, "PCA2X2Y1", "%f", 1, &coords[0].polyterms[4][1]);
    352             status &= fits_scan (header, "PCA2X1Y2", "%f", 1, &coords[0].polyterms[5][1]);
    353             status &= fits_scan (header, "PCA2X0Y3", "%f", 1, &coords[0].polyterms[6][1]);
     346            status &= gfits_scan (header, "PCA1X3Y0", "%f", 1, &coords[0].polyterms[3][0]);
     347            status &= gfits_scan (header, "PCA1X2Y1", "%f", 1, &coords[0].polyterms[4][0]);
     348            status &= gfits_scan (header, "PCA1X1Y2", "%f", 1, &coords[0].polyterms[5][0]);
     349            status &= gfits_scan (header, "PCA1X0Y3", "%f", 1, &coords[0].polyterms[6][0]);
     350            status &= gfits_scan (header, "PCA2X3Y0", "%f", 1, &coords[0].polyterms[3][1]);
     351            status &= gfits_scan (header, "PCA2X2Y1", "%f", 1, &coords[0].polyterms[4][1]);
     352            status &= gfits_scan (header, "PCA2X1Y2", "%f", 1, &coords[0].polyterms[5][1]);
     353            status &= gfits_scan (header, "PCA2X0Y3", "%f", 1, &coords[0].polyterms[6][1]);
    354354          case 2:
    355             status &= fits_scan (header, "PCA1X2Y0", "%f", 1, &coords[0].polyterms[0][0]);
    356             status &= fits_scan (header, "PCA1X1Y1", "%f", 1, &coords[0].polyterms[1][0]);
    357             status &= fits_scan (header, "PCA1X0Y2", "%f", 1, &coords[0].polyterms[2][0]);
    358             status &= fits_scan (header, "PCA2X2Y0", "%f", 1, &coords[0].polyterms[0][1]);
    359             status &= fits_scan (header, "PCA2X1Y1", "%f", 1, &coords[0].polyterms[1][1]);
    360             status &= fits_scan (header, "PCA2X0Y2", "%f", 1, &coords[0].polyterms[2][1]);
     355            status &= gfits_scan (header, "PCA1X2Y0", "%f", 1, &coords[0].polyterms[0][0]);
     356            status &= gfits_scan (header, "PCA1X1Y1", "%f", 1, &coords[0].polyterms[1][0]);
     357            status &= gfits_scan (header, "PCA1X0Y2", "%f", 1, &coords[0].polyterms[2][0]);
     358            status &= gfits_scan (header, "PCA2X2Y0", "%f", 1, &coords[0].polyterms[0][1]);
     359            status &= gfits_scan (header, "PCA2X1Y1", "%f", 1, &coords[0].polyterms[1][1]);
     360            status &= gfits_scan (header, "PCA2X0Y2", "%f", 1, &coords[0].polyterms[2][1]);
    361361          case 0:
    362362          case 1:
     
    365365      }
    366366    } else {
    367       if (fits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {
    368         status &= fits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
    369         status &= fits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
    370         status &= fits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
     367      if (gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {
     368        status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
     369        status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
     370        status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
    371371        /* renormalize */
    372372        scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
     
    382382  } else {
    383383    /* some of my thesis data uses this simple linear model - convert on read? */
    384     if (fits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
    385       status  = fits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
    386       status &= fits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);
    387       status &= fits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2); 
    388       status &= fits_scan (header, "DEC_X", "%f", 1, &coords[0].pc2_1);
    389       status &= fits_scan (header, "DEC_Y", "%f", 1, &coords[0].pc2_2);
     384    if (gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
     385      status  = gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
     386      status &= gfits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);
     387      status &= gfits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2); 
     388      status &= gfits_scan (header, "DEC_X", "%f", 1, &coords[0].pc2_1);
     389      status &= gfits_scan (header, "DEC_Y", "%f", 1, &coords[0].pc2_2);
    390390      coords[0].crpix1 = coords[0].crpix2 = 0.0;
    391391      coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
     
    394394  }
    395395  if (status) {
    396     if (!fits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {
    397       if (!fits_scan (header, "EPOCH", "%lf", 1, &equinox)) {
     396    if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {
     397      if (!gfits_scan (header, "EPOCH", "%lf", 1, &equinox)) {
    398398        equinox = 2000.0;
    399399      }
     
    422422  /* modifications to the ctype? */
    423423  OldAIPS = FALSE;
    424   fits_modify (header, "CTYPE2",   "%s",  1, coords[0].ctype);
     424  gfits_modify (header, "CTYPE2",   "%s",  1, coords[0].ctype);
    425425  if (!strcmp(coords[0].ctype, "MM")) {
    426     fits_modify (header, "CTYPE1",   "%s",  1, "LL");
     426    gfits_modify (header, "CTYPE1",   "%s",  1, "LL");
    427427    OldAIPS = TRUE;
    428428  } else {
     
    435435    if (!strcmp (csys, "NONE")) return (FALSE);
    436436    sprintf (ctype, "%s-%s", csys, &coords[0].ctype[5]);
    437     fits_modify (header, "CTYPE1",   "%s",  1, ctype);
     437    gfits_modify (header, "CTYPE1",   "%s",  1, ctype);
    438438  }   
    439439
    440   fits_modify (header, "CDELT1",   "%le", 1, coords[0].cdelt1);
    441   fits_modify (header, "CDELT2",   "%le", 1, coords[0].cdelt2);
    442   fits_modify (header, "CRVAL1",   "%lf", 1, coords[0].crval1);
    443   fits_modify (header, "CRVAL2",   "%lf", 1, coords[0].crval2); 
    444   fits_modify (header, "CRPIX1",   "%lf", 1, coords[0].crpix1);
    445   fits_modify (header, "CRPIX2",   "%lf", 1, coords[0].crpix2);
     440  gfits_modify (header, "CDELT1",   "%le", 1, coords[0].cdelt1);
     441  gfits_modify (header, "CDELT2",   "%le", 1, coords[0].cdelt2);
     442  gfits_modify (header, "CRVAL1",   "%lf", 1, coords[0].crval1);
     443  gfits_modify (header, "CRVAL2",   "%lf", 1, coords[0].crval2); 
     444  gfits_modify (header, "CRPIX1",   "%lf", 1, coords[0].crpix1);
     445  gfits_modify (header, "CRPIX2",   "%lf", 1, coords[0].crpix2);
    446446
    447447  if (OldAIPS) {
    448448    Lambda = coords[0].cdelt2 / coords[0].cdelt1;
    449449    rotate = DEG_RAD*atan2 (coords[0].pc2_1*Lambda, coords[0].pc1_1);
    450     fits_modify (header, "CROTA1", "%f", 1, rotate);
    451     fits_modify (header, "CROTA2", "%f", 1, rotate);
     450    gfits_modify (header, "CROTA1", "%f", 1, rotate);
     451    gfits_modify (header, "CROTA2", "%f", 1, rotate);
    452452    return (TRUE);
    453453  }
    454454
    455   fits_modify (header, "PC001001", "%le", 1, coords[0].pc1_1);
    456   fits_modify (header, "PC001002", "%le", 1, coords[0].pc1_2);
    457   fits_modify (header, "PC002001", "%le", 1, coords[0].pc2_1);
    458   fits_modify (header, "PC002002", "%le", 1, coords[0].pc2_2);
    459   fits_modify (header, "NPLYTERM", "%d",  1, coords[0].Npolyterms);
     455  gfits_modify (header, "PC001001", "%le", 1, coords[0].pc1_1);
     456  gfits_modify (header, "PC001002", "%le", 1, coords[0].pc1_2);
     457  gfits_modify (header, "PC002001", "%le", 1, coords[0].pc2_1);
     458  gfits_modify (header, "PC002002", "%le", 1, coords[0].pc2_2);
     459  gfits_modify (header, "NPLYTERM", "%d",  1, coords[0].Npolyterms);
    460460
    461461  /* RA Terms */
    462462  if (coords[0].Npolyterms > 1) {
    463     fits_modify (header, "PCA1X2Y0", "%le", 1, coords[0].polyterms[0][0]);   /* polyterms[0]); */
    464     fits_modify (header, "PCA1X1Y1", "%le", 1, coords[0].polyterms[1][0]);   /* polyterms[1]); */
    465     fits_modify (header, "PCA1X0Y2", "%le", 1, coords[0].polyterms[2][0]);   /* polyterms[2]); */
     463    gfits_modify (header, "PCA1X2Y0", "%le", 1, coords[0].polyterms[0][0]);   /* polyterms[0]); */
     464    gfits_modify (header, "PCA1X1Y1", "%le", 1, coords[0].polyterms[1][0]);   /* polyterms[1]); */
     465    gfits_modify (header, "PCA1X0Y2", "%le", 1, coords[0].polyterms[2][0]);   /* polyterms[2]); */
    466466  }
    467467  if (coords[0].Npolyterms > 2) {
    468     fits_modify (header, "PCA1X3Y0", "%le", 1, coords[0].polyterms[3][0]);   /* polyterms[3]); */
    469     fits_modify (header, "PCA1X2Y1", "%le", 1, coords[0].polyterms[4][0]);   /* polyterms[4]); */
    470     fits_modify (header, "PCA1X1Y2", "%le", 1, coords[0].polyterms[5][0]);   /* polyterms[5]); */
    471     fits_modify (header, "PCA1X0Y3", "%le", 1, coords[0].polyterms[6][0]);   /* polyterms[6]); */
     468    gfits_modify (header, "PCA1X3Y0", "%le", 1, coords[0].polyterms[3][0]);   /* polyterms[3]); */
     469    gfits_modify (header, "PCA1X2Y1", "%le", 1, coords[0].polyterms[4][0]);   /* polyterms[4]); */
     470    gfits_modify (header, "PCA1X1Y2", "%le", 1, coords[0].polyterms[5][0]);   /* polyterms[5]); */
     471    gfits_modify (header, "PCA1X0Y3", "%le", 1, coords[0].polyterms[6][0]);   /* polyterms[6]); */
    472472  }
    473473
    474474  /* Dec Terms */
    475475  if (coords[0].Npolyterms > 1) {
    476     fits_modify (header, "PCA2X2Y0", "%le", 1, coords[0].polyterms[0][1]);   /* polyterms[7]); */
    477     fits_modify (header, "PCA2X1Y1", "%le", 1, coords[0].polyterms[1][1]);   /* polyterms[8]); */
    478     fits_modify (header, "PCA2X0Y2", "%le", 1, coords[0].polyterms[2][1]);   /* polyterms[9]); */
     476    gfits_modify (header, "PCA2X2Y0", "%le", 1, coords[0].polyterms[0][1]);   /* polyterms[7]); */
     477    gfits_modify (header, "PCA2X1Y1", "%le", 1, coords[0].polyterms[1][1]);   /* polyterms[8]); */
     478    gfits_modify (header, "PCA2X0Y2", "%le", 1, coords[0].polyterms[2][1]);   /* polyterms[9]); */
    479479  }
    480480  if (coords[0].Npolyterms > 2) {
    481     fits_modify (header, "PCA2X3Y0", "%le", 1, coords[0].polyterms[3][1]);   /* polyterms[10]); */
    482     fits_modify (header, "PCA2X2Y1", "%le", 1, coords[0].polyterms[4][1]);   /* polyterms[11]); */
    483     fits_modify (header, "PCA2X1Y2", "%le", 1, coords[0].polyterms[5][1]);   /* polyterms[12]); */
    484     fits_modify (header, "PCA2X0Y3", "%le", 1, coords[0].polyterms[6][1]);   /* polyterms[13]); */
     481    gfits_modify (header, "PCA2X3Y0", "%le", 1, coords[0].polyterms[3][1]);   /* polyterms[10]); */
     482    gfits_modify (header, "PCA2X2Y1", "%le", 1, coords[0].polyterms[4][1]);   /* polyterms[11]); */
     483    gfits_modify (header, "PCA2X1Y2", "%le", 1, coords[0].polyterms[5][1]);   /* polyterms[12]); */
     484    gfits_modify (header, "PCA2X0Y3", "%le", 1, coords[0].polyterms[6][1]);   /* polyterms[13]); */
    485485  }
    486486  return (TRUE);
Note: See TracChangeset for help on using the changeset viewer.