IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 20, 2010, 12:05:07 PM (16 years ago)
Author:
eugene
Message:

optimizations for dvomerge and relastro; complete checks of db I/O success; fix overloaded image flags

Location:
trunk/Ohana
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana

    • Property svn:mergeinfo deleted
  • trunk/Ohana/src/libdvo/include/dvo.h

    r28855 r29001  
    8585# define PHOT_MAG 0x06  /* generic magnitude; never stored */
    8686
    87 /* Image.code values.  these are codes to note bad images */
    88 # define ID_IMAGE_NEW   0x0000  /* no nrphot attempted */
    89 # define ID_IMAGE_NOCAL 0x0001  /* used within nrphot to mean "don't apply fit" */
    90 # define ID_IMAGE_POOR  0x0002  /* relphot says image is bad */
    91 # define ID_IMAGE_SKIP  0x0004  /* external information image is bad */
    92 # define ID_IMAGE_FEW   0x0008  /* currently too few measurements for good value */
     87/* Image.code values -- these values are 32 bit (as of PS1_V1) */
     88typedef enum {
     89  ID_IMAGE_NEW          = 0x00000000,  /* no calibrations yet attempted */
     90  ID_IMAGE_PHOTOM_NOCAL = 0x00000001,  /* user-set value used within relphot: ignore */
     91  ID_IMAGE_PHOTOM_POOR  = 0x00000002,  /* relphot says image is bad (dMcal > limit) */
     92  ID_IMAGE_PHOTOM_SKIP  = 0x00000004,  /* user-set value: assert that this image has bad photometry */
     93  ID_IMAGE_PHOTOM_FEW   = 0x00000008,  /* currently too few measurements for photometry */
     94  ID_IMAGE_ASTROM_NOCAL = 0x00000010,  /* user-set value used within relastro: ignore */
     95  ID_IMAGE_ASTROM_POOR  = 0x00000020,  /* relastro says image is bad (dR,dD > limit) */
     96  ID_IMAGE_ASTROM_FAIL  = 0x00000040,  /* relastro fit diverged, fit not applied */
     97  ID_IMAGE_ASTROM_SKIP  = 0x00000080,  /* user-set value: assert that this image has bad astrometry */
     98  ID_IMAGE_ASTROM_FEW   = 0x00000100,  /* currently too few measurements for astrometry */
     99} DVOImageFlags;
    93100
    94101/* Measure.flags values -- these values are 32 bit (as of PS1_V1) */
    95102typedef enum {
    96   ID_MEAS_NOCAL        = 0x0001,  // detection ignored for this analysis (photcode, time range) -- internal only
    97   ID_MEAS_POOR_PHOTOM  = 0x0002,  // detection is photometry outlier                                             
    98   ID_MEAS_SKIP_PHOTOM  = 0x0004,  // detection was ignored for photometry measurement                             
    99   ID_MEAS_AREA         = 0x0008,  // detection near image edge                                               
    100   ID_MEAS_POOR_ASTROM  = 0x0010,  // detection is astrometry outlier                                             
    101   ID_MEAS_SKIP_ASTROM  = 0x0020,  // detection was ignored for astrometry measurement                             
    102   ID_MEAS_USED_OBJ     = 0x0040,  // detection was used during opdate objects                               
    103   ID_MEAS_USED_CHIP    = 0x0080,  // detection was used during update chips                                         
    104   ID_MEAS_BLEND_MEAS   = 0x0100,  // detection is within radius of multiple objects                                 
    105   ID_MEAS_BLEND_OBJ    = 0x0200,  // multiple detections within radius of object                                     
    106   ID_MEAS_UNDEF_3      = 0x0400,  // unused                                                                         
    107   ID_MEAS_UNDEF_4      = 0x0800,  // unused                                                                         
    108   ID_MEAS_BLEND_MEAS_X = 0x1000,  // detection is within radius of multiple objects across catalogs                 
    109   ID_MEAS_ARTIFACT     = 0x2000,  // detection is thought to be non-astronomical                                     
    110   ID_MEAS_UNDEF_5      = 0x4000,  // unused                                                                         
    111   ID_MEAS_UNDEF_6      = 0x8000,  // unused                                                                         
     103  ID_MEAS_NOCAL        = 0x00000001,  // detection ignored for this analysis (photcode, time range) -- internal only
     104  ID_MEAS_POOR_PHOTOM  = 0x00000002,  // detection is photometry outlier                                                 
     105  ID_MEAS_SKIP_PHOTOM  = 0x00000004,  // detection was ignored for photometry measurement                                 
     106  ID_MEAS_AREA         = 0x00000008,  // detection near image edge                                                   
     107  ID_MEAS_POOR_ASTROM  = 0x00000010,  // detection is astrometry outlier                                                 
     108  ID_MEAS_SKIP_ASTROM  = 0x00000020,  // detection was ignored for astrometry measurement                                 
     109  ID_MEAS_USED_OBJ     = 0x00000040,  // detection was used during opdate objects                                   
     110  ID_MEAS_USED_CHIP    = 0x00000080,  // detection was used during update chips                                     
     111  ID_MEAS_BLEND_MEAS   = 0x00000100,  // detection is within radius of multiple objects                             
     112  ID_MEAS_BLEND_OBJ    = 0x00000200,  // multiple detections within radius of object                                 
     113  ID_MEAS_UNDEF_3      = 0x00000400,  // unused                                                                     
     114  ID_MEAS_UNDEF_4      = 0x00000800,  // unused                                                                     
     115  ID_MEAS_BLEND_MEAS_X = 0x00001000,  // detection is within radius of multiple objects across catalogs             
     116  ID_MEAS_ARTIFACT     = 0x00002000,  // detection is thought to be non-astronomical                                 
     117  ID_MEAS_UNDEF_5      = 0x00004000,  // unused                                                                     
     118  ID_MEAS_UNDEF_6      = 0x00008000,  // unused                                                                     
    112119} DVOMeasureFlags;
    113120
     
    147154  ID_STAR_USE_PM  = 0x00100000, // proper motion used (not AVE or PAR)
    148155  ID_STAR_USE_PAR = 0x00200000, // parallax used (not AVE or PM)
     156  ID_OBJ_EXT      = 0x01000000, // extended in our data (eg, PS)
     157  ID_OBJ_EXT_ALT  = 0x02000000, // extended in external data (eg, 2MASS)
     158  ID_OBJ_GOOD     = 0x04000000, // good-quality measurement in our data (eg, PS)
     159  ID_OBJ_GOOD_ALT = 0x08000000, // good-quality measurement in external data (eg, 2MASS)
    149160} DVOAverageFlags;
    150161
  • trunk/Ohana/src/libdvo/src/LoadPhotcodesFITS.c

    r27580 r29001  
    4343  if (!strcmp (extname, "DVO_PHOTCODE")) {
    4444    PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
     45    if (!photcode_elixir) {
     46      fprintf (stderr, "ERROR: failed to read photcodes\n");
     47      exit (2);
     48    }
    4549    photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
    4650    free (photcode_elixir);
     
    4953  if (!strcmp (extname, "DVO_PHOTCODE_ELIXIR")) {
    5054    PhotCode_Elixir *photcode_elixir = gfits_table_get_PhotCode_Elixir (&db.ftable, &Ncode, &db.swapped);
     55    if (!photcode_elixir) {
     56      fprintf (stderr, "ERROR: failed to read photcodes\n");
     57      exit (2);
     58    }
    5159    photcode = PhotCode_Elixir_To_Internal (photcode_elixir, Ncode);
    5260    free (photcode_elixir);
     
    5563  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_1")) {
    5664    PhotCode_PS1_DEV_1 *photcode_ps1_dev_1 = gfits_table_get_PhotCode_PS1_DEV_1 (&db.ftable, &Ncode, &db.swapped);
     65    if (!photcode_ps1_dev_1) {
     66      fprintf (stderr, "ERROR: failed to read photcodes\n");
     67      exit (2);
     68    }
    5769    photcode = PhotCode_PS1_DEV_1_To_Internal (photcode_ps1_dev_1, Ncode);
    5870    free (photcode_ps1_dev_1);
     
    6173  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_2")) {
    6274    PhotCode_PS1_DEV_2 *photcode_ps1_dev_2 = gfits_table_get_PhotCode_PS1_DEV_2 (&db.ftable, &Ncode, &db.swapped);
     75    if (!photcode_ps1_dev_2) {
     76      fprintf (stderr, "ERROR: failed to read photcodes\n");
     77      exit (2);
     78    }
    6379    photcode = PhotCode_PS1_DEV_2_To_Internal (photcode_ps1_dev_2, Ncode);
    6480    free (photcode_ps1_dev_2);
     
    6783  if (!strcmp (extname, "DVO_PHOTCODE_PS1_DEV_3")) {
    6884    PhotCode_PS1_DEV_3 *photcode_ps1_dev_3 = gfits_table_get_PhotCode_PS1_DEV_3 (&db.ftable, &Ncode, &db.swapped);
     85    if (!photcode_ps1_dev_3) {
     86      fprintf (stderr, "ERROR: failed to read photcodes\n");
     87      exit (2);
     88    }
    6989    photcode = PhotCode_PS1_DEV_3_To_Internal (photcode_ps1_dev_3, Ncode);
    7090    free (photcode_ps1_dev_3);
     
    7393  if (!strcmp (extname, "DVO_PHOTCODE_PS1_V1")) {
    7494    PhotCode_PS1_V1 *photcode_ps1_v1 = gfits_table_get_PhotCode_PS1_V1 (&db.ftable, &Ncode, &db.swapped);
     95    if (!photcode_ps1_v1) {
     96      fprintf (stderr, "ERROR: failed to read photcodes\n");
     97      exit (2);
     98    }
    7599    photcode = PhotCode_PS1_V1_To_Internal (photcode_ps1_v1, Ncode);
    76100    free (photcode_ps1_v1);
     
    79103  if (!strcmp (extname, "DVO_PHOTCODE_PS1_V2")) {
    80104    PhotCode_PS1_V2 *photcode_ps1_v2 = gfits_table_get_PhotCode_PS1_V2 (&db.ftable, &Ncode, &db.swapped);
     105    if (!photcode_ps1_v2) {
     106      fprintf (stderr, "ERROR: failed to read photcodes\n");
     107      exit (2);
     108    }
    81109    photcode = PhotCode_PS1_V2_To_Internal (photcode_ps1_v2, Ncode);
    82110    free (photcode_ps1_v2);
     
    85113  if (!strcmp (extname, "DVO_PHOTCODE_PS1_REF")) {
    86114    PhotCode_PS1_REF *photcode_ps1_ref = gfits_table_get_PhotCode_PS1_REF (&db.ftable, &Ncode, &db.swapped);
     115    if (!photcode_ps1_ref) {
     116      fprintf (stderr, "ERROR: failed to read photcodes\n");
     117      exit (2);
     118    }
    87119    photcode = PhotCode_PS1_REF_To_Internal (photcode_ps1_ref, Ncode);
    88120    free (photcode_ps1_ref);
  • trunk/Ohana/src/libdvo/src/cmf-ps1-v1-alt.c

    r28241 r29001  
    1414  if (ftable[0].header[0].Naxis[0] != 136) {
    1515    fprintf (stderr, "ERROR: wrong format for CMF_PS1_V1_Alt: "OFF_T_FMT" vs %d\n",  ftable[0].header[0].Naxis[0], 136);
    16     exit (2);
     16    return (NULL);
    1717  }
    1818
  • trunk/Ohana/src/libdvo/src/coordops.c

    r28837 r29001  
    2020int XY_to_LM (double *L, double *M, double x, double y, Coords *coords) {
    2121
     22  OhanaProjection proj;
     23  OhanaProjectionMode mode;
    2224  double X, Y, X2, XY, Y2, X3, Y3;
     25
     26  proj = GetProjection (coords[0].ctype);
     27  mode = GetProjectionMode (proj);
    2328
    2429  /** convert pixel coordinates to cartesian system **/
     
    4550  }
    4651
     52  if (mode == PROJ_MODE_CARTESIAN) {
     53    *L += coords[0].crval1;
     54    *M += coords[0].crval2;
     55  }
     56
    4757  return (TRUE);
    4858}
     
    6474  /** Locally Cartesian Projections **/
    6575  if (mode == PROJ_MODE_CARTESIAN) {
    66     *ra  = L + coords[0].crval1;
    67     *dec = M + coords[0].crval2;
    68 
    6976    /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */
    7077    if (proj == PROJ_WRP) {
    7178      if (!gotMosaic) return (FALSE);
    72       XY_to_RD (ra, dec, *ra, *dec, &mosaic);
     79      XY_to_RD (ra, dec, L, M, &mosaic);
    7380    }
    7481    return (TRUE);
     
    183190
    184191  double phi, theta;
    185   double Lo, Mo;
    186192  double sphi, cphi, stht, ctht;
    187193  double salp, calp, sdel, cdel, sdp, cdp;
     
    201207    if (proj == PROJ_WRP) {
    202208      if (!gotMosaic) return (FALSE);
    203       RD_to_XY (&Lo, &Mo, ra, dec, &mosaic);
    204       *L = (Lo - coords[0].crval1);
    205       *M = (Mo - coords[0].crval2);
     209      RD_to_XY (L, M, ra, dec, &mosaic);
    206210      return (TRUE);
    207211    }
    208     *L = (ra  - coords[0].crval1);
    209     *M = (dec - coords[0].crval2);
     212    *L = ra;
     213    *M = dec;
    210214    return (TRUE);
    211215  }
     
    310314  double dX, dY, Lo, Mo, dL, dM;
    311315  double dLdX, dLdY, dMdX, dMdY, Do;
     316  OhanaProjection proj;
     317  OhanaProjectionMode mode;
     318
     319  proj = GetProjection (coords[0].ctype);
     320  mode = GetProjectionMode (proj);
    312321
    313322  *x = 0;
    314323  *y = 0;
     324
     325  if (mode == PROJ_MODE_CARTESIAN) {
     326    L -= coords[0].crval1;
     327    M -= coords[0].crval2;
     328  }
    315329
    316330  /* start with linear solution for X,Y */
     
    422436}
    423437
     438enum {COORD_TYPE_NONE, COORD_TYPE_PC, COORD_TYPE_ROT, COORD_TYPE_CD, COORD_TYPE_LIN};
     439
    424440int GetCoords (Coords *coords, Header *header) {
    425441 
     
    428444  double equinox;
    429445  char *ctype;
     446  int mode;
    430447 
    431448  rotate = 0.0;
     
    437454  strcpy (coords[0].ctype, "NONE");
    438455 
    439   status = FALSE;
    440   if (gfits_scan (header, "CTYPE2", "%s", 1, coords[0].ctype)) {
    441     status  = gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
    442     status &= gfits_scan (header, "CRPIX1", "%f", 1, &coords[0].crpix1);
    443     status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
    444     status &= gfits_scan (header, "CRPIX2", "%f", 1, &coords[0].crpix2);
    445 
    446     if (gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1)) {
    447       status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
    448       if (gfits_scan (header, "CROTA2", "%lf", 1, &rotate)) {
    449         Lambda = coords[0].cdelt2 / coords[0].cdelt1;
    450         coords[0].pc1_1 =  cos(rotate*RAD_DEG);
    451         coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
    452         coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
    453         coords[0].pc2_2 =  cos(rotate*RAD_DEG);
    454       }
    455       if (gfits_scan (header, "PC001001", "%f", 1, &coords[0].pc1_1)) {
    456         status &= gfits_scan (header, "PC001002", "%f", 1, &coords[0].pc1_2);
    457         status &= gfits_scan (header, "PC002001", "%f", 1, &coords[0].pc2_1);
    458         status &= gfits_scan (header, "PC002002", "%f", 1, &coords[0].pc2_2);
    459       }
     456  mode = COORD_TYPE_NONE;
     457  {   
     458    int haveCTYPE, haveCDELT, haveCROTA, haveCDij, havePCij, haveRAo;
     459    float tmp;
     460    char stmp[80];
     461   
     462    // there are a few different representations for scale and rotation.  choose an appropriate
     463    // set: (CDELTi + CROTAi), (CDELTi + PCij), (CDij),
     464
     465    haveCTYPE = gfits_scan (header, "CTYPE2",   "%s", 1, stmp);
     466    haveCDELT = gfits_scan (header, "CDELT1",   "%f", 1, &tmp);
     467    haveCROTA = gfits_scan (header, "CROTA1",   "%f", 1, &tmp);
     468    haveCDij  = gfits_scan (header, "CD1_1",    "%f", 1, &tmp);
     469    havePCij  = gfits_scan (header, "PC001001", "%f", 1, &tmp);
     470    haveRAo   = gfits_scan (header, "RA_O",     "%f", 1, &tmp);
     471   
     472    if (haveCTYPE && havePCij  && haveCDELT) { mode = COORD_TYPE_PC;   goto gotit; }
     473    if (haveCTYPE && haveCROTA && haveCDELT) { mode = COORD_TYPE_ROT;  goto gotit; }
     474    if (haveCTYPE && haveCDij)               { mode = COORD_TYPE_CD;   goto gotit; }
     475    if (haveRAo)                             { mode = COORD_TYPE_LIN;  goto gotit; }
     476    // fprintf (stderr, "no valid WCS keywords\n");
     477    return (FALSE);
     478  }
     479 
     480gotit:
     481
     482  status = TRUE;
     483  switch (mode) {
     484    case COORD_TYPE_PC:
     485      status &= gfits_scan (header, "CTYPE2",   "%s",  1, coords[0].ctype);
     486      status &= gfits_scan (header, "CRVAL1",   "%lf", 1, &coords[0].crval1);
     487      status &= gfits_scan (header, "CRPIX1",   "%f",  1, &coords[0].crpix1);
     488      status &= gfits_scan (header, "CRVAL2",   "%lf", 1, &coords[0].crval2); 
     489      status &= gfits_scan (header, "CRPIX2",   "%f",  1, &coords[0].crpix2);
     490
     491      status &= gfits_scan (header, "CDELT1",   "%f",  1, &coords[0].cdelt1);
     492      status &= gfits_scan (header, "CDELT2",   "%f",  1, &coords[0].cdelt2);
     493      status &= gfits_scan (header, "PC001001", "%f",  1, &coords[0].pc1_1);
     494      status &= gfits_scan (header, "PC001002", "%f",  1, &coords[0].pc1_2);
     495      status &= gfits_scan (header, "PC002001", "%f",  1, &coords[0].pc2_1);
     496      status &= gfits_scan (header, "PC002002", "%f",  1, &coords[0].pc2_2);
    460497
    461498      /* set NPLYTERM based on header.  if NPLYTERM is missing, it should have a
     
    491528          break;
    492529      }
    493     } else {
    494       if (gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1)) {
    495         status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
    496         status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
    497         status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
    498         /* renormalize */
    499         scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
    500         coords[0].cdelt1 = coords[0].cdelt2 = scale;
    501         coords[0].pc1_1 /= scale;
    502         coords[0].pc1_2 /= scale;
    503         coords[0].pc2_1 /= scale;
    504         coords[0].pc2_2 /= scale;
    505       } else {
    506         status = FALSE;
    507       }
    508     }
    509   } else {
    510     /* some of my thesis data uses this simple linear model - convert on read? */
    511     if (gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1)) {
    512       status  = gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
     530      break;
     531
     532    case COORD_TYPE_ROT:
     533      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
     534      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
     535      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
     536      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
     537      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
     538
     539      status &= gfits_scan (header, "CDELT1", "%f", 1, &coords[0].cdelt1);
     540      status &= gfits_scan (header, "CDELT2", "%f", 1, &coords[0].cdelt2);
     541
     542      status &= gfits_scan (header, "CROTA2", "%lf", 1, &rotate);
     543      Lambda = coords[0].cdelt2 / coords[0].cdelt1;
     544      coords[0].pc1_1 =  cos(rotate*RAD_DEG);
     545      coords[0].pc1_2 = -sin(rotate*RAD_DEG) * Lambda;
     546      coords[0].pc2_1 =  sin(rotate*RAD_DEG) / Lambda;
     547      coords[0].pc2_2 =  cos(rotate*RAD_DEG);
     548      break;
     549
     550    case COORD_TYPE_CD:
     551      status &= gfits_scan (header, "CTYPE2", "%s",  1, coords[0].ctype);
     552      status &= gfits_scan (header, "CRVAL1", "%lf", 1, &coords[0].crval1);
     553      status &= gfits_scan (header, "CRPIX1", "%f",  1, &coords[0].crpix1);
     554      status &= gfits_scan (header, "CRVAL2", "%lf", 1, &coords[0].crval2); 
     555      status &= gfits_scan (header, "CRPIX2", "%f",  1, &coords[0].crpix2);
     556
     557      status &= gfits_scan (header, "CD1_1", "%f", 1, &coords[0].pc1_1);
     558      status &= gfits_scan (header, "CD1_2", "%f", 1, &coords[0].pc1_2);
     559      status &= gfits_scan (header, "CD2_1", "%f", 1, &coords[0].pc2_1);
     560      status &= gfits_scan (header, "CD2_2", "%f", 1, &coords[0].pc2_2);
     561      /* renormalize */
     562      scale = hypot (coords[0].pc1_1, coords[0].pc1_2);
     563      coords[0].cdelt1 = coords[0].cdelt2 = scale;
     564      coords[0].pc1_1 /= scale;
     565      coords[0].pc1_2 /= scale;
     566      coords[0].pc2_1 /= scale;
     567      coords[0].pc2_2 /= scale;
     568      break;
     569
     570    case COORD_TYPE_LIN:
     571      /* some of my thesis data uses this simple linear model - convert on read? */
     572      status &= gfits_scan (header, "RA_O", "%lf", 1, &coords[0].crval1);
     573      status &= gfits_scan (header, "RA_X", "%f", 1, &coords[0].pc1_1);
    513574      status &= gfits_scan (header, "RA_Y", "%f", 1, &coords[0].pc1_2);
    514575      status &= gfits_scan (header, "DEC_O", "%lf", 1, &coords[0].crval2); 
     
    518579      coords[0].cdelt1 = coords[0].cdelt2 = 1.0;
    519580      strcpy (coords[0].ctype, "GENE");
    520     }
    521   }
     581      break;
     582  }
     583
    522584  if (status) {
    523585    if (!gfits_scan (header, "EQUINOX", "%lf", 1, &equinox)) {
     
    530592    }
    531593  }
     594
    532595  if (!status) {
    533     fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
     596    // fprintf (stderr, "error getting all elements for coordinate mode %s\n", coords[0].ctype);
    534597    coords[0].crval1 = coords[0].crpix1 = coords[0].cdelt1 = 0.0;
    535598    coords[0].crval2 = coords[0].crpix2 = coords[0].cdelt2 = 0.0;
  • trunk/Ohana/src/libdvo/src/dvo_catalog_mef.c

    r28241 r29001  
    125125    /* no conversions currently defined */
    126126    catalog[0].missing = gfits_table_get_Missing (&ftable, &catalog[0].Nmissing, NULL);
     127    if (!catalog[0].missing) {
     128      fprintf (stderr, "ERROR: failed to read missing\n");
     129      exit (2);
     130    }
    127131    if (Nmissing != catalog[0].Nmiss_disk) {
    128132      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
  • trunk/Ohana/src/libdvo/src/dvo_catalog_split.c

    r28241 r29001  
    285285    /* no conversions currently defined : this just does the byte swap */
    286286    catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     287    if (!catalog[0].missing) {
     288      fprintf (stderr, "ERROR: failed to read missing\n");
     289      exit (2);
     290    }
    287291    if (Nmissing != catalog[0].Nmiss_disk) {
    288292      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  catalog[0].Nmiss_disk);
     
    473477    /* no conversions currently defined : this just does the byte swap */
    474478    catalog[0].missing = gfits_table_get_Missing (&ftable, &Nmissing, NULL);
     479    if (!catalog[0].missing) {
     480      fprintf (stderr, "ERROR: failed to read missing\n");
     481      exit (2);
     482    }
    475483    if (Nmissing != Nrows) {
    476484      fprintf (stderr, "Warning: mismatch between Nmissing in PHU and Table headers ("OFF_T_FMT" vs "OFF_T_FMT")\n",  Nmissing,  Nrows);
  • trunk/Ohana/src/libdvo/src/dvo_convert.c

    r28241 r29001  
    3232    Average_##TYPE *tmpAverage; \
    3333    tmpAverage = gfits_table_get_Average_##TYPE (ftable, Naverage, NULL); \
     34    if (!tmpAverage) { \
     35      fprintf (stderr, "ERROR: failed to read averages\n"); \
     36      exit (2); \
     37    } \
    3438    average = Average_##TYPE##_ToInternal (tmpAverage, *Naverage, primary); \
    3539    free (tmpAverage); \
     
    3943  if (!strcmp (extname, "DVO_AVERAGE")) {
    4044    average = gfits_table_get_Average (ftable, Naverage, NULL);
     45    if (!average) {
     46      fprintf (stderr, "ERROR: failed to read averages\n");
     47      exit (2);
     48    }
    4149    *format = DVO_FORMAT_INTERNAL;
    4250    return (average);
     
    111119    Measure_##TYPE *tmpMeasure; \
    112120    tmpMeasure = gfits_table_get_Measure_##TYPE (ftable, Nmeasure, NULL); \
     121    if (!tmpMeasure) { \
     122      fprintf (stderr, "ERROR: failed to read measures\n"); \
     123      exit (2); \
     124    } \
    113125    measure = Measure_##TYPE##_ToInternal (tmpMeasure, *Nmeasure); \
    114126    free (tmpMeasure); \
     
    118130  if (!strcmp (extname, "DVO_MEASURE")) {
    119131    measure = gfits_table_get_Measure (ftable, Nmeasure, NULL);
     132    if (!measure) {
     133      fprintf (stderr, "ERROR: failed to read measures\n");
     134      exit (2);
     135    }
    120136    *format = DVO_FORMAT_INTERNAL;
    121137    return (measure);
     
    190206    SecFilt_##TYPE *tmpSecFilt; \
    191207    tmpSecFilt = gfits_table_get_SecFilt_##TYPE (ftable, Nsecfilt, NULL); \
     208    if (!tmpSecFilt) { \
     209      fprintf (stderr, "ERROR: failed to read secfilts\n"); \
     210      exit (2); \
     211    } \
    192212    secfilt = SecFilt_##TYPE##_ToInternal (tmpSecFilt, *Nsecfilt); \
    193213    free (tmpSecFilt); \
     
    197217  if (!strcmp (extname, "DVO_SECFILT")) {
    198218    secfilt = gfits_table_get_SecFilt (ftable, Nsecfilt, NULL);
     219    if (!secfilt) {
     220      fprintf (stderr, "ERROR: failed to read secfilts\n");
     221      exit (2);
     222    }
    199223    *format = DVO_FORMAT_INTERNAL;
    200224    return (secfilt);
     
    263287    Image_Elixir *tmpimage;
    264288    tmpimage = gfits_table_get_Image_Elixir (ftable, &Nimage, NULL);
     289    if (!tmpimage) {
     290      fprintf (stderr, "ERROR: failed to read images\n");
     291      exit (2);
     292    }
    265293    ftable[0].buffer = (char *) Image_Elixir_ToInternal (tmpimage, Nimage);
    266294    free (tmpimage);
     
    284312    *format = DVO_FORMAT_##FORMAT; \
    285313    tmpimage = gfits_table_get_Image_##TYPE (ftable, &Nimage, NULL); \
     314    if (!tmpimage) { \
     315      fprintf (stderr, "ERROR: failed to read images\n"); \
     316      exit (2); \
     317    } \
    286318    ftable[0].buffer = (char *) Image_##TYPE##_ToInternal (tmpimage, Nimage); \
    287319    free (tmpimage); \
     
    296328    Image *image;
    297329    image = gfits_table_get_Image (ftable, &Nimage, NULL);
     330    if (!image) {
     331      fprintf (stderr, "ERROR: failed to read images\n");
     332      exit (2);
     333    }
    298334    *format = DVO_FORMAT_INTERNAL;
    299335    return (TRUE);
  • trunk/Ohana/src/libdvo/src/skyregion_io.c

    r27435 r29001  
    4040  ALLOCATE (skytable, SkyTable, 1);
    4141  skytable[0].regions = gfits_table_get_SkyRegion (&ftable, &skytable[0].Nregions, NULL);
     42  if (!skytable[0].regions) {
     43    fprintf (stderr, "ERROR: failed to read sky regions\n");
     44    exit (2);
     45  }
     46
    4247  ALLOCATE (skytable[0].filename, char *, skytable[0].Nregions);
    4348  for (i = 0; i < skytable[0].Nregions; i++) {
Note: See TracChangeset for help on using the changeset viewer.