Changeset 13032
- Timestamp:
- Apr 25, 2007, 12:55:21 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_02_branch/psModules/src/objects/pmPSF_IO.c
r12943 r13032 6 6 * @author EAM, IfA 7 7 * 8 * @version $Revision: 1.13.2. 2$ $Name: not supported by cvs2svn $9 * @date $Date: 2007-04-2 1 00:03:31 $8 * @version $Revision: 1.13.2.3 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2007-04-25 22:55:21 $ 10 10 * 11 11 * Copyright 2004 Maui High Performance Computing Center, University of Hawaii … … 44 44 #include "pmSourceIO.h" 45 45 46 bool pmFPAviewWritePSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 47 { 48 49 pmFPA *fpa = file->fpa; 50 51 if (view->chip == -1) { 52 if (!pmFPAWritePSFmodel (fpa, view, file, config)) { 53 psError(PS_ERR_IO, false, "Failed to write PSF for fpa"); 54 return false; 55 } 56 return true; 57 } 58 59 if (view->chip >= fpa->chips->n) { 60 return false; 61 } 62 pmChip *chip = fpa->chips->data[view->chip]; 63 64 if (view->cell == -1) { 65 if (!pmChipWritePSFmodel (chip, view, file, config)) { 66 psError(PS_ERR_IO, false, "Failed to write PSF for chip"); 67 return false; 68 } 69 return true; 70 } 71 72 if (view->cell >= chip->cells->n) { 73 return false; 74 } 75 pmCell *cell = chip->cells->data[view->cell]; 76 77 if (view->readout == -1) { 78 if (!pmCellWritePSFmodel (cell, view, file, config)) { 79 psError(PS_ERR_IO, false, "Failed to write PSF for cell"); 80 return false; 81 } 82 return true; 83 } 84 85 if (view->readout >= cell->readouts->n) { 86 return false; 87 } 88 pmReadout *readout = cell->readouts->data[view->readout]; 89 90 if (!pmReadoutWritePSFmodel (readout, view, file, config)) { 91 psError(PS_ERR_IO, false, "Failed to write PSF for readout"); 92 return false; 93 } 94 return true; 95 } 96 97 // read in all chip-level PSFmodel files for this FPA 98 bool pmFPAWritePSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 99 { 100 101 for (int i = 0; i < fpa->chips->n; i++) { 102 103 pmChip *chip = fpa->chips->data[i]; 104 if (!pmChipWritePSFmodel (chip, view, file, config)) { 105 psError(PS_ERR_IO, false, "Failed to write PSF for %dth chip", i); 106 return false; 107 } 108 } 109 return true; 110 } 111 112 // read in all cell-level PSFmodel files for this chip 113 bool pmChipWritePSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 114 { 115 116 for (int i = 0; i < chip->cells->n; i++) { 117 118 pmCell *cell = chip->cells->data[i]; 119 if (!pmCellWritePSFmodel (cell, view, file, config)) { 120 psError(PS_ERR_IO, false, "Failed to write PSF for %dth cell", i); 121 return false; 122 } 123 } 124 return true; 125 } 126 127 // read in all readout-level PSFmodel files for this cell 128 bool pmCellWritePSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 129 { 130 131 for (int i = 0; i < cell->readouts->n; i++) { 132 133 pmReadout *readout = cell->readouts->data[i]; 134 if (!pmReadoutWritePSFmodel (readout, view, file, config)) { 135 psError(PS_ERR_IO, false, "Failed to write PSF for %dth readout", i); 136 return false; 137 } 138 } 139 return true; 140 } 141 142 // for each Readout (ie, analysed image), we write out: header + table with PSF model parameters, 143 // and header + image for the PSF residual images 144 bool pmReadoutWritePSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 145 { 146 bool status; 147 148 // select the psf of interest 149 pmPSF *psf = psMetadataLookupPtr (&status, readout->analysis, "PSPHOT.PSF"); 150 if (!psf) { 151 psError(PS_ERR_UNKNOWN, true, "missing PSF for this readout"); 152 return false; 153 } 154 155 // lookup the EXTNAME values used for table data and residual image segments 156 char *rule = NULL; 157 158 // Menu of EXTNAME rules 159 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 160 if (!menu) { 161 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 162 return false; 163 } 164 // EXTNAME for table data 165 rule = psMetadataLookupStr(&status, menu, "PSF.TABLE"); 166 if (!rule) { 167 psError(PS_ERR_UNKNOWN, true, "missing entry for PSF.TABLE in EXTNAME.RULES in camera.config"); 168 return false; 169 } 170 char *tableName = pmFPAfileNameFromRule (rule, file, view); 171 172 // write the PSF model parameters in a FITS table 173 174 // we need to write a header for the table, 175 psMetadata *header = psMetadataAlloc(); 176 177 char *modelName = pmModelGetType (psf->type); 178 psMetadataAddStr (header, PS_LIST_TAIL, "PSF_NAME", 0, "PSF model name", modelName); 179 180 psMetadataAddBool (header, PS_LIST_TAIL, "POISSON", 0, "Use Poisson errors in fits?", psf->poissonErrors); 181 182 int nPar = pmModelParameterCount (psf->type) ; 183 psMetadataAdd (header, PS_LIST_TAIL, "PSF_NPAR", PS_DATA_S32, "PSF model parameter count", nPar); 184 185 // save the dimensions of each parameter 186 for (int i = 0; i < nPar; i++) { 187 char name[9]; 188 psPolynomial2D *poly = psf->params_NEW->data[i]; 189 if (poly == NULL) continue; 190 snprintf (name, 9, "PAR%02d_NX", i); 191 psMetadataAddS32 (header, PS_LIST_TAIL, name, 0, "", poly->nX); 192 snprintf (name, 9, "PAR%02d_NY", i); 193 psMetadataAddS32 (header, PS_LIST_TAIL, name, 0, "", poly->nY); 194 } 195 196 // other required information describing the PSF 197 psMetadataAddF32 (header, PS_LIST_TAIL, "AP_RESID", 0, "aperture residual", psf->ApResid); 198 psMetadataAddF32 (header, PS_LIST_TAIL, "AP_ERROR", 0, "aperture residual scatter", psf->dApResid); 199 psMetadataAddF32 (header, PS_LIST_TAIL, "CHISQ", 0, "chi-square for fit", psf->chisq); 200 psMetadataAddS32 (header, PS_LIST_TAIL, "NSTARS", 0, "number of stars used to measure PSF", psf->nPSFstars); 201 202 // XXX can we drop this now? 203 psMetadataAddF32 (header, PS_LIST_TAIL, "SKY_BIAS", PS_DATA_F32, "sky bias level", psf->skyBias); 204 205 // build a FITS table of the PSF parameters 206 psArray *psfTable = psArrayAllocEmpty (100); 207 for (int i = 0; i < nPar; i++) { 208 psPolynomial2D *poly = psf->params_NEW->data[i]; 209 if (poly == NULL) continue; // skip unset parameters (eg, XPOS) 210 for (int ix = 0; ix < poly->nX; ix++) { 211 for (int iy = 0; iy < poly->nY; iy++) { 212 213 psMetadata *row = psMetadataAlloc (); 214 psMetadataAddS32 (row, PS_LIST_TAIL, "MODEL_TERM", 0, "", i); 215 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 216 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 217 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", poly->coeff[ix][iy]); 218 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", poly->coeffErr[ix][iy]); 219 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", poly->mask[ix][iy]); 220 221 psArrayAdd (psfTable, 100, row); 222 psFree (row); 223 } 224 } 225 } 226 227 // write an empty FITS segment if we have no PSF information 228 if (psfTable->n == 0) { 229 // XXX this is probably an error (if we have a PSF, how do we have no data?) 230 psFitsWriteBlank (file->fits, header, tableName); 231 } else { 232 psTrace ("pmFPAfile", 5, "writing psf data %s\n", tableName); 233 if (!psFitsWriteTable (file->fits, header, psfTable, tableName)) { 234 psError(PS_ERR_IO, false, "writing psf table data %s\n", tableName); 235 psFree (tableName); 236 psFree (psfTable); 237 psFree (header); 238 return false; 239 } 240 } 241 psFree (tableName); 242 psFree (psfTable); 243 psFree (header); 244 245 // EXTNAME for residual images 246 rule = psMetadataLookupStr(&status, menu, "PSF.RESID"); 247 if (!rule) { 248 psError(PS_ERR_UNKNOWN, true, "missing entry for PSF.RESID in EXTNAME.RULES in camera.config"); 249 return false; 250 } 251 char *imageName = pmFPAfileNameFromRule (rule, file, view); 252 253 // write the residual images (3D) 254 header = psMetadataAlloc (); 255 if (psf->residuals == NULL) { 256 // set some header keywords to make it clear there are no residuals? 257 psFitsWriteBlank (file->fits, header, imageName); 258 psFree (imageName); 259 psFree (header); 260 return true; 261 } 262 263 psMetadataAddS32 (header, PS_LIST_TAIL, "XBIN", 0, "", psf->residuals->xBin); 264 psMetadataAddS32 (header, PS_LIST_TAIL, "YBIN", 0, "", psf->residuals->yBin); 265 psMetadataAddS32 (header, PS_LIST_TAIL, "XCENTER", 0, "", psf->residuals->xCenter); 266 psMetadataAddS32 (header, PS_LIST_TAIL, "YCENTER", 0, "", psf->residuals->yCenter); 267 268 // write the residuals as three planes of the image 269 // this call creates an extension with NAXIS3 = 3 270 if (psf->residuals->Rx) { 271 // this call creates an extension with NAXIS3 = 3 272 psArray *images = psArrayAllocEmpty (3); 273 psArrayAdd (images, 1, psf->residuals->Ro); 274 psArrayAdd (images, 1, psf->residuals->Rx); 275 psArrayAdd (images, 1, psf->residuals->Ry); 276 277 psFitsWriteImageCube (file->fits, header, images, imageName); 278 279 // psFitsWriteImage(file->fits, header, psf->residuals->Ro, 3, imageName); 280 // psFitsUpdateImage(file->fits, psf->residuals->Rx, 0, 0, 1); 281 // psFitsUpdateImage(file->fits, psf->residuals->Ry, 0, 0, 2); 282 } else { 283 // this call creates an extension with NAXIS3 = 1 284 psFitsWriteImage(file->fits, header, psf->residuals->Ro, 0, imageName); 285 } 286 287 psFree (imageName); 288 psFree (header); 289 return true; 290 291 // XXX save the growth curve 292 // XXX save the ApResid fit 293 294 # if (0) 295 // build a FITS table of the fit to the Aperture Residuals 296 psArray *apresTable = psArrayAllocEmpty (100); 297 psPolynomial4D *poly = psf->ApTrend; 298 for (int ix = 0; ix < poly->nX; ix++) { 299 for (int iy = 0; iy < poly->nY; iy++) { 300 301 row = psMetadataAlloc (); 302 psMetadataAddS32 (row, PS_LIST_TAIL, "X_POWER", 0, "", ix); 303 psMetadataAddS32 (row, PS_LIST_TAIL, "Y_POWER", 0, "", iy); 304 psMetadataAddF32 (row, PS_LIST_TAIL, "VALUE", 0, "", poly->coeff[ix][iy]); 305 psMetadataAddF32 (row, PS_LIST_TAIL, "ERROR", 0, "", poly->coeffErr[ix][iy]); 306 psMetadataAddU8 (row, PS_LIST_TAIL, "MASK", 0, "", poly->mask[ix][iy]); 307 308 psArrayAdd (psfTable, 100, row); 309 psFree (row); 310 } 311 } 312 # endif 313 } 314 315 // XXX add in error handling 316 bool pmFPAviewReadPSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 317 { 318 319 pmFPA *fpa = file->fpa; 320 321 if (view->chip == -1) { 322 pmFPAReadPSFmodel (fpa, view, file, config); 323 return true; 324 } 325 326 if (view->chip >= fpa->chips->n) { 327 return false; 328 } 329 pmChip *chip = fpa->chips->data[view->chip]; 330 331 if (view->cell == -1) { 332 pmChipReadPSFmodel (chip, view, file, config); 333 return true; 334 } 335 336 if (view->cell >= chip->cells->n) { 337 return false; 338 } 339 pmCell *cell = chip->cells->data[view->cell]; 340 341 if (view->readout == -1) { 342 pmCellReadPSFmodel (cell, view, file, config); 343 return true; 344 } 345 346 if (view->readout >= cell->readouts->n) { 347 return false; 348 } 349 pmReadout *readout = cell->readouts->data[view->readout]; 350 351 pmReadoutReadPSFmodel (readout, view, file, config); 352 return true; 353 } 354 355 // read in all chip-level PSFmodel files for this FPA 356 bool pmFPAReadPSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 357 { 358 359 for (int i = 0; i < fpa->chips->n; i++) { 360 361 pmChip *chip = fpa->chips->data[i]; 362 pmChipReadPSFmodel (chip, view, file, config); 363 } 364 return true; 365 } 366 367 // read in all cell-level PSFmodel files for this chip 368 bool pmChipReadPSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 369 { 370 371 for (int i = 0; i < chip->cells->n; i++) { 372 373 pmCell *cell = chip->cells->data[i]; 374 pmCellReadPSFmodel (cell, view, file, config); 375 } 376 return true; 377 } 378 379 // read in all readout-level PSFmodel files for this cell 380 bool pmCellReadPSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 381 { 382 383 for (int i = 0; i < cell->readouts->n; i++) { 384 385 pmReadout *readout = cell->readouts->data[i]; 386 pmReadoutReadPSFmodel (readout, view, file, config); 387 } 388 return true; 389 } 390 391 // for each Readout (ie, analysed image), we write out: header + table with PSF model parameters, 392 // and header + image for the PSF residual images 393 bool pmReadoutReadPSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 394 { 395 bool status; 396 char *rule = NULL; 397 psMetadata *header = NULL; 398 399 // Menu of EXTNAME rules 400 psMetadata *menu = psMetadataLookupMetadata(&status, file->camera, "EXTNAME.RULES"); 401 if (!menu) { 402 psError(PS_ERR_UNKNOWN, true, "missing EXTNAME.RULES in camera.config"); 403 return false; 404 } 405 // EXTNAME for table data 406 rule = psMetadataLookupStr(&status, menu, "PSF.TABLE"); 407 if (!rule) { 408 psError(PS_ERR_UNKNOWN, true, "missing entry for PSF.TABLE in EXTNAME.RULES in camera.config"); 409 return false; 410 } 411 char *tableName = pmFPAfileNameFromRule (rule, file, view); 412 // EXTNAME for residual images 413 rule = psMetadataLookupStr(&status, menu, "PSF.RESID"); 414 if (!rule) { 415 psError(PS_ERR_UNKNOWN, true, "missing entry for PSF.RESID in EXTNAME.RULES in camera.config"); 416 return false; 417 } 418 char *imageName = pmFPAfileNameFromRule (rule, file, view); 419 420 // move fits pointer to table and read header 421 // advance to the table data extension 422 // since we have read the IMAGE header, the TABLE header should exist 423 if (!psFitsMoveExtName (file->fits, tableName)) { 424 psAbort("cannot find data extension %s in %s", tableName, file->filename); 425 } 426 427 // load the PSF model table header 428 header = psFitsReadHeader (NULL, file->fits); 429 if (!header) psAbort("cannot read table header"); 430 431 // load the PSF model parameters from the FITS table 432 char *modelName = psMetadataLookupStr (&status, header, "PSF_NAME"); 433 pmModelType type = pmModelSetType (modelName); 434 435 bool poissonErrors = psMetadataLookupBool (&status, header, "POISSON"); 436 437 // we determine the PSF parameter polynomials from the MD-defined polynomials 438 pmPSF *psf = pmPSFAlloc (type, poissonErrors, NULL); 439 440 // check the number of expected parameters 441 int nPar = psMetadataLookupS32 (&status, header, "PSF_NPAR"); 442 if (nPar != pmModelParameterCount (psf->type)) 443 psAbort("mismatch model par count"); 444 445 // load the dimensions of each parameter 446 for (int i = 0; i < nPar; i++) { 447 char name[9]; 448 snprintf (name, 9, "PAR%02d_NX", i); 449 int nXorder = psMetadataLookupS32 (&status, header, name); 450 snprintf (name, 9, "PAR%02d_NY", i); 451 int nYorder = psMetadataLookupS32 (&status, header, name); 452 psf->params_NEW->data[i] = psPolynomial2DAlloc (PS_POLYNOMIAL_ORD, nXorder, nYorder); 453 } 454 455 // other required information describing the PSF 456 psf->ApResid = psMetadataLookupF32 (&status, header, "AP_RESID"); 457 psf->dApResid = psMetadataLookupF32 (&status, header, "AP_ERROR"); 458 psf->chisq = psMetadataLookupF32 (&status, header, "CHISQ"); 459 psf->nPSFstars = psMetadataLookupS32 (&status, header, "NSTARS"); 460 461 // XXX can we drop this now? 462 psf->skyBias = psMetadataLookupF32 (&status, header, "SKY_BIAS"); 463 464 // read the raw table data 465 psArray *table = psFitsReadTable (file->fits); 466 467 // fill in the matching psf->params entries 468 for (int i = 0; i > table->n; i++) { 469 psMetadata *row = table->data[i]; 470 int iPar = psMetadataLookupS32 (&status, row, "MODEL_TERM"); 471 int xPow = psMetadataLookupS32 (&status, row, "X_POWER"); 472 int yPow = psMetadataLookupS32 (&status, row, "Y_POWER"); 473 // XXX sanity check here 474 475 psPolynomial2D *poly = psf->params_NEW->data[iPar]; 476 477 poly->coeff[xPow][yPow] = psMetadataLookupF32 (&status, row, "VALUE"); 478 poly->coeffErr[xPow][yPow] = psMetadataLookupF32 (&status, row, "ERROR"); 479 poly->mask[xPow][yPow] = psMetadataLookupU8 (&status, row, "MASK"); 480 } 481 psFree (header); 482 psFree (table); 483 484 // move fits pointer to residual image and read header 485 // advance to the table data extension 486 // since we have read the IMAGE header, the TABLE header should exist 487 if (!psFitsMoveExtName (file->fits, imageName)) { 488 psAbort("cannot find data extension %s in %s", imageName, file->filename); 489 } 490 491 header = psFitsReadHeader (NULL, file->fits); 492 int Naxis = psMetadataLookupS32 (&status, header, "NAXIS"); 493 if (Naxis != 0) { 494 495 int Nx = psMetadataLookupS32 (&status, header, "NAXIS1"); 496 int Ny = psMetadataLookupS32 (&status, header, "NAXIS2"); 497 int Nz = psMetadataLookupS32 (&status, header, "NAXIS3"); 498 499 int xBin = psMetadataLookupS32 (&status, header, "XBIN"); 500 int yBin = psMetadataLookupS32 (&status, header, "YBIN"); 501 502 int xSize = Nx / xBin; 503 int ySize = Ny / yBin; 504 505 psf->residuals = pmResidualsAlloc (xSize, ySize, xBin, yBin); 506 507 psf->residuals->xCenter = psMetadataLookupS32 (&status, header, "XCENTER"); 508 psf->residuals->yCenter = psMetadataLookupS32 (&status, header, "YCENTER"); 509 510 psRegion fullImage = {0, 0, 0, 0}; 511 psFitsReadImageBuffer(psf->residuals->Ro, file->fits, fullImage, 0); // Desired pixels 512 if (Nz > 1) { 513 assert (Nz == 3); 514 psFitsReadImageBuffer(psf->residuals->Rx, file->fits, fullImage, 1); // Desired pixels 515 psFitsReadImageBuffer(psf->residuals->Ry, file->fits, fullImage, 2); // Desired pixels 516 } 517 } 518 519 psMetadataAdd (readout->analysis, PS_LIST_TAIL, "PSPHOT.PSF", PS_DATA_UNKNOWN, "psphot psf", psf); 520 psFree (psf); 521 522 psFree (tableName); 523 psFree (imageName); 524 525 return true; 526 } 527 528 /************ old support functions, deprecate? **************/ 529 46 530 psMetadata *pmPSFtoMetadata (psMetadata *metadata, pmPSF *psf) 47 531 { … … 124 608 } 125 609 126 bool pmFPAviewWritePSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)127 {128 129 pmFPA *fpa = file->fpa;130 131 if (view->chip == -1) {132 pmFPAWritePSFmodel (fpa, view, file, config);133 return true;134 }135 136 if (view->chip >= fpa->chips->n) {137 return false;138 }139 pmChip *chip = fpa->chips->data[view->chip];140 141 if (view->cell == -1) {142 pmChipWritePSFmodel (chip, view, file, config);143 return true;144 }145 146 if (view->cell >= chip->cells->n) {147 return false;148 }149 pmCell *cell = chip->cells->data[view->cell];150 151 if (view->readout == -1) {152 pmCellWritePSFmodel (cell, view, file, config);153 return true;154 }155 156 if (view->readout >= cell->readouts->n) {157 return false;158 }159 pmReadout *readout = cell->readouts->data[view->readout];160 161 pmReadoutWritePSFmodel (readout, view, file, config);162 return true;163 }164 165 // read in all chip-level PSFmodel files for this FPA166 bool pmFPAWritePSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)167 {168 169 for (int i = 0; i < fpa->chips->n; i++) {170 171 pmChip *chip = fpa->chips->data[i];172 pmChipWritePSFmodel (chip, view, file, config);173 }174 return true;175 }176 177 // read in all cell-level PSFmodel files for this chip178 bool pmChipWritePSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)179 {180 181 for (int i = 0; i < chip->cells->n; i++) {182 183 pmCell *cell = chip->cells->data[i];184 pmCellWritePSFmodel (cell, view, file, config);185 }186 return true;187 }188 189 // read in all readout-level PSFmodel files for this cell190 bool pmCellWritePSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)191 {192 193 for (int i = 0; i < cell->readouts->n; i++) {194 195 pmReadout *readout = cell->readouts->data[i];196 pmReadoutWritePSFmodel (readout, view, file, config);197 }198 return true;199 }200 201 610 // read in all readout-level Objects files for this cell 202 bool pmReadoutWritePSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)611 bool pmReadoutWritePSFmodel_Config (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 203 612 { 204 613 bool status; … … 228 637 } 229 638 230 231 232 bool pmFPAviewReadPSFmodel (const pmFPAview *view, pmFPAfile *file, const pmConfig *config)233 {234 235 pmFPA *fpa = file->fpa;236 237 if (view->chip == -1) {238 pmFPAReadPSFmodel (fpa, view, file, config);239 return true;240 }241 242 if (view->chip >= fpa->chips->n) {243 return false;244 }245 pmChip *chip = fpa->chips->data[view->chip];246 247 if (view->cell == -1) {248 pmChipReadPSFmodel (chip, view, file, config);249 return true;250 }251 252 if (view->cell >= chip->cells->n) {253 return false;254 }255 pmCell *cell = chip->cells->data[view->cell];256 257 if (view->readout == -1) {258 pmCellReadPSFmodel (cell, view, file, config);259 return true;260 }261 262 if (view->readout >= cell->readouts->n) {263 return false;264 }265 pmReadout *readout = cell->readouts->data[view->readout];266 267 pmReadoutReadPSFmodel (readout, view, file, config);268 return true;269 }270 271 // read in all chip-level PSFmodel files for this FPA272 bool pmFPAReadPSFmodel (pmFPA *fpa, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)273 {274 275 for (int i = 0; i < fpa->chips->n; i++) {276 277 pmChip *chip = fpa->chips->data[i];278 pmChipReadPSFmodel (chip, view, file, config);279 }280 return true;281 }282 283 // read in all cell-level PSFmodel files for this chip284 bool pmChipReadPSFmodel (pmChip *chip, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)285 {286 287 for (int i = 0; i < chip->cells->n; i++) {288 289 pmCell *cell = chip->cells->data[i];290 pmCellReadPSFmodel (cell, view, file, config);291 }292 return true;293 }294 295 // read in all readout-level PSFmodel files for this cell296 bool pmCellReadPSFmodel (pmCell *cell, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)297 {298 299 for (int i = 0; i < cell->readouts->n; i++) {300 301 pmReadout *readout = cell->readouts->data[i];302 pmReadoutReadPSFmodel (readout, view, file, config);303 }304 return true;305 }306 307 639 // read in all readout-level Objects files for this cell 308 bool pmReadoutReadPSFmodel (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config)640 bool pmReadoutReadPSFmodel_Config (pmReadout *readout, const pmFPAview *view, pmFPAfile *file, const pmConfig *config) 309 641 { 310 642
Note:
See TracChangeset
for help on using the changeset viewer.
