Changeset 26367
- Timestamp:
- Dec 8, 2009, 8:30:42 AM (16 years ago)
- Location:
- trunk/ppViz/src/ppVizPSF
- Files:
-
- 6 edited
-
ppVizPSF.c (modified) (1 diff)
-
ppVizPSF.h (modified) (1 diff)
-
ppVizPSFArguments.c (modified) (2 diffs)
-
ppVizPSFCamera.c (modified) (2 diffs)
-
ppVizPSFData.c (modified) (1 diff)
-
ppVizPSFLoop.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ppViz/src/ppVizPSF/ppVizPSF.c
r26352 r26367 11 11 int main(int argc, char *argv[]) 12 12 { 13 ppVizPSFVersionPrint(); 14 13 15 ppVizPSFData *data = ppVizPSFDataInit(&argc, argv); 14 16 if (!data) { -
trunk/ppViz/src/ppVizPSF/ppVizPSF.h
r26362 r26367 13 13 psString outRoot; // Output root name 14 14 float minFlux; // Minimum flux for sources 15 int size; // Size of PSF image 16 float x, y; // Position of fake source 15 17 pmConfig *config; // Configuration 16 18 } ppVizPSFData; -
trunk/ppViz/src/ppVizPSF/ppVizPSFArguments.c
r26366 r26367 50 50 psMetadataAddStr(arguments, PS_LIST_TAIL, "-psf", 0, "Filename of PSF", NULL); 51 51 psMetadataAddStr(arguments, PS_LIST_TAIL, "-sources", 0, "Filename of sources", NULL); 52 psMetadataAddF32(arguments, PS_LIST_TAIL, "-x", 0, "x position of fake source [0..1]", NAN); 53 psMetadataAddF32(arguments, PS_LIST_TAIL, "-y", 0, "y position of fake source [0..1]", NAN); 52 54 if (argc == 1 || !psArgumentParse(arguments, &argc, argv) || argc != 2) { 53 55 usage(argv[0], arguments, data); 54 56 } 55 57 58 bool mdok; // Status of MD lookup 56 59 data->psfName = psMemIncrRefCounter(psMetadataLookupStr(NULL, arguments, "-psf")); 57 data->sourcesName = psMemIncrRefCounter(psMetadataLookupStr( NULL, arguments, "-sources"));60 data->sourcesName = psMemIncrRefCounter(psMetadataLookupStr(&mdok, arguments, "-sources")); 58 61 data->outRoot = psStringCopy(argv[1]); 62 data->x = psMetadataLookupF32(NULL, arguments, "-x"); 63 data->y = psMetadataLookupF32(NULL, arguments, "-y"); 59 64 psMetadataAddStr(data->config->arguments, PS_LIST_TAIL, "OUTPUT", 0, "Output root name", data->outRoot); 60 65 … … 63 68 64 69 PS_ASSERT_STRING_NON_EMPTY(data->psfName, false); 65 PS_ASSERT_STRING_NON_EMPTY(data->sourcesName, false);66 70 PS_ASSERT_STRING_NON_EMPTY(data->outRoot, false); 67 71 -
trunk/ppViz/src/ppVizPSF/ppVizPSFCamera.c
r26364 r26367 39 39 } 40 40 41 fileArguments("SOURCES", data->sourcesName, "Input sources", data->config); 42 pmFPAfile *srcs = pmFPAfileBindFromArgs(&status, psf, data->config, 43 "PSPHOT.INPUT.CMF", "SOURCES"); // File 44 if (!status || !srcs) { 45 psError(PS_ERR_IO, false, "Failed to build file from PSPHOT.INPUT.CMF"); 46 return false; 41 if (data->sourcesName) { 42 fileArguments("SOURCES", data->sourcesName, "Input sources", data->config); 43 pmFPAfile *srcs = pmFPAfileBindFromArgs(&status, psf, data->config, 44 "PSPHOT.INPUT.CMF", "SOURCES"); // File 45 if (!status || !srcs) { 46 psError(PS_ERR_IO, false, "Failed to build file from PSPHOT.INPUT.CMF"); 47 return false; 48 } 47 49 } 48 50 … … 67 69 } 68 70 71 if (!data->sourcesName) { 72 data->size = psMetadataLookupS32(NULL, recipe, "SIZE"); // Size of PSF 73 if (data->size <= 0) { 74 psError(PS_ERR_BAD_PARAMETER_VALUE, true, "Unable to find legitimate value for SIZE"); 75 return false; 76 } 77 } 78 69 79 return true; 70 80 } -
trunk/ppViz/src/ppVizPSF/ppVizPSFData.c
r26355 r26367 31 31 data->config = NULL; 32 32 data->minFlux = NAN; 33 data->size = 0; 34 data->x = NAN; 35 data->y = NAN; 33 36 34 37 return data; -
trunk/ppViz/src/ppVizPSF/ppVizPSFLoop.c
r26363 r26367 13 13 ) 14 14 { 15 ppVizPSFVersionPrint();16 17 15 pmConfig *config = data->config; // Configuration data 18 16 pmFPAfile *psfFile = pmFPAfileSelectSingle(config->files, "PSPHOT.PSF.LOAD", 0); // File with PSF … … 47 45 } 48 46 49 if (cell->readouts->n != 1) { 47 if (cell->readouts->n == 0) { 48 pmReadout *ro = pmReadoutAlloc(cell); 49 ro->data_exists = true; 50 cell->data_exists = true; 51 chip->data_exists = true; 52 psFree(ro); // Drop reference 53 } 54 55 if (cell->readouts->n > 1) { 50 56 psWarning("More than one readout present for chip %d, cell %d", view->chip, view->cell); 51 57 } … … 61 67 } 62 68 63 psArray *sources = psMetadataLookupPtr(NULL, readout->analysis, "PSPHOT.SOURCES"); // Sources64 69 pmPSF *psf = psMetadataLookupPtr(NULL, chip->analysis, "PSPHOT.PSF"); // PSF 70 assert(psf); 65 71 66 int numCols = psf->fieldNx, numRows = psf->fieldNy; // Size of image 72 bool mdok; // Status of MD lookup 73 psArray *sources = psMetadataLookupPtr(&mdok, readout->analysis, "PSPHOT.SOURCES"); // Sources 74 int numCols = 0, numRows = 0; // Size of image 75 psVector *xOffset = NULL, *yOffset = NULL; // Offset from source to true position 76 if (sources) { 77 psMemIncrRefCounter(sources); 78 numCols = psf->fieldNx; 79 numRows = psf->fieldNy; 80 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image from %ld input sources", 81 numCols, numRows, sources->n); 82 } else { 83 sources = psArrayAlloc(1); 84 pmSource *source = pmSourceAlloc(); // Fake source 85 sources->data[0] = source; 86 float xRel = isfinite(data->x) ? data->x : 0.5; // Relative position in x 87 float yRel = isfinite(data->y) ? data->y : 0.5; // Relative position in y 88 float xSrc = xRel * psf->fieldNx, ySrc = yRel * psf->fieldNy; // Position of source 89 source->peak = pmPeakAlloc(xSrc, ySrc, 1.0, PM_PEAK_LONE); 90 pmModel *model = pmModelFromPSFforXY(psf, xSrc, ySrc, 1.0); // Model for normalisation 91 float flux = model->modelFlux(model->params); // Flux for peak=1 92 psFree(model); 93 source->psfMag = -2.5 * log10(flux); 94 xOffset = psVectorAlloc(1, PS_TYPE_S32); 95 yOffset = psVectorAlloc(1, PS_TYPE_S32); 96 xOffset->data.S32[0] = data->size - xSrc; 97 yOffset->data.S32[0] = data->size - ySrc; 98 numCols = 2 * data->size + 1; 99 numRows = 2 * data->size + 1; 100 psLogMsg("ppVizPSF", PS_LOG_INFO, "Generating %dx%d image with single PSF", 101 numCols, numRows); 102 } 103 67 104 if (numCols <= 0 || numRows <= 0) { 68 105 psError(PS_ERR_UNKNOWN, true, "Image size isn't set: %dx%d.", numCols, numRows); … … 70 107 } 71 108 72 if (!pmReadoutFakeFromSources(readout, numCols, numRows, sources, 0, NULL, NULL, psf,109 if (!pmReadoutFakeFromSources(readout, numCols, numRows, sources, 0, xOffset, yOffset, psf, 73 110 data->minFlux, 0, false, true)) { 74 111 psError(PS_ERR_UNKNOWN, false, "Unable to generate fake readout."); 75 112 return false; 76 113 } 114 115 psFree(sources); 116 psFree(xOffset); 117 psFree(yOffset); 77 118 78 119 pmHDU *hdu = pmHDUGetLowest(psfFile->fpa, chip, cell); // HDU for readout
Note:
See TracChangeset
for help on using the changeset viewer.
