IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 37604


Ignore:
Timestamp:
Nov 14, 2014, 8:42:00 PM (12 years ago)
Author:
eugene
Message:

testing ICRF and Galaxy Model correctios

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

Legend:

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

    r37562 r37604  
    284284int           args                PROTO((int argc, char **argv));
    285285int           args_client         PROTO((int argc, char **argv));
    286 int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog));
     286int           bcatalog            PROTO((Catalog *subcatalog, Catalog *catalog, int Nsubcatalog));
    287287void          clean_images        PROTO((void));
    288288void          clean_measures      PROTO((Catalog *catalog, int Ncatalog, int final));
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FitChip.c

    r37479 r37604  
    7272      return FALSE;
    7373    }
    74     // fprintf (stderr, "using %d for %s\n", order_use, image[0].name);
     74    // XXX WATCH OUT HERE!!
     75    if (!CHIPMAP) order_use = MIN(order_use, 1);
     76    fprintf (stderr, "using %d for %s\n", order_use, image[0].name);
    7577
    7678    // when fitting the map, first fit a linear model (below? change Npolyterms to -1)
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/FrameCorrection.c

    r37562 r37604  
    180180
    181181    Average *average = &catalog[cat].average[ave];
    182     Measure *measure = &catalog[cat].measure[meas]; // MeasureTiny?
     182    MeasureTiny *measure = &catalog[cat].measureT[meas]; // MeasureTiny?
    183183
    184184    // record these in arcsec or degree?
     
    240240int FrameCorrectionFitLocal (Catalog *catalog, int Ncatalog, AstromOffsetMap *map, Coords *coords) {
    241241
     242  int i;
    242243  double Xave, Yave, Xmeas, Ymeas;
    243244  float *X, *Y, *dX, *dY;
    244245
     246  int Nicrf = ICRFmax();
     247  if (!Nicrf) {
     248    fprintf (stderr, "no matched ICRF quasars for reference correction, skipping\n");
     249    return FALSE;
     250  }
     251
     252  double *Rave, *Dave, *Rmeas, *Dmeas;
     253  float *dXf, *dYf, *dPos;
     254
    245255  int Npts = 0;
    246   int NPTS = 100;
    247 
    248   ALLOCATE (X, float, NPTS);
    249   ALLOCATE (Y, float, NPTS);
    250   ALLOCATE (dX, float, NPTS);
    251   ALLOCATE (dY, float, NPTS);
    252 
    253   int Nicrf = ICRFmax();
    254 
    255   int i;
     256  ALLOCATE (Rave, double, Nicrf);
     257  ALLOCATE (Dave, double, Nicrf);
     258  ALLOCATE (Rmeas, double, Nicrf);
     259  ALLOCATE (Dmeas, double, Nicrf);
     260
     261  ALLOCATE (X,  float, Nicrf);
     262  ALLOCATE (Y,  float, Nicrf);
     263  ALLOCATE (dX, float, Nicrf);
     264  ALLOCATE (dY, float, Nicrf);
     265  ALLOCATE (dXf, float, Nicrf);
     266  ALLOCATE (dYf, float, Nicrf);
     267
     268  ALLOCATE (dPos, float, Nicrf);
     269
     270  int *mask = NULL;
     271  ALLOCATE (mask, int, Nicrf);
     272  memset (mask, 0, Nicrf*sizeof(int));
     273
     274  // select the ICRF QSOS and save the necessary data
    256275  for (i = 0; i < Nicrf; i++) {
    257276
    258     int cat, meas, ave;
    259     ICRFdata (i, &cat, &meas, &ave);
     277    int cat, ave, meas;
     278    ICRFdata (i, &cat, &ave, &meas);
    260279
    261280    Average *average = &catalog[cat].average[ave];
    262     Measure *measure = &catalog[cat].measure[meas]; // MeasureTiny?
     281    MeasureTiny *measure = &catalog[cat].measureT[meas]; // MeasureTiny?
    263282
    264283    // this local correction is defined for (Rmin < R < Rmax, Dmin < D < Dmax)
     
    278297    dX[Npts] = Xave - Xmeas;
    279298    dY[Npts] = Yave - Ymeas;
     299    Rave[Npts] = average->R;
     300    Dave[Npts] = average->D;
     301    Rmeas[Npts] = measure->R;
     302    Dmeas[Npts] = measure->D;
    280303    Npts ++;
    281     if (Npts == NPTS) {
    282       NPTS += 100;
    283       REALLOCATE (X, float, NPTS);
    284       REALLOCATE (Y, float, NPTS);
    285       REALLOCATE (dX, float, NPTS);
    286       REALLOCATE (dY, float, NPTS);
    287     }
    288   }   
    289 
    290   AstromOffsetMapFit (map, X, Y, dX, Npts, TRUE);
    291   AstromOffsetMapFit (map, X, Y, dY, Npts, FALSE);
     304  }
     305
     306  float *Xfit, *Yfit, *dXfit, *dYfit;
     307  ALLOCATE (Xfit, float, Npts);
     308  ALLOCATE (Yfit, float, Npts);
     309  ALLOCATE (dXfit, float, Npts);
     310  ALLOCATE (dYfit, float, Npts);
     311
     312  int Niter;
     313  for (Niter = 0; Niter < 3; Niter ++) {
     314    int Nkeep = 0;
     315    for (i = 0; i < Npts; i++) {
     316      if (mask[i]) continue;
     317     
     318      Xfit[Nkeep] = X[i];
     319      Yfit[Nkeep] = Y[i];
     320      dXfit[Nkeep] = dX[i];
     321      dYfit[Nkeep] = dY[i];
     322      Nkeep ++;
     323    }
     324
     325    AstromOffsetMapFit (map, Xfit, Yfit, dXfit, Nkeep, TRUE);
     326    AstromOffsetMapFit (map, Xfit, Yfit, dYfit, Nkeep, FALSE);
     327
     328    for (i = 0; i < Npts; i++) {
     329      dXf[i] = AstromOffsetMapValue (map, X[i], Y[i], TRUE);
     330      dYf[i] = AstromOffsetMapValue (map, X[i], Y[i], FALSE);
     331    }
     332
     333    // generate a histogram of the dPos = sqrt((dXf - dX)^2 + (dYf - dY)^2) values
     334    Nkeep = 0;
     335    for (i = 0; i < Npts; i++) {
     336      if (mask[i]) continue;
     337      float dP = hypot((dXf[i] - dX[i]), (dYf[i] - dY[i]));
     338      if (isnan(dP)) continue; // not all points are in the map
     339      dPos[Nkeep] = dP;
     340      Nkeep ++;
     341    }
     342    fsort (dPos, Nkeep);
     343   
     344    float dPmax = 1.5*dPos[(int)(0.95*Nkeep)];
     345
     346    // mask points based on dPmax
     347    Nkeep = 0;
     348    for (i = 0; i < Npts; i++) {
     349      float dP = hypot((dXf[i] - dX[i]), (dYf[i] - dY[i]));
     350      if (dP > dPmax) mask[i] = 1;
     351      if (isnan(dP)) mask[i] = 1;
     352      if (mask[i]) Nkeep++;
     353    }
     354    fprintf (stderr, "keeping %d of %d points\n", Nkeep, Npts);
     355  }
     356  free (Xfit);
     357  free (Yfit);
     358  free (dXfit);
     359  free (dYfit);
     360
     361  // *** save the icrf points and fit residuals
     362  {
     363    FILE *f = fopen ("map.dat", "w");
     364
     365    for (i = 0; i < Npts; i++) {
     366      fprintf (f, "%3d %12.8f %12.8f  %12.8f %12.8f  %f %f : %f %f : %f %f : %d\n", i, Rave[i], Dave[i], Rmeas[i], Dmeas[i], X[i], Y[i], dX[i], dY[i], dXf[i], dYf[i], mask[i]);
     367    }   
     368    fclose (f);
     369  }
     370
     371  // write out the maps as images
     372  {
     373    Header header;
     374    Matrix matrix;
     375   
     376    gfits_init_header (&header);
     377    header.bitpix = -32;
     378    header.Naxes = 2;
     379    header.Naxis[0] = map->Nx;
     380    header.Naxis[1] = map->Ny;
     381
     382    gfits_create_header (&header);
     383    gfits_create_matrix (&header, &matrix);
     384    PutCoords (coords, &header);
     385
     386    float *buffer = (float *)matrix.buffer;
     387
     388    int ix, iy;
     389    for (ix = 0; ix < map->Nx; ix++) {
     390      for (iy = 0; iy < map->Ny; iy++) {
     391        buffer[ix + map->Nx*iy] = map->dXv[ix][iy];
     392      }
     393    }
     394   
     395    gfits_write_header ("map.dX.fits", &header);
     396    gfits_write_matrix ("map.dX.fits", &matrix);
     397
     398    for (ix = 0; ix < map->Nx; ix++) {
     399      for (iy = 0; iy < map->Ny; iy++) {
     400        buffer[ix + map->Nx*iy] = map->dYv[ix][iy];
     401      }
     402    }
     403    gfits_write_header ("map.dY.fits", &header);
     404    gfits_write_matrix ("map.dY.fits", &matrix);
     405  }
    292406
    293407  return TRUE;
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ICRF.c

    r37545 r37604  
    1818int ICRFsave (int cat, int ave, int meas) {
    1919 
     20  fprintf (stderr, "ICRF: %d %d %d\n", cat, ave, meas);
     21
    2022  ICRFtoCatalog[Nicrf] = cat;
    2123  ICRFtoAverage[Nicrf] = ave;
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/ImageOps.c

    r37545 r37604  
    810810    // XXX subtract off dR,dD GAL here
    811811    if (USE_GALAXY_MODEL) {
    812       ref[i].R += measure[0].RoffGAL;
    813       ref[i].D += measure[0].DoffGAL;
     812      ref[i].R += measure[0].RoffGAL / 3600.0;
     813      ref[i].D += measure[0].DoffGAL / 3600.0;
    814814    }
    815815
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/UpdateObjects.c

    r37545 r37604  
    210210
    211211    if (USE_GALAXY_MODEL) {
    212       Ri -= measure[0].RoffGAL;
    213       Di -= measure[0].DoffGAL;
     212      Ri -= measure[k].RoffGAL / 3600.0;
     213      Di -= measure[k].DoffGAL / 3600.0;
    214214    }
    215215
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/bcatalog.c

    r37545 r37604  
    1919int LimitDensityCatalog_ByNmeasureGrid (Catalog *subcatalog, Catalog *oldcatalog);
    2020
    21 int bcatalog (Catalog *subcatalog, Catalog *catalog) {
     21int bcatalog (Catalog *subcatalog, Catalog *catalog, int Nsubcatalog) {
    2222
    2323  off_t i, j, offset;
     
    6262
    6363  int Nicrf = 0;
     64
     65  FILE *f = fopen ("test.icrf.dat", "a");
    6466
    6567  /* exclude stars not in range or with too few measurements */
     
    98100        // we need to save the location of the ICRF QSOs in the database
    99101        if (subcatalog[0].measureT[Nmeasure].dbFlags & ID_MEAS_ICRF_QSO) {
    100           ICRFsave (i, Naverage, Nmeasure);
     102          ICRFsave (Nsubcatalog, Naverage, Nmeasure);
     103          fprintf (f, "%d %d %d : %f %f : %f %f\n", (int) Nsubcatalog, (int) Naverage, (int) Nmeasure,
     104                   catalog[0].average[i].R, catalog[0].average[i].D,
     105                   catalog[0].measure[offset].R, catalog[0].measure[offset].D);
    101106          Nicrf ++;
    102107        }
     
    224229  subcatalog[0].catID    = catalog[0].catID;
    225230  assert (Nsecfilt == catalog[0].Nsecfilt);
     231
     232  fclose (f);
    226233
    227234// limit the total number of stars in the catalog
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/initialize.c

    r37038 r37604  
    6363  initstats (STATMODE);
    6464
     65  if (USE_ICRF_CORRECT) ICRFinit();
     66
    6567  /* XXX drop irrelevant entries */
    6668  if (SHOW_PARAMS) {
  • branches/eam_branches/ipp-20140904/Ohana/src/relastro/src/load_catalogs.c

    r37545 r37604  
    6868      // results are in Average, Secfilt, and MeasureTiny
    6969      // Ncat tracks the actually used catalogs
    70       bcatalog (&catalog[Ncat], &tcatalog);
     70      bcatalog (&catalog[Ncat], &tcatalog, Ncat);
    7171      dvo_catalog_unlock (&tcatalog);
    7272      dvo_catalog_free (&tcatalog);
Note: See TracChangeset for help on using the changeset viewer.