IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10889


Ignore:
Timestamp:
Jan 3, 2007, 8:50:43 AM (19 years ago)
Author:
eugene
Message:

working on reading mosaic MEF images

Location:
trunk/Ohana/src/addstar
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/include/addstar.h

    r8640 r10889  
    88# include <netdb.h>
    99# include <arpa/inet.h>
     10# include <glob.h>
    1011
    1112/* used in find_matches, find_matches_refstars */
  • trunk/Ohana/src/addstar/src/addstar.c

    r8641 r10889  
    44
    55  int Nmatch, status;
    6   int i, Nstars, Nimage, Noverlap, Nsubset;
     6  int i, Nstars, Nimages, Noverlap, Nsubset;
    77  unsigned long long Naverage, Nmeasure;
    88  Stars *stars, **subset;
    9   Image image, *imageSet, *overlap;
     9  Image *images, *overlap;
    1010  Catalog catalog;
    1111  FITS_DB db;
     
    1414  SkyTable *sky = NULL;
    1515  SkyList *skylist = NULL;
     16  SkyList *newlist = NULL;
    1617
    1718  double dtime;
     
    3940  switch (options.mode) {
    4041    case M_IMAGE:
    41       stars = gstars (argv[1], &Nstars, options.photcode, &image);
     42      stars = gstars (argv[1], &Nstars, options.photcode, &images, &Nimages);
    4243      if ((DUMP != NULL) && !strcmp (DUMP, "rawstars")) dump_rawstars (stars, Nstars);
    4344      RegisterMosaic (MOSAIC);
    44       skylist = SkyListByImage (sky, -1, &image);
     45      for (i = 0; i < Nimages; i++) {
     46        newlist = SkyListByImage (sky, -1, &image);
     47        SkyListMergeLists (&skylist, &newlist);
     48      }
    4549      overlap = gimages (&db, &image, MOSAIC, &Noverlap);
    4650      break;
     
    5458      break;
    5559    case M_FAKEIMAGE:
    56       imageSet = fakeimage (argv[1], &Nimage, options.photcode);
     60      images = fakeimage (argv[1], &Nimages, options.photcode);
    5761      RegisterMosaic (MOSAIC);
    5862
     
    6569      }   
    6670
    67       dvo_image_addrows (&db, imageSet, Nimage);
     71      dvo_image_addrows (&db, imageSet, Nimages);
    6872      SetProtect (TRUE);
    6973      dvo_image_update (&db, VERBOSE);
  • trunk/Ohana/src/addstar/src/find_matches.c

    r8652 r10889  
    1414  Coords tcoords;
    1515
     16  /* changes needed to handle mosaic MEF images:
     17     - options should not carry photcode: this is set per star in gstars
     18     - validate that all images have the same equiv code value (same Nsec)
     19     - add dt to Stars.d and set in gstars, not here
     20     - add airmass to Stars.d and set in gstars, not here
     21     - set stars.t in gstars
     22     - disallow mosaic and missed?  otherwise, need to loop over all images
     23       for each missed source to see if it should have been found
     24     - Mcal_PS is supplied by image, but is not correctly set: it is
     25       calculated *after* find_matches in addstar
     26  */
     27
    1628  /* XXX EAM : options.photcode overridden by image.source.... */
     29  /* XXX this function could be modified to handle multiple photcodes as long
     30     as they match the same equiv code value, resulting in the same value of Nsec */
    1731  code = GetPhotcodebyCode (image[0].source);
    1832
  • trunk/Ohana/src/addstar/src/gstars.c

    r8643 r10889  
    11# include "addstar.h"
    22
    3 Stars *gstars (char *file, int *NSTARS, int photcode, Image *image) {
     3/* break into sections, loop over images and load stars one at a time */
     4
     5Stars *gstars (char *file, int *NSTARS, int photcode, Image **imageList, int Nimages) {
    46
    57  FILE *f;
    6   int j, N, Nbytes, naxis;
     8  int i, j, N, Nbytes, naxis;
    79  int itmp, hour, min, simple;
    810  char *name, *c, photname[64], line[80];
     
    1012  Stars *stars, *rdstars;
    1113  Header header;
     14  Image *images;
    1215
    1316  /* XXX which of these values are required, which are just interesting? */
     17
     18  # if (0)
     19  /* file may be a glob, in which case it should represent multiple chip files
     20     from a single mosaic image */
     21
     22  // parse the word as a glob
     23  glob_t globList;
     24  globList.gl_offs = 0;
     25  glob (file, 0, NULL, &globList);
     26
     27  // if the glob does not match, save the literal word:
     28  // otherwise save all glob matches
     29  if (globList.gl_pathc == 0) {
     30    if (!gfits_read_header (file, &header)) {
     31      fprintf (stderr, "ERROR: can't read header for %s\n", file);
     32      exit (1);
     33    }
     34  } else {
     35    for (i = 0; i < globList.gl_pathc; i++) {
     36      if (!gfits_read_header (globList.gl_pathv[i], &header)) {
     37        fprintf (stderr, "ERROR: can't read header for %s\n", globList.gl_pathv[i]);
     38        exit (1);
     39      }
     40    }
     41  }
     42  # endif
    1443
    1544  if (!gfits_read_header (file, &header)) {
     
    1948
    2049  /* find image rootname */
     50  /* if we are reading a MEF mosaic image, attached [extname] to the name of the image */
    2151  name = filebasename (file);
    2252  strcpy (image[0].name, name);
    2353  free (name);
    24 
    25   /* get astrometry information */
    26   if (!GetCoords (&image[0].coords, &header)) {
    27     fprintf (stderr, "ERROR: no astrometric solution in header\n");
    28     exit (1);
    29   }
    30   itmp = 0;
    31   gfits_scan (&header, "NASTRO",   "%d", 1, &itmp);
    32   if ((itmp == 0) && !ACCEPT_ASTROM) {
    33     fprintf (stderr, "ERROR: bad astrometric solution in header\n");
    34     exit (1);
    35   }
    36   if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
    37     if (MOSAIC == NULL) {
    38       fprintf (stderr, "ERROR: no mosaic for WRP image (use -mosaic)\n");
    39       exit (1);
    40     }
    41     RegisterMosaic (MOSAIC);
    42   } else {
    43     /* force image to lie in 0-360 range */
    44     while (image[0].coords.crval1 < 0) image[0].coords.crval1 += 360.0;
    45     while (image[0].coords.crval1 > 360.0) image[0].coords.crval1 -= 360.0;
    46   }
    47    
    48   /* CERROR in data file is in arcsec */
    49   if (!gfits_scan (&header, "CERROR",   "%lf", 1, &tmp)) tmp = 1.0;
    50   image[0].cerror = tmp * 50.0;
    51   gfits_scan (&header, "NAXIS1",   "%hd", 1, &image[0].NX);
    52   gfits_scan (&header, "NAXIS2",   "%hd", 1, &image[0].NY);
    53  
    54   /* get photcode from header */
    55   if (photcode == 0) {
    56     if (!gfits_scan (&header, "PHOTCODE", "%s", 1, photname)) {
    57       fprintf (stderr, "ERROR: photcode not supplied in header\n");
    58       exit (1);
    59     }
    60     photcode = GetPhotcodeCodebyName (photname);
    61     if (photcode == 0) {
    62       fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", photname);
    63       exit (1);
    64     }
    65   }
    66   if (photcode == 0) {
    67     fprintf (stderr, "ERROR: no valid photcode is supplied\n");
    68     exit (1);
    69   }
    70   image[0].source = photcode;
    71 
    72   image[0].NX -= XOVERSCAN;
    73   image[0].NY -= YOVERSCAN;
    74   gfits_scan (&header, ExptimeKeyword,  "%lf", 1, &tmp);
    75   image[0].exptime = tmp;
    76  
    77   /*** why are we no longer using APMIFIT?? ***/
    78   tmp = 0;
    79   /* gfits_scan (&header, "APMIFIT",  "%lf", 1, &tmp); */
    80   image[0].apmifit_PS = tmp;
    81 
    82   tmp = 0;
    83   /* gfits_scan (&header, "dAPMIFIT", "%lf", 1, &tmp); */
    84   image[0].dapmifit_PS = tmp;
    85 
    86   tmp = 0;
    87   gfits_scan (&header, "FLIMIT",   "%lf", 1, &tmp);
    88   image[0].detection_limit = tmp * 10.0;
    89 
    90   tmp = 0;
    91   gfits_scan (&header, "FSATUR",   "%lf", 1, &tmp);
    92   image[0].saturation_limit = tmp * 10.0;
    93 
    94   tmp = 0;
    95   gfits_scan (&header, "FWHM_X",   "%lf", 1, &tmp);
    96   image[0].fwhm_x = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
    97 
    98   tmp = 0;
    99   gfits_scan (&header, "FWHM_Y",   "%lf", 1, &tmp);
    100   image[0].fwhm_y = tmp * 25.0 * image[0].coords.cdelt1 * 3600.0;
    101 
    102   if (!gfits_scan (&header, "TZERO",   "%d",  1, &image[0].tzero)) {
    103     image[0].tzero = parse_time (&header);
    104   }
    105 
    106   if (STKeyword[0]) {
    107     /* get ST (used for airmass calculation) */
    108     gfits_scan (&header, STKeyword, "%s", 1, line);
    109     /* remove ':' characters */
    110     for (c = strchr (line, ':'); c != (char *) NULL; c = strchr (line, ':')) { *c = ' '; }
    111     sscanf (line, "%d %d %lf", &hour, &min, &sec);
    112     image[0].sidtime = hour + min/60.0 + sec/3600.0;
    113   } else {
    114     double jd;
    115     jd = sec_to_jd (image[0].tzero);
    116     image[0].sidtime  = ohana_lst (jd, Longitude);
    117   }
    118   image[0].latitude = Latitude;
    119 
    120   tmp = 0;
    121   gfits_scan (&header, "TRATE",   "%lf", 1, &tmp);
    122   image[0].trate = 10000 * tmp;
    123 
    124   tmp = 0;
    125   gfits_scan (&header, AirmassKeyword, "%lf", 1, &tmp);
    126   image[0].secz_PS = MIN (NO_MAG, tmp);
    127 
    128   if (!gfits_scan (&header, CCDNumKeyword, "%d", 1, &itmp)) {
    129     image[0].ccdnum = 0xff;
    130   } else {
    131     image[0].ccdnum = itmp;
    132   }
    133 
    134   gfits_scan (&header, "ZERO_PT", "%lf", 1, &ZeroPt);
    135   SetZeroPoint (ZeroPt);
    136 
    137   /* secz is in units milli-airmass */
    138   image[0].Mcal_PS = 0.0;
    139   image[0].Xm   = NO_MAG;
    140   image[0].code = 0;
    141   bzero (image[0].dummy, sizeof(image[0].dummy));
    142 
    143   /* find expected number of stars */
    144   if (!gfits_scan (&header, "NSTARS", "%d", 1, &image[0].nstar)) {
    145     fprintf (stderr, "ERROR: can't get NSTARS from header\n");
    146     exit (1);
    147   }
    14854
    14955  /* this is really lame.  get sky background from Flips data */
Note: See TracChangeset for help on using the changeset viewer.