IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Mar 2, 2005, 7:54:17 AM (21 years ago)
Author:
eugene
Message:

more work towards addstar-2-0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/addstar/src/calibrate.c

    r3347 r3361  
    11# include "addstar.h"
    22
    3 static int Ncal, NCAL;
     3static int Ncal, NCAL, *Nstar;
    44static float *Mobs, *dMobs, *Mref, *dMref, *Cref, *Airm;
    5 static float *RA, *DEC, *X, *Y;
    6 int *Nstar;
    75
    86void InitCalibration () {
    97
    10     fprintf (stderr, "calibrating the image...  %d\n", CalReference);
     8    fprintf (stderr, "calibrating the image...  %d\n", thiscode[0].equiv);
    119    Ncal = 0;
    1210    NCAL = 1000;
     
    1816    ALLOCATE (Airm,  float,  NCAL);
    1917    ALLOCATE (Nstar, int, NCAL);
    20     ALLOCATE (RA, float, NCAL);
    21     ALLOCATE (DEC, float, NCAL);
    22     ALLOCATE (X, float, NCAL);
    23     ALLOCATE (Y, float, NCAL);
    2418}
    2519 
    26 void SaveCalibration (float M, float dM, float Mr, float dMr, float Mc, float A, int N, float ra, float dec, float x, float y) {
     20void SaveCalibration (float M, float dM, float Mr, float dMr, float Mc, float A, int N) {
    2721
    2822  Mobs[Ncal] = M;
     
    3327  Airm[Ncal] = A;
    3428  Nstar[Ncal] = N;
    35 
    36   RA[Ncal] = ra;
    37   DEC[Ncal] = dec;
    38   X[Ncal] = x;
    39   Y[Ncal] = y;
    4029  Ncal ++;
    4130
     
    4938    REALLOCATE (Airm,  float, NCAL);
    5039    REALLOCATE (Nstar, int,   NCAL);
    51     REALLOCATE (RA, float, NCAL);
    52     REALLOCATE (DEC, float, NCAL);
    53     REALLOCATE (X, float, NCAL);
    54     REALLOCATE (Y, float, NCAL);
    5540  }
     41}
     42
     43/* this does not use the linked list to navigate the measure structure
     44   this is OK for old measures, but will break for entries which have
     45   already added a new measure to the list.  */
     46void AddToCalibration (Average *average, Measure *measure, Measure *new, int Nstar) {
     47
     48  int i, found0, found1, found2;
     49  float CalM0, CalM1, CalM2, dCalM;
     50  short CalC0, CalC1, CalC2;
     51
     52  found0 = found1 = found2 = FALSE;
     53  CalM0 = CalM1 = CalM2 = dCalM = NO_MAG;
     54
     55  CalC0 = thiscode[0].equiv;
     56  CalC1 = thiscode[0].c1;
     57  CalC2 = thiscode[0].c2;
     58
     59  for (i = 0; i < average[0].Nm; i++) {
     60    if (measure[0].source == CalC0) {
     61      found0 = TRUE;
     62      CalM0  = measure[i].M;
     63      dCalM  = measure[i].dM;
     64    }
     65    if (measure[i].source == CalC1) {
     66      found1 = TRUE;
     67      CalM1  = measure[i].M;
     68    }
     69    if (measure[i].source == CalC2) {
     70      found2 = TRUE;
     71      CalM2  = measure[i].M;
     72    }
     73    if (found0 && found1 && found2) {
     74      SaveCalibration (new[0].M, new[0].dM, CalM0, dCalM, CalM1-CalM2, new[0].airmass, Nstar);
     75      return;
     76    }
     77    /* n = next[n]; - if we use this, we need to pass in measure[0] above */
     78  }
     79  return;
    5680}
    5781
     
    5983
    6084  int i, MaxN, *Nlist, Nkeep;
     85  short int Mint;
    6186  float N, M1, M2, Klam, Clam, Xlam, Mabs, *Dmag, *dDmag;
    6287  float dMo, dMr, Mw, Dmed, W1, W2, NSigma;
     
    91116    /* if this entry has too many (or two few?) matches, skip it */
    92117    if (Nlist[Nstar[i]] != 1) continue;
    93     Mabs = 0.001*(Mobs[i] + Klam*(Airm[i] - 1000) + Clam + Xlam*(Mref[i] - Cref[i])) - ZeroPt;
    94 
     118    Mint = Clam + Mobs[i] + Xlam*Cref[i] + Klam*(Airm[i] - 1000);
     119    Mabs = 0.001*Mint - ZeroPt;
    95120    /* note: subpix correction is applied in gstars */
    96 
    97     if (DUMP_MATCHES)
    98       fprintf (stdout, "%d  %6.3f %6.3f %6.3f  %10.6f %10.6f  %7.2f %7.2f  %7.2f  %7.2f\n",
    99                i, Mabs, 0.001*Mref[i], 0.001*Cref[i], RA[i], DEC[i], X[i], Y[i], Airm[i], 0.001*dMobs[i]);
    100121
    101122    /* skip stars brighter than 8.0 */
     
    157178  }
    158179}
    159 
    160 # if (0)
    161 
    162 /* old correction - superceeded by subpix grid */
    163 
    164   /* find lo (Dmed - 0.1) + hi (Dmed + 0.1)
    165   lo = -1; hi = -1;
    166   for (i = 0; (lo == -1) && (i < Nkeep); i++) { if (Dmed - Dmag[i] < 0.1) lo = i; }
    167   for (i = Nkeep - 1; (hi == -1) && (i >= 0); i--) { if (Dmag[i] - Dmed < 0.1) hi = i; }
    168   if (lo == -1) lo = 0;
    169   if (hi == -1) hi = Nkeep - 1;
    170   */
    171 
    172   if (Nkeep < 3) {
    173     fprintf (stderr, "too few stars\n");
    174     image[0].Mcal = 10000;
    175     image[0].dMcal = 10000;
    176     return;
    177   }
    178   fsort2 (Dmag, dDmag, Nkeep);
    179 
    180   /* accumulate delta mags (25% - 75% of list) */
    181   M1 = 0.0;
    182   M2 = 0.0;
    183   N  = 0.0;
    184   for (i = 0.25*Nkeep; i <= 0.75*Nkeep; i++) {
    185 
    186     /* a straight mean works better, given the bad photometry of skyprobe */
    187     M1 += Dmag[i];
    188     M2 += SQ (Dmag[i]);
    189     N  += 1.0;
    190 
    191   }
    192 
    193   if (N > 1) {
    194     M1 = M1 / N;
    195     M2 = sqrt (fabs(M2/N - M1*M1));
    196     fprintf (stderr, "N: %.0f, mean: %f, stdev: %f, precision: %f\n", N, M1, M2, M2 / sqrt (N));
    197     image[0].Mcal = 1000 * M1;
    198     image[0].dMcal = 1000 * M2 / sqrt (N);
    199   } else {
    200     fprintf (stderr, "too few stars\n");
    201     image[0].Mcal = 10000;
    202     image[0].dMcal = 10000;
    203   }
    204 
    205 
    206     /* subpix correction : make parameters global! */
    207     dAs = 0;
    208     if (Y[i] < 400) dAs = 0.06 - 0.00015*Y[i];
    209     dYs = Y[i] - (int) (Y[i]) + 0.55;
    210     dMs = dAs * sin (6.28*dYs);
    211     /* Mabs -= dMs; */
    212 
    213 # endif
Note: See TracChangeset for help on using the changeset viewer.