IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 38284


Ignore:
Timestamp:
May 16, 2015, 6:34:16 AM (11 years ago)
Author:
eugene
Message:

finish setastro repair tycho mode (but probably not needed now)

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

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20150419/Ohana/src/uniphot/Makefile

    r38062 r38284  
    112112$(SRC)/setastrom.$(ARCH).o          \
    113113$(SRC)/initialize_setastrom.$(ARCH).o \
     114$(SRC)/tyc_correction.$(ARCH).o \
    114115$(SRC)/cam_correction.$(ARCH).o \
    115116$(SRC)/dcr_correction.$(ARCH).o \
    116117$(SRC)/kh_correction.$(ARCH).o \
    117118$(SRC)/astrom_correction.$(ARCH).o \
     119$(SRC)/repair_tycho_setastrom.$(ARCH).o \
    118120$(SRC)/update_dvo_setastrom.$(ARCH).o \
    119121$(SRC)/update_catalog_setastrom.$(ARCH).o \
     
    128130$(SRC)/update_dvo_setastrom.$(ARCH).o \
    129131$(SRC)/update_catalog_setastrom.$(ARCH).o \
     132$(SRC)/tyc_correction.$(ARCH).o \
    130133$(SRC)/cam_correction.$(ARCH).o \
    131134$(SRC)/dcr_correction.$(ARCH).o \
    132135$(SRC)/kh_correction.$(ARCH).o \
     136$(SRC)/repair_tycho_setastrom.$(ARCH).o \
    133137$(SRC)/astrom_correction.$(ARCH).o \
    134138$(SRC)/initialize_setastrom.$(ARCH).o
  • branches/eam_branches/ipp-20150419/Ohana/src/uniphot/include/setastrom.h

    r38282 r38284  
    9393int load_cam_correction (char *filename);
    9494int get_cam_correction (int chipID, int filter, float Xccd, float Yccd, double *dX, double *dY);
     95
     96int load_tyc_correction (char *filename);
     97int get_tyc_correction (double **R, double **D, int *N);
     98int repair_tycho_setastrom (Catalog *catalog, SkyRegion *region);
  • branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/repair_tycho_setastrom.c

    r38283 r38284  
    66  int Ntycho;
    77
     8  short TYCHO_B = GetPhotcodeCodebyName ("TYCHO_B"); myAssert (TYCHO_B, "TYCHO_B photcode not found\n");
     9  short TYCHO_V = GetPhotcodeCodebyName ("TYCHO_V"); myAssert (TYCHO_V, "TYCHO_V photcode not found\n");
     10
     11  // the tycho R,D entries are sorted by tychoR
    812  if (!get_tyc_correction (&tychoR, &tychoD, &Ntycho)) {
    913    fprintf (stderr, "TYCHO correction not loaded\n");
     
    1317  // first select the subset of objects which lie in this catalog:
    1418  int Ns = ohana_bisection_double (tychoR, Ntycho, region->Rmin);
     19  Ns = MAX(Ns, 0); // if Rmin = 0.0, Ns could be -1 (since there are no entries with R < 0.0
    1520
    16   NSUBSET = 100;
    17   Nsubset = 0;
     21  int NSUBSET = 100;
     22  int Nsubset = 0;
     23  int *index = NULL;
    1824  ALLOCATE (index, int, NSUBSET);
    1925
    20   // scan throught tycho stars to select those in this catalog
     26  // scan through tycho stars to select those in this catalog
    2127  while ((Ns < Ntycho) && (tychoR[Ns] < region->Rmax)) {
    2228    if (tychoD[Ns] < region->Dmin) continue;
    2329    if (tychoD[Ns] > region->Dmax) continue;
    24    
    25     Ns
     30    // we have an object in range (Rmin <= R < Rmax; Dmin <= D <= Dmax)
     31
     32    index[Nsubset] = Ns;
     33    Nsubset ++;
     34    CHECK_REALLOCATE (index, int, NSUBSET, Nsubset, 100);
     35  } 
     36  if (Nsubset == 0) {
     37    free (index);
     38    return TRUE;
     39  }
    2640 
     41  // now find matches within this catalog
    2742 
     43  /** allocate local arrays (stars) **/
     44  off_t *N1, *N2;
     45  double *X1, *Y1, *X2, *Y2;
     46  ALLOCATE (X1, double, Nsubset);
     47  ALLOCATE (Y1, double, Nsubset);
     48  ALLOCATE (N1, off_t,  Nsubset);
     49
     50  /** allocate local arrays (catalog) **/
     51  ALLOCATE (X2, double, catalog[0].Naverage);
     52  ALLOCATE (Y2, double, catalog[0].Naverage);
     53  ALLOCATE (N2, off_t,  catalog[0].Naverage);
     54
     55  Coords tcoords;
     56  InitCoords (&tcoords, "DEC--ARC");
     57  tcoords.crval1 = 0.5*(region[0].Rmin + region[0].Rmax);
     58  if (region[0].Dmax < 90) {
     59    tcoords.crval2 = 0.5*(region[0].Dmin + region[0].Dmax);
     60  } else {
     61    tcoords.crval2 = 90.0;
     62  }
     63  tcoords.cdelt1 = tcoords.cdelt2 = 1.0 / 3600.0;
     64
     65  /* build spatial index (RA sort) referencing input array sequence */
     66  int i, j, J, k;
     67  for (i = 0; i < Nsubset; i++) {
     68    RD_to_XY (&X1[i], &Y1[i], tychoR[index[i]], tychoD[index[i]], &tcoords);
     69    N1[i] = i;
     70  }
     71  sort_coords_index (X1, Y1, N1, Nsubset);
    2872 
     73  /* build spatial index (RA sort) */
     74  for (i = 0; i < catalog[0].Naverage; i++) {
     75    RD_to_XY (&X2[i], &Y2[i], catalog[0].average[i].R, catalog[0].average[i].D, &tcoords);
     76    N2[i] = i;
     77  }
     78  sort_coords_index (X2, Y2, N2, catalog[0].Naverage);
    2979
     80    /* choose a radius for matches (defined in args.c or ImageOptions.c) */
     81  float RADIUS = 1.0;
     82  float RADIUS2 = RADIUS*RADIUS;
     83
     84  float dX, dY, dR;
     85
     86  /** find matched stars **/
     87  for (i = j = 0; (i < Nsubset) && (j < catalog[0].Naverage); ) {
     88    if (!finite(X1[i]) || !finite(Y1[i])) { i++; continue; }
     89    if (!finite(X2[j]) || !finite(Y2[j])) { j++; continue; }
     90
     91    /* negative dX: j is too large; positive dX, i is too large */
     92    dX = X1[i] - X2[j];
     93    if (dX <= -1.02*RADIUS) { i++; continue; }
     94    if (dX >= +1.02*RADIUS) { j++; continue; }
     95
     96    /* within match range; look for matches */
     97    for (J = j; (dX > -1.02*RADIUS) && (J < catalog[0].Naverage); J++) {
     98      dX = X1[i] - X2[J];
     99      dY = Y1[i] - Y2[J];
     100      dR = dX*dX + dY*dY;
     101      if (dR > RADIUS2) continue;
     102
     103      /*** a match is found ***/
     104
     105      off_t Ns = N1[i];
     106      off_t Nc = N2[j];
     107
     108      off_t m = catalog[0].average[Nc].measureOffset;
     109
     110      // for these stars, the average.R,D values are correct; replace the measure.R,D
     111      for (k = 0; k < catalog[0].average[Nc].Nmeasure; k++) {
     112        // find the tycho photcodes:
     113        int valid = FALSE;
     114        valid = valid || (catalog[0].measure[m+k].photcode == TYCHO_B);
     115        valid = valid || (catalog[0].measure[m+k].photcode == TYCHO_V);
     116        if (!valid) continue;
     117        catalog[0].measure[m+k].R = tychoR[Ns];
     118        catalog[0].measure[m+k].D = tychoD[Ns];
     119      }
     120    }
     121  }
     122 
     123  free (X1);
     124  free (X2);
     125  free (Y1);
     126  free (Y2);
     127  free (N1);
     128  free (N2);
     129  free (index);
     130
     131  return TRUE;
    30132}
     133
  • branches/eam_branches/ipp-20150419/Ohana/src/uniphot/src/tyc_correction.c

    r38282 r38284  
    55static double *tychoD = NULL;
    66
     7// the tycho correction table just lists the tycho stars (R,D) for which the astrometry was messed up
    78int load_tyc_correction (char *filename) {
    89
Note: See TracChangeset for help on using the changeset viewer.