Changeset 15299
- Timestamp:
- Oct 11, 2007, 5:18:11 PM (19 years ago)
- Location:
- trunk/psModules/src
- Files:
-
- 3 edited
-
camera/pmHDUGenerate.c (modified) (3 diffs)
-
concepts/pmConceptsStandard.c (modified) (2 diffs)
-
concepts/pmConceptsStandard.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psModules/src/camera/pmHDUGenerate.c
r14955 r15299 13 13 #include "pmFPALevel.h" 14 14 #include "pmHDUUtils.h" 15 #include "pmConcepts.h" 16 #include "pmConceptsStandard.h" 15 17 #include "pmHDUGenerate.h" 16 18 … … 169 171 return true; 170 172 } 173 174 // Attempt to read CELL.TRIMSEC and CELL.BIASSEC from the cell format if they are specified by VALUE 175 static bool readTrimBias(psList *cells // List of cells below the HDU 176 ) 177 { 178 bool mdok; // Status of MD lookup 179 psListIterator *cellsIter = psListIteratorAlloc(cells, PS_LIST_HEAD, false); // Iterator for cells 180 pmCell *cell = NULL; // Cell from iteration 181 bool allFixed = true; // We're able to fix all TRIMSEC and BIASSEC 182 while ((cell = psListGetAndIncrement(cellsIter))) { 183 psMetadataItem *trimsecItem = psMetadataLookup(cell->concepts, "CELL.TRIMSEC"); // Item with trimsec 184 if (!trimsecItem || trimsecItem->type != PS_DATA_REGION) { 185 psWarning("CELL.TRIMSEC has not been initialised in cell --- ignored.\n"); 186 return false; 187 } 188 psRegion *trimsec = trimsecItem->data.V; // Trim section 189 if (psRegionIsNaN(*trimsec)) { 190 const char *trimsecSource = psMetadataLookupStr(&mdok, cell->config, "CELL.TRIMSEC.SOURCE"); 191 if (strcmp(trimsecSource, "VALUE") == 0) { 192 193 const char *trimsecStr = psMetadataLookupStr(&mdok, cell->config, "CELL.TRIMSEC"); 194 *trimsec = psRegionFromString(trimsecStr); 195 } else { 196 allFixed = false; 197 } 198 } 199 200 psMetadataItem *biassecItem = psMetadataLookup(cell->concepts, "CELL.BIASSEC"); // Bias sections 201 if (!biassecItem) { 202 psWarning("CELL.BIASSEC has not been initialised in cell --- ignored.\n"); 203 return false; 204 } 205 psList *biassecs = biassecItem->data.V; 206 if (biassecs->n != 0) { 207 allFixed = false; 208 continue; 209 } 210 211 const char *biassecSource = psMetadataLookupStr(&mdok, cell->config, "CELL.BIASSEC.SOURCE"); 212 if (strcmp(biassecSource, "VALUE") == 0) { 213 const char *biassecStr = psMetadataLookupStr(&mdok, cell->config, "CELL.BIASSEC"); 214 psFree(biassecItem->data.V); 215 biassecItem->data.V = p_pmConceptParseRegions(biassecStr); 216 } else { 217 allFixed = false; 218 } 219 } 220 psFree(cellsIter); 221 222 return allFixed; 223 } 224 171 225 172 226 // Generate CELL.TRIMSEC and CELL.BIASSEC for the cells … … 341 395 // Get the size of the HDU, either from existing trimsec and biassec, or generate these and try again 342 396 int xSize = 0, ySize = 0; // Size of HDU 343 if (!sizeHDU(&xSize, &ySize, cells) && !(generateTrimBias(cells) && sizeHDU(&xSize, &ySize, cells))) { 397 if (!sizeHDU(&xSize, &ySize, cells) && 398 !(readTrimBias(cells) && sizeHDU(&xSize, &ySize, cells)) && 399 !(generateTrimBias(cells) && sizeHDU(&xSize, &ySize, cells))) { 344 400 psError(PS_ERR_IO, true, "Unable to determine size of HDU!\n"); 345 401 return false; -
trunk/psModules/src/concepts/pmConceptsStandard.c
r15229 r15299 329 329 } 330 330 331 332 psList *p_pmConceptParseRegions(const char *region) 333 { 334 assert(region && strlen(region) > 0); 335 336 psList *list = psListAlloc(NULL); // List of regions 337 338 // a single BIASSEC is of the form [AAAA] 339 // we may have multiple BIASSEC entries separated by space, commas, or semicolons 340 int xParity = 0, yParity = 0; // Parity of region 341 char *p = strchr (region, '['); 342 while (p) { 343 char *q = strchr (p, ']'); 344 if (!q) { 345 break; 346 } 347 char *regionString = psStringAlloc(q - p + 2); 348 strncpy (regionString, p, q - p + 1); 349 regionString[q - p + 1] = 0; 350 351 psRegion *region = psAlloc(sizeof(psRegion)); // The region 352 *region = psRegionAndParityFromString(&xParity, &yParity, regionString); 353 psListAdd(list, PS_LIST_TAIL, region); 354 psFree(region); // Drop reference 355 psFree(regionString); // Drop reference 356 357 p = strchr (q, '['); 358 } 359 360 return list; 361 } 362 331 363 psMetadataItem *p_pmConceptParse_CELL_BIASSEC(const psMetadataItem *concept, 332 364 const psMetadataItem *pattern, … … 341 373 assert(pattern); 342 374 343 psList *biassecs = psListAlloc(NULL); // List of bias sections375 psList *biassecs; // List of bias sections 344 376 345 377 switch (concept->type) { 346 378 case PS_DATA_STRING: { 347 // a single BIASSEC is of the form [AAAA] 348 // we may have multiple BIASSEC entries separated by space, commas, or semicolons 349 int xParity = 0; 350 int yParity = 0; 351 char *p = strchr (concept->data.V, '['); 352 while (p != NULL) { 353 char *q = strchr (p, ']'); 354 if (q == NULL) break; 355 char *regionString = psAlloc (q - p + 2); 356 strncpy (regionString, p, q - p + 1); 357 regionString[q - p + 1] = 0; 358 359 psRegion *region = psAlloc(sizeof(psRegion)); // The region 360 *region = psRegionAndParityFromString(&xParity, &yParity, regionString); 361 psListAdd(biassecs, PS_LIST_TAIL, region); 362 psFree(region); // Drop reference 363 psFree(regionString); // Drop reference 364 365 p = strchr (q, '['); 366 } 379 biassecs = p_pmConceptParseRegions(concept->data.V); 367 380 break; 368 381 } 369 382 case PS_DATA_LIST: { 383 biassecs = psListAlloc(NULL); 370 384 psList *regions = concept->data.V; // The list of regions 371 385 psListIterator *regionsIter = psListIteratorAlloc(regions, PS_LIST_HEAD, false); // Iterator -
trunk/psModules/src/concepts/pmConceptsStandard.h
r12696 r15299 4 4 * @author Paul Price, IfA 5 5 * 6 * @version $Revision: 1.1 0$ $Name: not supported by cvs2svn $7 * @date $Date: 2007- 03-30 21:12:56$6 * @version $Revision: 1.11 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2007-10-12 03:18:11 $ 8 8 * Copyright 2005-2006 Institute for Astronomy, University of Hawaii 9 9 */ … … 14 14 /// @addtogroup Concepts Data Abstraction Concepts 15 15 /// @{ 16 17 /// Parse a list of region specifiers on a line 18 psList *p_pmConceptParseRegions(const char *region ///< Regions, separated by whitespace 19 ); 16 20 17 21 /// Parse the FPA.FILTER concept to apply a lookup table
Note:
See TracChangeset
for help on using the changeset viewer.
