IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 7, 2005, 6:15:46 PM (22 years ago)
Author:
eugene
Message:

adding mosaic astrometry concepts

Location:
trunk/Ohana/src/addstar
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/Makefile

    r3376 r3389  
     1#install:
     2#       @echo "addstar under re-construction"
    13default: addstar
    24help:
    … …  
    110112# utilities #################################################
    111113
    112 install:
     114# install:
    113115        for i in $(INSTALL); do make $$i.install; done
    114116
  • trunk/Ohana/src/addstar/include/addstar.h

    r3376 r3389  
    6262PhotCode *thiscode;
    6363GSCRegion UserPatch;
     64Coords *MOSAIC;
    6465
    6566char DateKeyword[64];
  • trunk/Ohana/src/addstar/src/args.c

    r3376 r3389  
    1414int args (int argc, char **argv) {
    1515 
    16   int i, N;
     16  int N;
    1717
    1818  /* check for help request */
    … …  
    6161  /* provide a time for dataset */
    6262  TIMEREF = 0;
    63   if ((i = get_argument (argc, argv, "-time"))) {
    64     remove_argument (i, &argc, argv);
    65     if (!str_to_time (argv[i], &TIMEREF)) {
     63  if ((N = get_argument (argc, argv, "-time"))) {
     64    remove_argument (N, &argc, argv);
     65    if (!str_to_time (argv[N], &TIMEREF)) {
    6666      fprintf (stderr, "syntax error in time\n");
    6767      exit (1);
    6868    }
    69     remove_argument (i, &argc, argv);
     69    remove_argument (N, &argc, argv);
     70  }
     71  /* provide a mosaic for distortion */
     72  MOSAIC = NULL;
     73  if ((N = get_argument (argc, argv, "-mosaic"))) {
     74    Header header;
     75    ALLOCATE (MOSAIC, Coords, 1);
     76
     77    remove_argument (N, &argc, argv);
     78    if (!fits_read_header (argv[N], &header)) {
     79      fprintf (stderr, "ERROR: can't read header for mosaic %s\n", argv[N]);
     80      exit (1);
     81    }
     82    if (!GetCoords (MOSAIC, &header)) {
     83      fprintf (stderr, "ERROR: no astrometric solution in header\n");
     84      exit (1);
     85    }
     86    if (strcmp(&MOSAIC[0].ctype[4], "-DIS")) {
     87      fprintf (stderr, "ERROR: not a mosaic distortion header\n");
     88      exit (1);
     89    }
     90    remove_argument (N, &argc, argv);
     91    fits_free_header (&header);
    7092  }
    7193 
    … …  
    7395  /* only add to existing objects */
    7496  ONLY_MATCH = FALSE;
    75   if ((i = get_argument (argc, argv, "-only-match"))) {
     97  if ((N = get_argument (argc, argv, "-only-match"))) {
    7698    ONLY_MATCH = TRUE;
    77     remove_argument (i, &argc, argv);
     99    remove_argument (N, &argc, argv);
    78100  }
    79101  /* don't add missed pts to Missed table (image only) */
    … …  
    85107  /* replace measurement, don't duplicate (ref/cat only) */
    86108  REPLACE = FALSE;
    87   if ((i = get_argument (argc, argv, "-replace"))) {
     109  if ((N = get_argument (argc, argv, "-replace"))) {
    88110    REPLACE = TRUE;
    89     remove_argument (i, &argc, argv);
     111    remove_argument (N, &argc, argv);
    90112  }
    91113  /* only add image potion to image table */
    … …  
    133155    fprintf (stderr, "USAGE: addstar -ref (filename)\n");
    134156    fprintf (stderr, "  cur: %s ", argv[0]);
    135     for (i = 0; i < argc; i++) { fprintf (stderr, "%s ", argv[i]); }
     157    for (N = 0; N < argc; N++) { fprintf (stderr, "%s ", argv[N]); }
    136158    fprintf (stderr, "\n"); 
    137159    exit (2);
  • trunk/Ohana/src/addstar/src/find_matches.c

    r3376 r3389  
    4949  REALLOCATE (catalog[0].missing, Missing, NMISS);
    5050 
    51   /* project onto rectilinear grid with 1 arcsec pixels, sort by X */
    52   /* reference for coords is this image */
    53   tcoords = image[0].coords;
    54   tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
    55   tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
    56   tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
    57   strcpy (tcoords.ctype, "RA---TAN");
    58  
     51  /* project onto rectilinear grid with 1 arcsec pixels */
     52  /* we keep the original crpix1,2 and crref1,2 */
     53  /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */
     54  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
     55    tcoords = MOSAIC[0];
     56    tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     57    tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
     58    tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
     59    tcoords.Npolyterms = 1;
     60    strcpy (tcoords.ctype, "RA---TAN");
     61  } else {
     62    tcoords = image[0].coords;
     63    tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     64    tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
     65    tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
     66    strcpy (tcoords.ctype, "RA---TAN");
     67  }
     68
    5969  for (i = 0; i < Nstars; i++) {
    6070    fRD_to_XY (&X1[i], &Y1[i], stars[i].R, stars[i].D, &tcoords);
    … …  
    134144      /* calculate accurate per-star airmass */
    135145      secz = airmass (image[0].secz, stars[N].R, stars[N].D, SiderealTime, Latitude);
    136 
    137146     
    138147      /** add measurements for this star **/
    … …  
    162171      if (*Mval == NO_MAG) *Mval = Mrel;
    163172
     173      /** this is a little tricky: the new measures are not in the measure sequence
     174          this call can run into the next star if we have had two measures found at this location. **/
    164175      if (CALIBRATE) {
    165         /** this is a little tricky: the new measures are not in the measure sequence
    166             this call can run into the next star if we have had two measures found at this location. **/
    167176        AddToCalibration (&catalog[0].average[n], &catalog[0].measure[m], &catalog[0].measure[Nmeas], N);
    168177      }
    … …  
    202211
    203212  /* add reference for undetected catalog stars */
     213  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) RegisterMosaic (MOSAIC);
    204214  for (j = 0; (j < Nave) && !SKIP_MISSED; j++) {
    205215    n = N2[j];
    … …  
    287297    /** now add references from all previous non-detection observations of this spot on the sky */
    288298    for (j = 0; (j < Noverlap) && !SKIP_MISSED; j++) {
     299      if (!FindMosaicForImage (overlap, Noverlap, j)) continue;
    289300      if (!in_image (catalog[0].average[Nave].R, catalog[0].average[Nave].D, &overlap[j])) continue;
    290301      if (catalog[0].average[Nave].Nn < 1) {
  • trunk/Ohana/src/addstar/src/gimages.c

    r3376 r3389  
    3838  /* project onto rectilinear grid with 1 arcsec pixels */
    3939  /* we keep the original crpix1,2 and crref1,2 */
    40   tcoords = image[0].coords;
    41   tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
    42   tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
    43   tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
    44   strcpy (tcoords.ctype, "RA---TAN");
     40  /* for mosaic astrometry, the grid should be w.r.t. the tangent-plane, not chip coords */
     41  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
     42    tcoords = MOSAIC[0];
     43    tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     44    tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
     45    tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
     46    tcoords.Npolyterms = 1;
     47    strcpy (tcoords.ctype, "RA---TAN");
     48    RegisterMosaic (MOSAIC);
     49    /* register so image->sky conversions below have correct mosaic */
     50  } else {
     51    tcoords = image[0].coords;
     52    tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     53    tcoords.pc1_1 = tcoords.pc2_2 = 1.0;
     54    tcoords.pc1_2 = tcoords.pc2_1 = 0.0;
     55    strcpy (tcoords.ctype, "RA---TAN");
     56  }
    4557
    4658  /* define original corners */
    … …  
    5163  Xo[4] = 0;           Yo[4] = 0;  /* so we can make a loop easily */
    5264  for (j = 0; j < 5; j++) {
     65    /* XY-to_RD is two-level if ctype == WRP */
    5366    XY_to_RD (&r, &d, Xo[j], Yo[j], &image[0].coords);
    5467    RD_to_XY (&Xo[j], &Yo[j], r, d, &tcoords);
    … …  
    7790  }
    7891
    79   NTIMAGE = 100;
     92  /* kind of dangerous, see note below */
     93  NTIMAGE = MAX (MIN (Nimage, 1000), 1);
    8094  ALLOCATE (timage, Image, NTIMAGE);
    8195
    … …  
    87101  for (Ntimage = 0; Ntimage < Nimage; Ntimage += ntimage) {
    88102    ntimage = Fread (timage, sizeof(Image), NTIMAGE, f, "image");
     103    if (ntimage == 0) Shutdown ("expected %d images, only found %d", Nimage, Ntimage);
     104    BuildChipMatch (timage, ntimage);
     105
    89106    for (i = 0; i < ntimage; i++) {
     107
     108      /* if any of these images are WRP images, need to find matching DIS */
     109      if (!FindMosaicForImage (timage, ntimage, i)) {
     110        fprintf (stderr, "!");
     111        continue;
     112      }
     113
    90114      addtolist = FALSE;
    91115      /* define image corners */
    … …  
    116140      }
    117141    }
     142  }
    118143
    119     if (ntimage == 0) {
    120       Shutdown ("expected %d images, only found %d", Nimage, Ntimage);
    121     }
    122   }
     144  BuildChipMatch (pimage, npimage);
    123145
    124146  if (VERBOSE) fprintf (stderr, "found %d overlapping images\n", npimage);
    … …  
    129151}
    130152 
     153/* this function tries to find overlapping images with the current image.
     154   it loads the image table in blocks (up to 1000 at a time) and looks
     155   for overlaps within the set.  the search is not very robust. in
     156   addition, it needs to look for mosaic DIS images matching any WRP images.
     157   if the WRP image is loaded near the beginning of a block, then the corresponding DIS
     158   may be in the previous block, and thus missed
     159*/
  • trunk/Ohana/src/addstar/src/gregion_image.c

    r3376 r3389  
    1212  impatch.DEC[0] = +90;
    1313  impatch.DEC[1] = -90;
     14
     15  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
     16    if (MOSAIC == NULL) Shutdown ("no mosaic for WRP image (use -mosaic)");
     17    RegisterMosaic (MOSAIC);
     18  }   
    1419
    1520  for (x = 0; x <= 1; x++) {
  • trunk/Ohana/src/addstar/src/gstars.c

    r3361 r3389  
    5252    exit (1);
    5353  }
     54  if (!strcmp (&image[0].coords.ctype[4], "-WRP")) {
     55    if (MOSAIC == NULL) {
     56      fprintf (stderr, "ERROR: no mosaic for WRP image (use -mosaic)\n");
     57      exit (1);
     58    }
     59    RegisterMosaic (MOSAIC);
     60  }   
    5461   
    5562  /* get ST (used for airmass calculation) */
Note: See TracChangeset for help on using the changeset viewer.