Changeset 30616
- Timestamp:
- Feb 13, 2011, 11:30:02 AM (15 years ago)
- Location:
- trunk/Ohana/src
- Files:
-
- 34 edited
- 1 copied
-
photdbc/include/photdbc.h (modified) (2 diffs)
-
photdbc/src/ConfigInit.c (modified) (2 diffs)
-
photdbc/src/args.c (modified) (4 diffs)
-
photdbc/src/find_images.c (modified) (1 diff)
-
photdbc/src/initialize.c (modified) (2 diffs)
-
photdbc/src/make_subcatalog.c (modified) (7 diffs)
-
relastro/include/relastro.h (modified) (6 diffs)
-
relastro/src/ConfigInit.c (modified) (1 diff)
-
relastro/src/FitChip.c (modified) (6 diffs)
-
relastro/src/GetAstromError.c (modified) (3 diffs)
-
relastro/src/ImageOps.c (modified) (17 diffs)
-
relastro/src/StarMaps.c (modified) (3 diffs)
-
relastro/src/UpdateChips.c (modified) (3 diffs)
-
relastro/src/UpdateObjectOffsets.c (modified) (1 diff)
-
relastro/src/UpdateObjects.c (modified) (2 diffs)
-
relastro/src/args.c (modified) (3 diffs)
-
relastro/src/bcatalog.c (modified) (2 diffs)
-
relastro/src/load_catalogs.c (modified) (1 diff)
-
relastro/src/plotstuff.c (modified) (1 diff)
-
relastro/src/relastro.c (modified) (1 diff)
-
relastro/src/relastroVisual.c (modified) (21 diffs)
-
relastro/src/select_images.c (modified) (8 diffs)
-
relphot/Makefile (modified) (1 diff)
-
relphot/include/relphot.h (modified) (4 diffs)
-
relphot/src/ConfigInit.c (modified) (1 diff)
-
relphot/src/ImageOps.c (modified) (5 diffs)
-
relphot/src/MosaicOps.c (modified) (4 diffs)
-
relphot/src/args.c (modified) (3 diffs)
-
relphot/src/bcatalog.c (modified) (1 diff)
-
relphot/src/help.c (copied) (copied from branches/eam_branches/ipp-20101205/Ohana/src/relphot/src/help.c )
-
relphot/src/initialize.c (modified) (1 diff)
-
relphot/src/load_catalogs.c (modified) (2 diffs)
-
relphot/src/load_images.c (modified) (3 diffs)
-
relphot/src/relphot.c (modified) (1 diff)
-
relphot/src/select_images.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/photdbc/include/photdbc.h
r29938 r30616 51 51 double DMGAIN; 52 52 double CHISQ_MAX; 53 double SIGMA_MIN_KEEP; 53 54 double SIGMA_MAX; 54 55 double AVE_SIGMA_LIM; 55 56 int NMEAS_MIN; 57 int NMEAS_MIN_FILTERED; 58 int NCODE_MIN; 56 59 double ZERO_POINT; 60 61 int ExcludeByMinSigma; 57 62 58 63 int ExcludeByInstMag; … … 65 70 SkyRegion REGION; 66 71 PhotCodeData photcodes; 72 73 char *PHOTCODE_DROP_LIST, *PHOTCODE_SKIP_LIST; 74 int NphotcodesDrop, NphotcodesSkip; 75 PhotCode **photcodesDrop, **photcodesSkip; 67 76 68 77 # define FLAG_AREA 0X0001 -
trunk/Ohana/src/photdbc/src/ConfigInit.c
r28331 r30616 26 26 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 27 27 28 WarnConfig (config, "PHOTDBC_JOIN_RADIUS", "%lf", 0, &JOIN_RADIUS); 28 // XXX join_stars (in photdbc.c) is currently disabled 29 // WarnConfig (config, "PHOTDBC_JOIN_RADIUS", "%lf", 0, &JOIN_RADIUS); 30 31 // XXX unique_measures (in photdbc.c) is currently disabled 29 32 // WarnConfig (config, "UNIQ_RADIUS", "%lf", 0, &UNIQ_RADIUS); 30 33 34 // XXX flag_measures (in photdbc.c) is currently disabled 31 35 // WarnConfig (config, "XMIN", "%lf", 0, &XMIN); 32 36 // WarnConfig (config, "XMAX", "%lf", 0, &XMAX); … … 37 41 // WarnConfig (config, "MMIN", "%lf", 0, &tmp); MMIN = 1000*tmp; 38 42 // WarnConfig (config, "MMAX", "%lf", 0, &tmp); MMAX = 1000*tmp; 43 // WarnConfig (config, "CHISQ_MAX", "%lf", 0, &CHISQ_MAX); 44 45 // XXX get_mags (in photdbc.c) is currently disabled 39 46 // WarnConfig (config, "DMSYS", "%lf", 0, &tmp); DMSYS = SQ(1000*tmp); 40 47 // WarnConfig (config, "DMGAIN", "%lf", 0, &DMGAIN); 41 // WarnConfig (config, "CHISQ_MAX", "%lf", 0, &CHISQ_MAX);42 48 43 49 ScanConfig (config, "SIGMA_MAX", "%lf", 0, &SIGMA_MAX); 44 50 ScanConfig (config, "AVE_SIGMA_LIM", "%lf", 0, &AVE_SIGMA_LIM); 45 51 ScanConfig (config, "NMEAS_MIN", "%d", 0, &NMEAS_MIN); 52 ScanConfig (config, "NMEAS_MIN_FILTERED", "%d", 0, &NMEAS_MIN_FILTERED); 46 53 47 54 WarnConfig (config, "GSCFILE", "%s", 0, GSCFILE); -
trunk/Ohana/src/photdbc/src/args.c
r29938 r30616 19 19 ExcludeByInstMag = FALSE; 20 20 if ((N = get_argument (argc, argv, "-instmag"))) { 21 remove_argument (N, &argc, argv);22 21 ExcludeByInstMag = TRUE; 23 22 remove_argument (N, &argc, argv); … … 25 24 remove_argument (N, &argc, argv); 26 25 INST_MAG_MAX = atof(argv[N]); 26 remove_argument (N, &argc, argv); 27 } 28 29 ExcludeByMinSigma = FALSE; 30 if ((N = get_argument (argc, argv, "-min-sigma"))) { 31 ExcludeByMinSigma = TRUE; 32 remove_argument (N, &argc, argv); 33 SIGMA_MIN_KEEP = atof(argv[N]); 34 remove_argument (N, &argc, argv); 27 35 } 28 36 29 37 ExcludeByMaxMinMag = FALSE; 30 38 if ((N = get_argument (argc, argv, "-maxminmag"))) { 31 remove_argument (N, &argc, argv);32 39 ExcludeByMaxMinMag = TRUE; 33 40 remove_argument (N, &argc, argv); 34 41 MAX_MIN_MAG = atof(argv[N]); 42 remove_argument (N, &argc, argv); 35 43 } 36 44 … … 61 69 } 62 70 71 PHOTCODE_DROP_LIST = NULL; 72 if ((N = get_argument (argc, argv, "-photcode-drop"))) { 73 remove_argument (N, &argc, argv); 74 PHOTCODE_DROP_LIST = strcreate(argv[N]); 75 remove_argument (N, &argc, argv); 76 } 77 78 PHOTCODE_SKIP_LIST = NULL; 79 if ((N = get_argument (argc, argv, "-photcode-skip"))) { 80 remove_argument (N, &argc, argv); 81 PHOTCODE_SKIP_LIST = strcreate(argv[N]); 82 remove_argument (N, &argc, argv); 83 } 84 63 85 if (argc != 2) usage(); 64 86 … … 81 103 fprintf (stderr, "USAGE: photdbc (output)\n\n"); 82 104 fprintf (stderr, " this program takes an existing DVO database and makes a copy, applying a number of optional\n"); 83 fprintf (stderr, " filters in the process. \n ");84 fprintf (stderr, "\n"); 85 fprintf (stderr, " photdbc (output)\n ");86 fprintf (stderr, "\n"); 87 fprintf (stderr, " allowed filters / restrictions include:\n ");88 fprintf (stderr, "\n"); 105 fprintf (stderr, " filters in the process. \n\n"); 106 107 fprintf (stderr, " photdbc (output)\n\n"); 108 109 fprintf (stderr, " allowed filters / restrictions include:\n\n"); 110 89 111 fprintf (stderr, " -region Rmin Rmax Dmin Dmax : limit operation to the specified region \n"); 90 fprintf (stderr, " -join : join measurements between stars using JOIN_RADIUS\n"); 91 fprintf (stderr, " -ccdregion X Y X Y : only keep detections within the specified detector region\n"); 92 fprintf (stderr, " (can this be limited to specific photcodes? cameras? detectors?)\n"); 93 fprintf (stderr, " -photcode_limits code Mmin Mmax : allow multiples of these\n"); 94 fprintf (stderr, "\n"); 95 fprintf (stderr, " SIGMA_MAX\n"); 96 fprintf (stderr, " NMEAS_MIN\n"); 97 fprintf (stderr, " INST_MAG_MAX\n"); 98 fprintf (stderr, " INST_MAG_MIN\n"); 112 113 fprintf (stderr, " -photcode-drop : remove these photcodes from the output (REF or DEP only)\n"); 114 fprintf (stderr, " -photcode-skip : ignore these photcodes when assessing the validity (keep unless object is dropped)\n"); 115 116 fprintf (stderr, " -instmag (min) (max) : range of valid instrumental magnitudes (or measurements are dropped)\n"); 117 fprintf (stderr, " -min-sigma (sigma) : object must have one measurement error less than sigma or object is dropped\n"); 118 119 fprintf (stderr, " -maxminmag (mag) : object must have one magnitude less than this or object is dropped\n"); 120 121 fprintf (stderr, " option options:\n"); 122 fprintf (stderr, " -v : verbose mode\n"); 123 fprintf (stderr, " -params : list the current parameters\n\n"); 124 125 fprintf (stderr, "ptolemy.rc config values used by this program:\n"); 126 fprintf (stderr, " SIGMA_MAX : drop measurements with errors greater than this\n"); 127 fprintf (stderr, " NMEAS_MIN : drop objects with fewer measurements than this\n"); 128 fprintf (stderr, " NMEAS_MIN_FILTERED : drop objects with fewer measurements than this after filtering above\n"); 129 fprintf (stderr, " AVE_SIGMA_LIM : drop objects if all average mags are greater than this\n"); 130 99 131 exit (2); 100 132 } 133 134 // fprintf (stderr, " -join : join measurements between stars using JOIN_RADIUS\n"); 135 // fprintf (stderr, " -ccdregion X Y X Y : only keep detections within the specified detector region\n"); 136 // fprintf (stderr, " (can this be limited to specific photcodes? cameras? detectors?)\n"); 137 // fprintf (stderr, " -photcode_limits code Mmin Mmax : allow multiples of these\n"); -
trunk/Ohana/src/photdbc/src/find_images.c
r29001 r30616 122 122 these are measurements from external sources, like USNO */ 123 123 124 assignMcal (&image[nimage], (double *) NULL, -1); 124 // assignMcal (&image[nimage], (double *) NULL, -1); 125 image[nimage].Mcal = 0; 125 126 image[nimage].code = ID_IMAGE_NEW; 126 127 -
trunk/Ohana/src/photdbc/src/initialize.c
r29938 r30616 2 2 3 3 void initialize (int argc, char **argv) { 4 5 int NPHOTCODES; 6 char *codename, *ptr, *list; 4 7 5 8 /* are these set correctly? */ … … 11 14 ConfigInit (&argc, argv); 12 15 args (argc, argv); 16 17 NphotcodesDrop = 0; 18 photcodesDrop = NULL; 19 if (PHOTCODE_DROP_LIST != NULL) { 20 NPHOTCODES = 10; 21 ALLOCATE (photcodesDrop, PhotCode *, NPHOTCODES); 22 23 /* parse the comma-separated list of photcodesDrop */ 24 list = PHOTCODE_DROP_LIST; 25 while ((codename = strtok_r (list, ",", &ptr)) != NULL) { 26 list = NULL; // pass NULL on successive strtok_r calls 27 fprintf (stderr, "PHOTCODE_LIST: %s\n", PHOTCODE_DROP_LIST); 28 fprintf (stderr, "codename: %s\n", codename); 29 if ((photcodesDrop[NphotcodesDrop] = GetPhotcodebyName (codename)) == NULL) { 30 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 31 exit (1); 32 } 33 NphotcodesDrop ++; 34 CHECK_REALLOCATE (photcodesDrop, PhotCode *, NPHOTCODES, NphotcodesDrop, 10); 35 } 36 } 37 38 NphotcodesSkip = 0; 39 photcodesSkip = NULL; 40 if (PHOTCODE_SKIP_LIST != NULL) { 41 NPHOTCODES = 10; 42 ALLOCATE (photcodesSkip, PhotCode *, NPHOTCODES); 43 44 /* parse the comma-separated list of photcodesSkip */ 45 list = PHOTCODE_SKIP_LIST; 46 while ((codename = strtok_r (list, ",", &ptr)) != NULL) { 47 list = NULL; // pass NULL on successive strtok_r calls 48 fprintf (stderr, "PHOTCODE_LIST: %s\n", PHOTCODE_SKIP_LIST); 49 fprintf (stderr, "codename: %s\n", codename); 50 if ((photcodesSkip[NphotcodesSkip] = GetPhotcodebyName (codename)) == NULL) { 51 fprintf (stderr, "ERROR: photcode %s not found in photcode table\n", codename); 52 exit (1); 53 } 54 NphotcodesSkip ++; 55 CHECK_REALLOCATE (photcodesSkip, PhotCode *, NPHOTCODES, NphotcodesSkip, 10); 56 } 57 } 13 58 14 59 if (SHOW_PARAMS) { -
trunk/Ohana/src/photdbc/src/make_subcatalog.c
r28331 r30616 5 5 int make_subcatalog (Catalog *subcatalog, Catalog *catalog) { 6 6 7 off_t i, j, offset; 7 int found; 8 off_t i, j, k, offset; 8 9 off_t NAVERAGE, NMEASURE, Naverage, Nmeasure, Nm, Nsecfilt; 9 double mag, minMag; 10 int keep; 10 double mag, minMag, minSigma; 11 int keep, *secSkip; 12 PhotCode *photcode; 11 13 12 14 Nsecfilt = GetPhotcodeNsecfilt (); 13 15 assert (catalog[0].Nsecfilt == Nsecfilt); 16 17 // set up a list of SEC entries to ignore when evaluating a source 18 ALLOCATE (secSkip, int, Nsecfilt); 19 for (i = 0; i < Nsecfilt; i++) { 20 secSkip[i] = FALSE; 21 photcode = GetPhotcodebyNsec(i); 22 for (k = 0; k < NphotcodesSkip; k++) { 23 if (photcodesSkip[k][0].code != photcode[0].code) continue; 24 secSkip[i] = TRUE; 25 } 26 } 14 27 15 28 /* we are moving only the subset of measurements from catalog[0] to subcatalog[0] */ … … 38 51 } 39 52 53 // exclude stars with too few measurements 54 if (NCODE_MIN) { 55 // drop if all of the allowed average photcodes have ncode < NCODE_MIN values 56 keep = FALSE; 57 for (j = 0; !keep && (j < Nsecfilt); j++) { 58 if (secSkip[j]) continue; 59 if (catalog[0].secfilt[Nsecfilt*i+j].Ncode >= NCODE_MIN) { 60 keep = TRUE; 61 } 62 } 63 if (!keep) continue; 64 } 65 40 66 /* assign average and secfilt values */ 41 67 subcatalog[0].average[Naverage] = catalog[0].average[i]; … … 45 71 } 46 72 47 minMag = 32; 73 minMag = 32; 74 minSigma = 32; 48 75 Nm = 0; 49 76 for (j = 0; j < catalog[0].average[i].Nmeasure; j++) { … … 52 79 53 80 # if 0 54 if (DropPhotcode) {55 ecode = GetPhotcodeEquivCodebyCode (catalog[0].measure[offset].photcode);56 if (ecode == photcode[0].code) continue;57 }58 81 if (DropNonStellar && catalog[0].measure[offset].dophot != 1) continue; 59 82 # endif 60 83 61 /* exclude measurements by measurement error */ 84 // remove certain photcodes from the output measurements 85 if (NphotcodesDrop > 0) { 86 found = FALSE; 87 for (k = 0; (k < NphotcodesSkip) && !found; k++) { 88 if (photcodesSkip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 89 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 90 } 91 if (found) continue; 92 } 93 94 // ignore certain photcodes to assess the measurements 95 if (NphotcodesSkip > 0) { 96 found = FALSE; 97 for (k = 0; (k < NphotcodesSkip) && !found; k++) { 98 if (photcodesSkip[k][0].code == catalog[0].measure[offset].photcode) found = TRUE; 99 if (photcodesSkip[k][0].code == GetPhotcodeEquivCodebyCode(catalog[0].measure[offset].photcode)) found = TRUE; 100 } 101 if (found) goto keep; 102 } 103 104 // exclude measurements by measurement error -- drop exactly this measurement 62 105 if (SIGMA_MAX && (catalog[0].measure[offset].dM > SIGMA_MAX)) continue; 63 106 64 / * select measurements by mag limit */107 // select measurements by mag limit -- drop exactly this measurement 65 108 if (ExcludeByInstMag) { 66 109 mag = PhotInst (&catalog[0].measure[offset]); … … 69 112 } 70 113 114 // check measurements for this object -- drop object if no measurements pass 115 if (ExcludeByMinSigma) { 116 minSigma = MIN (minSigma, catalog[0].measure[offset].dM); 117 } 118 119 // check measurements for this object -- drop object if no measurements pass 71 120 if (ExcludeByMaxMinMag) { 72 121 mag = PhotSys (&catalog[0].measure[offset], &catalog[0].average[i], &catalog[0].secfilt[i*Nsecfilt]); 73 122 minMag = MIN (minMag, mag); 74 123 } 124 125 keep: 75 126 76 127 subcatalog[0].measure[Nmeasure] = catalog[0].measure[offset]; … … 90 141 } 91 142 92 // after measurement exclusion, exclude stars with too few measurements93 if ( Nm < NMEAS_MIN) {143 // exclude faint objects 144 if (ExcludeByMinSigma && (minSigma > SIGMA_MIN_KEEP)) { 94 145 Nmeasure -= Nm; 95 146 continue; 96 147 } 148 149 // after measurement exclusion, exclude stars with too few measurements 150 if (NMEAS_MIN_FILTERED && (Nm < NMEAS_MIN_FILTERED)) { 151 Nmeasure -= Nm; 152 continue; 153 } 154 97 155 subcatalog[0].average[Naverage].Nmissing = 0; 98 156 subcatalog[0].average[Naverage].Nmeasure = Nm; … … 122 180 return (TRUE); 123 181 } 182 183 /** 184 the purpose of this function is to create a subset database. there are several ways this could be done: 185 186 * reject all measurements from all objects that fail to meet some criteria (objects may lose measurements and/or be dropped) 187 188 * only reject an object if all measurements fail to meet some criteria (ie, keep all measurements if any measurement passes) 189 190 * only apply the keep / reject criteria to certain photcodes 191 192 193 *** 194 195 * options: 196 197 minimum value for nmeas : NMEAS_MIN 198 minimum value for nmeas : NMEAS_MIN_FILTERED 199 minimum value for ncode : NCODE_MIN (drop if all ncode < NCODE_MIN) (respect photcodes) 200 reject faint meas : SIGMA_MAX 201 reject faint source : SIGMA_MIN_KEEP (keep source source if its minimum dMag < this limit) 202 203 **/ -
trunk/Ohana/src/relastro/include/relastro.h
r29001 r30616 26 26 double dPos; 27 27 int mask; 28 int Nmeas; 28 29 } StarData; 29 30 … … 94 95 95 96 double SIGMA_LIM; 96 int SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored97 int SRC_MEAS_TOOFEW; //catalog objects wich fewer detections then this are ignored 97 98 double MIN_ERROR; 99 100 int IMFIT_CLIP_NITER; // number of clipping iterations to perform in FitChip 101 double IMFIT_CLIP_NSIGMA; // number of sigma to clip in FitChip 102 double IMFIT_SYS_SIGMA_LIM; // max dMag for objects used to measure systematic scatter 98 103 99 104 double RADIUS; // match radius for high-speed objects … … 141 146 int FlagOutlier; 142 147 int CLIP_THRESH; 148 int USE_BASIC_CHECK; 143 149 144 150 FitMode FIT_MODE; … … 296 302 void fixImageRaw (Catalog *catalog, int Ncatalog, off_t im); 297 303 void FlagOutliers(Catalog *catalog); 298 int MeasFilterTest(Measure *measure );304 int MeasFilterTest(Measure *measure, int applySigmaLim); 299 305 300 306 int sun_ecliptic (double jd, double *lambda, double *beta, double *epsilon); … … 325 331 int UpdateObjectOffsets (SkyList *skylist); 326 332 327 int relastroVisualPlot RawRef(StarData *raw, StarData *ref, double dRmax, int numObj);328 int relastroVisualPlotScatter(double values[], double thresh, int npts);329 int relastroVisualPlotOutliers(Catalog *catalog, int offset, int Nmeasure, 330 StatType statsR, StatType statsD, double thresh);331 332 333 int relastroVisualPlotChipFit(StarData *raw, StarData *ref, double dRmax, int numObj); 334 // int relastroVisualPlotRawRef(StarData *raw, StarData *ref, double dRmax, int numObj); 335 // int relastroVisualPlotScatter(double values[], double thresh, int npts); 336 // int relastroVisualPlotOutliers(Catalog *catalog, int offset, int Nmeasure, StatType statsR, StatType statsD, double thresh); 337 void relastroSetVisual(int state); 338 int relastroGetVisual(void); 333 339 334 340 int FixProblemImages (SkyList *skylist); … … 352 358 int createStarMapPoints(); 353 359 int checkStarMap(int N); 360 361 int GetScatterRawRef(float *dLsig, float *dMsig, float *dRsig, int *nKeep, StarData *raw, StarData *ref, int Nstars, float SigmaLimit); -
trunk/Ohana/src/relastro/src/ConfigInit.c
r29001 r30616 19 19 if (VERBOSE) fprintf (stderr, "loaded config file: %s\n", file); 20 20 21 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM);21 GetConfig (config, "RELASTRO_SIGMA_LIM", "%lf", 0, &SIGMA_LIM); // exclude measurements on this basis 22 22 GetConfig (config, "RELASTRO_SRC_MEAS_TOOFEW", "%d", 0, &SRC_MEAS_TOOFEW); 23 24 if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NITER", "%d", 0, &IMFIT_CLIP_NITER)) IMFIT_CLIP_NITER = 3; 25 if (!ScanConfig (config, "RELASTRO_IMFIT_CLIP_NSIGMA", "%lf", 0, &IMFIT_CLIP_NSIGMA)) IMFIT_CLIP_NSIGMA = 3.0; 26 if (!ScanConfig (config, "RELASTRO_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 23 27 24 28 // XXX these are used in relphot to identify poor stars / images -- define -
trunk/Ohana/src/relastro/src/FitChip.c
r29001 r30616 2 2 # include "relastroVisual.h" 3 3 4 // XXX make these user parameters5 # define FIT_CHIP_NITER 36 # define FIT_CHIP_NSIGMA 3.07 8 // XXX save the fit[0].Npts value in the image table?9 10 // XXX save measurements of the fit quality (scatter, chisq) in the image table11 12 4 int FitChip (StarData *raw, StarData *ref, int Nmatch, Image *image) { 13 5 14 int i, Nscatter, Niter, skip; 15 CoordFit *fit; 16 double dL, dM, dR, dRmax, *values; 17 18 ALLOCATE (values, double, Nmatch); 19 for (Niter = 0; Niter < FIT_CHIP_NITER; Niter ++) { 6 int i, NstatFull, Nstat, Niter, skip; 7 float dLsig, dMsig, dRsig; 8 float dLsigFull, dMsigFull, dRsigFull; 9 float dL, dM, dR, dRmax; 10 11 CoordFit *fit = NULL; 12 13 dRmax = 0.0; 14 15 for (Niter = 0; Niter < IMFIT_CLIP_NITER; Niter ++) { 16 17 // measure the scatter for the unmarked (good) measurements with dM < limit 18 // SIGMA_LIM here is redundant with ImageOps.c:915 19 GetScatterRawRef(&dLsig, &dMsig, &dRsig, &Nstat, raw, ref, Nmatch, SIGMA_LIM); 20 dRmax = IMFIT_CLIP_NSIGMA*dRsig; 21 22 // (a) skip unfittable points 23 // (b) mark good and bad points for fit (in and outliers) 20 24 21 25 // measure the scatter distribution (use only the bright end detections) 22 for (i = Nscatter =0; i < Nmatch; i++) {26 for (i = 0; i < Nmatch; i++) { 23 27 if (raw[i].mask) continue; 24 if (isnan(raw[i].dMag) || raw[i].dMag > SIGMA_LIM) continue; 28 if (isnan(raw[i].dMag)) { 29 raw[i].mask |= 0x0004; 30 continue; 31 } 32 if (raw[i].dMag > SIGMA_LIM) { 33 raw[i].mask |= 0x0008; 34 continue; 35 } // is this redundant with ImageOps.c:915? 25 36 26 37 dL = raw[i].L - ref[i].L; 27 38 dM = raw[i].M - ref[i].M; 28 39 dR = hypot (dL, dM); 29 30 values[Nscatter] = dR; 31 Nscatter++; 32 } 33 34 if (Nscatter > 5) { 35 // for a 2D Gaussian, 40% of the points are within 1 sigma; dRmax is ~ 3 sigma 36 // XXX this test is not sensible for Nscatter < XXX (5?) 37 dsort (values, Nscatter); 38 dRmax = FIT_CHIP_NSIGMA*values[(int)(0.40*Nscatter)]; 39 relastroVisualPlotScatter(values, dRmax, Nscatter); 40 relastroVisualPlotRawRef(raw, ref, dRmax, Nmatch); 41 } else { 42 dRmax = 0; 43 } 40 if (dR > dRmax) { 41 raw[i].mask |= 0x0010; 42 continue; 43 } 44 } 45 46 // figures to assess the fitting process: 47 // x vs dx, x vs dy, y vs dx, y vs dy : 48 // residual vector field 49 // dx vs mag, dy vs mag 50 relastroVisualPlotChipFit(raw, ref, dRmax, Nmatch); 44 51 45 52 // fit the requested order polynomial … … 47 54 image[0].coords.Npolyterms = CHIPORDER; 48 55 } 56 if (fit) fit_free (fit); 49 57 fit = fit_init (image[0].coords.Npolyterms); 50 58 51 59 // generate the fit matches 52 60 for (i = 0; i < Nmatch; i++) { 53 if (raw[i].mask) { 54 continue; 55 } 56 if (isnan(raw[i].dMag) || raw[i].dMag > SIGMA_LIM) { 57 continue; 58 } 59 60 // only keep objects within dRmax 61 dL = raw[i].L - ref[i].L; 62 dM = raw[i].M - ref[i].M; 63 dR = hypot (dL, dM); 64 65 // fprintf (stderr, "fit %f %f -> %f %f : %f %f (%f vs %f) wt: %f\n", raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].L, raw[i].M, dR, dRmax, raw[i].dPos); 66 67 if ((dRmax > 0.0) && (dR > dRmax)) continue; 68 61 if (raw[i].mask) continue; 69 62 fit_add (fit, raw[i].X, raw[i].Y, ref[i].L, ref[i].M, raw[i].dPos); 70 63 } … … 88 81 } 89 82 if (skip) { 90 if (VERBOSE ) fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, image[0].coords.Npolyterms);83 if (VERBOSE2) fprintf (stderr, "insufficient measurements (%d) for requested order (%d)\n", fit[0].Npts, image[0].coords.Npolyterms); 91 84 fit_free (fit); 92 free (values);93 85 image[0].flags |= ID_IMAGE_ASTROM_FEW; 94 86 return FALSE; 95 87 } 96 97 // fprintf (stderr, "scatter limit: %f based on %d detections; using %d of %d for fit\n", dRmax, Nscatter, fit[0].Npts, Nmatch);98 88 99 89 // measure the fit, update the coords & object coordinates … … 110 100 } 111 101 112 fit_free (fit);113 114 102 for (i = 0; i < Nmatch; i++) { 115 103 XY_to_LM (&raw[i].L, &raw[i].M, raw[i].X, raw[i].Y, &image[0].coords); … … 118 106 } 119 107 120 free (values); 108 // count mask classes 109 int nMask1 = 0; 110 int nMask2 = 0; 111 int nMask3 = 0; 112 int nMask4 = 0; 113 int nMask5 = 0; 114 for (i = 0; i < Nmatch; i++) { 115 if (!raw[i].mask) continue; 116 if (raw[i].mask & 0x01) nMask1 ++; 117 if (raw[i].mask & 0x02) nMask2 ++; 118 if (raw[i].mask & 0x04) nMask3 ++; 119 if (raw[i].mask & 0x08) nMask4 ++; 120 if (raw[i].mask & 0x10) nMask5 ++; 121 } 122 123 GetScatterRawRef(&dLsigFull, &dMsigFull, &dRsigFull, &NstatFull, raw, ref, Nmatch, SIGMA_LIM); 124 GetScatterRawRef(&dLsig, &dMsig, &dRsig, &Nstat, raw, ref, Nmatch, IMFIT_SYS_SIGMA_LIM); 125 126 int Nm = 0; 127 int Ns = 0; 128 for (i = 0; i < Nmatch; i++) { 129 if (raw[i].mask) continue; 130 Nm += raw[i].Nmeas; 131 Ns++; 132 } 133 image[0].nLinkAstrom = (Nm / Ns); 134 135 if (VERBOSE) fprintf (stderr, "fit sigma: %f (%f, %f) : full: %f (%f, %f), scatter limit: %f (%d full, %d bright, %d fit, %d all) (%d %d %d %d %d)\n", dRsig, dLsig, dMsig, dRsigFull, dLsigFull, dMsigFull, dRmax, NstatFull, Nstat, fit[0].Npts, Nmatch, nMask1, nMask2, nMask3, nMask4, nMask5); 136 137 image[0].dXpixSys = dLsig; 138 image[0].dYpixSys = dMsig; 139 image[0].nFitAstrom = fit[0].Npts; 140 141 if (fit) fit_free (fit); 142 121 143 return TRUE; 144 } 145 146 // measure the scatter distribution (limit selected objects by dMag) 147 int GetScatterRawRef(float *dLsig, float *dMsig, float *dRsig, int *nKeep, StarData *raw, StarData *ref, int Nstars, float SigmaLimit) { 148 149 int i, Ns; 150 float dL, dM, dLsum, dLsum2, dMsum, dMsum2, *dR; 151 152 ALLOCATE (dR, float, Nstars); 153 154 Ns = 0; 155 dLsum = dLsum2 = dMsum = dMsum2 = 0.0; 156 for (i = 0; i < Nstars; i++) { 157 if (raw[i].mask) continue; 158 if (isnan(raw[i].dMag)) continue; 159 if ((SigmaLimit > 0.0) && (raw[i].dMag > SigmaLimit)) continue; 160 161 dL = raw[i].L - ref[i].L; 162 dM = raw[i].M - ref[i].M; 163 164 dLsum += dL; 165 dLsum2 += dL*dL; 166 dMsum += dM; 167 dMsum2 += dM*dM; 168 169 dR[Ns] = hypot (dL, dM); 170 Ns++; 171 } 172 173 *dLsig = sqrt((dLsum2 / Ns) - SQ(dLsum/Ns)); 174 *dMsig = sqrt((dMsum2 / Ns) - SQ(dMsum/Ns)); 175 *nKeep = Ns; 176 177 if (Ns < 5) { 178 *dRsig = NAN; 179 free (dR); 180 return (FALSE); 181 } 182 183 // for a 2D Gaussian, 40% of the points are within R = 1 sigma 184 fsort (dR, Ns); 185 *dRsig = dR[(int)(0.40*Ns)]; 186 187 free (dR); 188 return (TRUE); 122 189 } 123 190 … … 162 229 fclose (f); 163 230 */ 231 -
trunk/Ohana/src/relastro/src/GetAstromError.c
r29938 r30616 1 1 # include "relastro.h" 2 # define WEIGHTED_ERRORS 1 2 3 3 4 float GetAstromError (Measure *measure, int mode) { 4 //BIG HACKXXXXXXXX 5 return 0.1; 5 6 6 PhotCode *code; 7 float dPobs, dPsys, dPtotal, dM, AS, MS; 7 float dPobs, dPsys, dPtotal, dM, AS, MS, dX, dY; 8 9 if (!WEIGHTED_ERRORS) { 10 // if we don't understand the errors at all, this at least lets us get things roughly 11 // right: 12 return 0.1; 13 } 14 8 15 switch (mode) { 9 16 case ERROR_MODE_RA: 10 dPobs = measure[0].dXccd / 100.0; // need to redefine this as RAerr17 dPobs = FromShortPixels(measure[0].dXccd); // dXccd is a value in pixels 11 18 break; 12 19 case ERROR_MODE_DEC: 13 dPobs = measure[0].dYccd / 100.0; // need to redefine this as RAerr20 dPobs = FromShortPixels(measure[0].dYccd); // dYccd is a value in pixels 14 21 break; 15 22 case ERROR_MODE_POS: 16 dPobs = hypot (measure[0].dXccd, measure[0].dYccd) / 100.0; // need to redefine this as RAerr 23 dX = FromShortPixels(measure[0].dXccd); // dXccd is a value in pixels 24 dY = FromShortPixels(measure[0].dYccd); // dYccd is a value in pixels 25 dPobs = hypot (dX, dY); 17 26 break; 18 27 default: 19 28 abort(); 20 29 } 21 /* the astrometric errors are not being carried yet (but should be!) */22 /* we use the photometric mag error as a weighting term */23 30 24 31 code = GetPhotcodebyCode (measure[0].photcode); … … 27 34 dPsys = code[0].astromErrSys; 28 35 dM = measure[0].dM; 29 dPtotal = sqrt(SQ(dPsys) + AS*SQ(dPobs) + MS*SQ(dM)); 30 31 //XXX dXccd, dYccd are now working correctly 32 //dPtotal = AS * dPobs; 36 dPtotal = sqrt(SQ(dPsys) + SQ(AS*dPobs) + SQ(MS*dM)); 33 37 34 38 dPtotal = MAX (dPtotal, MIN_ERROR); … … 36 40 } 37 41 42 /* for a long time, psphot was either not reported position errors, or was reporting 43 * completely wrong astrometry errors. This function lets us handle, in the 44 * configuration, different strategies to generating a position error 45 * 46 * astrometry systematic error : this is the minimum expected per-position error. You 47 * should probably measure this from you data. watch out for the chicken and egg problem! 48 * 49 * astrometry error scale : this field lets you accept position errors in (say) pixels and 50 * convert them with this term to arcsec. AS : pixel scale in arcsec 51 * 52 * astrometry mag scale : this field lets you define position errors based on the 53 * photometry error. the scale factor should be something like a typical seeing number 54 * (in arcsec) for the given instrument 55 * 56 */ -
trunk/Ohana/src/relastro/src/ImageOps.c
r29001 r30616 146 146 free (clist); 147 147 free (mlist); 148 free (Nlist); 149 free (NLIST); 148 150 } 149 151 … … 325 327 for (j = 0; j < average[0].Nmeasure; j++) { 326 328 off = average[0].measureOffset + j; 327 fprintf (stderr, " %f, %f\n", measure[off].dR, measure[off].dD);329 fprintf (stderr, "dR, dD, mag, dMag: %f, %f, %f, %f\n", measure[off].dR, measure[off].dD, measure[off].M, measure[off].dM); 328 330 } 329 331 return; … … 336 338 off_t i, m, c, n, nPos; 337 339 double X, Y, L, M, P, Q, R, D, dR, dD; 338 double dPos, DPOS_MAX_ASEC;340 double dPos, dPosSys, DPOS_MAX_ASEC; 339 341 340 342 Mosaic *mosaic; … … 359 361 } 360 362 361 // accumulate the rms position offsets. if this value, or any specific entry, is too362 // large, we will reset the image to the original coords at the end of the analysis363 363 // these are used to accumulate the rms position offsets. if this value, or any 364 // specific entry, is too large, we will reset the image to the original coords at the 365 // end of the analysis 364 366 dPos = 0.0; 365 367 nPos = 0; 368 369 // convert the image systematic error in pixels to a value in arcsec 370 { 371 double dLsig, dMsig; 372 double Ro, Do, Rx, Dx, dP0, dP1; 373 Coords *coords; 374 375 // these values are in pixels, but we to convert to arcsec 376 dLsig = image[0].dXpixSys; 377 dMsig = image[0].dYpixSys; 378 379 if (moscoords == NULL) { 380 coords = imcoords; 381 } else { 382 coords = moscoords; 383 } 384 XY_to_LM (&Ro, &Do, 0.0, 0.0, coords); 385 XY_to_LM (&Rx, &Dx, dLsig, 0.0, coords); 386 dP0 = 3600.0 * hypot(Rx - Ro, Dx - Do); // convert to arcsec 387 XY_to_LM (&Rx, &Dx, 0.0, dLsig, coords); 388 dP1 = 3600.0 * hypot(Rx - Ro, Dx - Do); // convert to arcsec 389 dPosSys = 0.5 * (dP0 + dP1); 390 } 366 391 367 392 for (i = 0; i < Nlist[im]; i++) { … … 390 415 // complain if the new location is far from the average location 391 416 // NOTE: This should never happen, or our StarMap tests are not working 392 if (fabs(dR) > 1.5*ADDSTAR_RADIUS) {417 if (fabs(dR) > 3.0*ADDSTAR_RADIUS) { 393 418 fprintf (stderr, "measurement is far from average location (R): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD); 394 419 dump_measures (&catalog[c].average[n], catalog[c].measure); 395 420 // abort (); 396 421 } 397 if (fabs(dD) > 1.5*ADDSTAR_RADIUS) {422 if (fabs(dD) > 3.0*ADDSTAR_RADIUS) { 398 423 fprintf (stderr, "measurement is far from average location (D): %f %f (%f %f)\n", catalog[c].average[n].R, catalog[c].average[n].D, dR, dD); 399 424 dump_measures (&catalog[c].average[n], catalog[c].measure); … … 418 443 catalog[c].measure[m].dR = dR; 419 444 catalog[c].measure[m].dD = dD; 420 445 421 446 if (catalog[c].measure[m].dR > +180.0*3600.0) { 422 447 // average on high end of boundary, move star up … … 429 454 catalog[c].measure[m].dR = 3600.0*(catalog[c].average[n].R - R); 430 455 } 456 457 // set the systematic error for this image: 458 catalog[c].measure[m].dRsys = ToShortPixels(dPosSys); 431 459 } 432 460 … … 544 572 545 573 // an object with only one detection provides no information about the image calibration 546 //XXX this is already taken care of in bcatalog 547 raw[i].mask = FALSE; 548 int mask = FALSE; 574 // XXX this is already taken care of in bcatalog 575 raw[i].mask = 0x0000; 549 576 if (catalog[c].average[n].Nmeasure <= SRC_MEAS_TOOFEW) { 550 mask = TRUE;577 raw[i].mask |= 0x0001; 551 578 } 552 579 if (!finite(catalog[c].measure[m].dR) || !finite(catalog[c].measure[m].dD)) { 553 mask = TRUE; 554 } 555 556 raw[i].mask = mask; 557 580 raw[i].mask |= 0x0002; 581 } 582 raw[i].Nmeas = catalog[c].average[n].Nmeasure; // record so we can check how well connected an image is 558 583 559 584 switch (mode) { … … 685 710 686 711 // skip measurements based on user selected criteria 687 if (!MeasFilterTest(&catalog[0].measure[m] )) continue;712 if (!MeasFilterTest(&catalog[0].measure[m], FALSE)) continue; 688 713 R[N] = catalog[0].measure[m].dR; 689 714 D[N] = catalog[0].measure[m].dD; … … 711 736 712 737 // skip measurements based on user selected criteria 713 if (!MeasFilterTest(&catalog[0].measure[m] )) continue;738 if (!MeasFilterTest(&catalog[0].measure[m], FALSE)) continue; 714 739 715 740 x = catalog[0].measure[m].dR - statsR.median; … … 725 750 } 726 751 727 //examine results 728 relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, 729 catalog[0].average[j].Nmeasure, 730 statsR, statsD, Ns); 752 // examine results 753 // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns); 731 754 } 732 755 … … 784 807 785 808 // skip measurements based on user selected criteria 786 if (!MeasFilterTest(&catalog[0].measure[m] )) continue;809 if (!MeasFilterTest(&catalog[0].measure[m], FALSE)) continue; 787 810 R[N] = catalog[0].measure[m].dR; 788 811 D[N] = catalog[0].measure[m].dD; … … 806 829 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 807 830 //skip bad measurements 808 if (!MeasFilterTest(&catalog[0].measure[m] )) continue;831 if (!MeasFilterTest(&catalog[0].measure[m], FALSE)) continue; 809 832 x = catalog[0].measure[m].dR - statsR.median; 810 833 y = catalog[0].measure[m].dD - statsD.median; … … 838 861 for (k = 0; k < catalog[0].average[j].Nmeasure; k++, m++) { 839 862 //skip bad measurements 840 if (!MeasFilterTest(&catalog[0].measure[m] )) continue;863 if (!MeasFilterTest(&catalog[0].measure[m], FALSE)) continue; 841 864 x = catalog[0].measure[m].dR - statsR.median; 842 865 y = catalog[0].measure[m].dD - statsD.median; … … 852 875 } //done rejecting outliers 853 876 854 //examine results 855 relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, 856 catalog[0].average[j].Nmeasure, 857 statsR, statsD, Ns); 877 // examine results 878 // relastroVisualPlotOutliers(catalog, catalog[0].average[j].measureOffset, catalog[0].average[j].Nmeasure, statsR, statsD, Ns); 858 879 859 880 } //done looping over objects … … 871 892 872 893 /** Determine whether a measurement should be included in the analysis, based on supplied filter criteria */ 873 int MeasFilterTest(Measure *measure) { 894 // we only optionally apply the sigma limit: for object averages, this should not be used (should it?) 895 int MeasFilterTest(Measure *measure, int applySigmaLim) { 874 896 int found, k; 875 897 long mask; … … 917 939 918 940 /* select measurements by measurement error */ 919 if ((SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) return FALSE; 941 if (applySigmaLim && (SIGMA_LIM > 0) && (measure[0].dM > SIGMA_LIM)) { 942 return FALSE; 943 } 920 944 921 945 /* select measurements by mag limit */ -
trunk/Ohana/src/relastro/src/StarMaps.c
r29001 r30616 79 79 starmap[N].stars[ybin*NX_MAP + xbin] ++; 80 80 } 81 MARKTIME("assign stars to starmap bins: %f sec\n", dtime);81 if (VERBOSE2) { MARKTIME("assign stars to starmap bins: %f sec\n", dtime); } 82 82 83 83 return (TRUE); … … 117 117 } 118 118 119 if (VERBOSE ) fprintf (stderr, "starmap: %d points for image %s\n", starmap[i].Npoints, images[i].name);119 if (VERBOSE2) fprintf (stderr, "starmap: %d points for image %s\n", starmap[i].Npoints, images[i].name); 120 120 } 121 121 … … 145 145 } 146 146 147 if (VERBOSE ) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax);147 if (VERBOSE2) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax); 148 148 149 if (dLmax > DPOS_MAX) return (FALSE); 150 if (dMmax > DPOS_MAX) return (FALSE); 149 if (dLmax > DPOS_MAX) { 150 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax); 151 return (FALSE); 152 } 153 if (dMmax > DPOS_MAX) { 154 if (VERBOSE) fprintf (stderr, "max deviations for %s using %d pts : %f, %f\n", images[N].name, starmap[N].Npoints, dLmax, dMmax); 155 return (FALSE); 156 } 151 157 return (TRUE); 152 158 } -
trunk/Ohana/src/relastro/src/UpdateChips.c
r29001 r30616 1 1 # include "relastro.h" 2 int plotChipFits (double *Ro, double *Do, char *mode, int Nimage); 3 int saveCenter (Image *image, double *Ro, double *Do, int im); 2 4 3 5 int UpdateChips (Catalog *catalog, int Ncatalog) { 4 6 7 int Nskip, Nmosaic, NnewFit, NoldFit; 8 5 9 /* we can measure new image parameters for each non-mosaic chip independently */ 6 off_t i, Nimage, Nraw, Nref ;10 off_t i, Nimage, Nraw, Nref, nFitAstr; 7 11 Image *image; 8 12 StarData *raw, *ref; 9 13 Coords *oldCoords; 14 float dXpixSys, dYpixSys; 15 double *Ro, *Do; 16 char *mode; 17 18 Nskip = Nmosaic = NnewFit = NoldFit = 0; 10 19 11 20 image = getimages (&Nimage); 12 21 22 // save fit results for summary plot 23 ALLOCATE (Ro, double, Nimage); 24 ALLOCATE (Do, double, Nimage); 25 ALLOCATE (mode, char, Nimage); 26 13 27 for (i = 0; i < Nimage; i++) { 14 28 15 29 /* skip all except WRP images */ 16 if (strcmp(&image[i].coords.ctype[4], "-WRP")) continue; 30 if (strcmp(&image[i].coords.ctype[4], "-WRP")) { 31 Nmosaic ++; 32 mode[i] = 0; 33 continue; 34 } 17 35 18 36 /* convert measure coordinates to raw entries */ 19 37 raw = getImageRaw (catalog, Ncatalog, i, &Nraw, MODE_MOSAIC); 20 if (!raw) continue; 38 if (!raw) { 39 Nskip ++; 40 mode[i] = 0; 41 continue; 42 } 21 43 22 44 /* convert average coordinates to ref entries */ 23 45 ref = getImageRef (catalog, Ncatalog, i, &Nref, MODE_MOSAIC); 24 if (!ref) continue; 46 if (!ref) { 47 Nskip ++; 48 mode[i] = 0; 49 continue; 50 } 25 51 26 52 // note that Nraw & Nref must be equal: if not, we made a programming error in one of these two functions. 27 53 assert (Nraw == Nref); 28 54 55 // save these in case of failure 29 56 saveCoords (&image[i].coords, i); 57 dXpixSys = image[i].dXpixSys; 58 dYpixSys = image[i].dYpixSys; 59 nFitAstr = image[i].nFitAstrom; 30 60 31 61 // FitChip does iterative, clipped fitting … … 33 63 if (!FitChip (raw, ref, Nraw, &image[i])) { 34 64 if (VERBOSE) fprintf (stderr, "reject fit for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 65 66 // restore status quo ante 35 67 oldCoords = getCoords (i); 36 68 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 69 image[i].dXpixSys = dXpixSys; 70 image[i].dYpixSys = dYpixSys; 71 image[i].nFitAstrom = nFitAstr; 72 73 saveCenter (image, &Ro[i], &Do[i], i); 74 mode[i] = 1; 75 NoldFit ++; 37 76 free (raw); 38 77 free (ref); … … 42 81 if (!checkStarMap (i)) { 43 82 if (VERBOSE) fprintf (stderr, "fit diverges too much for image %s ("OFF_T_FMT") : Nstars: "OFF_T_FMT"\n", image[i].name, i, Nraw); 83 // restore status quo ante 44 84 oldCoords = getCoords (i); 45 85 memcpy (&image[i].coords, oldCoords, sizeof(Coords)); 86 image[i].dXpixSys = dXpixSys; 87 image[i].dYpixSys = dYpixSys; 88 image[i].nFitAstrom = nFitAstr; 89 90 saveCenter (image, &Ro[i], &Do[i], i); 91 mode[i] = 2; 46 92 image[i].flags |= ID_IMAGE_ASTROM_POOR; 47 } 48 93 NoldFit ++; 94 free (raw); 95 free (ref); 96 continue; 97 } 98 99 saveCenter (image, &Ro[i], &Do[i], i); 100 mode[i] = 3; 101 NnewFit ++; 49 102 free (raw); 50 103 free (ref); 51 104 } 52 105 106 plotChipFits (Ro, Do, mode, Nimage); 107 108 fprintf (stderr, "UpdateChips: %d fitted, %d keep old, %d skipped, %d mosaic (skipped)\n", NnewFit, NoldFit, Nskip, Nmosaic); 53 109 return (TRUE); 54 110 } 55 111 112 int saveCenter (Image *image, double *Ro, double *Do, int im) { 113 114 Mosaic *mosaic; 115 Coords *moscoords, *imcoords; 116 double X, Y, L, M, P, Q, R, D; 117 118 moscoords = NULL; 119 if (!strcmp(&image[im].coords.ctype[4], "-WRP")) { 120 mosaic = getMosaicForImage (im); 121 if (mosaic == NULL) return FALSE; // if we cannot find the associated image, skip it 122 moscoords = &mosaic[0].coords; 123 } 124 imcoords = &image[im].coords; 125 126 if (!strcmp(&image[im].coords.ctype[4], "-WRP")) { 127 X = 0.5*image[im].NX; 128 Y = 0.5*image[im].NY; 129 } else { 130 X = 0.0; 131 Y = 0.0; 132 } 133 134 if (moscoords == NULL) { 135 // this is a Simple image (not a mosaic) 136 // note that for a Simple image, L,M = P,Q 137 XY_to_LM (&L, &M, X, Y, imcoords); 138 LM_to_RD (&R, &D, L, M, imcoords); 139 } else { 140 XY_to_LM (&L, &M, X, Y, imcoords); 141 XY_to_LM (&P, &Q, L, M, moscoords); 142 LM_to_RD (&R, &D, P, Q, moscoords); 143 } 144 145 double Rmid; 146 if (UserCatalog) { 147 Rmid = UserCatalogRA; 148 } else { 149 Rmid = 0.5*(UserPatch.Rmin + UserPatch.Rmax); 150 } 151 152 R = ohana_normalize_angle_to_midpoint (R, Rmid); 153 154 *Ro = R; 155 *Do = D; 156 157 return (TRUE); 158 } 159 160 int plotChipFits (double *Ro, double *Do, char *mode, int Nimage) { 161 162 static int kapa = -1; 163 164 int i, N; 165 double Rmin, Rmax, Dmin, Dmax; 166 float *xvec, *yvec; 167 Graphdata graphdata; 168 169 if (!relastroGetVisual()) return (TRUE); 170 171 if (kapa == -1) { 172 kapa = KapaOpenNamedSocket("kapa", "relastro"); 173 if (kapa == -1) { 174 fprintf (stderr, "can't open kapa window\n"); 175 return FALSE; 176 } 177 } 178 179 Rmin = +720; 180 Rmax = -720; 181 Dmin = +90; 182 Dmax = -90; 183 184 // find the R, D range 185 for (i = 0; i < Nimage; i++) { 186 if (!mode[i]) continue; 187 188 Rmin = MIN(Rmin, Ro[i]); 189 Rmax = MAX(Rmax, Ro[i]); 190 Dmin = MIN(Dmin, Do[i]); 191 Dmax = MAX(Dmax, Do[i]); 192 } 193 194 ALLOCATE (xvec, float, Nimage); 195 ALLOCATE (yvec, float, Nimage); 196 197 bzero (&graphdata, sizeof(Graphdata)); 198 plot_defaults (&graphdata); 199 graphdata.xmin = Rmin; 200 graphdata.xmax = Rmax; 201 graphdata.ymin = Dmin; 202 graphdata.ymax = Dmax; 203 graphdata.style = 2; 204 graphdata.size = 1; 205 206 KapaSetFont (kapa, "helvetica", 14); 207 KapaSetLimits (kapa, &graphdata); 208 KapaBox (kapa, &graphdata); 209 210 // *** good images *** 211 N = 0; 212 for (i = 0; i < Nimage; i++) { 213 if (mode[i] != 3) continue; 214 xvec[N] = Ro[i]; 215 yvec[N] = Do[i]; 216 N++; 217 } 218 graphdata.ptype = 7; 219 graphdata.color = KapaColorByName("black"); 220 KapaPrepPlot (kapa, N, &graphdata); 221 KapaPlotVector (kapa, N, xvec, "x"); 222 KapaPlotVector (kapa, N, yvec, "y"); 223 224 // *** reject fit *** 225 N = 0; 226 for (i = 0; i < Nimage; i++) { 227 if (mode[i] != 1) continue; 228 xvec[N] = Ro[i]; 229 yvec[N] = Do[i]; 230 N++; 231 } 232 graphdata.ptype = 3; 233 graphdata.color = KapaColorByName("red"); 234 KapaPrepPlot (kapa, N, &graphdata); 235 KapaPlotVector (kapa, N, xvec, "x"); 236 KapaPlotVector (kapa, N, yvec, "y"); 237 238 // *** divergent fit *** 239 N = 0; 240 for (i = 0; i < Nimage; i++) { 241 if (mode[i] != 2) continue; 242 xvec[N] = Ro[i]; 243 yvec[N] = Do[i]; 244 N++; 245 } 246 graphdata.ptype = 2; 247 graphdata.color = KapaColorByName("blue"); 248 KapaPrepPlot (kapa, N, &graphdata); 249 KapaPlotVector (kapa, N, xvec, "x"); 250 KapaPlotVector (kapa, N, yvec, "y"); 251 252 free (xvec); 253 free (yvec); 254 255 return (TRUE); 256 } 257 258 // XXX if (!FindMosaicForImage (image, Nimage, i)) { } -
trunk/Ohana/src/relastro/src/UpdateObjectOffsets.c
r27581 r30616 40 40 UpdateMeasures (&catalog, 1); 41 41 42 UpdateObjects (&catalog, 1); 43 42 44 freeImageBins (1); 43 45 -
trunk/Ohana/src/relastro/src/UpdateObjects.c
r29938 r30616 103 103 104 104 //does the measurement pass the supplied filtering constraints? 105 if (!MeasFilterTest(&catalog[i].measure[m] )) {105 if (!MeasFilterTest(&catalog[i].measure[m], FALSE)) { 106 106 catalog[i].measure[m].dbFlags &= ~ID_MEAS_USED_OBJ; 107 107 continue; … … 134 134 135 135 // dX, dY : error in arcsec -- 136 // dX[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_RA); 137 // dY[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_DEC); 138 139 dX[N] = 0.1; 140 dY[N] = 0.1; 136 dX[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_RA); 137 dY[N] = GetAstromError (&catalog[i].measure[m], ERROR_MODE_DEC); 138 139 // add systematic error in quadrature, if desired 140 // only do this after the fit has converged (or you will never improve the poor images) 141 // if (INCLUDE_SYS_ERR) { 142 // float dRsys = FromShortPixels(catalog[i].measure[m].dRsys); 143 // dX[N] = hypot(dX[N], dRsys); 144 // dY[N] = hypot(dY[N], dRsys); 145 // } 146 147 // dX[N] = 0.1; 148 // dY[N] = 0.1; 149 141 150 dT[N] = catalog[i].measure[m].dt; 142 151 -
trunk/Ohana/src/relastro/src/args.c
r28184 r30616 13 13 remove_argument (N, &argc, argv); 14 14 FIT_TARGET = TARGET_OBJECTS; 15 16 // check for object fitting modes (not valid for images) 17 if ((N = get_argument (argc, argv, "-pm"))) { 18 remove_argument (N, &argc, argv); 19 FIT_MODE = FIT_PM_ONLY; 20 } 21 if ((N = get_argument (argc, argv, "-par"))) { 22 remove_argument (N, &argc, argv); 23 FIT_MODE = FIT_PAR_ONLY; 24 } 25 if ((N = get_argument (argc, argv, "-pmpar"))) { 26 remove_argument (N, &argc, argv); 27 FIT_MODE = FIT_PM_AND_PAR; 28 } 29 } 15 } 16 17 // check for object fitting modes 18 if ((N = get_argument (argc, argv, "-pm"))) { 19 remove_argument (N, &argc, argv); 20 FIT_MODE = FIT_PM_ONLY; 21 } 22 if ((N = get_argument (argc, argv, "-par"))) { 23 remove_argument (N, &argc, argv); 24 FIT_MODE = FIT_PAR_ONLY; 25 } 26 if ((N = get_argument (argc, argv, "-pmpar"))) { 27 remove_argument (N, &argc, argv); 28 FIT_MODE = FIT_PM_AND_PAR; 29 } 30 30 31 if ((N = get_argument (argc, argv, "-high-speed"))) { 31 32 // XXX include a parallax / no-parallax option … … 93 94 usage (); 94 95 } 96 } 97 98 USE_BASIC_CHECK = FALSE; 99 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 100 remove_argument (N, &argc, argv); 101 USE_BASIC_CHECK = TRUE; 95 102 } 96 103 … … 144 151 VERBOSE = VERBOSE2 = TRUE; 145 152 remove_argument (N, &argc, argv); 153 } 154 155 if ((N = get_argument (argc, argv, "-visual"))) { 156 remove_argument (N, &argc, argv); 157 relastroSetVisual(TRUE); 146 158 } 147 159 -
trunk/Ohana/src/relastro/src/bcatalog.c
r29001 r30616 45 45 offset = catalog[0].average[i].measureOffset + j; 46 46 47 // filter objects based on user supplied criteria 48 if (!MeasFilterTest(&catalog[0].measure[offset] )) {47 // filter objects based on user supplied criteria, including SIGMA_LIM 48 if (!MeasFilterTest(&catalog[0].measure[offset], TRUE)) { 49 49 catalog[0].measure[offset].dbFlags &= ~ID_MEAS_USED_CHIP; 50 50 continue; … … 78 78 subcatalog[0].measure[Nmeasure].dbFlags &= ~ID_MEAS_AREA; 79 79 } 80 80 81 81 Nmeasure ++; 82 82 Nm ++; -
trunk/Ohana/src/relastro/src/load_catalogs.c
r29001 r30616 26 26 pcatalog[0].Nsecfilt = GetPhotcodeNsecfilt (); 27 27 28 if (!dvo_catalog_open (pcatalog, skylist[0].regions[i], VERBOSE , "w")) {28 if (!dvo_catalog_open (pcatalog, skylist[0].regions[i], VERBOSE2, "w")) { 29 29 fprintf (stderr, "ERROR: failure reading catalog %s\n", pcatalog[0].filename); 30 30 exit (1); 31 31 } 32 if (VERBOSE && !pcatalog[0].Naves_disk) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename);32 if (VERBOSE2 && !pcatalog[0].Naves_disk) fprintf (stderr, "no data in %s, skipping\n", pcatalog[0].filename); 33 33 34 34 //outlier rejection -
trunk/Ohana/src/relastro/src/plotstuff.c
r27588 r30616 146 146 graphdata[0].ymax = dUNDEF; 147 147 148 graphdata[0].ticktextPad = NAN; 149 graphdata[0].labelPadXm = NAN; 150 graphdata[0].labelPadXp = NAN; 151 graphdata[0].labelPadYm = NAN; 152 graphdata[0].labelPadYp = NAN; 153 graphdata[0].padXm = NAN; 154 graphdata[0].padXp = NAN; 155 graphdata[0].padYm = NAN; 156 graphdata[0].padYp = NAN; 148 157 } -
trunk/Ohana/src/relastro/src/relastro.c
r29001 r30616 78 78 MARKTIME("update chips: %f sec\n", dtime); 79 79 } 80 // create summary plots of the process 81 // relastroVisualSummaryChips(); 80 82 break; 81 83 -
trunk/Ohana/src/relastro/src/relastroVisual.c
r24308 r30616 11 11 #define KAPAY 700 12 12 13 static int kapa = -1;13 static int kapa1 = -1; 14 14 static int kapa2 = -1; 15 15 static int kapa3 = -1; 16 static int kapa4 = -1; 16 17 17 18 static int isVisual = FALSE; 18 static int plotRawRef = FALSE;19 static int plotScatter = FALSE;20 static int plotResid = FALSE;21 static int plotVector = FALSE;19 static int plotRawRef = TRUE; 20 // static int plotScatter = TRUE; 21 // static int plotResid = TRUE; 22 // static int plotVector = TRUE; 22 23 static int plotOutliers = TRUE; 23 24 … … 29 30 fprintf(stderr, "Failure to open kapa.\n"); 30 31 isVisual = 0; 31 return 0;32 return FALSE; 32 33 } 33 // KapaResize (*kapid, KAPAX, KAPAY); 34 } 35 return 1; 34 } 35 return TRUE; 36 36 } 37 37 … … 49 49 isVisual = 0; 50 50 } 51 return 1; 51 return TRUE; 52 } 53 54 void relastroSetVisual(int state) { 55 isVisual = state; 56 } 57 58 int relastroGetVisual(void) { 59 return isVisual; 52 60 } 53 61 … … 70 78 graphdata->xmax = xhi; 71 79 graphdata->ymax = yhi; 72 return 1; 73 } 74 75 static int residPlot(float x[], float y[], 76 float xVec[], float yVec[], 77 int npts, int *kapaID) { 78 if (!isVisual || !plotResid) return TRUE; 80 return TRUE; 81 } 82 83 /** 4-panel plot of x vs dx, y vs dx, x vs dy, y vs dy **/ 84 int relastroVisualRawRef(int *kapaID, float *x, float *y, float *dx, float *dy, float *dPos, int npts) { 85 79 86 Graphdata graphdata; 80 87 KapaSection section; … … 83 90 84 91 KapaInitGraph(&graphdata); 85 KapaClear Plots(*kapaID);92 KapaClearSections(*kapaID); 86 93 KapaSetFont(*kapaID, "helvetica", 14); 87 94 … … 89 96 section.x = 0.0; section.y = 0.0; 90 97 section.dx = .45, section.dy = .45; 98 section.bg = KapaColorByName("white"); 91 99 graphdata.ptype = 7; 92 100 graphdata.style = 2; 101 graphdata.etype |= 0x01; 93 102 94 103 KapaSetSection(*kapaID, §ion); 95 if(!scaleGraphdata(x, xVec, &graphdata, npts)) return 0;104 if(!scaleGraphdata(x, dx, &graphdata, npts)) return 0; 96 105 KapaSetLimits(*kapaID, &graphdata); 97 106 KapaBox(*kapaID, &graphdata); … … 100 109 KapaPrepPlot(*kapaID, npts, &graphdata); 101 110 KapaPlotVector(*kapaID, npts, x, "x"); 102 KapaPlotVector(*kapaID, npts, xVec, "y"); 111 KapaPlotVector(*kapaID, npts, dx, "y"); 112 KapaPlotVector(*kapaID, npts, dPos, "dym"); 113 KapaPlotVector(*kapaID, npts, dPos, "dyp"); 103 114 104 115 section.x = .5; section.y = 0; section.name="1"; 105 116 KapaSetSection(*kapaID, §ion); 106 if(!scaleGraphdata(x, yVec, &graphdata, npts)) return 0;117 if(!scaleGraphdata(x, dy, &graphdata, npts)) return 0; 107 118 KapaSetLimits(*kapaID, &graphdata); 108 119 KapaBox(*kapaID, &graphdata); … … 111 122 KapaPrepPlot(*kapaID, npts, &graphdata); 112 123 KapaPlotVector(*kapaID, npts, x, "x"); 113 KapaPlotVector(*kapaID, npts, yVec, "y"); 124 KapaPlotVector(*kapaID, npts, dy, "y"); 125 KapaPlotVector(*kapaID, npts, dPos, "dym"); 126 KapaPlotVector(*kapaID, npts, dPos, "dyp"); 114 127 115 128 section.x = .0; section.y = .5; section.name="2"; 116 129 KapaSetSection(*kapaID, §ion); 117 if(!scaleGraphdata(y, xVec, &graphdata, npts)) return 0;;130 if(!scaleGraphdata(y, dx, &graphdata, npts)) return 0;; 118 131 KapaSetLimits(*kapaID, &graphdata); 119 132 KapaBox(*kapaID, &graphdata); … … 122 135 KapaPrepPlot(*kapaID, npts, &graphdata); 123 136 KapaPlotVector(*kapaID, npts, y, "x"); 124 KapaPlotVector(*kapaID, npts, xVec, "y"); 137 KapaPlotVector(*kapaID, npts, dx, "y"); 138 KapaPlotVector(*kapaID, npts, dPos, "dym"); 139 KapaPlotVector(*kapaID, npts, dPos, "dyp"); 125 140 126 141 section.x = .5; section.y = .5; section.name="3"; 127 142 KapaSetSection(*kapaID, §ion); 128 if(!scaleGraphdata(y, yVec, &graphdata, npts)) return 0;143 if(!scaleGraphdata(y, dy, &graphdata, npts)) return 0; 129 144 KapaSetLimits(*kapaID, &graphdata); 130 145 KapaBox(*kapaID, &graphdata); … … 133 148 KapaPrepPlot(*kapaID, npts, &graphdata); 134 149 KapaPlotVector(*kapaID, npts, y, "x"); 135 KapaPlotVector(*kapaID, npts, yVec, "y"); 136 137 return 1; 138 } 139 140 141 /**Plot a vector field*/ 142 static int plotVectorField(float x[], float y[], 143 float xVec[], float yVec[], 144 int npts, int *kapaID, double maxVecLength) { 145 146 if(!plotVector) return 1; 150 KapaPlotVector(*kapaID, npts, dy, "y"); 151 KapaPlotVector(*kapaID, npts, dPos, "dym"); 152 KapaPlotVector(*kapaID, npts, dPos, "dyp"); 153 154 return TRUE; 155 } 156 157 158 /** Plot a vector field (circles at vector origin, scaled lines giving vector directions */ 159 int relastroVisualVectorField(int *kapaID, float *x, float *y, float *dx, float *dy, int npts, double maxVecLength) { 147 160 148 161 Graphdata graphdata; 149 float singleX[2], singleY[2];162 float *xVec, *yVec; 150 163 float vecScaleFactor; 151 164 float graphSize; 152 165 int i; 153 166 char plotTitle[50]; 154 sprintf(plotTitle, "Maximum Vector Size = %5.1e", maxVecLength); 155 167 168 if (!npts) return FALSE; 156 169 if (!initWindow(kapaID)) return 0; 157 170 171 snprintf(plotTitle, 50, "Maximum Vector Size = %5.1e", maxVecLength); 172 158 173 KapaInitGraph(&graphdata); 159 KapaClearPlots(*kapaID); 160 if(!scaleGraphdata(x, y, &graphdata, npts)) return 0; 174 KapaClearSections(*kapaID); 175 KapaSetFont(*kapaID, "helvetica", 14); 176 177 if (!scaleGraphdata(x, y, &graphdata, npts)) return 0; 161 178 162 179 graphSize = graphdata.xmax - graphdata.xmin; … … 164 181 graphSize = graphdata.ymax - graphdata.ymin; 165 182 } 166 167 183 vecScaleFactor = graphSize * 0.02 / (float)maxVecLength; 168 #ifdef TESTING 169 fprintf(stderr, "GraphSize: %e\n maxVecLength: %e\n vecScaleFactor: %e\n", 170 graphSize, maxVecLength, vecScaleFactor); 171 #endif 172 184 185 // fprintf(stderr, "GraphSize: %e\n maxVecLength: %e\n vecScaleFactor: %e\n", graphSize, maxVecLength, vecScaleFactor); 173 186 174 187 KapaSetFont (*kapaID, "helvetica", 14); … … 179 192 graphdata.ptype = 7; 180 193 graphdata.style = 2; 194 graphdata.color = KapaColorByName("black"); 181 195 KapaPrepPlot(*kapaID, npts, &graphdata); 182 196 KapaPlotVector(*kapaID, npts, x, "x"); 183 197 KapaPlotVector(*kapaID, npts, y, "y"); 184 198 185 //plot each vector individually 186 graphdata.ptype = 0; 187 graphdata.style = 0; 199 ALLOCATE (xVec, float, 2*npts); 200 ALLOCATE (yVec, float, 2*npts); 201 for (i = 0; i < npts; i++) { 202 xVec[2*i + 0] = x[i]; 203 yVec[2*i + 0] = y[i]; 204 xVec[2*i + 1] = x[i] + dx[i] * vecScaleFactor; 205 yVec[2*i + 1] = y[i] + dy[i] * vecScaleFactor; 206 } 207 208 graphdata.ptype = 100; // line segements by point pair 209 graphdata.style = 2; 188 210 graphdata.color = KapaColorByName("blue"); 189 for(i = 0; i < npts; i++) { 190 singleX[0] = x[i]; 191 singleY[0] = y[i]; 192 singleX[1] = x[i] + xVec[i] * vecScaleFactor; 193 singleY[1] = y[i] + yVec[i] * vecScaleFactor; 194 KapaPrepPlot(*kapaID, 2, &graphdata); 195 KapaPlotVector(*kapaID, 2, singleX, "x"); 196 KapaPlotVector(*kapaID, 2, singleY, "y"); 197 } 198 return 1; 199 } 200 201 int relastroVisualPlotScatter(double values[], double thresh, int npts) { 202 float *x, *data; 203 int i; 204 float xline[2], yline[2]; 205 if (!isVisual || !plotScatter) return 1; 206 if (!initWindow(&kapa2)) return 0; 207 208 ALLOCATE(x, float, npts); 209 ALLOCATE(data, float, npts); 210 211 for(i = 0; i < npts; i++) { 212 x[i] = i; 213 data[i] = (float) values[i]; 214 } 211 KapaPrepPlot (*kapaID, 2*npts, &graphdata); 212 KapaPlotVector(*kapaID, 2*npts, xVec, "x"); 213 KapaPlotVector(*kapaID, 2*npts, yVec, "y"); 214 215 free (xVec); 216 free (yVec); 217 return TRUE; 218 } 219 220 int relastroVisualPlotScatter(int *kapaID, float *dXfit, float *dYfit, float *mag, int npts) { 215 221 216 222 Graphdata graphdata; 217 223 KapaSection section; 218 section.x = 0; section.y = 0; section.dx = 1; section.dy = 1; 219 section.name = "junk";224 225 if (!initWindow(kapaID)) return 0; 220 226 221 227 KapaInitGraph(&graphdata); 222 KapaClearPlots(kapa2); 223 KapaSetSection(kapa2, §ion); 224 225 graphdata.ptype = 0; 226 graphdata.style = 0; 227 graphdata.xmin = 0; 228 graphdata.xmax = npts; 229 graphdata.ymin = 0; 230 graphdata.ymax = data[npts-1]; 231 232 KapaSetFont(kapa2, "helvetica", 14); 233 KapaSetLimits(kapa2, &graphdata); 234 KapaBox(kapa2, &graphdata); 235 KapaSendLabel( kapa2, "Object", KAPA_LABEL_XM); 236 KapaSendLabel( kapa2, "Offset(pixels)", KAPA_LABEL_YM); 237 KapaSendLabel( kapa2, "Astrometric Offset with fit cutoff", 238 KAPA_LABEL_XP); 239 KapaPrepPlot(kapa2, npts, &graphdata); 240 KapaPlotVector(kapa2, npts, x, "x"); 241 KapaPlotVector(kapa2, npts, data, "y"); 242 243 graphdata.color = KapaColorByName("red"); 244 KapaPrepPlot(kapa2, 2, &graphdata); 245 yline[0] = (float) thresh; 246 yline[1] = (float) thresh; 247 xline[0] = graphdata.xmin; 248 xline[1] = graphdata.xmax; 249 KapaPlotVector(kapa2, 2, xline, "x"); 250 KapaPlotVector(kapa2, 2, yline, "y"); 251 252 askUser(&plotScatter); 253 return 1; 254 } 255 256 228 KapaClearSections(*kapaID); 229 KapaSetFont(*kapaID, "helvetica", 14); 230 231 section.name = "a"; 232 section.x = 0.0; section.y = 0.0; section.dx = 1.0; section.dy = 0.5; 233 section.bg = KapaColorByName("white"); 234 KapaSetSection(*kapaID, §ion); 235 236 graphdata.ptype = 2; 237 graphdata.style = 2; 238 239 if(!scaleGraphdata(mag, dXfit, &graphdata, npts)) return 0; 240 KapaSetLimits(*kapaID, &graphdata); 241 KapaBox(*kapaID, &graphdata); 242 KapaSendLabel(*kapaID, "mag", KAPA_LABEL_XM); 243 KapaSendLabel(*kapaID, "dXfit", KAPA_LABEL_YM); 244 KapaPrepPlot(*kapaID, npts, &graphdata); 245 KapaPlotVector(*kapaID, npts, mag, "x"); 246 KapaPlotVector(*kapaID, npts, dXfit, "y"); 247 248 section.name = "b"; 249 section.x = 0.0; section.y = 0.5; section.dx = 1.0; section.dy = 0.5; 250 section.bg = KapaColorByName("white"); 251 KapaSetSection(*kapaID, §ion); 252 253 graphdata.ptype = 2; 254 graphdata.style = 2; 255 256 if(!scaleGraphdata(mag, dYfit, &graphdata, npts)) return 0; 257 KapaSetLimits(*kapaID, &graphdata); 258 KapaBox(*kapaID, &graphdata); 259 KapaSendLabel(*kapaID, "mag", KAPA_LABEL_XM); 260 KapaSendLabel(*kapaID, "dYfit", KAPA_LABEL_YM); 261 KapaPrepPlot(*kapaID, npts, &graphdata); 262 KapaPlotVector(*kapaID, npts, mag, "x"); 263 KapaPlotVector(*kapaID, npts, dYfit, "y"); 264 265 return TRUE; 266 } 257 267 258 268 /** plot raw vs ref (L, M). Only those whose distance is < drMax are used in fit*/ 259 int relastroVisualPlotRawRef(StarData *raw, StarData *ref, double dRmax, int numObj) { 260 261 if( !isVisual || !plotRawRef) return 1; 262 if( !initWindow(&kapa)) return 0; 269 int relastroVisualPlotFittedStars(int *kapaID, float *rawX, float *rawY, float *refX, float *refY, int numNoFit, float *rawXfit, float *rawYfit, float *refXfit, float *refYfit, int numFit) { 270 271 Graphdata graphdata; 272 273 if (!initWindow(kapaID)) return 0; 274 275 KapaInitGraph(&graphdata); 276 KapaClearPlots(*kapaID); 277 278 graphdata.ptype = 7; 279 graphdata.style = 2; 280 281 if(!scaleGraphdata(rawXfit, rawYfit, &graphdata, numFit)) { 282 fprintf(stderr, "Not enough finite points for plotting"); 283 return 0; 284 } 285 286 KapaSetFont(*kapaID, "helvetica", 14); 287 KapaSetLimits(*kapaID, &graphdata); 288 KapaBox(*kapaID, &graphdata); 289 KapaSendLabel( *kapaID, "X", KAPA_LABEL_XM); 290 KapaSendLabel( *kapaID, "Y", KAPA_LABEL_YM); 291 KapaSendLabel( *kapaID, "orange, red, green, blue: (raw, ref), (nofit, fit)", 292 KAPA_LABEL_XP); 293 294 graphdata.color = KapaColorByName("orange"); 295 graphdata.size = 1; 296 KapaPrepPlot(*kapaID, numNoFit, &graphdata); 297 KapaPlotVector(*kapaID, numNoFit, rawX, "x"); 298 KapaPlotVector(*kapaID, numNoFit, rawY, "y"); 299 300 graphdata.color = KapaColorByName("red"); 301 graphdata.size = 2; 302 KapaPrepPlot(*kapaID, numNoFit, &graphdata); 303 KapaPlotVector(*kapaID, numNoFit, refX, "x"); 304 KapaPlotVector(*kapaID, numNoFit, refY, "y"); 305 306 graphdata.color = KapaColorByName("green"); 307 graphdata.size = 1; 308 KapaPrepPlot(*kapaID, numFit, &graphdata); 309 KapaPlotVector(*kapaID, numFit, rawXfit, "x"); 310 KapaPlotVector(*kapaID, numFit, rawYfit, "y"); 311 312 graphdata.color = KapaColorByName("blue"); 313 graphdata.size = 2; 314 KapaPrepPlot(*kapaID, numFit, &graphdata); 315 KapaPlotVector(*kapaID, numFit, refXfit, "x"); 316 KapaPlotVector(*kapaID, numFit, refYfit, "y"); 317 318 return TRUE; 319 } 320 321 /** create various plots using the data in raw and ref **/ 322 int relastroVisualPlotChipFit(StarData *raw, StarData *ref, double dRmax, int numObj) { 263 323 264 324 float *rawX, *rawY, *refX, *refY; 265 325 float *rawXfit, *rawYfit, *refXfit, *refYfit; 266 326 float *magRaw, *magRef, *magRawfit, *magReffit; 267 float * xVec, *yVec;327 float *dXfit, *dYfit, *dPos; 268 328 int numFit = 0, numNoFit = 0; 269 329 double dL, dM, dR; 330 331 if (!isVisual) return TRUE; 270 332 271 333 ALLOCATE(rawX, float, numObj); … … 273 335 ALLOCATE(refX, float, numObj); 274 336 ALLOCATE(refY, float, numObj); 337 ALLOCATE(magRaw, float, numObj); 338 ALLOCATE(magRef, float, numObj); 339 275 340 ALLOCATE(rawXfit, float, numObj); 276 341 ALLOCATE(rawYfit, float, numObj); 277 342 ALLOCATE(refXfit, float, numObj); 278 343 ALLOCATE(refYfit, float, numObj); 279 ALLOCATE(magRaw, float, numObj);280 ALLOCATE(magRef, float, numObj);281 344 ALLOCATE(magRawfit, float, numObj); 282 345 ALLOCATE(magReffit, float, numObj); 346 ALLOCATE(dXfit, float, numObj); 347 ALLOCATE(dYfit, float, numObj); 348 ALLOCATE(dPos, float, numObj); 283 349 284 350 int i; 285 351 for(i = 0; i < numObj; i++) { 286 if (raw[i].mask) continue;352 if (raw[i].mask) continue; // XXX 287 353 288 354 dL = raw[i].L - ref[i].L; 289 355 dM = raw[i].M - ref[i].M; 290 356 dR = hypot (dL, dM); 357 358 // XXX change the selection to a mask-based thing 291 359 if (dR > dRmax) { 360 // UNFITTED values 292 361 rawX[numNoFit] = raw[i].X; 293 362 rawY[numNoFit] = raw[i].Y; … … 298 367 numNoFit++; 299 368 } else { 300 rawXfit[numFit] = raw[i].X; 301 rawYfit[numFit] = raw[i].Y; 302 refXfit[numFit] = ref[i].X; 303 refYfit[numFit] = ref[i].Y; 304 magRaw[numFit] = raw[i].Mag; 305 magRef[numFit] = ref[i].Mag; 369 // FITTED values 370 rawXfit[numFit] = raw[i].X; 371 rawYfit[numFit] = raw[i].Y; 372 refXfit[numFit] = ref[i].X; 373 refYfit[numFit] = ref[i].Y; 374 magRawfit[numFit] = raw[i].Mag; 375 magReffit[numFit] = ref[i].Mag; 376 dPos[numFit] = ref[i].dPos; 377 dXfit[numFit] = raw[i].X - ref[i].X; 378 dYfit[numFit] = raw[i].Y - ref[i].Y; 306 379 numFit++; 307 380 } … … 310 383 if (numFit == 0) return 0; 311 384 312 Graphdata graphdata; 313 314 KapaInitGraph(&graphdata); 315 KapaClearPlots(kapa); 316 317 graphdata.ptype = 7; 318 graphdata.style = 2; 319 320 if(!scaleGraphdata(rawXfit, rawYfit, &graphdata, numFit)) { 321 fprintf(stderr, "Not enough finite points for plotting"); 322 return 0; 323 } 324 325 KapaSetFont(kapa, "helvetica", 14); 326 KapaSetLimits(kapa, &graphdata); 327 KapaBox(kapa, &graphdata); 328 KapaSendLabel( kapa, "X", KAPA_LABEL_XM); 329 KapaSendLabel( kapa, "Y", KAPA_LABEL_YM); 330 KapaSendLabel( kapa, "orange, red, green, blue: (raw, ref), (nofit, fit)", 331 KAPA_LABEL_XP); 332 333 graphdata.color = KapaColorByName("orange"); 334 graphdata.size = 1; 335 KapaPrepPlot(kapa, numNoFit, &graphdata); 336 KapaPlotVector(kapa, numNoFit, rawX, "x"); 337 KapaPlotVector(kapa, numNoFit, rawY, "y"); 338 339 graphdata.color = KapaColorByName("red"); 340 graphdata.size = 2; 341 KapaPrepPlot(kapa, numNoFit, &graphdata); 342 KapaPlotVector(kapa, numNoFit, refX, "x"); 343 KapaPlotVector(kapa, numNoFit, refY, "y"); 344 345 graphdata.color = KapaColorByName("green"); 346 graphdata.size = 1; 347 KapaPrepPlot(kapa, numFit, &graphdata); 348 KapaPlotVector(kapa, numFit, rawXfit, "x"); 349 KapaPlotVector(kapa, numFit, rawYfit, "y"); 350 351 graphdata.color = KapaColorByName("blue"); 352 graphdata.size = 2; 353 KapaPrepPlot(kapa, numFit, &graphdata); 354 KapaPlotVector(kapa, numFit, refXfit, "x"); 355 KapaPlotVector(kapa, numFit, refYfit, "y"); 356 357 ALLOCATE(xVec, float, numFit); 358 ALLOCATE(yVec, float, numFit); 359 360 //plot the fitted objects as vectors 361 for(i = 0; i < numFit; i++) { 362 xVec[i] = rawXfit[i] - refXfit[i]; 363 yVec[i] = rawYfit[i] - refYfit[i]; 364 } 365 366 plotVectorField(rawXfit, rawYfit, xVec, yVec, numFit, &kapa3, dRmax); 367 if(!residPlot(rawXfit, rawYfit, xVec, yVec, numFit, &kapa2)) { 368 fprintf(stderr, "Unable to plot residuals"); 369 return 0; 370 } 371 372 FREE(xVec); 373 FREE(yVec); 385 // 4-panel plot of x vs dx, y vs dx, x vs dy, y vs dy 386 relastroVisualRawRef(&kapa1, rawXfit, rawYfit, dXfit, dYfit, dPos, numFit); 387 388 // vector line plot for the fit 389 relastroVisualVectorField(&kapa2, rawXfit, rawYfit, dXfit, dYfit, numFit, dRmax); 390 391 // dXfit, dYfit vs mag 392 relastroVisualPlotScatter(&kapa3, dXfit, dYfit, magRawfit, numFit); 393 394 // plot the positions of the fitted stars on the chip 395 relastroVisualPlotFittedStars(&kapa4, rawX, rawY, refX, refY, numNoFit, rawXfit, rawYfit, refXfit, refYfit, numFit); 374 396 375 397 askUser(&plotRawRef); 376 398 399 FREE(dXfit); 400 FREE(dYfit); 401 FREE(dPos); 377 402 FREE(rawX); 378 403 FREE(rawY); … … 388 413 FREE(magReffit); 389 414 390 return 1;415 return TRUE; 391 416 } 392 417 … … 403 428 KapaSection section; 404 429 405 if (!isVisual || !plotOutliers) return 1;406 if (!initWindow(&kapa )) return 0;430 if (!isVisual || !plotOutliers) return TRUE; 431 if (!initWindow(&kapa1)) return 0; 407 432 408 433 // populate vectors … … 426 451 for(i = 0; i < Nmeasure; i++, m++) { 427 452 meas = catalog[0].measure[m]; 428 if (!MeasFilterTest(&meas )) continue;453 if (!MeasFilterTest(&meas, FALSE)) continue; 429 454 xmin = MIN(xmin, meas.dR); 430 455 xmax = MAX(xmax, meas.dR); … … 459 484 section.x = 0; section.y = 0; section.dx = 1; section.dy = 1; 460 485 section.name = "junk"; 486 section.bg = KapaColorByName("white"); 461 487 462 488 KapaInitGraph(&graphdata); 463 KapaClearPlots(kapa );464 KapaSetFont(kapa , "helvetica", 14);489 KapaClearPlots(kapa1); 490 KapaSetFont(kapa1, "helvetica", 14); 465 491 466 492 graphdata.ptype = 7; … … 472 498 graphdata.ymax = ymax; 473 499 474 KapaSetSection(kapa , §ion);475 KapaSetLimits(kapa , &graphdata);476 KapaBox(kapa , &graphdata);477 478 KapaSendLabel( kapa , "RA (arcsec)", KAPA_LABEL_XM);479 KapaSendLabel( kapa , "Dec (arcsec)", KAPA_LABEL_YM);480 KapaSendLabel( kapa , "Points flagged as outliers (red)",500 KapaSetSection(kapa1, §ion); 501 KapaSetLimits(kapa1, &graphdata); 502 KapaBox(kapa1, &graphdata); 503 504 KapaSendLabel( kapa1, "RA (arcsec)", KAPA_LABEL_XM); 505 KapaSendLabel( kapa1, "Dec (arcsec)", KAPA_LABEL_YM); 506 KapaSendLabel( kapa1, "Points flagged as outliers (red)", 481 507 KAPA_LABEL_XP); 482 508 483 509 graphdata.color = KapaColorByName("green"); 484 KapaPrepPlot(kapa , Nin, &graphdata);485 KapaPlotVector(kapa , Nin, Rin, "x");486 KapaPlotVector(kapa , Nin, Din, "y");510 KapaPrepPlot(kapa1, Nin, &graphdata); 511 KapaPlotVector(kapa1, Nin, Rin, "x"); 512 KapaPlotVector(kapa1, Nin, Din, "y"); 487 513 488 514 graphdata.color = KapaColorByName("red"); 489 KapaPrepPlot(kapa , Nout, &graphdata);490 KapaPlotVector(kapa , Nout, Rout, "x");491 KapaPlotVector(kapa , Nout, Dout, "y");515 KapaPrepPlot(kapa1, Nout, &graphdata); 516 KapaPlotVector(kapa1, Nout, Rout, "x"); 517 KapaPlotVector(kapa1, Nout, Dout, "y"); 492 518 493 519 graphdata.color = KapaColorByName("black"); 494 520 graphdata.ptype = 0; 495 521 graphdata.style = 0; 496 KapaPrepPlot(kapa, 100, &graphdata); 497 KapaPlotVector(kapa, 100, xCirc, "x"); 498 KapaPlotVector(kapa, 100, yCirc, "y"); 499 500 501 522 KapaPrepPlot(kapa1, 100, &graphdata); 523 KapaPlotVector(kapa1, 100, xCirc, "x"); 524 KapaPlotVector(kapa1, 100, yCirc, "y"); 525 502 526 askUser(&plotOutliers); 503 527 … … 510 534 } 511 535 512 536 # if (0) 537 int relastroVisualSummaryChips() { 538 539 // plot the dXsys, dYsys histograms 540 541 // plot x vs dx, y vs dy, etc for all mosaics 542 543 // plot a map of median star scatter 544 545 } 546 # endif 547 -
trunk/Ohana/src/relastro/src/select_images.c
r29001 r30616 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \ 19 float dtime; \ 20 gettimeofday (&stop, (void *) NULL); \ 21 dtime = DTIME (stop, start); \ 22 fprintf (stderr, MSG, __VA_ARGS__); } 17 23 18 24 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { … … 25 31 Coords tcoords; 26 32 SkyRegionCoords *skycoords; 27 33 struct timeval start, stop; 34 35 double RmaxSkyRegion, RminSkyRegion, RmidSkyRegion, DminSkyRegion, DmaxSkyRegion; 36 28 37 double *RmaxSky; 29 38 off_t *index; … … 40 49 return NULL; 41 50 } 51 52 gettimeofday (&start, (void *) NULL); 42 53 43 54 // the comparison is made in the catalog local projection. below we set crval1,2 … … 52 63 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 53 64 ALLOCATE (index, off_t, skylist[0].Nregions); 65 66 RminSkyRegion = +360.0; 67 RmaxSkyRegion = -360.0; 68 DminSkyRegion = +90.0; 69 DmaxSkyRegion = -90.0; 54 70 55 71 /* compare with each region file */ … … 80 96 skycoords[i].Xc[3] -= dx; skycoords[i].Yc[3] += dy; 81 97 skycoords[i].Xc[4] -= dx; skycoords[i].Yc[4] -= dy; 82 } 98 99 RminSkyRegion = MIN(RminSkyRegion, skylist[0].regions[i][0].Rmin); 100 RmaxSkyRegion = MAX(RmaxSkyRegion, skylist[0].regions[i][0].Rmax); 101 DminSkyRegion = MIN(DminSkyRegion, skylist[0].regions[i][0].Dmin); 102 DmaxSkyRegion = MAX(DmaxSkyRegion, skylist[0].regions[i][0].Dmax); 103 } 104 RmidSkyRegion = 0.5*(RminSkyRegion + RmaxSkyRegion); 105 MARKTIME("create sky region coords: %f sec\n", dtime); 83 106 84 107 dsortindex (RmaxSky, index, skylist[0].Nregions); 108 MARKTIME("sort sky coords: %f sec\n", dtime); 85 109 86 110 if (VERBOSE) fprintf (stderr, "finding images\n"); 87 111 BuildChipMatch (timage, Ntimage); 112 MARKTIME("build chip match: %f sec\n", dtime); 88 113 89 114 nimage = 0; … … 124 149 } 125 150 126 /* define image corners */ 127 Xi[0] = 0; Yi[0] = 0; 128 Xi[1] = timage[i].NX; Yi[1] = 0; 129 Xi[2] = timage[i].NX; Yi[2] = timage[i].NY; 130 Xi[3] = 0; Yi[3] = timage[i].NY; 131 Xi[4] = 0; Yi[4] = 0; 151 /* define image corners - note the DIS images (mosaic phu) are special */ 152 if (!strcmp(&timage[i].coords.ctype[4], "-DIS")) { 153 Xi[0] = -0.5*timage[i].NX; Yi[0] = -0.5*timage[i].NY; 154 Xi[1] = +0.5*timage[i].NX; Yi[1] = -0.5*timage[i].NY; 155 Xi[2] = +0.5*timage[i].NX; Yi[2] = +0.5*timage[i].NY; 156 Xi[3] = -0.5*timage[i].NX; Yi[3] = +0.5*timage[i].NY; 157 Xi[4] = -0.5*timage[i].NX; Yi[4] = -0.5*timage[i].NY; 158 } else { 159 Xi[0] = 0; Yi[0] = 0; 160 Xi[1] = timage[i].NX; Yi[1] = 0; 161 Xi[2] = timage[i].NX; Yi[2] = timage[i].NY; 162 Xi[3] = 0; Yi[3] = timage[i].NY; 163 Xi[4] = 0; Yi[4] = 0; 164 } 132 165 found = FALSE; 133 166 134 167 /* transform corners to ra,dec */ 135 168 double RminImage = 360.0; 169 double RmaxImage = 0.0; 170 double DminImage = +90.0; 171 double DmaxImage = -90.0; 172 // int leftside = FALSE; 136 173 for (j = 0; j < 5; j++) { 137 174 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 175 Ri[j] = ohana_normalize_angle_to_midpoint (Ri[j], RmidSkyRegion); 176 138 177 RminImage = MIN(RminImage, Ri[j]); 139 } 178 RmaxImage = MAX(RmaxImage, Ri[j]); 179 DminImage = MIN(DminImage, Di[j]); 180 DmaxImage = MAX(DmaxImage, Di[j]); 181 } 182 if (RmaxImage - RminImage > 180.0) { 183 double tmp = RminImage; 184 RmaxImage = RminImage; 185 RminImage = tmp - 360.0; 186 } 187 188 // check that this image is even in range of the searched region 189 if (DminImage > DmaxSkyRegion) continue; 190 if (DmaxImage < DminSkyRegion) continue; 191 192 // the sky region RA is defined to be 0 - 360.0 193 if (RminImage > RmaxSkyRegion) continue; 194 if (RmaxImage < RminSkyRegion) continue; 195 196 // image overlaps region, keep it 197 if (USE_BASIC_CHECK) goto found_it; 140 198 141 199 // RA(nStart) is guaranteed to be < RminImage: … … 161 219 for (j = 0; (j < 4) && !found; j++) { 162 220 found = corner_check (&Xi[j], &Yi[j], &skycoords[m].Xc[0], &skycoords[m].Yc[0]); 221 if (found) goto found_it; 163 222 } 164 223 /* check if catalog corner inside image */ 165 224 for (j = 0; (j < 4) && !found; j++) { 166 225 found = corner_check (&skycoords[m].Xc[j], &skycoords[m].Yc[j], &Xi[0], &Yi[0]); 226 if (found) goto found_it; 167 227 } 168 228 /* check if edges cross */ … … 170 230 for (k = 0; (k < 4) && !found; k++) { 171 231 found = edge_check (&Xi[j], &Yi[j], &skycoords[m].Xc[k], &skycoords[m].Yc[k]); 232 if (found) goto found_it; 172 233 } 173 234 } 174 if (!found) continue; 175 176 image[nimage] = timage[i]; 177 /* always allow 'few' images to succeed, if possible */ 178 if (image[nimage].flags & ID_IMAGE_ASTROM_FEW) { 179 image[nimage].flags &= ~ID_IMAGE_ASTROM_FEW; 180 } 181 if (RESET) { 182 // XXX do we need / want to do this in relastro? 183 assignMcal (&image[nimage], (double *) NULL, -1); 184 image[nimage].dMcal = NAN; 185 image[nimage].flags &= ~badImage; 186 } 187 line_number[nimage] = i; 188 nimage ++; 189 if (nimage == NIMAGE) { 190 NIMAGE += 100; 191 REALLOCATE (image, Image, NIMAGE); 192 REALLOCATE (line_number, off_t, NIMAGE); 193 } 194 } 195 } 196 235 } 236 if (!found) continue; 237 238 found_it: 239 image[nimage] = timage[i]; 240 /* always allow 'few' images to succeed, if possible */ 241 if (image[nimage].flags & ID_IMAGE_ASTROM_FEW) { 242 image[nimage].flags &= ~ID_IMAGE_ASTROM_FEW; 243 } 244 if (RESET) { 245 // XXX do we need / want to do this in relastro? 246 // assignMcal (&image[nimage], (double *) NULL, -1); 247 // image[nimage].Mcal = NAN; 248 // image[nimage].dMcal = NAN; 249 image[nimage].flags &= ~badImage; 250 } 251 line_number[nimage] = i; 252 nimage ++; 253 if (nimage == NIMAGE) { 254 NIMAGE += 100; 255 REALLOCATE (image, Image, NIMAGE); 256 REALLOCATE (line_number, off_t, NIMAGE); 257 } 258 } 259 MARKTIME("finish image selection: %f sec\n", dtime); 260 197 261 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); 198 262 -
trunk/Ohana/src/relphot/Makefile
r17242 r30616 29 29 $(SRC)/StarOps.$(ARCH).o \ 30 30 $(SRC)/args.$(ARCH).o \ 31 $(SRC)/help.$(ARCH).o \ 31 32 $(SRC)/bcatalog.$(ARCH).o \ 32 33 $(SRC)/global_stats.$(ARCH).o \ -
trunk/Ohana/src/relphot/include/relphot.h
r27586 r30616 13 13 float Mcal; 14 14 float dMcal; 15 float dMsys; 16 short nFitPhotom; 15 17 short Xm; 16 18 float secz; … … 50 52 double STAR_CHISQ; 51 53 double MIN_ERROR; 54 double IMFIT_SYS_SIGMA_LIM; 52 55 53 56 int VERBOSE; … … 103 106 SkyRegion UserPatch; 104 107 int UserPatchSelect; 108 109 int USE_BASIC_CHECK; 105 110 106 111 # ifdef GRID_V1 … … 215 220 void write_coords PROTO((Header *header, Coords *coords)); 216 221 int relphot_objects (void); 222 223 void relphot_usage (void); 224 void relphot_help (int argc, char **argv); -
trunk/Ohana/src/relphot/src/ConfigInit.c
r25757 r30616 20 20 GetConfig (config, "MAG_LIM", "%lf", 0, &MAG_LIM); 21 21 GetConfig (config, "SIGMA_LIM", "%lf", 0, &SIGMA_LIM); 22 23 if (!ScanConfig (config, "RELPHOT_IMFIT_SYS_SIGMA_LIM", "%lf", 0, &IMFIT_SYS_SIGMA_LIM)) IMFIT_SYS_SIGMA_LIM = 0.01; 24 22 25 GetConfig (config, "STAR_SCATTER", "%lf", 0, &STAR_SCATTER); 23 26 GetConfig (config, "IMAGE_SCATTER", "%lf", 0, &IMAGE_SCATTER); -
trunk/Ohana/src/relphot/src/ImageOps.c
r29001 r30616 124 124 free (clist); 125 125 free (mlist); 126 free (Nlist); 127 free (NLIST); 126 128 } 127 129 … … 299 301 300 302 off_t i, j, m, c, n, N, Nmax, mark, bad; 301 int Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys ;302 float Msys, Mrel, Mmos, Mgrid ;303 int Nfew, Nbad, Nmos, Ngrid, Nrel, Nsys, Nbright; 304 float Msys, Mrel, Mmos, Mgrid, McalBright, McalBright2; 303 305 double *list, *dlist; 304 306 StatType stats; … … 318 320 319 321 Nfew = Nbad = Nmos = Ngrid = Nrel = Nsys = 0; 322 323 // counters to measure the bright-end scatter 324 McalBright = McalBright2 = 0.0; 325 Nbright = 0; 320 326 321 327 for (i = 0; i < Nimage; i++) { … … 361 367 list[N] = Msys - Mrel - Mmos - Mgrid; 362 368 dlist[N] = MAX (catalog[c].measure[m].dM, MIN_ERROR); 369 if (catalog[c].measure[m].dM < IMFIT_SYS_SIGMA_LIM) { 370 McalBright += list[N]; 371 McalBright2 += SQ(list[N]); 372 Nbright ++; 373 } 363 374 N++; 364 375 } … … 378 389 liststats (list, dlist, N, &stats); 379 390 image[i].Mcal = stats.mean; 380 image[i].dMcal = stats.sigma; 391 image[i].dMcal = stats.error; 392 image[i].dMagSys = stats.sigma; 393 image[i].nFitPhotom = N; 381 394 image[i].Xm = 100.0*log10(stats.chisq); 382 395 } -
trunk/Ohana/src/relphot/src/MosaicOps.c
r29001 r30616 73 73 mosaic[Nmosaic].Mcal = 0.0; 74 74 mosaic[Nmosaic].dMcal = 0.0; 75 mosaic[Nmosaic].dMsys = 0.0; 75 76 mosaic[Nmosaic].Xm = 0.0; 76 77 mosaic[Nmosaic].flags = image[i].flags; … … 189 190 image[im].dMcal = mosaic[i].dMcal; 190 191 image[im].Xm = mosaic[i].Xm; 192 image[im].dMagSys = mosaic[i].dMsys; 193 image[im].nFitPhotom = mosaic[i].nFitPhotom; 191 194 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_FEW); 192 195 image[im].flags |= (mosaic[i].flags & ID_IMAGE_PHOTOM_POOR); … … 400 403 mark = (N < IMAGE_TOOFEW) || (N < IMAGE_GOOD_FRACTION*Nlist[i]); 401 404 if (mark) { 402 fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]);405 if (VERBOSE2) { fprintf (stderr, "marked mosaic %s ("OFF_T_FMT"), ("OFF_T_FMT" < %d) || ("OFF_T_FMT" < %f*"OFF_T_FMT")\n", image[imlist[i][0]].name, i, N, IMAGE_TOOFEW, N, IMAGE_GOOD_FRACTION, Nlist[i]); } 403 406 mosaic[i].flags |= ID_IMAGE_PHOTOM_FEW; 404 407 Nfew ++; … … 410 413 if (PoorImages) fprintf (stderr, "Mmos: %f %f %d "OFF_T_FMT"\n", stats.mean, stats.sigma, stats.Nmeas, N); 411 414 mosaic[i].Mcal = stats.mean; 412 mosaic[i].dMcal = stats.sigma; 415 mosaic[i].dMcal = stats.error; 416 mosaic[i].dMsys = stats.sigma; 417 mosaic[i].nFitPhotom = N; 413 418 mosaic[i].Xm = 100.0*log10(stats.chisq); 414 419 } -
trunk/Ohana/src/relphot/src/args.c
r27586 r30616 1 1 # include "relphot.h" 2 void usage (void);3 2 4 3 int args (int argc, char **argv) { … … 53 52 } 54 53 54 USE_BASIC_CHECK = FALSE; 55 if ((N = get_argument (argc, argv, "-basic-image-search"))) { 56 remove_argument (N, &argc, argv); 57 USE_BASIC_CHECK = TRUE; 58 } 59 55 60 VERBOSE = VERBOSE2 = FALSE; 56 61 if ((N = get_argument (argc, argv, "-v"))) { … … 228 233 if (UpdateAverages && (argc == 1)) return TRUE; 229 234 if (UserPatchSelect && (argc == 2)) return TRUE; 230 if (argc != 3) usage ();235 if (argc != 3) relphot_usage (); 231 236 232 237 return TRUE; 233 238 } 234 235 void usage () {236 fprintf (stderr, "ERROR: USAGE: relphot (region) (photcode)\n");237 fprintf (stderr, " or: relphot (photcode) -region RA RA DEC DEC\n");238 fprintf (stderr, " or: relphot -averages -region RA RA DEC DEC\n");239 fprintf (stderr, " options: \n");240 fprintf (stderr, " -time (start) (stop)\n");241 fprintf (stderr, " -v : verbose output\n");242 fprintf (stderr, " -vv : more verbose output\n");243 fprintf (stderr, " -outroot (outroot)\n");244 fprintf (stderr, " -plot\n");245 fprintf (stderr, " -plotdelay (seconds)\n");246 fprintf (stderr, " -statmode (mode)\n");247 fprintf (stderr, " -refcode (name) : give extra weight to this photcode\n");248 fprintf (stderr, " -n (nloop)\n");249 fprintf (stderr, " -reset\n");250 fprintf (stderr, " -update\n");251 fprintf (stderr, " -params\n");252 fprintf (stderr, " -mosaic (mosaic)\n");253 fprintf (stderr, " -imfreeze\n");254 fprintf (stderr, " -grid\n");255 fprintf (stderr, " -area Xmin Xmax Ymin Ymax\n");256 fprintf (stderr, " -instmag min max\n");257 fprintf (stderr, " \n");258 exit (2);259 } -
trunk/Ohana/src/relphot/src/bcatalog.c
r28660 r30616 119 119 120 120 if (VERBOSE) { 121 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog \n",122 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i);121 fprintf (stderr, "using "OFF_T_FMT" stars ("OFF_T_FMT" measures) of "OFF_T_FMT" for catalog %s\n", 122 subcatalog[0].Naverage, subcatalog[0].Nmeasure, i, catalog[0].filename); 123 123 fprintf (stderr, "rejections: %d code, %d time, %d dophot, %d mag, %d sigma, %d imag, %d few\n", 124 124 Ncode, Ntime, Ndophot, Nmag, Nsigma, Nimag, Nfew); -
trunk/Ohana/src/relphot/src/initialize.c
r29001 r30616 5 5 int N; 6 6 7 relphot_help (argc, argv); 7 8 ConfigInit (&argc, argv); 8 9 args (argc, argv); -
trunk/Ohana/src/relphot/src/load_catalogs.c
r29754 r30616 6 6 Catalog *catalog, tcatalog; 7 7 8 if (VERBOSE ) fprintf (stderr, "loading catalog data\n");8 if (VERBOSE2) fprintf (stderr, "loading catalog data\n"); 9 9 10 10 ALLOCATE (catalog, Catalog, skylist[0].Nregions); … … 22 22 tcatalog.Nsecfilt = GetPhotcodeNsecfilt (); // set the desired number in case we need to create the catalog 23 23 24 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE , "r")) {24 if (!dvo_catalog_open (&tcatalog, skylist[0].regions[i], VERBOSE2, "r")) { 25 25 fprintf (stderr, "ERROR: failure reading catalog %s\n", tcatalog.filename); 26 26 exit (1); 27 27 } 28 if (VERBOSE && !tcatalog.Naves_disk) fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); 28 if (!tcatalog.Naves_disk) { 29 if (VERBOSE2) { fprintf (stderr, "no data in %s, skipping\n", tcatalog.filename); } 30 dvo_catalog_unlock (&tcatalog); 31 dvo_catalog_free (&tcatalog); 32 continue; 33 } 34 29 35 Nstar_total += tcatalog.Naverage; 30 36 Nmeas_total += tcatalog.Nmeasure; -
trunk/Ohana/src/relphot/src/load_images.c
r29001 r30616 1 1 # include "relphot.h" 2 3 # define MARKTIME(MSG,...) { \ 4 float dtime; \ 5 gettimeofday (&stop, (void *) NULL); \ 6 dtime = DTIME (stop, start); \ 7 fprintf (stderr, MSG, __VA_ARGS__); } 2 8 3 9 SkyList *load_images (FITS_DB *db, char *regionName, SkyRegion *region, int RegionSelect) { … … 6 12 off_t Nimage, Nsubset, Nchar; 7 13 off_t *LineNumber; 14 struct timeval start, stop; 8 15 9 16 SkyTable *sky = NULL; 10 17 SkyList *skylist = NULL; 18 19 gettimeofday (&start, (void *) NULL); 11 20 12 21 // load the current sky table (layout of all SkyRegions) … … 29 38 exit (2); 30 39 } 40 MARKTIME("read image table: %f sec\n", dtime); 31 41 32 42 // select the images which overlap the selected sky regions 33 43 subset = select_images (skylist, image, Nimage, &LineNumber, &Nsubset); 44 MARKTIME("selected images: %f sec\n", dtime); 34 45 35 46 gfits_vtable_from_ftable (&db[0].ftable, &db[0].vtable, LineNumber, Nsubset); 47 MARKTIME("converted ftable to vtable: %f sec\n", dtime); 36 48 37 49 initImages (subset, Nsubset); 50 MARKTIME("init images: %f sec\n", dtime); 51 38 52 initMosaics (subset, Nsubset); 53 MARKTIME("init mosaics: %f sec\n", dtime); 39 54 40 55 return (skylist); -
trunk/Ohana/src/relphot/src/relphot.c
r27480 r30616 85 85 if (PLOTSTUFF) { 86 86 plot_star_coords (catalog, Ncatalog); 87 plot_mosaic_fields (catalog);87 // plot_mosaic_fields (catalog); 88 88 } 89 89 -
trunk/Ohana/src/relphot/src/select_images.c
r29001 r30616 15 15 void dsortindex (double *X, off_t *Y, int N); 16 16 off_t getRegionStartByRA (double R, double *Rref, off_t Nregions); 17 18 # define MARKTIME(MSG,...) { \ 19 float dtime; \ 20 gettimeofday (&stop, (void *) NULL); \ 21 dtime = DTIME (stop, start); \ 22 fprintf (stderr, MSG, __VA_ARGS__); } 17 23 18 24 Image *select_images (SkyList *skylist, Image *timage, off_t Ntimage, off_t **LineNumber, off_t *Nimage) { … … 25 31 Coords tcoords; 26 32 SkyRegionCoords *skycoords; 27 33 struct timeval start, stop; 34 35 double RmaxSkyRegion, RminSkyRegion, DminSkyRegion, DmaxSkyRegion, RmidSkyRegion; 36 28 37 double *RmaxSky; 29 38 off_t *index; … … 35 44 return NULL; 36 45 } 46 47 gettimeofday (&start, (void *) NULL); 37 48 38 49 // the comparison is made in the catalog local projection. below we set crval1,2 … … 47 58 ALLOCATE (RmaxSky, double, skylist[0].Nregions); 48 59 ALLOCATE (index, off_t, skylist[0].Nregions); 60 61 RminSkyRegion = +360.0; 62 RmaxSkyRegion = -360.0; 63 DminSkyRegion = +90.0; 64 DmaxSkyRegion = -90.0; 49 65 50 66 /* compare with each region file */ … … 75 91 skycoords[i].Xc[3] -= dx; skycoords[i].Yc[3] += dy; 76 92 skycoords[i].Xc[4] -= dx; skycoords[i].Yc[4] -= dy; 77 } 93 94 RminSkyRegion = MIN(RminSkyRegion, skylist[0].regions[i][0].Rmin); 95 RmaxSkyRegion = MAX(RmaxSkyRegion, skylist[0].regions[i][0].Rmax); 96 DminSkyRegion = MIN(DminSkyRegion, skylist[0].regions[i][0].Dmin); 97 DmaxSkyRegion = MAX(DmaxSkyRegion, skylist[0].regions[i][0].Dmax); 98 } 99 RmidSkyRegion = 0.5*(RminSkyRegion + RmaxSkyRegion); 100 MARKTIME("create sky region coords: %f sec\n", dtime); 78 101 79 102 dsortindex (RmaxSky, index, skylist[0].Nregions); 103 MARKTIME("sort sky coords: %f sec\n", dtime); 80 104 81 105 if (VERBOSE) fprintf (stderr, "finding images\n"); 82 106 BuildChipMatch (timage, Ntimage); 107 MARKTIME("build chip match: %f sec\n", dtime); 83 108 84 109 nimage = 0; … … 100 125 } 101 126 127 // this adds 1.3 sec for 3M images 102 128 if (!FindMosaicForImage (timage, Ntimage, i)) { 103 129 fprintf (stderr, "cannot find mosaic for "OFF_T_FMT"\n", i); … … 113 139 found = FALSE; 114 140 115 /* transform corners to ra,dec */141 /* transform corners to ra,dec -- costs ~3sec for 3M images */ 116 142 double RminImage = 360.0; 143 double RmaxImage = 0.0; 144 double DminImage = +90.0; 145 double DmaxImage = -90.0; 117 146 for (j = 0; j < 5; j++) { 118 147 XY_to_RD (&Ri[j], &Di[j], Xi[j], Yi[j], &timage[i].coords); 148 Ri[j] = ohana_normalize_angle_to_midpoint (Ri[j], RmidSkyRegion); 149 119 150 RminImage = MIN(RminImage, Ri[j]); 120 } 121 122 // RA(nStart) is guaranteed to be < RminImage: 151 RmaxImage = MAX(RmaxImage, Ri[j]); 152 DminImage = MIN(DminImage, Di[j]); 153 DmaxImage = MAX(DmaxImage, Di[j]); 154 } 155 if (RmaxImage - RminImage > 180.0) { 156 double tmp = RminImage; 157 RmaxImage = RminImage; 158 RminImage = tmp - 360.0; 159 } 160 161 // check that this image is even in range of the searched region 162 if (DminImage > DmaxSkyRegion) continue; 163 if (DmaxImage < DminSkyRegion) continue; 164 165 // the sky region RA is defined to be 0 - 360.0 166 if (RminImage > RmaxSkyRegion) continue; 167 if (RmaxImage < RminSkyRegion) continue; 168 169 // image overlaps region, keep it 170 if (USE_BASIC_CHECK) goto found_it; 171 172 // RA(nStart) is guaranteed to be < RminImage: -- costs 0.5sec for 3M images 123 173 nStart = getRegionStartByRA (RminImage, RmaxSky, skylist[0].Nregions); 124 174 125 175 /* compare with each region file */ 126 for (iSky = 0; (iSky < skylist[0].Nregions) && !found; iSky++) {176 for (iSky = nStart; (iSky < skylist[0].Nregions) && !found; iSky++) { 127 177 128 178 m = index[iSky]; … … 142 192 for (j = 0; (j < 4) && !found; j++) { 143 193 found = corner_check (&Xi[j], &Yi[j], &skycoords[m].Xc[0], &skycoords[m].Yc[0]); 194 if (found) goto found_it; 144 195 } 145 196 /* check if catalog corner inside image */ 146 197 for (j = 0; (j < 4) && !found; j++) { 147 198 found = corner_check (&skycoords[m].Xc[j], &skycoords[m].Yc[j], &Xi[0], &Yi[0]); 199 if (found) goto found_it; 148 200 } 149 201 /* check if edges cross */ … … 151 203 for (k = 0; (k < 4) && !found; k++) { 152 204 found = edge_check (&Xi[j], &Yi[j], &skycoords[m].Xc[k], &skycoords[m].Yc[k]); 205 if (found) goto found_it; 153 206 } 154 207 } 155 if (!found) continue; 156 157 image[nimage] = timage[i]; 158 /* always allow 'few' images to succeed, if possible */ 159 if (image[nimage].flags & ID_IMAGE_PHOTOM_FEW) { 160 image[nimage].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR); 161 } 162 if (RESET) { 163 assignMcal (&image[nimage], (double *) NULL, -1); 164 image[nimage].dMcal = NAN; 165 image[nimage].flags &= ~ID_IMAGE_PHOTOM_POOR; 166 } 167 line_number[nimage] = i; 168 nimage ++; 169 if (nimage == NIMAGE) { 170 NIMAGE += 100; 171 REALLOCATE (image, Image, NIMAGE); 172 REALLOCATE (line_number, off_t, NIMAGE); 173 } 174 } 175 } 176 208 } 209 if (!found) continue; 210 211 found_it: 212 image[nimage] = timage[i]; 213 /* always allow 'few' images to succeed, if possible */ 214 if (image[nimage].flags & ID_IMAGE_PHOTOM_FEW) { 215 image[nimage].flags &= ~(ID_IMAGE_PHOTOM_FEW | ID_IMAGE_PHOTOM_POOR); 216 } 217 if (RESET) { 218 // XXX assignMcal (&image[nimage], (double *) NULL, -1); 219 // XXX this needs to be thought through a bit more 220 image[nimage].Mcal = 0.0; 221 image[nimage].dMcal = NAN; 222 image[nimage].flags &= ~ID_IMAGE_PHOTOM_POOR; 223 } 224 line_number[nimage] = i; 225 nimage ++; 226 if (nimage == NIMAGE) { 227 NIMAGE += 100; 228 REALLOCATE (image, Image, NIMAGE); 229 REALLOCATE (line_number, off_t, NIMAGE); 230 } 231 } 232 MARKTIME("finish image selection: %f sec\n", dtime); 233 177 234 if (VERBOSE) fprintf (stderr, "found "OFF_T_FMT" images\n", nimage); 178 235 … … 295 352 return (Nlo); 296 353 } 354 355 off_t getRegionStopByRA (double R, double *Rref, off_t Nregions) { 356 357 // use bisection to find the overlapping mosaic 358 359 off_t Nlo, Nhi, N; 360 361 // find the last mosaic before start 362 Nlo = 0; Nhi = Nregions; 363 while (Nhi - Nlo > 10) { 364 N = 0.5*(Nlo + Nhi); 365 if (Rref[N] < R) { 366 Nlo = MAX(N, 0); 367 } else { 368 Nhi = MIN(N, Nregions); 369 } 370 } 371 return (Nlo); 372 }
Note:
See TracChangeset
for help on using the changeset viewer.
