IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 14531


Ignore:
Timestamp:
Aug 16, 2007, 8:52:31 AM (19 years ago)
Author:
eugene
Message:

adding input psf

Location:
trunk/ppSim/src
Files:
2 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/ppSim/src/ppSimArguments.c

    r14463 r14531  
    88{
    99    fprintf(stderr, "\nPan-STARRS data simulator\n\n");
    10     fprintf(stderr, "Usage: %s -camera CAMERA_NAME\n", program);
     10    fprintf(stderr, "Usage: %s -camera CAMERA_NAME (output)\n", program);
    1111    fprintf(stderr, "\n");
    1212    psArgumentHelp(arguments);
     
    6868    psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1);
    6969
     70    pmConfigFileSetsMD (config->arguments, &argc, argv, "PSPHOT.PSF", "-psf", "-psflist");
     71
    7072    if (!config->camera) {
    7173        psErrorStackPrint(stderr, "A camera name must be specified using the -camera option.");
    7274        usage(argv[0], arguments, config);
    7375    }
    74 
    75     if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) {
    76         usage(argv[0], arguments, config);
    77     }
     76 
     77    if (!psArgumentParse(arguments, &argc, argv)) { usage (argv[0], arguments, config); }
     78
     79    if (argc != 2) { usage(argv[0], arguments, config); }
    7880
    7981    psString formatName = psMetadataLookupStr(NULL, arguments, "-format"); // Name of format
     
    113115        type = PPSIM_TYPE_OBJECT;
    114116    } else {
    115         psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised exposure type: %s", typeStr);
     117        psErrorStackPrint(stderr, "Unrecognised exposure type: %s", typeStr);
    116118        usage(argv[0], arguments, config);
    117119    }
     
    179181
    180182        if (isnan(ra0) || isnan(dec0) || isnan(pa) || isnan(scale) || isnan(zp) || isnan(seeing)) {
    181             psError(PS_ERR_BAD_PARAMETER_VALUE, false,
    182                     "-ra, -dec, -pa, -scale, -zp, -seeing must be specified for OBJECT type");
     183            psErrorStackPrint(stderr, "-ra, -dec, -pa, -scale, -zp, -seeing must be specified for OBJECT type");
    183184            usage(argv[0], arguments, config);
    184185        }
  • trunk/ppSim/src/ppSimCreate.c

    r14463 r14531  
    2424    }
    2525    file->save = true;
     26
     27    // have we supplied a psf model?
     28    if (psMetadataLookupPtr(NULL, config->arguments, "PSPHOT.PSF")) {
     29        bool status = false;
     30        pmFPAfileBindFromArgs(&status, file, config, "PSPHOT.PSF.LOAD", "PSPHOT.PSF");
     31        if (!status) {
     32            psError(PS_ERR_UNKNOWN, false, "Failed to find/build PSPHOT.PSF.LOAD");
     33            return status;
     34        }
     35    }
    2636
    2737    pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level at which PHU goes
  • trunk/ppSim/src/ppSimLoadStars.c

    r14463 r14531  
    2222    float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale;
    2323    psFree(bounds);
     24
     25    float x0fpa = 0.5*(bounds->x0 + bounds->x1);
     26    float y0fpa = 0.5*(bounds->y0 + bounds->y1);
    2427
    2528    psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN",  PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius);
     
    4750
    4851        // Convert to x,y position on tangent plane, in pixels
    49         float div = sin(star->ra) * sin(dec0) + cos(star->dec) * cos(dec0) * cos(star->ra - ra0) / scale;
     52        float div = (sin(star->ra) * sin(dec0) + cos(star->dec) * cos(dec0) * cos(star->ra - ra0)) * scale;
    5053        float xi = cos(star->dec) * sin(star->ra - ra0) / div;
    5154        float eta = (sin(star->dec) * cos(dec0) - cos(star->dec) * sin(dec0) * cos(star->ra - ra0)) / div;
    5255
    53         // Apply rotation
    54         star->x = cos(pa) * xi - sin(pa) * eta;
    55         star->y = sin(pa) * xi + cos(pa) * eta;
     56        // Apply rotation, make FPA center of boresite
     57        star->x = cos(pa) * xi - sin(pa) * eta + x0fpa;
     58        star->y = sin(pa) * xi + cos(pa) * eta + y0fpa;
    5659
    5760        // Convert magnitude to peak flux
  • trunk/ppSim/src/ppSimLoop.c

    r14463 r14531  
    2323
    2424    // Add random stars
    25     // XXX put this in a wrapper (add to array of stars)
    2625    if (type == PPSIM_TYPE_OBJECT) {
    2726        ppSimMakeStars (stars, fpa, config, rng);
     
    3029    pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA
    3130
     31    // load any needed files (eg, input image, PSF)
     32    if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     33        psError(PSPHOT_ERR_DATA, false, "failed IO for fpa in ppSim\n");
     34        psFree(view);
     35        return false;
     36    }
     37
    3238    ppSimUpdateConceptsFPA (fpa, config);
    3339
    3440    pmChip *chip;                       // Chip from FPA
    3541    while ((chip = pmFPAviewNextChip(view, fpa, 1))) {
     42
     43        // load any needed files (eg, input image, PSF)
     44        if (!pmFPAfileIOChecks (config, view, PM_FPA_BEFORE)) {
     45            psError(PSPHOT_ERR_DATA, false, "failed IO for chip %d in ppSim\n", view->chip);
     46            psFree (view);
     47            return false;
     48        }
     49
     50        pmPSF *psf = NULL;
     51        if (type == PPSIM_TYPE_OBJECT) {
     52            psf = ppSimSetPSF (config);
     53        }
    3654
    3755        pmCell *cell;                   // Cell from chip
  • trunk/ppSim/src/ppSimMakeStars.c

    r14463 r14531  
    6363            ppSimStar *star = ppSimStarAlloc ();
    6464
    65             star->x    = (psRandomUniform(rng) - 0.5) * xSize ; // x position
    66             star->y    = (psRandomUniform(rng) - 0.5) * ySize; // y position
     65            // make fpa center of distribution
     66            star->x    = psRandomUniform(rng) * xSize; // x position
     67            star->y    = psRandomUniform(rng) * ySize; // y position
    6768            star->peak = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux
     69            star->flux = star->peak * sqrt(2.0*M_PI)*seeing;
    6870            stars->data[oldSize + i] = star;
    6971        }
     72        stars->n = stars->nalloc;
    7073    }
    7174    return true;
  • trunk/ppSim/src/ppSimUtils.c

    r14463 r14531  
    22
    33// Generate a header containing WCS keywords
     4// this function is called with only one of fpa, chip, cell not NULL
    45bool ppSimInitHeader(pmConfig *config,
    56                     pmFPA *fpa,
     
    1112    float dec0 = psMetadataLookupF32(NULL, config->arguments, "DEC"); // Boresight Dec (radians)
    1213    float pa = psMetadataLookupF32(NULL, config->arguments, "PA"); // Position angle (radians)
    13     float scale = psMetadataLookupF32(NULL, config->arguments, "SCALE") *
    14         M_PI / 3600.0 / 180.0; // Plate scale (radians/pixel)
    15 
    16     int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
    17     int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
    18     int xParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY");
    19     int yParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY");
    20 
    21     int x0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
    22     int y0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
    23     int xParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
    24     int yParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
     14    float scale = psMetadataLookupF32(NULL, config->arguments, "SCALE"); // plate scale in arcsec / pixel
     15    scale *= M_PI / 3600.0 / 180.0; // convert plate scale to radians/pixel
    2516
    2617    int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y
     
    2920    int xParity, yParity;
    3021    if (cell) {
     22        int x0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.X0");
     23        int y0Chip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.Y0");
     24        int xParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.XPARITY");
     25        int yParityChip = psMetadataLookupS32(NULL, cell->parent->concepts, "CHIP.YPARITY");
     26
     27        int x0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.X0");
     28        int y0Cell = psMetadataLookupS32(NULL, cell->concepts, "CELL.Y0");
     29        int xParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.XPARITY");
     30        int yParityCell = psMetadataLookupS32(NULL, cell->concepts, "CELL.YPARITY");
     31
    3132        x0 = PPSIM_FPA_TO_CELL(0.0, x0Cell, xParityCell, binning, x0Chip, xParityChip);
    3233        y0 = PPSIM_FPA_TO_CELL(0.0, y0Cell, yParityCell, binning, y0Chip, yParityChip);
     
    3536    }
    3637    if (chip) {
     38        int x0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.X0");
     39        int y0Chip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.Y0");
     40        int xParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.XPARITY");
     41        int yParityChip = psMetadataLookupS32(NULL, chip->concepts, "CHIP.YPARITY");
     42
    3743        x0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, x0Chip, xParityChip);
    3844        y0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, y0Chip, yParityChip);
Note: See TracChangeset for help on using the changeset viewer.