Changeset 20805
- Timestamp:
- Nov 19, 2008, 3:28:01 PM (17 years ago)
- Location:
- trunk/psastro/src
- Files:
-
- 1 added
- 11 edited
-
Makefile.am (modified) (1 diff)
-
psastro.h (modified) (2 diffs)
-
psastroArguments.c (modified) (3 diffs)
-
psastroAstromGuess.c (modified) (2 diffs)
-
psastroCleanup.c (modified) (1 diff)
-
psastroFixChips.c (modified) (2 diffs)
-
psastroLoadRefstars.c (modified) (1 diff)
-
psastroLuminosityFunction.c (modified) (1 diff)
-
psastroMosaicSetMatch.c (modified) (2 diffs)
-
psastroOneChipFit.c (modified) (1 diff)
-
psastroRemoveClumps.c (modified) (5 diffs)
-
psastroVisual.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psastro/src/Makefile.am
r20649 r20805 53 53 psastroErrorCodes.c \ 54 54 psastroVersion.c \ 55 psastroVisual.c \ 55 56 psastroDefineFiles.c \ 56 57 psastroAnalysis.c \ -
trunk/psastro/src/psastro.h
r20640 r20805 52 52 psArray *psastroRemoveClumps (psArray *input, int scale); 53 53 54 54 55 // utility functions: 55 56 bool psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip, psArray *rawstars, psArray *refstars); … … 75 76 psString psastroVersion(void); 76 77 psString psastroVersionLong(void); 78 79 // psastroVisual functions 80 bool psastroSetVisual (bool mode); 81 bool psastroVisualClose(); 82 bool psastroVisualPlotLuminosityFunction (psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc); 83 bool psastroVisualPlotRawStars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe); 84 bool psastroVisualPlotRefStars (psArray *refstars, psMetadata *recipe); 85 bool psastroVisualPlotRemoveClumps (psArray *input, psImage *count, int scale, float limit); 86 bool psastroVisualPlotFixChips (pmFPAfile *input, psVector *xOld, psVector *yOld); 87 bool psastroVisualPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe); 88 bool psastroVisualPlotAstromGuessCheck (psVector *cornerPo, psVector *cornerQo, psVector *cornerPn, psVector *cornerQn, psVector *cornerPd, psVector *cornerQd); 89 bool psastroVisualPlotMosaicOneChip (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe); 90 bool psastroVisualPlotCommonScale (pmFPA *fpa, psVector *oldScale); 91 bool psastroVisualPlotMosaicMatches (psArray *rawstars, psArray *refstars, psArray *match, int iteration, psMetadata *recipe); 77 92 78 93 // demo plots -
trunk/psastro/src/psastroArguments.c
r20640 r20805 37 37 psArgumentRemove (N, &argc, argv); 38 38 } 39 39 40 40 // apply the chip correction based on the reference astrometry? 41 41 if ((N = psArgumentGet (argc, argv, "-fixchips"))) { … … 51 51 status = pmConfigFileSetsMD (config->arguments, &argc, argv, "ASTROM.MODEL", "-astrommodel", "-astrommodellist"); 52 52 if (status) { 53 // if supplied, assume -fixchips is desired53 // if supplied, assume -fixchips is desired 54 54 psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true); 55 55 } … … 85 85 } 86 86 87 // run in visual mode? 88 if ((N = psArgumentGet (argc, argv, "-visual"))) { 89 psArgumentRemove (N, &argc, argv); 90 psastroSetVisual (true); 91 pmAstromSetVisual (true); 92 } 93 87 94 // dump the configuration to a file? 88 95 if ((N = psArgumentGet (argc, argv, "-dumpconfig"))) { -
trunk/psastro/src/psastroAstromGuess.c
r20796 r20805 142 142 psastroDumpRawstars (rawstars, fpa, chip); 143 143 } 144 145 psastroVisualPlotRawStars(rawstars, fpa, chip, recipe); 144 146 145 147 if (psTraceGetLevel("psastro.plot") > 0) { … … 362 364 psVector *cornerQd = (psVector *) psBinaryOp (NULL, cornerQn, "-", cornerQf); 363 365 366 psastroVisualPlotAstromGuessCheck (cornerPo, cornerQo, cornerPn, cornerQn, cornerPd, cornerQd); 367 364 368 psStats *statsP = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); 365 369 psStats *statsQ = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV); -
trunk/psastro/src/psastroCleanup.c
r14641 r20805 11 11 pmConceptsDone (); 12 12 pmConfigDone (); 13 psastroVisualClose (); 14 pmAstromVisualClose (); 13 15 fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psastro"); 14 16 // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psastro"); -
trunk/psastro/src/psastroFixChips.c
r20795 r20805 190 190 } 191 191 192 psFree (xObs);193 psFree (yObs);194 192 psFree (xRef); 195 193 psFree (yRef); … … 321 319 } 322 320 321 psastroVisualPlotFixChips (input, xObs, yObs); 322 psFree (xObs); 323 psFree (yObs); 323 324 psFree (map); 324 325 psFree (view); -
trunk/psastro/src/psastroLoadRefstars.c
r20319 r20805 137 137 psastroDumpRefstars (refstars, "refstars.dat"); 138 138 } 139 140 psastroVisualPlotRefStars (refstars, recipe); 139 141 140 142 if (psTraceGetLevel("psastro.plot") > 0) { -
trunk/psastro/src/psastroLuminosityFunction.c
r20037 r20805 129 129 lumFunc->sPeak = sPeak; 130 130 131 #if 0 132 psastroLuminosityFunctionPlot(lnMag, Mag, lumFunc, rawFunc); 133 #endif 131 psastroVisualPlotLuminosityFunction(lnMag, Mag, lumFunc, rawFunc); 134 132 135 133 psFree (lnMag); -
trunk/psastro/src/psastroMosaicSetMatch.c
r17108 r20805 10 10 11 11 // use small radius to match stars (assume starting astrometry is good) 12 bool status = false; 12 bool status = false; 13 13 sprintf (radiusWord, "PSASTRO.MOSAIC.RADIUS.N%d", iteration); 14 double RADIUS = psMetadataLookupF32 (&status, recipe, radiusWord); 15 if (!status) { 16 psError(PS_ERR_IO, false, "Failed to lookup matching radius: %s", radiusWord); 17 psFree (view);18 return false; 19 } 14 double RADIUS = psMetadataLookupF32 (&status, recipe, radiusWord); 15 if (!status) { 16 psError(PS_ERR_IO, false, "Failed to lookup matching radius: %s", radiusWord); 17 psFree (view); 18 return false; 19 } 20 20 21 21 if (RADIUS <= 0.0) { 22 if (iteration == 0) {23 psError(PS_ERR_IO, false, "Invalid match radius for first iteration: %s", radiusWord); 24 psFree (view);25 return false; 26 } 27 psWarning ("skipping match for iteration %d\n", iteration);28 psFree (view);29 return true;22 if (iteration == 0) { 23 psError(PS_ERR_IO, false, "Invalid match radius for first iteration: %s", radiusWord); 24 psFree (view); 25 return false; 26 } 27 psWarning ("skipping match for iteration %d\n", iteration); 28 psFree (view); 29 return true; 30 30 } 31 31 … … 34 34 psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process); 35 35 if (!chip->process || !chip->file_exists) { continue; } 36 if (!chip->fromFPA) { continue; }37 38 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) {36 if (!chip->fromFPA) { continue; } 37 38 while ((cell = pmFPAviewNextCell (view, fpa, 1)) != NULL) { 39 39 psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process); 40 40 if (!cell->process || !cell->file_exists) { continue; } 41 41 42 // process each of the readouts43 // XXX there can only be one readout per chip, right?44 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) {45 if (! readout->data_exists) { continue; }42 // process each of the readouts 43 // XXX there can only be one readout per chip, right? 44 while ((readout = pmFPAviewNextReadout (view, fpa, 1)) != NULL) { 45 if (! readout->data_exists) { continue; } 46 46 47 // select the raw objects for this readout48 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS");49 if (rawstars == NULL) { continue; }47 // select the raw objects for this readout 48 psArray *rawstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.RAWSTARS"); 49 if (rawstars == NULL) { continue; } 50 50 51 // select the raw objects for this readout52 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS");53 if (refstars == NULL) { continue; }54 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n);51 // select the raw objects for this readout 52 psArray *refstars = psMetadataLookupPtr (NULL, readout->analysis, "PSASTRO.REFSTARS"); 53 if (refstars == NULL) { continue; } 54 psTrace ("psastro", 4, "Trying %ld refstars\n", refstars->n); 55 55 56 psArray *matches = pmAstromRadiusMatchChip (rawstars, refstars, RADIUS);57 psTrace ("psastro", 4, "Matched %ld refstars\n", matches->n);56 psArray *matches = pmAstromRadiusMatchChip (rawstars, refstars, RADIUS); 57 psTrace ("psastro", 4, "Matched %ld refstars\n", matches->n); 58 58 59 // XXX drop the old one 60 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.MATCH", PS_DATA_ARRAY | PS_META_REPLACE, "astrometry matches", matches); 61 psFree (matches); 62 } 63 } 59 psastroVisualPlotMosaicMatches(rawstars, refstars, matches, iteration, recipe); 60 61 // XXX drop the old one 62 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSASTRO.MATCH", PS_DATA_ARRAY | PS_META_REPLACE, "astrometry matches", matches); 63 psFree (matches); 64 } 65 } 64 66 } 65 67 psFree (view); -
trunk/psastro/src/psastroOneChipFit.c
r20794 r20805 156 156 } 157 157 158 psastroVisualPlotOneChipFit (rawstars, refstars, match, recipe); 159 158 160 if (psTraceGetLevel("psastro.plot") > 0) { 159 161 psastroPlotOneChipFit (rawstars, refstars, match, recipe); -
trunk/psastro/src/psastroRemoveClumps.c
r17109 r20805 11 11 float Ymax = obj->FP->y; 12 12 for (int i = 0; i < input->n; i++) { 13 obj = (pmAstromObj *)input->data[i];14 if (!isfinite(obj->FP->x)) continue;15 if (!isfinite(obj->FP->y)) continue;16 Xmin = PS_MIN (Xmin, obj->FP->x);17 Xmax = PS_MAX (Xmax, obj->FP->x);18 Ymin = PS_MIN (Ymin, obj->FP->y);19 Ymax = PS_MAX (Ymax, obj->FP->y);13 obj = (pmAstromObj *)input->data[i]; 14 if (!isfinite(obj->FP->x)) continue; 15 if (!isfinite(obj->FP->y)) continue; 16 Xmin = PS_MIN (Xmin, obj->FP->x); 17 Xmax = PS_MAX (Xmax, obj->FP->x); 18 Ymin = PS_MIN (Ymin, obj->FP->y); 19 Ymax = PS_MAX (Ymax, obj->FP->y); 20 20 } 21 21 … … 27 27 // accumulate 2D histogram in image 28 28 for (int i = 0; i < input->n; i++) { 29 obj = (pmAstromObj *)input->data[i];30 if (!isfinite(obj->FP->x)) continue;31 if (!isfinite(obj->FP->y)) continue;32 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols);33 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows);34 count->data.U32[Yi][Xi] ++;29 obj = (pmAstromObj *)input->data[i]; 30 if (!isfinite(obj->FP->x)) continue; 31 if (!isfinite(obj->FP->y)) continue; 32 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols); 33 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows); 34 count->data.U32[Yi][Xi] ++; 35 35 } 36 36 … … 38 38 psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MAX | PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV); 39 39 if (!psImageStats(stats, count, NULL, 0)) { 40 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n");41 psFree(stats);42 psFree(count);43 return NULL;40 psError(PS_ERR_UNKNOWN, false, "Unable to get image statistics.\n"); 41 psFree(stats); 42 psFree(count); 43 return NULL; 44 44 } 45 45 46 46 if (stats->max < 1) { 47 psError(PS_ERR_UNKNOWN, false, "no valid sources in image\n");48 psFree(stats);49 psFree(count);50 return NULL;47 psError(PS_ERR_UNKNOWN, false, "no valid sources in image\n"); 48 psFree(stats); 49 psFree(count); 50 return NULL; 51 51 } 52 52 … … 55 55 psTrace ("psastro", 4, "skipping stars in cells with more than %f stars\n", limit); 56 56 57 psastroVisualPlotRemoveClumps (input, count, scale, limit); 58 57 59 // find and exclude objects in bad pixels 58 60 psArray *output = psArrayAllocEmpty (input->n); 59 61 for (int i = 0; i < input->n; i++) { 60 obj = (pmAstromObj *)input->data[i];61 if (!isfinite(obj->FP->x)) continue;62 if (!isfinite(obj->FP->y)) continue;63 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols);64 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows);65 if (count->data.U32[Yi][Xi] > limit) continue;66 psArrayAdd (output, 16, obj);62 obj = (pmAstromObj *)input->data[i]; 63 if (!isfinite(obj->FP->x)) continue; 64 if (!isfinite(obj->FP->y)) continue; 65 int Xi = PS_MIN (PS_MAX((obj->FP->x - Xmin) / scale + 5, 0), count->numCols); 66 int Yi = PS_MIN (PS_MAX((obj->FP->y - Ymin) / scale + 5, 0), count->numRows); 67 if (count->data.U32[Yi][Xi] > limit) continue; 68 psArrayAdd (output, 16, obj); 67 69 } 68 70 … … 77 79 for (int iy = 0; iy < count->numRows; iy++) { 78 80 for (int ix = 0; ix < count->numCols; ix++) { 79 if (count->data.U32[iy][ix] > limit) {80 psPlane *pixel = psPlaneAlloc();81 pixel->x = ix;82 pixel->y = iy;83 psArrayAdd (badpix, 16, pixel);84 psFree (pixel);85 }81 if (count->data.U32[iy][ix] > limit) { 82 psPlane *pixel = psPlaneAlloc(); 83 pixel->x = ix; 84 pixel->y = iy; 85 psArrayAdd (badpix, 16, pixel); 86 psFree (pixel); 87 } 86 88 } 87 89 }
Note:
See TracChangeset
for help on using the changeset viewer.
