Changeset 6847 for branches/rel10_ifa/psModules/src/astrom/pmFPAfile.c
- Timestamp:
- Apr 12, 2006, 8:18:22 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/rel10_ifa/psModules/src/astrom/pmFPAfile.c
r6834 r6847 2 2 #include "pslib.h" 3 3 #include "psAdditionals.h" 4 #include "pmConfig.h" 4 5 #include "pmHDU.h" 5 6 #include "pmFPA.h" … … 22 23 psFree (file->names); 23 24 25 psFree (file->format); 26 psFree (file->name); 27 24 28 if (file->fits != NULL) { 25 29 psFitsClose (file->fits); … … 54 58 file->fits = NULL; 55 59 file->names = psMetadataAlloc(); 60 61 file->format = NULL; 62 file->name = NULL; 56 63 57 64 file->filerule = NULL; … … 188 195 if (fpa != NULL) { 189 196 file->fpa = psMemIncrRefCounter(fpa); 197 } 198 199 // for WRITE type of data, the output format needs to be determined 200 // this is only needed if the output file is not identical in structure to the input 201 char *formatName = psMetadataLookupStr (&status, data, "FILE.FORMAT"); 202 if (formatName && strcasecmp (formatName, "NONE")) { 203 psMetadata *formats = psMetadataLookupMD(&status, camera, "FORMATS"); // List of formats 204 char *formatFile = psMetadataLookupStr (&status, formats, formatName); 205 readConfig (&file->format, formatFile, formatName); 190 206 } 191 207 … … 332 348 bool pmFPAfileWrite (pmFPAfile *file, const pmFPAview *view) 333 349 { 350 // XXX test return false; 351 334 352 if (file->mode != PM_FPA_MODE_WRITE) 335 353 return false; … … 372 390 bool pmFPAfileCreate (pmFPAfile *file, const pmFPAview *view) 373 391 { 392 // XXX test return false; 374 393 if (file->mode != PM_FPA_MODE_WRITE) 375 394 return false; … … 389 408 case PM_FPA_FILE_IMAGE: 390 409 /* create a PHU for thie file, if it does not exist */ 391 pmFPAfileCopy View (file->src, file->fpa, view);410 pmFPAfileCopyStructureView (file->fpa, file->src, file->format, file->xBin, file->yBin, view); 392 411 psTrace ("pmFPAfile", 5, "created fpa data elements for %s (fpa: %p)\n", file->filename, file->fpa); 393 412 break; … … 698 717 699 718 // set the view to the corresponding entry for this phu 700 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);719 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format); 701 720 702 721 // XXX is this the correct psMD to save the filename? … … 786 805 787 806 // set the view to the corresponding entry for this phu 788 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format);807 pmFPAview *view = pmFPAAddSourceFromHeader (fpa, phu, format); 789 808 790 809 // XXX is this the correct psMD to save the filename? … … 803 822 } 804 823 # endif 824 825 // create a new output pmFPAfile based on an existing FPA 826 pmFPAfile *pmFPAfileFromFPA (pmConfig *config, pmFPA *src, int xBin, int yBin, char *filename) 827 { 828 // XXX pmFPAConstruct has many leaks (6919) 829 pmFPA *fpa = pmFPAConstruct (config->camera); 830 pmFPAfile *file = pmFPAfileDefine (config->files, config->camera, fpa, filename); 831 file->src = src; // inherit output elements from this source pmFPA 832 file->xBin = xBin; 833 file->yBin = yBin; 834 835 return file; 836 } 805 837 806 838 // look for the given name on the argument list. … … 879 911 880 912 // set the view to the corresponding entry for this phu 881 pmFPAview *view = pmFPAAddSourceFromHeader (file->fpa, phu, format);913 pmFPAview *view = pmFPAAddSourceFromHeader (file->fpa, phu, format); 882 914 883 915 // XXX is this the correct psMD to save the filename? … … 957 989 bool pmFPAfileCopyView (pmFPA *out, pmFPA *in, const pmFPAview *view) 958 990 { 959 // XXX how to we transmit the required binning factor?960 991 // pmFPAWrite takes care of all PHUs as needed 961 992 if (view->chip == -1) { … … 985 1016 return false; 986 1017 987 // XXX disable readout write for now 988 # if (0) 989 990 if (view->readout >= cell->readouts->n) { 991 return false; 992 } 993 pmReadout *readout = cell->readouts->data[view->readout]; 994 995 if (view->nRows == 0) { 996 pmReadoutWrite (readout, fits, NULL, NULL); 997 } else { 998 pmReadoutWriteSegment (readout, fits, view->nRows, view->iRows, NULL, NULL); 999 } 1000 return true; 1001 # endif 1002 } 1003 1004 // need to distinguish between a "copy structure" and a "copy data" 1005 // need to allow for binning when performing the "copy structure" 1018 // XXX add readout / segment equivalents 1019 } 1020 1021 // given an already-opened fits file, write the components corresponding 1022 // to the specified view 1023 bool pmFPAfileCopyStructureView (pmFPA *out, pmFPA *in, psMetadata *format, int xBin, int yBin, const pmFPAview *view) 1024 { 1025 // pmFPAWrite takes care of all PHUs as needed 1026 if (view->chip == -1) { 1027 pmFPAAddSourceFromView (out, view, format); 1028 pmFPACopyStructure (out, in, xBin, yBin); 1029 return true; 1030 } 1031 if (view->chip >= in->chips->n) { 1032 return false; 1033 } 1034 pmChip *inChip = in->chips->data[view->chip]; 1035 pmChip *outChip = out->chips->data[view->chip]; 1036 1037 if (view->cell == -1) { 1038 pmFPAAddSourceFromView (out, view, format); 1039 pmChipCopyStructure (outChip, inChip, xBin, yBin); 1040 return true; 1041 } 1042 if (view->cell >= inChip->cells->n) { 1043 return false; 1044 } 1045 pmCell *inCell = inChip->cells->data[view->cell]; 1046 pmCell *outCell = outChip->cells->data[view->cell]; 1047 1048 if (view->readout == -1) { 1049 pmFPAAddSourceFromView (out, view, format); 1050 pmCellCopyStructure (outCell, inCell, xBin, yBin); 1051 return true; 1052 } 1053 return false; 1054 1055 // XXX add readout / segment equivalents 1056 }
Note:
See TracChangeset
for help on using the changeset viewer.
