IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 20805


Ignore:
Timestamp:
Nov 19, 2008, 3:28:01 PM (17 years ago)
Author:
eugene
Message:

import visualizations from cnb_branch_20081011

Location:
trunk/psastro/src
Files:
1 added
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/psastro/src/Makefile.am

    r20649 r20805  
    5353        psastroErrorCodes.c         \
    5454        psastroVersion.c            \
     55        psastroVisual.c             \
    5556        psastroDefineFiles.c        \
    5657        psastroAnalysis.c           \
  • trunk/psastro/src/psastro.h

    r20640 r20805  
    5252psArray          *psastroRemoveClumps (psArray *input, int scale);
    5353
     54
    5455// utility functions:
    5556bool              psastroUpdateChipToFPA (pmFPA *fpa, pmChip *chip, psArray *rawstars, psArray *refstars);
     
    7576psString          psastroVersion(void);
    7677psString          psastroVersionLong(void);
     78
     79// psastroVisual functions
     80bool psastroSetVisual (bool mode);
     81bool psastroVisualClose();
     82bool psastroVisualPlotLuminosityFunction (psVector *lnMag, psVector *Mag, pmLumFunc *lumFunc, pmLumFunc *rawFunc);
     83bool psastroVisualPlotRawStars (psArray *rawstars, pmFPA *fpa, pmChip *chip, psMetadata *recipe);
     84bool psastroVisualPlotRefStars (psArray *refstars, psMetadata *recipe);
     85bool psastroVisualPlotRemoveClumps (psArray *input, psImage *count, int scale, float limit);
     86bool psastroVisualPlotFixChips (pmFPAfile *input, psVector *xOld, psVector *yOld);
     87bool psastroVisualPlotOneChipFit (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
     88bool psastroVisualPlotAstromGuessCheck (psVector *cornerPo, psVector *cornerQo, psVector *cornerPn, psVector *cornerQn, psVector *cornerPd, psVector *cornerQd);
     89bool psastroVisualPlotMosaicOneChip (psArray *rawstars, psArray *refstars, psArray *match, psMetadata *recipe);
     90bool psastroVisualPlotCommonScale (pmFPA *fpa, psVector *oldScale);
     91bool psastroVisualPlotMosaicMatches (psArray *rawstars, psArray *refstars, psArray *match, int iteration, psMetadata *recipe);
    7792
    7893// demo plots
  • trunk/psastro/src/psastroArguments.c

    r20640 r20805  
    3737        psArgumentRemove (N, &argc, argv);
    3838    }
    39    
     39
    4040    // apply the chip correction based on the reference astrometry?
    4141    if ((N = psArgumentGet (argc, argv, "-fixchips"))) {
     
    5151    status = pmConfigFileSetsMD (config->arguments, &argc, argv, "ASTROM.MODEL", "-astrommodel", "-astrommodellist");
    5252    if (status) {
    53         // if supplied, assume -fixchips is desired
     53        // if supplied, assume -fixchips is desired
    5454        psMetadataAddBool (config->arguments, PS_LIST_TAIL, "PSASTRO.FIX.CHIPS", PS_META_REPLACE, "", true);
    5555    }
     
    8585    }
    8686
     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
    8794    // dump the configuration to a file?
    8895    if ((N = psArgumentGet (argc, argv, "-dumpconfig"))) {
  • trunk/psastro/src/psastroAstromGuess.c

    r20796 r20805  
    142142                    psastroDumpRawstars (rawstars, fpa, chip);
    143143                }
     144
     145                psastroVisualPlotRawStars(rawstars, fpa, chip, recipe);
    144146
    145147                if (psTraceGetLevel("psastro.plot") > 0) {
     
    362364    psVector *cornerQd = (psVector *) psBinaryOp (NULL, cornerQn, "-", cornerQf);
    363365
     366    psastroVisualPlotAstromGuessCheck (cornerPo, cornerQo, cornerPn, cornerQn, cornerPd, cornerQd);
     367
    364368    psStats *statsP = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
    365369    psStats *statsQ = psStatsAlloc (PS_STAT_SAMPLE_MEAN | PS_STAT_SAMPLE_STDEV);
  • trunk/psastro/src/psastroCleanup.c

    r14641 r20805  
    1111    pmConceptsDone ();
    1212    pmConfigDone ();
     13    psastroVisualClose ();
     14    pmAstromVisualClose ();
    1315    fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, stdout, false), "psastro");
    1416    // fprintf (stderr, "found %d leaks at %s\n", psMemCheckLeaks (0, NULL, NULL, false), "psastro");
  • trunk/psastro/src/psastroFixChips.c

    r20795 r20805  
    190190    }
    191191
    192     psFree (xObs);
    193     psFree (yObs);
    194192    psFree (xRef);
    195193    psFree (yRef);
     
    321319    }
    322320
     321    psastroVisualPlotFixChips (input, xObs, yObs);
     322    psFree (xObs);
     323    psFree (yObs);
    323324    psFree (map);
    324325    psFree (view);
  • trunk/psastro/src/psastroLoadRefstars.c

    r20319 r20805  
    137137        psastroDumpRefstars (refstars, "refstars.dat");
    138138    }
     139
     140    psastroVisualPlotRefStars (refstars, recipe);
    139141
    140142    if (psTraceGetLevel("psastro.plot") > 0) {
  • trunk/psastro/src/psastroLuminosityFunction.c

    r20037 r20805  
    129129    lumFunc->sPeak = sPeak;
    130130
    131 #if 0
    132     psastroLuminosityFunctionPlot(lnMag, Mag, lumFunc, rawFunc);
    133 #endif
     131    psastroVisualPlotLuminosityFunction(lnMag, Mag, lumFunc, rawFunc);
    134132
    135133    psFree (lnMag);
  • trunk/psastro/src/psastroMosaicSetMatch.c

    r17108 r20805  
    1010
    1111    // use small radius to match stars (assume starting astrometry is good)
    12     bool status = false; 
     12    bool status = false;
    1313    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    }
    2020
    2121    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;
    3030    }
    3131
     
    3434        psTrace ("psastro", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
    3535        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) {
    3939            psTrace ("psastro", 4, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
    4040            if (!cell->process || !cell->file_exists) { continue; }
    4141
    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; }
     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; }
    4646
    47                 // select the raw objects for this readout
    48                 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; }
    5050
    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);
     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);
    5555
    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);
    5858
    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        }
    6466    }
    6567    psFree (view);
  • trunk/psastro/src/psastroOneChipFit.c

    r20794 r20805  
    156156    }
    157157
     158    psastroVisualPlotOneChipFit (rawstars, refstars, match, recipe);
     159
    158160    if (psTraceGetLevel("psastro.plot") > 0) {
    159161        psastroPlotOneChipFit (rawstars, refstars, match, recipe);
  • trunk/psastro/src/psastroRemoveClumps.c

    r17109 r20805  
    1111    float Ymax = obj->FP->y;
    1212    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);
    2020    }
    2121
     
    2727    // accumulate 2D histogram in image
    2828    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] ++;
    3535    }
    3636
     
    3838    psStats *stats = psStatsAlloc (PS_STAT_MAX | PS_STAT_MAX | PS_STAT_SAMPLE_MEDIAN | PS_STAT_SAMPLE_STDEV);
    3939    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;
    4444    }
    4545
    4646    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;
    5151    }
    5252
     
    5555    psTrace ("psastro", 4, "skipping stars in cells with more than %f stars\n", limit);
    5656
     57    psastroVisualPlotRemoveClumps (input, count, scale, limit);
     58
    5759    // find and exclude objects in bad pixels
    5860    psArray *output = psArrayAllocEmpty (input->n);
    5961    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);
    6769    }
    6870
     
    7779for (int iy = 0; iy < count->numRows; iy++) {
    7880    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        }
    8688    }
    8789}
Note: See TracChangeset for help on using the changeset viewer.