IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37446


Ignore:
Timestamp:
Sep 29, 2014, 8:42:00 AM (12 years ago)
Author:
eugene
Message:

initial testing of the astrom map IO / application is now working in relastro

Location:
branches/eam_branches/ipp-20140904/Ohana/src/relastro
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/include/relastro.h

    r37261 r37446  
    204204int    PLOTDELAY;
    205205int    CHIPORDER;
     206int    CHIPMAP;
    206207
    207208int MaxDensityUse;
     
    547548int isGPC1stack (int photcode);
    548549int isGPC1warp (int photcode);
     550
     551int save_astrom_table ();
     552AstromOffsetTable *get_astrom_table ();
     553
     554int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts);
     555
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FitChip.c

    r37438 r37446  
    5757    relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch);
    5858
     59    // for polynomial fits, I used (5,30,60) = (5,6,7) stars per term
     60
    5961    // set the maximum order for the polynomial (based on number of stars kept above)
    6062    int order_use = 0;
    61     if (Nkeep >  5) order_use = 1; // 4 stars per polynomial term (per dimension)
    62     if (Nkeep > 30) order_use = 2; // 5 stars per polynomial term (per dimension)
    63     if (Nkeep > 60) order_use = 3; // 6 stars per polynomial term (per dimension)
     63    if (Nkeep >   5) order_use = 1; //  5 stars per cell
     64    if (Nkeep >  24) order_use = 2; //  6 stars per cell
     65    if (Nkeep >  63) order_use = 3; //  7 stars per cell
     66    if (Nkeep > 128) order_use = 4; //  8 stars per cell
     67    if (Nkeep > 225) order_use = 5; //  9 stars per cell
     68    if (Nkeep > 360) order_use = 6; // 10 stars per cell
    6469    if (order_use < 1) {
    6570      if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for linear fit\n", Nkeep);
     
    6772      return FALSE;
    6873    }
     74    // fprintf (stderr, "using %d for %s\n", order_use, image[0].name);
    6975
    7076    // when fitting the map, first fit a linear model (below? change Npolyterms to -1)
    71     if (MAP) {
     77    if (CHIPMAP) {
    7278      image[0].coords.Npolyterms = 1;
    7379    } else {
     
    99105    }
    100106
     107    // apply fit to get the fitted X,Y coordinates.  we need these to fit the residual map below
    101108    for (i = 0; i < Nmatch; i++) {
    102       // we have not yet fitted the map, so image[0].coords.Npolyterms needs to
    103       // be 1 here...
     109      // we have not yet fitted the map, so Npolyterms needs to be 1 here:
     110      LM_to_XY (&ref[i].X, &ref[i].Y, ref[i].L, ref[i].M, &image[0].coords);
     111    }
     112
     113    if (CHIPMAP) {
     114      if (image[0].coords.offsetMap == NULL) {
     115        // allocate a new table and assign to this image
     116        AstromOffsetTable *table = get_astrom_table ();
     117        AstromOffsetTableNewMap(table, order_use, image);
     118      }
     119      fit_map (image[0].coords.offsetMap, raw, ref, Nmatch);
     120      image[0].coords.Npolyterms = -1;
     121    }
     122
     123    for (i = 0; i < Nmatch; i++) {
     124      // if we have fitted the map above, Npolyterms needs to be -1 here:
    104125      XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[0].coords);
    105     }
    106 
    107     // where do we apply the fit all the way b
    108 
    109     if (MAP) {
    110       if (image[0].coords.offsetMap == NULL) {
    111         AstromOffsetMap *map = AstromOffsetTableNewMap(table, order);
    112         image[0].coords.offsetMap = map;
    113       }
    114       fit_map (image[0].coords.offsetMap, raw, ref);
    115       image[0].coords.Npolyterm = -1;
    116126    }
    117127  }
     
    274284*/
    275285
    276 int fit_map (AstromOffsetMap *map) {
     286int fit_map (AstromOffsetMap *map, StarData *raw, StarData *ref, int Npts) {
    277287
    278288  // we are actually fitting the residual after the linear fit has been taken off
     
    280290  // fit the linear terms as above
    281291  // calculate dX (raw.X - ref.X) and dY
    282  
    283   AstromOffsetMapFit (map, x, y, dX, Npts, TRUE);
    284   AstromOffsetMapFit (map, x, y, dY, Npts, FALSE);
     292
     293  int i, N;
     294
     295  float *x, *y, *dX, *dY;
     296  ALLOCATE (x,  float, Npts);
     297  ALLOCATE (y,  float, Npts);
     298  ALLOCATE (dX, float, Npts);
     299  ALLOCATE (dY, float, Npts);
     300
     301  N = 0;
     302  for (i = 0; i < Npts; i++) {
     303    if (raw[i].mask) continue;
     304    x[N] = raw[i].X;
     305    y[N] = raw[i].Y;
     306    dX[N] = ref[i].X - raw[i].X;
     307    dY[N] = ref[i].Y - raw[i].Y;
     308    N++;
     309  }
     310
     311  // in coordsops.c:XY_to_LM, the map is defined to carry dX,dY so that:
     312  // (L,M) = f(X',Y') : (X',Y') = (X,Y) + (dX,dY)
     313
     314  AstromOffsetMapFit (map, x, y, dX, N, TRUE);
     315  AstromOffsetMapFit (map, x, y, dY, N, FALSE);
     316
     317  free (x);
     318  free (y);
     319  free (dX);
     320  free (dY);
    285321
    286322  return TRUE;
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/args.c

    r37038 r37446  
    370370    CHIPORDER = atoi(argv[N]);
    371371    remove_argument (N, &argc, argv);
     372  }
     373
     374  CHIPMAP = FALSE;
     375  if ((N = get_argument (argc, argv, "-chipmap"))) {
     376    remove_argument (N, &argc, argv);
     377    CHIPMAP = TRUE;
    372378  }
    373379
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/high_speed_utils.c

    r33652 r37446  
    141141    off_t n;
    142142    for (n = 0; n < NfieldsA; n++) {
    143         valuesA[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], &fieldsA[n]);
     143      valuesA[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], NULL, NULL, &fieldsA[n]);
    144144    }
    145145    return dbBooleanCond(stackA, NstackA, valuesA);
     
    155155    off_t n;
    156156    for (n = 0; n < NfieldsB; n++) {
    157         valuesB[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], &fieldsB[n]);
     157        valuesB[n] = dbExtractAverages (&catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt], &catalog[0].measure[m], NULL, NULL, &fieldsB[n]);
    158158    }
    159159    return dbBooleanCond(stackB, NstackB, valuesB);
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_images.c

    r37378 r37446  
    11# include "relastro.h"
     2
     3static AstromOffsetTable *table = NULL;
     4
     5/* AstromOffsetMap is the map of Astrometry Offsets for non-polynomial astrometric
     6 * corrections for each chip. 
     7 */
    28
    39int load_images (FITS_DB *db, SkyList *skylist, int UseFullOverlap) {
     
    1723  MARKTIME("  convert image table: %f sec\n", dtime);
    1824
     25  // assign image->parent and image->coords.mosaic
    1926  BuildChipMatch (image, Nimage);
    2027  MARKTIME("build chip match: %f sec\n", dtime);
     28
     29  char mapfile[DVO_MAX_PATH];
     30  snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
     31  table = AstromOffsetMapLoad (mapfile, VERBOSE);
     32
     33  // assign images.coords.offsetMap -> table->map[i]
     34  if (table) {
     35    AstromOffsetTableMatchChips (image, Nimage, table);
     36  } else {
     37    table = AstromOffsetTableInit ();
     38  }
    2139
    2240  // select the images which overlap the selected sky regions
     
    5472  return TRUE;
    5573}
     74
     75int save_astrom_table () {
     76
     77  char mapfile[DVO_MAX_PATH];
     78  snprintf (mapfile, DVO_MAX_PATH, "%s/AstroMap.fits", CATDIR);
     79  AstromOffsetMapSave (table, mapfile);
     80
     81  return TRUE;
     82}
     83
     84AstromOffsetTable *get_astrom_table () {
     85  return table;
     86}
     87
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/relastro_images.c

    r36833 r37446  
    102102  if (PARALLEL) {
    103103    // save the updated image parameters
     104    // need to also save the image map table...
     105    save_astrom_table ();
    104106    dvo_image_update (&db, VERBOSE);
    105107    dvo_image_unlock (&db);
     
    114116  if (!PARALLEL) {
    115117    // save the updated image parameters
     118    save_astrom_table ();
    116119    dvo_image_update (&db, VERBOSE);
    117120    dvo_image_unlock (&db);
Note: See TracChangeset for help on using the changeset viewer.