IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Nov 8, 2011, 2:44:12 PM (15 years ago)
Author:
eugene
Message:

merge changes from trunk

Location:
branches/eam_branches/ipp-20110906
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-20110906

  • branches/eam_branches/ipp-20110906/psvideophot

  • branches/eam_branches/ipp-20110906/psvideophot/src/psvideoLoop.c

    r31813 r32630  
    4444    }
    4545
     46    psString class_id = psMetadataLookupStr(&status, config->arguments, "CLASS_ID");
     47    psString cell_id = psMetadataLookupStr(&status, config->arguments, "CELL_ID");
     48
    4649
    4750    pmConfigCamerasCull(config, NULL);
     
    5659    }
    5760
     61    psArray *output = NULL;
     62
    5863    pmChip *chip;                       // Chip from FPA
    5964    while ((chip = pmFPAviewNextChip(view, input->fpa, 1)) != NULL) {
    6065        psLogMsg ("psvideophotLoop", 4, "Chip %d: %x %x\n", view->chip, chip->file_exists, chip->process);
     66        psString chipName = psMetadataLookupStr(&status, chip->concepts, "CHIP.NAME");
     67        if (strcmp(chipName, class_id)) {
     68            continue;
     69        }
    6170        if (!chip->process || !chip->file_exists) {
    62             continue;
     71            ESCAPE("target chip has no data");
    6372        }
    6473        if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    6574            ESCAPE("load failure for Chip");
    6675        }
     76        (void) class_id;
    6777
    6878        double threshold = THRESHOLD;
     
    7282        while ((cell = pmFPAviewNextCell(view, input->fpa, 1)) != NULL) {
    7383            psLogMsg ("psvideophotLoop", 5, "Cell %d: %x %x\n", view->cell, cell->file_exists, cell->process);
     84            psString cellName = psMetadataLookupStr(&status, cell->concepts, "CELL.NAME");
     85            if (strcmp(cellName, cell_id)) {
     86                continue;
     87            }
    7488            if (!cell->process || !cell->file_exists) {
    75                 continue;
     89                ESCAPE("target cell has no data");
    7690            }
    7791            if (!pmFPAfileIOChecks(config, view, PM_FPA_BEFORE)) {
    7892                ESCAPE("load failure for Cell");
    7993            }
     94
     95            psLogMsg("psvideophotLoop", 1, "Found target cell %s %d. %ld readouts\n", cellName, view->cell, cell->readouts->n);
    8096
    8197            // Put version information into the header
     
    87103
    88104            if (cell->readouts->n <2) {
    89               continue;
     105              psLogMsg("psvideophotLoop", 1, "cell %s has only %ld readouts\n", cellName, cell->readouts->n);
     106              ESCAPE("invalid video Cell");
    90107            }
    91 
    92             psString cellName = psMetadataLookupStr(&status, cell->concepts, "CELL.NAME");
    93             psLogMsg("psvideophotLoop", 1, "Found video cell %s %d\n", cellName, view->cell);
    94108
    95109            // get the position of this cell on the chip
     
    114128
    115129            // go find the video extension data
    116             psString video_extension_name = NULL;
    117             psStringAppend(&video_extension_name, "video_table_%s", cellName);
     130            psString video_extension_name = psMetadataLookupStr(&status, config->arguments, "VIDEOEXTNAME");
     131            if (!video_extension_name) {
     132                psStringAppend(&video_extension_name, "video_table_%s", cellName);
     133            }
    118134            psArray *video_table = readVideoTable(input, video_extension_name);
    119135            if (!video_table) {
     
    121137                ESCAPE("invalid image file");
    122138            }
    123             psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table);
     139            psFree(video_extension_name);
     140            // psMetadataAddArray(cell->analysis, PS_LIST_TAIL, "VIDEO_DATA", 0, "", video_table);
     141
     142            output = (psArray *) psMemIncrRefCounter(video_table);
    124143
    125144            if (cell->readouts->n != video_table->n) {
     
    180199                double cnpix2 = psMetadataLookupS32(&status, row, "cnpix2");
    181200
     201                // avoid errors from unused variables
    182202                (void) frame_start; (void) frame_complete;
    183203                (void) rowpre; (void) cnpix1; (void) cnpix2; (void) fwhm_x; (void) fwhm_y; (void) fwhm;
     
    191211                double star_readout_y = (centroid_y - cnpix2) / yBin;
    192212
     213#ifdef notdef
    193214                printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.6f %6.3f %6.3f %6.3f\n",
    194215                        frame, flux, snr, sky, star_readout_x, star_readout_y, frame_complete - frame_start,
    195216                            fwhm, fwhm_x, fwhm_y);
    196 
     217#endif
    197218                psStatsInit(stats);
    198219
     
    206227                double stddev = stats->sampleStdev;
    207228                double median = stats->sampleMedian;
     229                double vpFlux = 0;
     230                double vpSum = 0;
     231                double xy[2] = {0, 0};
    208232                if (stddev > threshold) {
    209233
    210                     double sum = 0;
    211                     // XXX: use a point data type
    212                     double xy[2];
    213                     Centering(readout->image, EDGE, &sum, xy, median);
    214                     double ourFlux;
    215                     ourFlux = SubSum(readout->image, xy, median);
    216 
    217                     printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.2f\n",
    218                              frame, ourFlux, ourFlux/stddev, median, xy[0], xy[1], stddev);
     234                    Centering(readout->image, EDGE, &vpSum, xy, median);
     235
     236                    vpFlux = SubSum(readout->image, xy, median);
     237
     238//                    printf("%4d %9.2f %9.2f %9.2f %.1f %.1f %9.2f\n",
     239//                             frame, vpFlux, vpFlux/median, median, xy[0], xy[1], stddev);
    219240                } else {
    220                     printf("%4d %9.2f %9.2f %8.2f\n",
    221                             frame, 0.0,   stddev, median);
    222                 }
     241//                    printf("%4d %9.2f %9.2f %8.2f\n",
     242//                            frame, 0.0,   stddev, median);
     243                }
     244                if (frame % 60 == 0) {
     245                    printf("frame  flux        sky       snr     X    Y     dt        fwhm   fwhm_x fwhm_y  vp_flux   vp_median vp_sum    vp_stddev vp_x vp_y\n");
     246                }
     247                printf("%4d   %9.2f %9.2f %9.2f %.1f %.1f %9.6f %6.3f %6.3f %6.3f   %9.2f %9.2f %9.2f %9.2f %.1f %.1f\n",
     248                        frame, flux, sky, snr, star_readout_x, star_readout_y, frame_complete - frame_start,
     249                            fwhm, fwhm_x, fwhm_y,
     250                            vpFlux, median, vpSum, stddev, xy[0], xy[1]);
     251                psMetadataAddF32(row, PS_LIST_TAIL, "vp_flux", 0, "vp flux", vpFlux);
     252                psMetadataAddF32(row, PS_LIST_TAIL, "vp_median", 0, "vp meidan", median);
     253                psMetadataAddF32(row, PS_LIST_TAIL, "vp_stddev", 0, "vp meidan", stddev);
     254                psMetadataAddF32(row, PS_LIST_TAIL, "vp_sum", 0, "vp sum of source", vpSum);
     255                psMetadataAddF32(row, PS_LIST_TAIL, "vp_x", 0, "centroid x from vp", xy[0]);
     256                psMetadataAddF32(row, PS_LIST_TAIL, "vp_y", 0, "centroid y from vp", xy[1]);
    223257            }
    224258            psLogMsg ("psvideophotLoop", 5, "Done processing video cell");
     
    247281    psFree(view);
    248282
    249     // Dump configuration
    250     psString dump_file = psMetadataLookupStr(&status, config->arguments, "DUMP_CONFIG");
    251     if (dump_file) {
    252         if (!pmConfigDump(config, dump_file)) {
    253             ESCAPE("Unable to dump configuration.");
    254         }
    255     }
     283    psString outputName = psMetadataLookupStr(&status, config->arguments, "OUTPUT");
     284    psString realName = pmConfigConvertFilename(outputName, config, true, true);
     285    if (!realName) {
     286        psError(PS_ERR_UNKNOWN, false, "failed to convert filename for %s", outputName);
     287        ESCAPE("cannot save output");
     288    }
     289    psFits *outFits = psFitsOpen(realName, "w");
     290    if (!outFits) {
     291        psError(PS_ERR_UNKNOWN, false, "failed to open output filename for %s", outputName);
     292        ESCAPE(" ");
     293    }
     294
     295    psMetadata *outputHeader = lastHDU ? lastHDU->header : NULL;
     296    if (!psFitsWriteTable(outFits, outputHeader, output, "videophotemetry")) {
     297        psError(PS_ERR_UNKNOWN, false, "failed to write videophotometry table");
     298        ESCAPE("cannot write output");
     299    }
     300    psFitsClose(outFits);
    256301
    257302    return true;
Note: See TracChangeset for help on using the changeset viewer.