IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 12487


Ignore:
Timestamp:
Mar 18, 2007, 12:08:06 PM (19 years ago)
Author:
eugene
Message:

return an error on header parse errors; calling program will exit or skip

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/ReadImageHeader.c

    r12332 r12487  
    55int ReadImageHeader (Header *header, Image *image, int photcode) {
    66
    7   int Nastro, ccdnum, hour, min;
     7  int Nastro, ccdnum, hour, min, Nx, Ny;
    88  double tmp, sec;
    99  char *c, photname[64], line[80];
     
    1111  /* get astrometry information */
    1212  if (!GetCoords (&image[0].coords, header)) {
    13     fprintf (stderr, "ERROR: no astrometric solution in header\n");
    14     exit (1);
     13    fprintf (stderr, "no astrometric solution in header\n");
     14    return (FALSE);
    1515  }
    16   gfits_scan (header, "NAXIS1",   "%hd", 1, &image[0].NX);
    17   gfits_scan (header, "NAXIS2",   "%hd", 1, &image[0].NY);
     16  // XXX currently, image uses an unsigned short for NX,XY. this is rather restrictive
     17  // and needs to be at least checked.
     18  gfits_scan (header, "NAXIS1",   "%d", 1, &Nx);
     19  gfits_scan (header, "NAXIS2",   "%d", 1, &Ny);
     20  if ((Nx < 0) || (Nx > 0xffff)) {
     21    fprintf (stderr, "WARNING: NX, NY out of range : image boundary will be wrong\n");
     22  }
     23  image[0].NX = Nx;
     24  image[0].NY = Ny;
    1825
    1926  if (!gfits_scan (header, "TZERO",   "%d",  1, &image[0].tzero)) {
     
    3138  gfits_scan (header, "NASTRO", "%d", 1, &Nastro);
    3239  if ((Nastro == 0) && !ACCEPT_ASTROM) {
    33     fprintf (stderr, "ERROR: bad astrometric solution in header\n");
    34     exit (1);
     40    fprintf (stderr, "bad astrometric solution in header\n");
     41    return (FALSE);
    3542  }
    3643  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
    3744    if (MOSAIC == NULL) {
    38       fprintf (stderr, "ERROR: no mosaic for WRP image (use -mosaic)\n");
    39       exit (1);
     45      fprintf (stderr, "no mosaic for WRP image (use -mosaic)\n");
     46      return (FALSE);
    4047    }
    4148    RegisterMosaic (MOSAIC);
     
    5360  if (photcode == 0) {
    5461    if (!gfits_scan (header, "PHOTCODE", "%s", 1, photname)) {
    55       fprintf (stderr, "ERROR: photcode not supplied in header\n");
    56       exit (1);
     62      fprintf (stderr, "photcode not supplied in header\n");
     63      return (FALSE);
    5764    }
    5865    photcode = GetPhotcodeCodebyName (photname);
    5966    if (photcode == 0) {
    60       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", photname);
    61       exit (1);
     67      fprintf (stderr, "photcode %s not found in photcode table\n", photname);
     68      return (FALSE);
    6269    }
    6370  }
    6471  if (photcode == 0) {
    65     fprintf (stderr, "ERROR: no valid photcode is supplied\n");
    66     exit (1);
     72    fprintf (stderr, "no valid photcode is supplied\n");
     73    return (FALSE);
    6774  }
    6875  image[0].photcode = photcode;
     
    137144  /* find expected number of stars */
    138145  if (!gfits_scan (header, "NSTARS", "%d", 1, &image[0].nstar)) {
    139     fprintf (stderr, "ERROR: can't get NSTARS from header\n");
    140     exit (1);
     146    fprintf (stderr, "can't get NSTARS from header\n");
     147    return (FALSE);
    141148  }
    142149
Note: See TracChangeset for help on using the changeset viewer.