IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 3389


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

adding mosaic astrometry concepts

Location:
trunk/Ohana/src
Files:
1 added
12 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) */
  • trunk/Ohana/src/libohana/Makefile

    r2833 r3389  
    2828$(SRC)/Fread.$(ARCH).o          $(SRC)/glockfile.$(ARCH).o       \
    2929$(SRC)/LoadPhotcodes.$(ARCH).o  $(SRC)/photfits.$(ARCH).o        \
    30 $(SRC)/phot_catalog.$(ARCH).o   $(SRC)/imreg_datatypes.$(ARCH).o
     30$(SRC)/phot_catalog.$(ARCH).o   $(SRC)/imreg_datatypes.$(ARCH).o \
     31$(SRC)/mosaic_astrom.$(ARCH).o
    3132
    3233$(DESTLIB)/libohana.a: $(LIB)/libohana.$(ARCH).a
  • trunk/Ohana/src/libohana/doc/ChangeLog.txt

    r3260 r3389  
     1
     2  changed meaning of PLY / WRP / DIS (see coordtrans.txt)
     3  added check on ALLOCATE/REALLOCATE to avoid failures on Nvalues < 1
     4
     5libohana-1-2
     6  added 'STG' to allowed coordinate transforms (inaccurate & stop-gap)
     7  set default Npolyterms to 1
     8  initialized filemode in glockfile.c
    19
    210libohana-1-1
  • trunk/Ohana/src/libohana/doc/coordtrans.txt

    r2413 r3389  
     1
     2I have changed the meaning of coord type PLY from the historical
     3meaning.  The only previous use that is in a DVO-style database is in
     4the loneos data (all cfht data needed to go to linear terms).  these
     5can be easily converted by changing from PLY to DIS.
     6
     7There are now three types of higher-order transformation which may be
     8used depending on the circumstance.  The new naming scheme is:
     9
     10PLY : a cartesian transformation (ie, no projection implied)
     11DIS : equivalent to TAN projection with up-to-3rd order polynomial
     12WRP : a second-level cartesian transformation, implying the presence
     13      of a DIS coord frame (must be registered with libohana function)
    114
    215{
  • trunk/Ohana/src/libohana/include/loneos.h

    r3363 r3389  
    410410int  fRD_to_XY (float *x,  float *y,   double ra, double dec, Coords *coords);
    411411int  GetCoords (Coords *coords, Header *header);
     412int  PutCoords (Coords *coords, Header *header);
     413void RegisterMosaic (Coords *coords);
     414void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch);
     415
    412416short int putMi (double value);
    413417double getMi (short int value);
     
    458462void ParseColorTerms (char *terms, float *X, int *N);
    459463
    460 void coords_precess (double *ra, double *dec, double in_epoch, double out_epoch);
    461 
    462464int get_image_type (char *name);
    463465char *get_type_name (int type);
  • trunk/Ohana/src/libohana/src/coordops.c

    r3371 r3389  
    22# include <loneos.h>
    33
     4static Coords *mosaic = NULL;
     5
     6void RegisterMosaic (Coords *coords) {
     7  mosaic = coords;
     8}
     9
    410int XY_to_RD (double *ra, double *dec, double x, double y, Coords *coords) {
    511
    6   int Polynomial, Zenithal, Cartesian, PseudoCyl;
     12  int Zenith1, Zenith2, Zenithal, Polynomial, Cartesian, PseudoCyl;
    713  char *type;
    814  double L, M, X, Y, T, Z;
     
    1521  type = &coords[0].ctype[4];
    1622 
    17   /* DIS and PLY are identical & apply projection; WRP is cartesian */
     23  /* DIS is equiv to TAN with higher order terms
     24     PLY is cartesian with higher order terms
     25     WRP is equiv to PLY, with implied mosaic */
     26
    1827  Polynomial = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-WRP");
    19   Zenithal   = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-SIN") || !strcmp(type, "-STG") || !strcmp(type, "-ZEA") || !strcmp(&coords[0].ctype[0], "MM");
    20   Cartesian  = !strcmp(type, "-LIN") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE");
     28  Cartesian  = !strcmp(type, "-LIN") || !strcmp(type, "-PLY") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE");
    2129  PseudoCyl  = !strcmp(type, "-AIT") || !strcmp(type, "-GLS") || !strcmp(type, "-PAR");
     30  Zenith1    = !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG");
     31  Zenith2    = !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM");
     32  Zenithal   = !strcmp(type, "-ZEA") || Zenith1 || Zenith2;
    2233  if (!Zenithal && !Cartesian && !PseudoCyl) return (FALSE);
    2334
     
    4556    *ra  = L + coords[0].crval1;
    4657    *dec = M + coords[0].crval2;
     58
     59    /* mosaic astrometry : WRP is chip astrometry; apply mosaic (DIS) term */
     60    if (!strcmp(type, "-WRP")) {
     61      if (mosaic == NULL) return (FALSE);
     62      XY_to_RD (ra, dec, L + coords[0].crval1, M + coords[0].crval2, mosaic);
     63    }
    4764    return (TRUE);
    4865  }
     
    6077
    6178    /* this is wrong : STG is not TAN - need to put in correct relationships.  but is a close approx */
    62     if (!strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG")) {
     79    if (Zenith1) {
    6380      if (R == 0) {
    6481        stht = 1.0;
     
    7087      }
    7188    }
    72     if (!strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
     89    if (Zenith2) {
    7390      ctht = RAD_DEG * R;
    7491      stht = sqrt (1 - ctht*ctht);
     
    124141
    125142  char *type;
    126   int i, status, Polynomial, Zenithal, Cartesian, PseudoCyl;
     143  int i, status, Polynomial, Zenith1, Zenith2, Zenithal, Cartesian, PseudoCyl;
    127144  double phi, theta;
    128145  double determ;
     
    139156
    140157  Polynomial = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-WRP");
    141   Zenithal   = !strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-SIN") || !strcmp(type, "-STG") || !strcmp(type, "-ZEA") || !strcmp(&coords[0].ctype[0], "MM");
    142   Cartesian  = !strcmp(type, "-LIN") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE");
     158  Cartesian  = !strcmp(type, "-LIN") || !strcmp(type, "-PLY") || !strcmp(type, "-WRP") || !strcmp(&coords[0].ctype[0], "GENE");
    143159  PseudoCyl  = !strcmp(type, "-AIT") || !strcmp(type, "-GLS") || !strcmp(type, "-PAR");
     160  Zenith1    = !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG");
     161  Zenith2    = !strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM");
     162  Zenithal   = !strcmp(type, "-ZEA") || Zenith1 || Zenith2;
    144163  if (!Zenithal && !Cartesian && !PseudoCyl) return (FALSE);
    145164
    146165  /**** Locally Cartesian Projections ****/
    147166  if (Cartesian) {
    148     L = (ra  - coords[0].crval1);
    149     M = (dec - coords[0].crval2);
     167    if (!strcmp(type, "-WRP")) {
     168      if (mosaic == NULL) return (FALSE);
     169      RD_to_XY (&Lo, &Mo, ra, dec, mosaic);
     170      L = (Lo - coords[0].crval1);
     171      M = (Mo - coords[0].crval2);
     172    } else {
     173      L = (ra  - coords[0].crval1);
     174      M = (dec - coords[0].crval2);
     175    }
    150176  }
    151177 
     
    164190    if (stht < 0) status = FALSE;
    165191
    166     if (!strcmp(type, "-PLY") || !strcmp(type, "-DIS") || !strcmp(type, "-TAN") || !strcmp(type, "-STG")) {
     192    if (Zenith1) {
    167193      L =  DEG_RAD * sphi / stht;
    168194      M = -DEG_RAD * cphi / stht;
    169195    }
    170     if (!strcmp(type, "-SIN") || !strcmp(&coords[0].ctype[0], "MM")) {
     196    if (Zenith2) {
    171197      L =  DEG_RAD * sphi;
    172198      M = -DEG_RAD * cphi;
Note: See TracChangeset for help on using the changeset viewer.