IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 22, 2013, 7:29:00 AM (13 years ago)
Author:
eugene
Message:

working on fiximids

Location:
branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/initialize_fiximids.c

    r35591 r35592  
    55    fprintf (stderr, "  options:\n");
    66    fprintf (stderr, "    -v : verbose mode\n");
     7    fprintf (stderr, "    -cpt n0000/0000.00.cpt : only repair this cpt file \n");
     8    fprintf (stderr, "    -region Rmin Rmax Dmin Dmax : only repair this region\n");
    79    fprintf (stderr, "    -update : actually write results to detections tables\n");
    8     fprintf (stderr, "    -parallel : run in parallel mode\n");
     10    fprintf (stderr, "    -parallel : run in parallel mode\n\n");
     11
    912    fprintf (stderr, "    -h     : this help list\n");
    1013    fprintf (stderr, "    -help  : this help list\n");
    1114    fprintf (stderr, "    --h    : this help list\n");
    1215    fprintf (stderr, "    --help : this help list\n");
     16   
    1317    fprintf (stderr, "    Note that the dvo db can be specified by -D CATDIR (directory)\n");
    1418    exit (2);
     
    170174  }
    171175
     176  SINGLE_CPT = NULL;
     177  if ((N = get_argument (argc, argv, "-cpt"))) {
     178    remove_argument (N, &argc, argv);
     179    SINGLE_CPT = strcreate (argv[N]);
     180    remove_argument (N, &argc, argv);
     181  }
     182
    172183  // region of interest
    173184  UserPatch.Rmin = 0;
  • branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/load_images_fiximids.c

    r35591 r35592  
    11# include "fiximids.h"
    22
    3 // array of mosaic definition structures
    4 static off_t   Nmosaic;
    5 static Mosaic *mosaic;
     3off_t Nimage;
     4e_time *startImage;
     5e_time *stopImage;
     6short *photcodeImage;
    67
    7 // list of mosaic associated with each image 
    8 static off_t    Nmosaic_for_images; // number of images (for off_ternal checks)
    9 static off_t    *mosaic_for_images; // array of: image -> mosaic
    10 
    11 Image *load_images_fiximids (FITS_DB *db, off_t *Nimage) {
     8Image *load_images_fiximids (FITS_DB *db, off_t *N) {
    129
    1310  Image *image;
     
    2522  }
    2623
     24  // XXX init lookup tables
     25
    2726  fprintf (stderr, "loaded "OFF_T_FMT" images\n", *Nimage);
    2827
     
    3332// This code is copied from relastro/src/MosaicOps.c
    3433
    35 off_t getMosaicByTimes (unsigned int start, unsigned int stop, unsigned int *startMos, unsigned int *stopMos, off_t *indexMos) {
     34off_t FindImageID (e_time time, short photcode) {
    3635
    37   // use bisection to find the overlapping mosaic
     36  // use bisection to find the overlapping imagea
    3837
    3938  off_t Nlo, Nhi, N;
  • branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_catalog_fiximids.c

    r35591 r35592  
    77
    88  found = 0;   
    9   for (i = 0; i < catalog[0].Naverage; i++) {
     9  for (i = 0; i < catalog[0].Nmeasure; i++) {
     10   
     11    // only do PS1 / GPC1 photcodes?
     12    // XXX if (catalog[0].measure[i].photcode < 10000) continue;
     13    // XXX if (catalog[0].measure[i].photcode > 10600) continue;
    1014
    11     off_t m = catalog[0].average[i].measureOffset;
    12     for (j = 0; j < catalog[0].average[i].Nmeasure; j++, m++) {
    13       off_t ID = catalog[0].measure[m].imageID;
    14       if (ID <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode)
     15    // we have a measure with a given photcode and time:
     16    short photcode = catalog[0].measure[i].photcode;
     17    e_time time = catalog[0].measure[i].t;
    1518
    16       // XXX only do GPC1 data for now
    17       catalog[0].measure[m].pltscale = pltScale;
    18       if (catalog[0].measure[m].photcode < 10000) continue;
    19       if (catalog[0].measure[m].photcode > 10600) continue;
    20      
    21       // index[ID] = seqN
     19    off_t imageID = FindImageID (time, photcode);
     20    if (imageID <= 0) continue; // detections with imageID == 0 do not have a valid image (eg, ref photcode)
    2221
    23       off_t seq = index[ID];
     22    if (imageID == catalog[0].measure[i].imageID) {
     23      // existing image ID is valid
     24      Nvalid ++;
     25      onImage[imageID] ++;
     26      continue;
     27    }
    2428
    25       Mosaic *mosaic = getMosaicForImage(seq);
    26       Coords *coords = &image[seq].coords;
    27       Coords *mosaicCoords = mosaic ? &mosaic->coords : NULL;
     29    // existing image ID is NOT valid
     30    catalog[0].measure[i].imageID = imageID;
     31    Ninvalid ++;
     32    onImage[imageID] ++;
     33    continue;
    2834
    29       double Xccd = catalog[0].measure[m].Xccd;
    30       double Yccd = catalog[0].measure[m].Yccd;
    31      
    32       fiximids_local_astrometry (&posAngle, &pltScale, Xccd, Yccd, mosaicCoords, coords);
    33 
    34       catalog[0].measure[m].posangle = ToShortDegrees(posAngle);
    35       catalog[0].measure[m].pltscale = pltScale;
    36       myAssert(isfinite(catalog[0].measure[m].posangle), "oops: fiximids made a nan");
    37       myAssert(isfinite(catalog[0].measure[m].pltscale), "oops: fiximids made a nan");
    38       found ++;
    39     }
     35    found ++;
    4036  }
    4137
     
    4541}
    4642
    47 // this is basically a re-write / adaptation of pmSourceLocalAstrometry
    48 // posangle in degrees, plate scale in arcseconds/pixel
    49 int fiximids_local_astrometry (float *posAngle, float *pltScale, double x, double y, Coords *mosaic, Coords *coords) {
    50 
    51   double Lx, Mx, Po, Qo, Px, Qx, Py, Qy;
    52 
    53   // calculate the astrometry for the coordinate of interest
    54   XY_to_LM (&Lx, &Mx, x,       y,       coords);
    55   if (mosaic) {
    56     XY_to_LM (&Po, &Qo, Lx,      Mx,      mosaic);
    57   } else {
    58     Po = Lx;
    59     Qo = Mx;
    60   }
    61 
    62   XY_to_LM (&Lx, &Mx, x + 1.0, y,       coords);
    63   if (mosaic) {
    64     XY_to_LM (&Px, &Qx, Lx,      Mx,      mosaic);
    65   } else {
    66     Px = Lx;
    67     Qx = Mx;
    68   }
    69 
    70   XY_to_LM (&Lx, &Mx, x,       y + 1.0, coords);
    71   if (mosaic) {
    72     XY_to_LM (&Py, &Qy, Lx,      Mx,      mosaic);
    73   } else {
    74     Py = Lx;
    75     Qy = Mx;
    76   }
    77 
    78   // XXX units for the resulting Tangent Plane coordinates??
    79 
    80   double dPdX = Px - Po;
    81   double dPdY = Py - Po;
    82 
    83   double dQdX = Qx - Qo;
    84   double dQdY = Qy - Qo;
    85 
    86   double pltScale_x = hypot(dPdX, dQdX);
    87   double pltScale_y = hypot(dPdY, dQdY);
    88   *pltScale = 3600.0*0.5*(pltScale_x + pltScale_y);
    89 
    90   double posAngle_x, posAngle_y;
    91   double crossProduct = dPdX * dQdY - dPdY * dQdX;
    92   if  (crossProduct > 0.) {
    93     *pltScale *= -1.0;
    94     posAngle_x = atan2 (dQdX, dPdX);
    95     posAngle_y = atan2 (dQdY, dPdY) - M_PI_2;
    96   } else {
    97     posAngle_x = atan2 (dQdX, -dPdX);
    98     posAngle_y = atan2 (dQdY,  dPdY) - M_PI_2;
    99   }
    100 
    101   // with errors, these may end up on opposite sides of the M_PI boundary. 
    102   if (posAngle_x - posAngle_y > M_PI) {
    103     posAngle_y += 2.0 * M_PI;
    104   }
    105   if (posAngle_y - posAngle_x > M_PI) {
    106     posAngle_x += 2.0 * M_PI;
    107   }
    108   *posAngle = 0.5*(posAngle_x + posAngle_y)*DEG_RAD;
    109 
    110   return TRUE;
    111 }
  • branches/eam_branches/ipp-20130509/Ohana/src/uniphot/src/update_dvo_fiximids.c

    r35591 r35592  
    120120
    121121    char tmpline[1024];
    122     if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",              command);                    strcpy (command, tmpline); }
    123     if (UPDATE)        { snprintf (tmpline, 1024, "%s -update",         command);                    strcpy (command, tmpline); }
     122    if (VERBOSE)       { snprintf (tmpline, 1024, "%s -v",                  command); strcpy (command, tmpline); }
     123    if (SINGLE_CPT)    { snprintf (tmpline, 1024, "%s -cpt %s", SINGLE_CPT, command); strcpy (command, tmpline); }
     124    if (UPDATE)        { snprintf (tmpline, 1024, "%s -update",             command); strcpy (command, tmpline); }
    124125
    125126    if (PARALLEL_MANUAL) continue;
Note: See TracChangeset for help on using the changeset viewer.