Changeset 5585
- Timestamp:
- Nov 23, 2005, 10:47:32 AM (20 years ago)
- Files:
-
- 9 edited
-
branches/addstar-1-3-0/Ohana/src/addstar/include/addstar.h (modified) (2 diffs)
-
branches/addstar-1-3-0/Ohana/src/addstar/src/ConfigInit.c (modified) (1 diff)
-
branches/addstar-1-3-0/Ohana/src/addstar/src/args.c (modified) (1 diff)
-
branches/addstar-1-3-0/Ohana/src/addstar/src/calibrate.c (modified) (7 diffs)
-
trunk/Ohana/src/addstar/include/addstar.h (modified) (2 diffs)
-
trunk/Ohana/src/addstar/src/ConfigInit.c (modified) (1 diff)
-
trunk/Ohana/src/addstar/src/addstar.c (modified) (1 diff)
-
trunk/Ohana/src/addstar/src/args.c (modified) (1 diff)
-
trunk/Ohana/src/addstar/src/calibrate.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/addstar-1-3-0/Ohana/src/addstar/include/addstar.h
r5347 r5585 68 68 /* these globals are used separately by both client and server (KEEP) */ 69 69 double ZeroPt; // double check for consistency 70 double CAL_INSTMAG_MAX; 71 double CAL_INSTMAG_MIN; 70 72 int VERBOSE; 71 73 … … 93 95 void InitCalibration PROTO(()); 94 96 GSCRegion *LoadRegions PROTO((int *nregions)); 95 void SaveCalibration PROTO((float M , float dM, float Mr, float dMr, float Mc, float A, int N));97 void SaveCalibration PROTO((float Mo, float dMo, float Mr, float dMr, float Mi, int N)); 96 98 void SetProtect PROTO((int mode)); 97 99 int SetSignals PROTO(()); -
branches/addstar-1-3-0/Ohana/src/addstar/src/ConfigInit.c
r5347 r5585 43 43 ScanConfig (config, "OBSERVATORY-LATITUDE", "%lf", 0, &Latitude); 44 44 ScanConfig (config, "SUBPIX_DATAFILE", "%s", 0, SubpixDatafile); 45 46 /* instrumental magnitude range for calibration mode */ 47 if (!ScanConfig (config, "CAL_INSTMAG_MAX", "%lf", 0, &CAL_INSTMAG_MAX)) CAL_INSTMAG_MAX = -9.0; 48 if (!ScanConfig (config, "CAL_INSTMAG_MIN", "%lf", 0, &CAL_INSTMAG_MIN)) CAL_INSTMAG_MIN = -13.0; 45 49 46 50 /* location of needed data sources */ -
branches/addstar-1-3-0/Ohana/src/addstar/src/args.c
r5328 r5585 144 144 options.calibrate = TRUE; 145 145 remove_argument (N, &argc, argv); 146 InitCalibration (FALSE); 147 } 148 if ((N = get_argument (argc, argv, "-excal"))) { 149 options.calibrate = TRUE; 150 remove_argument (N, &argc, argv); 151 InitCalibration (FALSE); 152 } 153 if ((N = get_argument (argc, argv, "-incal"))) { 154 options.calibrate = TRUE; 155 remove_argument (N, &argc, argv); 156 InitCalibration (TRUE); 146 157 } 147 158 -
branches/addstar-1-3-0/Ohana/src/addstar/src/calibrate.c
r5328 r5585 1 1 # include "addstar.h" 2 2 3 static int InternalCal; 3 4 static int Ncal, NCAL, *Nstar; 4 static float *Mobs, *dMobs, *Mref, *dMref, * Cref, *Airm;5 static float *Mobs, *dMobs, *Mref, *dMref, *Minst; 5 6 6 void InitCalibration ( ) {7 void InitCalibration (int mode) { 7 8 8 fprintf (stderr, "calibrating the image...\n"); 9 Ncal = 0; 10 NCAL = 1000; 11 ALLOCATE (Mobs, float, NCAL); 12 ALLOCATE (dMobs, float, NCAL); 13 ALLOCATE (Mref, float, NCAL); 14 ALLOCATE (dMref, float, NCAL); 15 ALLOCATE (Cref, float, NCAL); 16 ALLOCATE (Airm, float, NCAL); 17 ALLOCATE (Nstar, int, NCAL); 9 InternalCal = mode; 10 11 fprintf (stderr, "calibrating the image...\n"); 12 Ncal = 0; 13 NCAL = 1000; 14 ALLOCATE (Mobs, float, NCAL); 15 ALLOCATE (dMobs, float, NCAL); 16 ALLOCATE (Mref, float, NCAL); 17 ALLOCATE (dMref, float, NCAL); 18 ALLOCATE (Minst, float, NCAL); 19 ALLOCATE (Nstar, int, NCAL); 18 20 } 19 21 20 void SaveCalibration (float M , float dM, float Mr, float dMr, float Mc, float A, int N) {22 void SaveCalibration (float Mo, float dMo, float Mr, float dMr, float Mi, int N) { 21 23 22 Mobs[Ncal] = M;23 dMobs[Ncal] = dM ;24 Mref[Ncal] = Mr;24 Mobs[Ncal] = Mo; 25 dMobs[Ncal] = dMo; 26 Mref[Ncal] = Mr; 25 27 dMref[Ncal] = dMr; 26 Cref[Ncal] = Mc; 27 Airm[Ncal] = A; 28 Minst[Ncal] = Mi; 28 29 Nstar[Ncal] = N; 29 30 Ncal ++; … … 31 32 if (Ncal == NCAL) { 32 33 NCAL += 1000; 34 REALLOCATE (Mobs, float, NCAL); 33 35 REALLOCATE (dMobs, float, NCAL); 34 REALLOCATE (Mobs, float, NCAL);35 36 REALLOCATE (Mref, float, NCAL); 36 REALLOCATE (dMref, float, NCAL); 37 REALLOCATE (Cref, float, NCAL); 38 REALLOCATE (Airm, float, NCAL); 37 REALLOCATE (dMref, float, NCAL); 38 REALLOCATE (Minst, float, NCAL); 39 39 REALLOCATE (Nstar, int, NCAL); 40 40 } … … 44 44 void AddToCalibration (Average *average, Measure *measure, Measure *new, int *next, int Nstar) { 45 45 46 int i, m, found0, found1, found2;46 int i, j, m, found0, found1, found2; 47 47 float CalM0, CalM1, CalM2, dCalM; 48 float Mcal, color, factor; 48 49 short CalC0, CalC1, CalC2; 49 PhotCode *code; 50 51 PhotCode *mycode; // photcode of this measurement 52 PhotCode *incode; // mycode.equiv (internal reference) 53 PhotCode *excode; // incode.equiv (external reference) 50 54 51 55 found0 = found1 = found2 = FALSE; 52 56 CalM0 = CalM1 = CalM2 = dCalM = NO_MAG; 53 57 54 code = GetPhotcodebyCode (new[0].source); 55 CalC0 = code[0].equiv; 56 CalC1 = code[0].c1; 57 CalC2 = code[0].c2; 58 // we have two options here: 59 // - calibrate to internal system (Mcal) 60 // - calibrate to external system (Mref) 61 62 mycode = GetPhotcodebyCode (new[0].source); 63 incode = GetPhotcodebyCode (mycode[0].equiv); 64 excode = GetPhotcodebyCode (incode[0].equiv); 65 66 if (InternalCal) { 67 CalC0 = incode[0].code; 68 } else { 69 CalC0 = excode[0].code; 70 } 71 CalC1 = mycode[0].c1; 72 CalC2 = mycode[0].c2; 58 73 59 74 m = average[0].offset; … … 73 88 } 74 89 if (found0 && found1 && found2) { 75 SaveCalibration (new[0].M_PS, new[0].dM_PS, CalM0, dCalM, CalM1-CalM2, new[0].airmass_PS, Nstar); 90 Mcal = new[0].M_PS + 0.001*mycode[0].C + mycode[0].K*(new[0].airmass_PS - 1.0) - ZeroPt; 91 color = CalM1 - CalM2 - 0.001*mycode[0].dX; 92 factor = color; 93 for (j = 0; j < mycode[0].Nc; j++) { 94 Mcal += mycode[0].X[j]*factor; 95 factor *= color; 96 } 97 if (!InternalCal) { 98 Mcal += 0.001*incode[0].C; 99 } 100 // if we want to apply a Mcal -> Mref color correction, we need the additional color term 101 SaveCalibration (Mcal, new[0].dM_PS, CalM0, dCalM, new[0].M_PS - ZeroPt - new[0].dt_PS, Nstar); 76 102 return; 77 103 } … … 84 110 85 111 int i, MaxN, *Nlist, Nkeep; 86 float Mint; 87 float N, M1, M2, Klam, Clam, Xlam, Mabs, *Dmag, *dDmag; 112 float N, M1, M2, *Dmag, *dDmag; 88 113 float dMo, dMr, Mw, Dmed, W1, W2, NSigma; 89 PhotCode *code;90 91 code = GetPhotcodebyCode (image[0].source);92 114 93 115 /* reject multiple matched-stars */ … … 114 136 ALLOCATE (dDmag, float, Ncal); 115 137 Nkeep = 0; 116 Clam = code[0].C*0.001; /* photcode.C still in millimags */117 Klam = code[0].K;118 Xlam = code[0].X[0];119 138 for (i = 0; i < Ncal; i++) { 120 139 /* if this entry has too many (or two few?) matches, skip it */ 121 140 if (Nlist[Nstar[i]] != 1) continue; 122 Mint = Clam + Mobs[i] + Xlam*Cref[i] + Klam*(Airm[i] - 1.000);123 Mabs = Mint - ZeroPt;124 /* note: subpix correction is applied in gstars */125 141 126 /* skip stars brighter than 8.0 */ 127 /* XXX EAM : perhaps make this more flexible?? */ 128 if (Mabs > 9.0) continue; 129 if (Mabs < 5.0) continue; 142 /* clip by instrumental magnitude */ 143 if (Minst[i] > CAL_INSTMAG_MAX) continue; 144 if (Minst[i] < CAL_INSTMAG_MIN) continue; 130 145 131 146 /* XXX EAM: note the artificial 0.005 dmag here */ … … 133 148 dMo = MAX (0.005, dMobs[i]); 134 149 135 Dmag[Nkeep] = (M abs- Mref[i]);150 Dmag[Nkeep] = (Mobs[i] - Mref[i]); 136 151 dDmag[Nkeep] = (dMr*dMr + dMo*dMo); 137 152 Nkeep ++; -
trunk/Ohana/src/addstar/include/addstar.h
r5445 r5585 71 71 /* these globals are used separately by both client and server (KEEP) */ 72 72 double ZeroPt; // double check for consistency 73 double CAL_INSTMAG_MAX; 74 double CAL_INSTMAG_MIN; 73 75 int VERBOSE; 74 76 … … 91 93 FILE *GetDB PROTO((int *state)); 92 94 void InitCalibration PROTO(()); 93 void SaveCalibration PROTO((float M , float dM, float Mr, float dMr, float Mc, float A, int N));95 void SaveCalibration PROTO((float Mo, float dMo, float Mr, float dMr, float Mi, int N)); 94 96 void SetProtect PROTO((int mode)); 95 97 int SetSignals PROTO(()); -
trunk/Ohana/src/addstar/src/ConfigInit.c
r5445 r5585 43 43 ScanConfig (config, "OBSERVATORY-LATITUDE", "%lf", 0, &Latitude); 44 44 ScanConfig (config, "SUBPIX_DATAFILE", "%s", 0, SubpixDatafile); 45 46 /* instrumental magnitude range for calibration mode */ 47 if (!ScanConfig (config, "CAL_INSTMAG_MAX", "%lf", 0, &CAL_INSTMAG_MAX)) CAL_INSTMAG_MAX = -9.0; 48 if (!ScanConfig (config, "CAL_INSTMAG_MIN", "%lf", 0, &CAL_INSTMAG_MIN)) CAL_INSTMAG_MIN = -13.0; 45 49 46 50 /* location of needed data sources */ -
trunk/Ohana/src/addstar/src/addstar.c
r5448 r5585 60 60 SkyList *tmp; 61 61 tmp = SkyListExistingSubset (skylist, CATDIR); 62 SkyListFree (skylist );62 SkyListFree (skylist, FALSE); 63 63 skylist = tmp; 64 64 } -
trunk/Ohana/src/addstar/src/args.c
r5443 r5585 144 144 options.calibrate = TRUE; 145 145 remove_argument (N, &argc, argv); 146 InitCalibration (FALSE); 147 } 148 if ((N = get_argument (argc, argv, "-excal"))) { 149 options.calibrate = TRUE; 150 remove_argument (N, &argc, argv); 151 InitCalibration (FALSE); 152 } 153 if ((N = get_argument (argc, argv, "-incal"))) { 154 options.calibrate = TRUE; 155 remove_argument (N, &argc, argv); 156 InitCalibration (TRUE); 146 157 } 147 158 -
trunk/Ohana/src/addstar/src/calibrate.c
r5328 r5585 1 1 # include "addstar.h" 2 2 3 static int InternalCal; 3 4 static int Ncal, NCAL, *Nstar; 4 static float *Mobs, *dMobs, *Mref, *dMref, * Cref, *Airm;5 static float *Mobs, *dMobs, *Mref, *dMref, *Minst; 5 6 6 void InitCalibration ( ) {7 void InitCalibration (int mode) { 7 8 8 fprintf (stderr, "calibrating the image...\n"); 9 Ncal = 0; 10 NCAL = 1000; 11 ALLOCATE (Mobs, float, NCAL); 12 ALLOCATE (dMobs, float, NCAL); 13 ALLOCATE (Mref, float, NCAL); 14 ALLOCATE (dMref, float, NCAL); 15 ALLOCATE (Cref, float, NCAL); 16 ALLOCATE (Airm, float, NCAL); 17 ALLOCATE (Nstar, int, NCAL); 9 InternalCal = mode; 10 11 fprintf (stderr, "calibrating the image...\n"); 12 Ncal = 0; 13 NCAL = 1000; 14 ALLOCATE (Mobs, float, NCAL); 15 ALLOCATE (dMobs, float, NCAL); 16 ALLOCATE (Mref, float, NCAL); 17 ALLOCATE (dMref, float, NCAL); 18 ALLOCATE (Minst, float, NCAL); 19 ALLOCATE (Nstar, int, NCAL); 18 20 } 19 21 20 void SaveCalibration (float M , float dM, float Mr, float dMr, float Mc, float A, int N) {22 void SaveCalibration (float Mo, float dMo, float Mr, float dMr, float Mi, int N) { 21 23 22 Mobs[Ncal] = M;23 dMobs[Ncal] = dM ;24 Mref[Ncal] = Mr;24 Mobs[Ncal] = Mo; 25 dMobs[Ncal] = dMo; 26 Mref[Ncal] = Mr; 25 27 dMref[Ncal] = dMr; 26 Cref[Ncal] = Mc; 27 Airm[Ncal] = A; 28 Minst[Ncal] = Mi; 28 29 Nstar[Ncal] = N; 29 30 Ncal ++; … … 31 32 if (Ncal == NCAL) { 32 33 NCAL += 1000; 34 REALLOCATE (Mobs, float, NCAL); 33 35 REALLOCATE (dMobs, float, NCAL); 34 REALLOCATE (Mobs, float, NCAL);35 36 REALLOCATE (Mref, float, NCAL); 36 REALLOCATE (dMref, float, NCAL); 37 REALLOCATE (Cref, float, NCAL); 38 REALLOCATE (Airm, float, NCAL); 37 REALLOCATE (dMref, float, NCAL); 38 REALLOCATE (Minst, float, NCAL); 39 39 REALLOCATE (Nstar, int, NCAL); 40 40 } … … 44 44 void AddToCalibration (Average *average, Measure *measure, Measure *new, int *next, int Nstar) { 45 45 46 int i, m, found0, found1, found2;46 int i, j, m, found0, found1, found2; 47 47 float CalM0, CalM1, CalM2, dCalM; 48 float Mcal, color, factor; 48 49 short CalC0, CalC1, CalC2; 49 PhotCode *code; 50 51 PhotCode *mycode; // photcode of this measurement 52 PhotCode *incode; // mycode.equiv (internal reference) 53 PhotCode *excode; // incode.equiv (external reference) 50 54 51 55 found0 = found1 = found2 = FALSE; 52 56 CalM0 = CalM1 = CalM2 = dCalM = NO_MAG; 53 57 54 code = GetPhotcodebyCode (new[0].source); 55 CalC0 = code[0].equiv; 56 CalC1 = code[0].c1; 57 CalC2 = code[0].c2; 58 // we have two options here: 59 // - calibrate to internal system (Mcal) 60 // - calibrate to external system (Mref) 61 62 mycode = GetPhotcodebyCode (new[0].source); 63 incode = GetPhotcodebyCode (mycode[0].equiv); 64 excode = GetPhotcodebyCode (incode[0].equiv); 65 66 if (InternalCal) { 67 CalC0 = incode[0].code; 68 } else { 69 CalC0 = excode[0].code; 70 } 71 CalC1 = mycode[0].c1; 72 CalC2 = mycode[0].c2; 58 73 59 74 m = average[0].offset; … … 73 88 } 74 89 if (found0 && found1 && found2) { 75 SaveCalibration (new[0].M_PS, new[0].dM_PS, CalM0, dCalM, CalM1-CalM2, new[0].airmass_PS, Nstar); 90 Mcal = new[0].M_PS + 0.001*mycode[0].C + mycode[0].K*(new[0].airmass_PS - 1.0) - ZeroPt; 91 color = CalM1 - CalM2 - 0.001*mycode[0].dX; 92 factor = color; 93 for (j = 0; j < mycode[0].Nc; j++) { 94 Mcal += mycode[0].X[j]*factor; 95 factor *= color; 96 } 97 if (!InternalCal) { 98 Mcal += 0.001*incode[0].C; 99 } 100 // if we want to apply a Mcal -> Mref color correction, we need the additional color term 101 SaveCalibration (Mcal, new[0].dM_PS, CalM0, dCalM, new[0].M_PS - ZeroPt - new[0].dt_PS, Nstar); 76 102 return; 77 103 } … … 84 110 85 111 int i, MaxN, *Nlist, Nkeep; 86 float Mint; 87 float N, M1, M2, Klam, Clam, Xlam, Mabs, *Dmag, *dDmag; 112 float N, M1, M2, *Dmag, *dDmag; 88 113 float dMo, dMr, Mw, Dmed, W1, W2, NSigma; 89 PhotCode *code;90 91 code = GetPhotcodebyCode (image[0].source);92 114 93 115 /* reject multiple matched-stars */ … … 114 136 ALLOCATE (dDmag, float, Ncal); 115 137 Nkeep = 0; 116 Clam = code[0].C*0.001; /* photcode.C still in millimags */117 Klam = code[0].K;118 Xlam = code[0].X[0];119 138 for (i = 0; i < Ncal; i++) { 120 139 /* if this entry has too many (or two few?) matches, skip it */ 121 140 if (Nlist[Nstar[i]] != 1) continue; 122 Mint = Clam + Mobs[i] + Xlam*Cref[i] + Klam*(Airm[i] - 1.000);123 Mabs = Mint - ZeroPt;124 /* note: subpix correction is applied in gstars */125 141 126 /* skip stars brighter than 8.0 */ 127 /* XXX EAM : perhaps make this more flexible?? */ 128 if (Mabs > 9.0) continue; 129 if (Mabs < 5.0) continue; 142 /* clip by instrumental magnitude */ 143 if (Minst[i] > CAL_INSTMAG_MAX) continue; 144 if (Minst[i] < CAL_INSTMAG_MIN) continue; 130 145 131 146 /* XXX EAM: note the artificial 0.005 dmag here */ … … 133 148 dMo = MAX (0.005, dMobs[i]); 134 149 135 Dmag[Nkeep] = (M abs- Mref[i]);150 Dmag[Nkeep] = (Mobs[i] - Mref[i]); 136 151 dDmag[Nkeep] = (dMr*dMr + dMo*dMo); 137 152 Nkeep ++;
Note:
See TracChangeset
for help on using the changeset viewer.
