- Timestamp:
- Dec 16, 2005, 5:18:39 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/pap_branch_051214/psModules/src/astrom/pmAstrometry.c
r5739 r5795 10 10 * XXX: We should review the extent of the warning messages on these functions 11 11 * when the transformations are not successful. 12 * 12 * 13 13 * XXX: Should we implement non-linear cell->chip transforms? 14 * 15 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $16 * @date $Date: 2005-12- 08 00:00:57$14 * 15 * @version $Revision: 1.11.2.1 $ $Name: not supported by cvs2svn $ 16 * @date $Date: 2005-12-17 03:18:38 $ 17 17 * 18 18 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 60 60 psFree(readout->mask); 61 61 psFree(readout->weight); 62 //63 // XXX: Not sure if this is the right way to do things. Currently the psListAdd()64 // increase the memory reference counter to the list data. So, we65 // iterate through the list, and decrement the reference counters.66 //67 if (1) {68 if ((readout->bias != NULL) && (readout->bias->head != NULL)) {69 psListElem *tmpElem = (psListElem *) readout->bias->head;70 while (NULL != tmpElem) {71 psMemDecrRefCounter((psImage *) tmpElem->data);72 tmpElem = tmpElem->next;73 }74 }75 }76 psFree(readout->bias);77 62 psFree(readout->analysis); 78 63 psFree(readout->parent); … … 88 73 psFree(cell->concepts); 89 74 psFree(cell->analysis); 75 psFree(cell->camera); 90 76 // 91 77 // Set the parent to NULL in all cell->readouts before psFree(cell->readouts) … … 101 87 psFree(cell->readouts); 102 88 psFree(cell->parent); 103 psFree(cell-> private);89 psFree(cell->hdu); 104 90 } 105 91 } … … 125 111 psFree(chip->cells); 126 112 psFree(chip->parent); 127 psFree(chip-> private);113 psFree(chip->hdu); 128 114 } 129 115 } … … 151 137 } 152 138 psFree(fpa->chips); 153 psFree(fpa-> private);139 psFree(fpa->hdu); 154 140 psFree(fpa->phu); 155 141 } 156 142 } 157 143 144 void p_pmHDUFree(p_pmHDU *hdu) 145 { 146 if (hdu) { 147 psFree(hdu->extname); 148 psFree(hdu->header); 149 psFree(hdu->images); 150 psFree(hdu->masks); 151 psFree(hdu->weights); 152 } 153 } 154 158 155 // XXX: Verify these default values for row0, col0, rowBins, colBins 156 // PAP: These values may disappear in the future in favour of values in parent->concepts? 159 157 pmReadout *pmReadoutAlloc(pmCell *cell) 160 158 { 161 159 pmReadout *tmpReadout = (pmReadout *) psAlloc(sizeof(pmReadout)); 162 160 163 tmpReadout->col0 = -1;164 tmpReadout->row0 = -1;165 tmpReadout->colBins = -1;166 tmpReadout->rowBins = -1;161 tmpReadout->col0 = 0; 162 tmpReadout->row0 = 0; 163 tmpReadout->colBins = 0; 164 tmpReadout->rowBins = 0; 167 165 tmpReadout->image = NULL; 168 166 tmpReadout->mask = NULL; 169 167 tmpReadout->weight = NULL; 170 tmpReadout->bias = NULL;171 168 tmpReadout->analysis = psMetadataAlloc(); 172 169 tmpReadout->parent = cell; … … 179 176 180 177 // XXX: Verify these default values for row0, col0. 178 // PAP: These values may disappear in the future in favour of values in the "concepts"? 181 179 pmCell *pmCellAlloc( 182 180 pmChip *chip, 183 psMetadata *camera data,184 psStringname)181 psMetadata *cameraData, 182 const char *name) 185 183 { 186 184 pmCell *tmpCell = (pmCell *) psAlloc(sizeof(pmCell)); 187 185 188 tmpCell->col0 = -1;189 tmpCell->row0 = -1;186 tmpCell->col0 = 0; 187 tmpCell->row0 = 0; 190 188 tmpCell->toChip = NULL; 191 189 tmpCell->toFPA = NULL; … … 196 194 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CELL.NAME to metadata.\n"); 197 195 } 198 tmpCell->camera = cameradata;199 tmpCell->analysis = NULL;196 tmpCell->camera = psMemIncrRefCounter(cameraData); 197 tmpCell->analysis = psMetadataAlloc(); 200 198 tmpCell->readouts = psArrayAlloc(0); 201 tmpCell->parent = chip;199 tmpCell->parent = psMemIncrRefCounter(chip); 202 200 if (chip != NULL) { 203 201 chip->cells = psArrayAdd(chip->cells, 1, (psPtr) tmpCell); 204 202 } 205 tmpCell->valid = false;206 tmpCell-> private= NULL;203 tmpCell->valid = true; // All cells are valid by default 204 tmpCell->hdu = NULL; 207 205 208 206 psMemSetDeallocator(tmpCell, (psFreeFunc) cellFree); … … 211 209 212 210 // XXX: Verify these default values for row0, col0. 211 // PAP: row0, col0 may disappear in the future in favour of storing values in the "concepts". 213 212 pmChip *pmChipAlloc( 214 213 pmFPA *fpa, 215 psStringname)214 const char *name) 216 215 { 217 216 pmChip *tmpChip = (pmChip *) psAlloc(sizeof(pmChip)); 218 217 219 tmpChip->col0 = -1;220 tmpChip->row0 = -1;218 tmpChip->col0 = 0; 219 tmpChip->row0 = 0; 221 220 tmpChip->toFPA = NULL; 222 221 tmpChip->fromFPA = NULL; … … 226 225 psLogMsg(__func__, PS_LOG_WARN, "WARNING: Could not add CHIP.NAME to metadata.\n"); 227 226 } 228 tmpChip->analysis = NULL;227 tmpChip->analysis = psMetadataAlloc(); 229 228 tmpChip->cells = psArrayAlloc(0); 230 tmpChip->parent = fpa;229 tmpChip->parent = psMemIncrRefCounter(fpa); 231 230 if (fpa != NULL) { 232 231 fpa->chips = psArrayAdd(fpa->chips, 1, (psPtr) tmpChip); 233 232 } 234 tmpChip->valid = false;235 tmpChip-> private= NULL;233 tmpChip->valid = true; // Work on all chips, by default 234 tmpChip->hdu = NULL; 236 235 237 236 psMemSetDeallocator(tmpChip, (psFreeFunc) chipFree); … … 248 247 tmpFPA->concepts = psMetadataAlloc(); 249 248 tmpFPA->analysis = NULL; 250 tmpFPA->camera = camera;249 tmpFPA->camera = psMemIncrRefCounter((psPtr)camera); 251 250 tmpFPA->chips = psArrayAlloc(0); 252 tmpFPA-> private= NULL;251 tmpFPA->hdu = NULL; 253 252 tmpFPA->phu = NULL; 254 253 255 254 psMemSetDeallocator(tmpFPA, (psFreeFunc) FPAFree); 256 255 return(tmpFPA); 256 } 257 258 p_pmHDU *p_pmHDUAlloc(const char *extname) 259 { 260 p_pmHDU *hdu = psAlloc(sizeof(p_pmHDU)); 261 psMemSetDeallocator(hdu, (psFreeFunc)p_pmHDUFree); 262 263 hdu->extname = psStringCopy(extname); 264 hdu->header = NULL; 265 hdu->images = NULL; 266 hdu->masks = NULL; 267 hdu->weights = NULL; 268 269 return hdu; 257 270 } 258 271 … … 800 813 } 801 814 815 816 /***************************************************************************** 817 *****************************************************************************/ 818 819 // Set cells within a chip to a specified validity 820 static bool setCellsValid(const pmChip *chip, // Chip of interest 821 bool valid // Valid? 822 ) 823 { 824 PS_ASSERT_PTR_NON_NULL(chip, false); 825 826 psArray *cells = chip->cells; // Component cells 827 if (! cells) { 828 return false; 829 } 830 for (int i = 0; i < cells->n; i++) { 831 pmCell *tmpCell = cells->data[i]; // Cell of interest 832 if (tmpCell) { 833 tmpCell->valid = valid; 834 } 835 } 836 837 return true; 838 } 839 802 840 /***************************************************************************** 803 841 *****************************************************************************/ … … 807 845 { 808 846 PS_ASSERT_PTR_NON_NULL(fpa, false); 809 if ((fpa->chips == NULL) || (chipNum >= fpa->chips->n)) { 847 848 psArray *chips = fpa->chips; // Component chips 849 if ((chips == NULL) || (chipNum >= chips->n)) { 810 850 return(false); 811 851 } 812 psBool rc = true; 813 814 for (psS32 i = 0 ; i < fpa->chips->n ; i++) { 815 pmChip *tmpChip = (pmChip *) fpa->chips->data[i]; 852 853 for (int i = 0 ; i < chips->n ; i++) { 854 pmChip *tmpChip = (pmChip *) chips->data[i]; 816 855 if (tmpChip == NULL) { 817 rc = false; 856 continue; 857 } 858 if (i == chipNum) { 859 tmpChip->valid = true; 860 setCellsValid(tmpChip, true); 818 861 } else { 819 if (i == chipNum) { 820 tmpChip->valid = true; 821 } else { 822 tmpChip->valid = false; 823 } 824 } 825 } 826 827 return(rc); 862 tmpChip->valid = false; 863 setCellsValid(tmpChip, false); 864 } 865 866 } 867 868 return true; 828 869 } 829 870 … … 831 872 /***************************************************************************** 832 873 XXX: The SDRS is ambiguous on a few things: 833 Whether or not the other chips should be set valid=true. 834 Should we return the number of chip valid=true before or after they're set, 874 Whether or not the other chips should be set valid=true. [PAP: No] 875 Should we return the number of chip valid=true before or after they're set, [PAP: After] 835 876 *****************************************************************************/ 836 877 /** 837 * 878 * 838 879 * pmFPAExcludeChip shall set valid to false only for the specified chip 839 880 * number (chipNum). In the event that the specified chip number does not exist … … 841 882 * The function shall return the number of chips within the fpa that have valid 842 883 * set to true. 843 * 884 * 844 885 */ 845 886 int pmFPAExcludeChip( … … 849 890 PS_ASSERT_PTR_NON_NULL(fpa, false); 850 891 851 if (fpa->chips == NULL) { 892 psArray *chips = fpa->chips; // Component chips 893 if (chips == NULL) { 852 894 psLogMsg(__func__, PS_LOG_WARN, "WARNING: fpa->chips == NULL\n"); 853 895 return(0); 854 896 } 855 if ((chipNum >= fpa->chips->n) || (NULL == (pmChip *) fpa->chips->data[chipNum])) {897 if ((chipNum >= chips->n) || (NULL == (pmChip *) chips->data[chipNum])) { 856 898 psLogMsg(__func__, PS_LOG_WARN, "WARNING: the specified chip (%d) does not exist.\n", chipNum); 857 899 return(0); 858 900 } 859 901 860 psS32 numChips = 0;861 for ( psS32 i = 0 ; i < fpa->chips->n ; i++) {862 pmChip *tmpChip = (pmChip *) fpa->chips->data[i];902 int numChips = 0; // Number of valid chips 903 for (int i = 0 ; i < chips->n ; i++) { 904 pmChip *tmpChip = (pmChip *) chips->data[i]; // Chip of interest 863 905 if (tmpChip != NULL) { 864 906 if (i == chipNum) { 865 907 tmpChip->valid = false; 866 } else {867 tmpChip->valid = true;908 setCellsValid(tmpChip, false); // Wipe out the cell as well 909 } else if (tmpChip->valid) { 868 910 numChips++; 869 911 }
Note:
See TracChangeset
for help on using the changeset viewer.
