Changeset 14531
- Timestamp:
- Aug 16, 2007, 8:52:31 AM (19 years ago)
- Location:
- trunk/ppSim/src
- Files:
-
- 2 added
- 6 edited
-
ppSimArguments.c (modified) (4 diffs)
-
ppSimCreate.c (modified) (1 diff)
-
ppSimInsertSource.c (added)
-
ppSimInsertSources.c (added)
-
ppSimLoadStars.c (modified) (2 diffs)
-
ppSimLoop.c (modified) (2 diffs)
-
ppSimMakeStars.c (modified) (1 diff)
-
ppSimUtils.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppSim/src/ppSimArguments.c
r14463 r14531 8 8 { 9 9 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); 11 11 fprintf(stderr, "\n"); 12 12 psArgumentHelp(arguments); … … 68 68 psMetadataAddS32(arguments, PS_LIST_TAIL, "-bin", 0, "Binning in x and y", 1); 69 69 70 pmConfigFileSetsMD (config->arguments, &argc, argv, "PSPHOT.PSF", "-psf", "-psflist"); 71 70 72 if (!config->camera) { 71 73 psErrorStackPrint(stderr, "A camera name must be specified using the -camera option."); 72 74 usage(argv[0], arguments, config); 73 75 } 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); } 78 80 79 81 psString formatName = psMetadataLookupStr(NULL, arguments, "-format"); // Name of format … … 113 115 type = PPSIM_TYPE_OBJECT; 114 116 } else { 115 psError (PS_ERR_BAD_PARAMETER_VALUE, true, "Unrecognised exposure type: %s", typeStr);117 psErrorStackPrint(stderr, "Unrecognised exposure type: %s", typeStr); 116 118 usage(argv[0], arguments, config); 117 119 } … … 179 181 180 182 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"); 183 184 usage(argv[0], arguments, config); 184 185 } -
trunk/ppSim/src/ppSimCreate.c
r14463 r14531 24 24 } 25 25 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 } 26 36 27 37 pmFPALevel phuLevel = pmFPAPHULevel(file->format); // Level at which PHU goes -
trunk/ppSim/src/ppSimLoadStars.c
r14463 r14531 22 22 float radius = 0.5 * PS_MAX(bounds->x1 - bounds->x0, bounds->y1 - bounds->y0) * scale; 23 23 psFree(bounds); 24 25 float x0fpa = 0.5*(bounds->x0 + bounds->x1); 26 float y0fpa = 0.5*(bounds->y0 + bounds->y1); 24 27 25 28 psMetadataAdd(astroRecipe, PS_LIST_TAIL, "RA_MIN", PS_DATA_F32 | PS_META_REPLACE, "", ra0 - radius); … … 47 50 48 51 // 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; 50 53 float xi = cos(star->dec) * sin(star->ra - ra0) / div; 51 54 float eta = (sin(star->dec) * cos(dec0) - cos(star->dec) * sin(dec0) * cos(star->ra - ra0)) / div; 52 55 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; 56 59 57 60 // Convert magnitude to peak flux -
trunk/ppSim/src/ppSimLoop.c
r14463 r14531 23 23 24 24 // Add random stars 25 // XXX put this in a wrapper (add to array of stars)26 25 if (type == PPSIM_TYPE_OBJECT) { 27 26 ppSimMakeStars (stars, fpa, config, rng); … … 30 29 pmFPAview *view = pmFPAviewAlloc(0);// View for iterating over FPA 31 30 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 32 38 ppSimUpdateConceptsFPA (fpa, config); 33 39 34 40 pmChip *chip; // Chip from FPA 35 41 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 } 36 54 37 55 pmCell *cell; // Cell from chip -
trunk/ppSim/src/ppSimMakeStars.c
r14463 r14531 63 63 ppSimStar *star = ppSimStarAlloc (); 64 64 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 67 68 star->peak = expf((logf(i + 1) - logf(norm)) / starsLum); // Peak flux 69 star->flux = star->peak * sqrt(2.0*M_PI)*seeing; 68 70 stars->data[oldSize + i] = star; 69 71 } 72 stars->n = stars->nalloc; 70 73 } 71 74 return true; -
trunk/ppSim/src/ppSimUtils.c
r14463 r14531 2 2 3 3 // Generate a header containing WCS keywords 4 // this function is called with only one of fpa, chip, cell not NULL 4 5 bool ppSimInitHeader(pmConfig *config, 5 6 pmFPA *fpa, … … 11 12 float dec0 = psMetadataLookupF32(NULL, config->arguments, "DEC"); // Boresight Dec (radians) 12 13 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 25 16 26 17 int binning = psMetadataLookupS32(NULL, config->arguments, "BINNING"); // Binning in x and y … … 29 20 int xParity, yParity; 30 21 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 31 32 x0 = PPSIM_FPA_TO_CELL(0.0, x0Cell, xParityCell, binning, x0Chip, xParityChip); 32 33 y0 = PPSIM_FPA_TO_CELL(0.0, y0Cell, yParityCell, binning, y0Chip, yParityChip); … … 35 36 } 36 37 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 37 43 x0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, x0Chip, xParityChip); 38 44 y0 = PPSIM_FPA_TO_CELL(0.0, 0, 1, binning, y0Chip, yParityChip);
Note:
See TracChangeset
for help on using the changeset viewer.
