Changeset 4309
- Timestamp:
- Jun 17, 2005, 2:48:18 PM (21 years ago)
- Location:
- trunk/archive/scripts/src
- Files:
-
- 4 added
- 10 edited
-
Makefile (modified) (2 diffs)
-
gpc1_raw.config (modified) (2 diffs)
-
papFocalPlane.c (modified) (20 diffs)
-
papFocalPlane.h (modified) (7 diffs)
-
papStuff.c (modified) (3 diffs)
-
papStuff.h (modified) (1 diff)
-
papmodule.h (added)
-
pmCameraFromHeader.c (modified) (2 diffs)
-
pmFPAFromHeader.c (modified) (3 diffs)
-
pmFPARead.c (added)
-
pmFPARead.h (added)
-
psAdditionals.c (modified) (3 diffs)
-
psAdditionals.h (modified) (1 diff)
-
test_pmFPARead.c (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/archive/scripts/src/Makefile
r4092 r4309 1 1 SHELL = /bin/sh 2 2 CC = gcc 3 CFLAGS += -O 2 -g -std=c99-I/home/mithrandir/price/pan-starrs/jhroot/i686-pc-linux-gnu/include/ -D_GNU_SOURCE3 CFLAGS += -O0 -g -std=c99 -Werror -I/home/mithrandir/price/pan-starrs/jhroot/i686-pc-linux-gnu/include/ -D_GNU_SOURCE 4 4 PSLIB += -L/home/mithrandir/price/pan-starrs/jhroot/i686-pc-linux-gnu/lib/ -lpslib -lgsl -lgslcblas -lfftw3f -lsla -lcfitsio -lm -lxml2 -lmysqlclient 5 5 LDFLAGS += $(PSLIB) 6 6 7 OBJS = test_pmFPAfromHeader.o pmCameraFromHeader.o pmFPAFromHeader.o psAdditionals.o papStuff.o 7 BUILD_OBJS = test_pmFPAfromHeader.o pmCameraFromHeader.o pmFPAFromHeader.o psAdditionals.o papStuff.o 8 BUILD_TARGET = test_pmFPAfromHeader 8 9 9 TARGET = test_pmFPAfromHeader 10 READ_OBJS = test_pmFPARead.o pmCameraFromHeader.o pmFPARead.o papFocalPlane.o psAdditionals.o papStuff.o 11 READ_TARGET = test_pmFPARead 10 12 11 13 .PHONY: tags clean empty … … 14 16 $(CC) -c $(CFLAGS) $(OPTFLAGS) $< 15 17 16 $( TARGET): $(OBJS)17 $(CC) $(CFLAGS) -o $@ $( OBJS) $(LDFLAGS) $(OPTFLAGS)18 $(READ_TARGET): $(READ_OBJS) 19 $(CC) $(CFLAGS) -o $@ $(READ_OBJS) $(LDFLAGS) $(OPTFLAGS) 18 20 19 21 clean: -
trunk/archive/scripts/src/gpc1_raw.config
r4092 r4309 17 17 CONTENTS METADATA 18 18 # Extension name, type 19 cell00 STR pitch10u 20 cell01 STR pitch10u 21 cell10 STR pitch10u 22 cell11 STR pitch12u 19 xy00 STR pitch10u 20 xy01 STR pitch10u 21 xy02 STR pitch10u 22 xy03 STR pitch10u 23 xy04 STR pitch10u 24 xy05 STR pitch10u 25 xy06 STR pitch10u 26 xy07 STR pitch10u 27 xy10 STR pitch10u 28 xy11 STR pitch10u 29 xy12 STR pitch10u 30 xy13 STR pitch10u 31 xy14 STR pitch10u 32 xy15 STR pitch10u 33 xy16 STR pitch10u 34 xy17 STR pitch10u 35 xy20 STR pitch10u 36 xy21 STR pitch10u 37 xy22 STR pitch10u 38 xy23 STR pitch10u 39 xy24 STR pitch10u 40 xy25 STR pitch10u 41 xy26 STR pitch10u 42 xy27 STR pitch10u 43 xy30 STR pitch10u 44 xy31 STR pitch10u 45 xy32 STR pitch10u 46 xy33 STR pitch10u 47 xy34 STR pitch10u 48 xy35 STR pitch10u 49 xy36 STR pitch10u 50 xy37 STR pitch10u 51 xy40 STR pitch10u 52 xy41 STR pitch10u 53 xy42 STR pitch10u 54 xy43 STR pitch10u 55 xy44 STR pitch10u 56 xy45 STR pitch10u 57 xy46 STR pitch10u 58 xy47 STR pitch10u 59 xy50 STR pitch10u 60 xy51 STR pitch10u 61 xy52 STR pitch10u 62 xy53 STR pitch10u 63 xy54 STR pitch10u 64 xy55 STR pitch10u 65 xy56 STR pitch10u 66 xy57 STR pitch10u 67 xy60 STR pitch10u 68 xy61 STR pitch10u 69 xy62 STR pitch10u 70 xy63 STR pitch10u 71 xy64 STR pitch10u 72 xy65 STR pitch10u 73 xy66 STR pitch10u 74 xy67 STR pitch10u 75 xy70 STR pitch10u 76 xy71 STR pitch10u 77 xy72 STR pitch10u 78 xy73 STR pitch10u 79 xy74 STR pitch10u 80 xy75 STR pitch10u 81 xy76 STR pitch10u 82 xy77 STR pitch10u 23 83 END 24 84 … … 26 86 CELLS METADATA 27 87 pitch10u METADATA 28 CELL.BIASSEC STR VALUE:[ 1:10,1:614];[625:674,1:614]29 CELL.TRIMSEC STR VALUE:[1 1:624,1:614]88 CELL.BIASSEC STR VALUE:[575:606,1:594] 89 CELL.TRIMSEC STR VALUE:[1:574,1:594] 30 90 # CELL.BIASSEC STR HEADER:BIASSEC 31 # CELL.TRIMSEC STR HEADER: TRIMSEC91 # CELL.TRIMSEC STR HEADER:DATASEC 32 92 END 33 93 94 # This is just in here for fun 34 95 pitch12u METADATA 35 96 CELL.BIASSEC STR VALUE:[1:10,1:512];[523:574,1:512] -
trunk/archive/scripts/src/papFocalPlane.c
r4092 r4309 1 1 #include <stdio.h> 2 #include <string.h> 2 3 #include "pslib.h" 3 4 #include "papFocalPlane.h" 4 #include "pmRead.h" 5 #include "psAdditionals.h" 6 #include "pmFPARead.h" 5 7 6 8 // I'm sure this code, especially the DB lookup, leaks memory something chronic.... … … 8 10 9 11 // Look for a value already cached 10 static psMetadataItem *getValueFromCache(const p sFPA *fpa, // The FPA that contains the chip11 const p sChip *chip, // The chip that contains the cell12 const p sCell *cell, // The cell12 static psMetadataItem *getValueFromCache(const papFPA *fpa, // The FPA that contains the chip 13 const papChip *chip, // The chip that contains the cell 14 const papCell *cell, // The cell 13 15 const char *valueName // Name of value 14 16 ) … … 31 33 32 34 // Put a value that we've found into the cache 33 static void setValueInCache(p sFPA *fpa, // The FPA that contains the chip34 p sChip *chip, // The chip that contains the cell35 p sCell *cell, // The cell35 static void setValueInCache(papFPA *fpa, // The FPA that contains the chip 36 papChip *chip, // The chip that contains the cell 37 papCell *cell, // The cell 36 38 const char *valueName, // Name of value 37 39 const psMetadataItem *value // Item containing the value … … 56 58 57 59 58 static psMetadataItem *getValueFromHeader( const psFPA *fpa, // The FPA that contains the chip59 const psChip *chip, // The chip that contains the cell60 const psCell *cell, // The cell60 static psMetadataItem *getValueFromHeader(papFPA *fpa, // The FPA that contains the chip 61 papChip *chip, // The chip that contains the cell 62 papCell *cell, // The cell 61 63 const char *valueName // Name of value 62 64 ) 63 65 { 66 bool mdStatus = true; // Status of MD lookup 67 64 68 // Look for how to translate the concept into a FITS header name 65 const char *header = psMetadataLookupString( fpa->fits, valueName);69 const char *header = psMetadataLookupString(&mdStatus, fpa->fits, valueName); 66 70 if (strlen(header) > 0) { 67 71 // We have a FITS header to look up --- search each level … … 70 74 if (cellItem) { 71 75 // XXX: Need to clean up before returning 72 setValueInCache(NULL, NULL, cell, cellItem);76 setValueInCache(NULL, NULL, cell, valueName, cellItem); 73 77 return cellItem; 74 78 } … … 79 83 if (chipItem) { 80 84 // XXX: Need to clean up before returning 81 setValueInCache(NULL, chip, cell, chipItem);85 setValueInCache(NULL, chip, cell, valueName, chipItem); 82 86 return chipItem; 83 87 } … … 88 92 if (fpaItem) { 89 93 // XXX: Need to clean up before returning 90 setValueInCache(fpa, chip, cell, fpaItem);94 setValueInCache(fpa, chip, cell, valueName, fpaItem); 91 95 return fpaItem; 92 96 } … … 100 104 101 105 // Look for a default 102 static psMetadataItem *getValueFromDefault( const psFPA *fpa, // The FPA that contains the chip103 const psChip *chip, // The chip that contains the cell104 const psCell *cell, // The cell106 static psMetadataItem *getValueFromDefault(papFPA *fpa, // The FPA that contains the chip 107 papChip *chip, // The chip that contains the cell 108 papCell *cell, // The cell 105 109 const char *valueName // Name of value 106 110 ) 107 111 { 108 psMetadataItem *defItem = psMetadataLookup( fpa->defaults, valueName);112 psMetadataItem *defItem = psMetadataLookup((psMetadata*)fpa->defaults, valueName); 109 113 if (defItem) { 110 setValueInCache(fpa, chip, cell, defItem);114 setValueInCache(fpa, chip, cell, valueName, defItem); 111 115 } 112 116 return defItem; // defItem is either NULL or points to what was desired … … 115 119 116 120 // Look for a database lookup 117 static psMetadataItem *getValueFromDB( const psFPA *fpa, // The FPA that contains the chip118 const psChip *chip, // The chip that contains the cell119 const psCell *cell, // The cell121 static psMetadataItem *getValueFromDB(papFPA *fpa, // The FPA that contains the chip 122 papChip *chip, // The chip that contains the cell 123 papCell *cell, // The cell 120 124 const char *valueName // Name of value 121 125 ) … … 123 127 if (fpa->db) { 124 128 // The database has been initialised 125 126 psMetadata *dbLookup = psMetadataLookupMD( fpa->database, valueName);129 bool mdStatus = true; // Status of MD lookup 130 psMetadata *dbLookup = psMetadataLookupMD(&mdStatus, fpa->database, valueName); 127 131 if (dbLookup) { 128 const char *tableName = psMetadataLookupString( dbLookup, "TABLE"); // Name of the table129 const char *colName = psMetadataLookupString( dbLookup, "COLUMN"); // Name of the column130 const char *givenCols = psMetadataLookupString( dbLookup, "GIVENDBCOL"); // Name of "where" columns131 const char *givenPS = psMetadataLookupString( dbLookup, "GIVENPS"); // Values for "where" columns132 const char *tableName = psMetadataLookupString(&mdStatus, dbLookup, "TABLE"); // Name of the table 133 const char *colName = psMetadataLookupString(&mdStatus, dbLookup, "COLUMN"); // Name of the column 134 const char *givenCols = psMetadataLookupString(&mdStatus, dbLookup, "GIVENDBCOL"); // Name of "where" columns 135 const char *givenPS = psMetadataLookupString(&mdStatus, dbLookup, "GIVENPS"); // Values for "where" columns 132 136 133 137 // Now, need to get the "given"s … … 135 139 psList *cols = papSplit(givenCols, ",;"); // List of column names 136 140 psList *values = papSplit(givenPS, ",;"); // List of value names for the columns 137 psMetadata *selection = psMetadataAlloc( NULL); // The stuff to select in the DB141 psMetadata *selection = psMetadataAlloc(); // The stuff to select in the DB 138 142 if (cols->size != values->size) { 139 143 psLogMsg(__func__, PS_LOG_WARN, "The GIVENDBCOL and GIVENPS entries for %s do not have " … … 159 163 } 160 164 if (! item) { 161 psLogMsg(__func__, PS_LOG_ERR , "Unable to find the value name %s for DB "165 psLogMsg(__func__, PS_LOG_ERROR, "Unable to find the value name %s for DB " 162 166 " lookup on %s --- ignored.\n", name, valueName); 163 167 } else { … … 199 203 } 200 204 201 psMetadataItem *psCellGetValue( const psFPA *fpa, // The FPA that contains the cell205 psMetadataItem *psCellGetValue(papFPA *fpa, // The FPA that contains the cell 202 206 const char *chipName, // The name of the chip 203 207 const char *cellName, // The name of the cell … … 205 209 ) 206 210 { 207 psChip *chip = psMetadataLookupChip(fpa, chipName); // The chip 208 psCell *cell = psMetadataLookupCell(chip, cellName); // The cell 211 bool mdStatus = true; // Status of MD lookup 212 papChip *chip = psMetadataLookupChip(&mdStatus, fpa->chips, chipName); // The chip 213 papCell *cell = psMetadataLookupCell(&mdStatus, chip->cells, cellName); // The cell 209 214 210 215 // Try cache, headers, database, defaults in order … … 223 228 } 224 229 225 float psCellGetValueF32( const psFPA *fpa, // The FPA that contains the cell230 float psCellGetValueF32(papFPA *fpa, // The FPA that contains the cell 226 231 const char *chipName, // The name of the chip 227 232 const char *cellName, // The name of the cell … … 244 249 } 245 250 246 int psCellGetValueS32( const psFPA *fpa, // The FPA that contains the cell251 int psCellGetValueS32(papFPA *fpa, // The FPA that contains the cell 247 252 const char *chipName, // The name of the chip 248 253 const char *cellName, // The name of the cell … … 250 255 ) 251 256 { 252 int value = NAN; // Result257 int value = 0; // Result 253 258 psMetadataItem *item = psCellGetValue(fpa, chipName, cellName, valueName); // The item 254 259 if (! item) { … … 266 271 267 272 268 double psCellGetValueF64( const psFPA *fpa, // The FPA that contains the cell273 double psCellGetValueF64(papFPA *fpa, // The FPA that contains the cell 269 274 const char *chipName, // The name of the chip 270 275 const char *cellName, // The name of the cell … … 288 293 289 294 290 psString psCellGetValueString( const psFPA *fpa, // The FPA that contains the cell295 psString psCellGetValueString(papFPA *fpa, // The FPA that contains the cell 291 296 const char *chipName, // The name of the chip 292 297 const char *cellName, // The name of the cell … … 308 313 return value; 309 314 } 315 316 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 317 // Allocators 318 ////////////////////////////////////////////////////////////////////////////////////////////////////////////// 319 320 papFPA *papFPAAlloc(psMetadata *fits, // FITS translation info 321 psMetadata *database, // Database lookup info 322 psMetadata *defaults, // Defaults info 323 psDB *db // Database handle 324 ) 325 { 326 papFPA *fpa = psAlloc(sizeof(papFPA));// The FPA 327 psMemSetDeallocator(fpa, (psFreeFcn)p_papFPAFree); 328 329 // Fill in the various components 330 fpa->fits = psMemIncrRefCounter(fits); 331 fpa->database = psMemIncrRefCounter(database); 332 fpa->defaults = psMemIncrRefCounter(defaults); 333 334 fpa->values = psMetadataAlloc(); 335 fpa->header = NULL; 336 fpa->db = psMemIncrRefCounter(db); 337 338 fpa->chips = psMetadataAlloc(); 339 fpa->images = NULL; 340 341 return fpa; 342 } 343 344 void p_papFPAFree(papFPA *fpa) 345 { 346 psFree((psPtr)fpa->fits); 347 psFree((psPtr)fpa->database); 348 psFree((psPtr)fpa->defaults); 349 350 psFree(fpa->values); 351 psFree(fpa->header); 352 if (fpa->db) { 353 psDBCleanup((psDB*)fpa->db); 354 } 355 356 psFree(fpa->chips); 357 psFree(fpa->images); 358 } 359 360 papChip *papChipAlloc(papFPA *fpa, // FPA to which the chip belongs 361 const char *name // Name of the chip 362 ) 363 { 364 papChip *chip = psAlloc(sizeof(papChip)); // The chip 365 psMemSetDeallocator(chip, (psFreeFcn)p_papChipFree); 366 psMetadataAdd(fpa->chips, PS_LIST_TAIL, name, PS_META_CHIP, "Added on allocation of chip", chip); 367 368 chip->values = psMetadataAlloc(); 369 chip->header = NULL; 370 371 chip->cells = psMetadataAlloc(); 372 chip->images = NULL; 373 374 return chip; 375 } 376 377 void p_papChipFree(papChip *chip) 378 { 379 psFree(chip->values); 380 psFree(chip->header); 381 psFree(chip->cells); 382 psFree(chip->images); 383 } 384 385 papCell *papCellAlloc(papChip *chip, // Chip to which the cell belongs 386 const char *name, // Name of the cell 387 int nReadouts // Number of readouts contained 388 ) 389 { 390 papCell *cell = psAlloc(sizeof(papCell)); // The cell 391 psMemSetDeallocator(cell, (psFreeFcn)p_papCellFree); 392 psMetadataAdd(chip->cells, PS_LIST_TAIL, name, PS_META_CELL, "Added on allocation of cell", cell); 393 394 cell->values = psMetadataAlloc(); 395 cell->header = NULL; 396 397 cell->readouts = psArrayAlloc(nReadouts); 398 cell->images = NULL; 399 400 return cell; 401 } 402 403 void p_papCellFree(papCell *cell) 404 { 405 psFree(cell->values); 406 psFree(cell->header); 407 psFree(cell->readouts); 408 psFree(cell->images); 409 } 410 411 papReadout *papReadoutAlloc(papCell *cell, // Cell to which the readout belongs 412 int readoutNum, // Number of the readout 413 psImage *image, // The pixels 414 psList *overscans, // The overscan images 415 int col0, int row0, int colParity, int rowParity, int colBin, int rowBin // Data 416 ) 417 { 418 papReadout *readout = psAlloc(sizeof(papReadout)); 419 psMemSetDeallocator(readout, (psFreeFcn)p_papReadoutFree); 420 psArray *readouts = cell->readouts; 421 if (readoutNum >= readouts->nalloc) { 422 readouts = psArrayRealloc(readouts, readoutNum); 423 cell->readouts = readouts; 424 } 425 readouts->data[readoutNum] = readout; 426 427 // Set the components 428 readout->image = image; 429 readout->overscans = overscans; 430 431 readout->values = psMetadataAlloc(); 432 433 *(int*)&readout->col0 = col0; 434 *(int*)&readout->row0 = row0; 435 *(int*)&readout->colParity = colParity; 436 *(int*)&readout->rowParity = rowParity; 437 *(int*)&readout->colBins = colBin; 438 *(int*)&readout->rowBins = rowBin; 439 440 return readout; 441 } 442 443 void p_papReadoutFree(papReadout *readout) 444 { 445 psFree(readout->image); 446 psFree(readout->overscans); 447 psFree(readout->values); 448 } -
trunk/archive/scripts/src/papFocalPlane.h
r4092 r4309 3 3 4 4 #include "pslib.h" 5 #include "papStuff.h" 6 7 // Temporary metadata types 8 #define PS_META_CHIP PS_META_UNKNOWN 9 #define PS_META_CELL PS_META_UNKNOWN 10 5 11 6 12 typedef struct { 7 13 // How to get information 8 psMetadata *defaults; // IPP concepts supplied with defaults9 psMetadata *database; // IPP concepts supplied from database lookup10 psMetadata *fits;// IPP concepts supplied from FITS headers11 14 const psMetadata *defaults; // IPP concepts supplied with defaults 15 const psMetadata *database; // IPP concepts supplied from database lookup 16 const psMetadata *fits; // IPP concepts supplied from FITS headers 17 12 18 // A source of information 19 psMetadata *values; // Important values (cached) 13 20 psMetadata *header; // The FITS header 14 21 psDB *db; // The database handle … … 17 24 psMetadata *chips; // The chips (referred to by name) 18 25 19 ps Image *image; // The pixel data, if it corresponds to this level20 } p sFPA;26 psArray *images; // The pixel data, if it corresponds to this level 27 } papFPA; 21 28 22 29 typedef struct { … … 28 35 psMetadata *cells; // The cells (referred to by name) 29 36 30 ps Image *image; // The pixel data, if it corresponds to this level31 } p sChip;37 psArray *images; // The pixel data, if it corresponds to this level 38 } papChip; 32 39 33 40 typedef struct { … … 39 46 psArray *readouts; // The readouts (referred to by number) 40 47 41 ps Image *image; // The pixel data, if it corresponds to this level42 } p sCell;48 psArray *images; // The pixel data, if it corresponds to this level 49 } papCell; 43 50 44 51 … … 53 60 psList *overscans; // Array of subimages containing the overscan region(s) 54 61 psMetadata* values; // readout-level metadata 55 } p sReadout;62 } papReadout; 56 63 57 64 58 65 // Look for a particular value for a given cell (referred to by FPA+chip+cell) 59 psMetadataItem *psCellGetValue( const psFPA *fpa, // The FPA that contains the cell66 psMetadataItem *psCellGetValue(papFPA *fpa, // The FPA that contains the cell 60 67 const char *chipName, // The name of the chip 61 68 const char *cellName, // The name of the cell … … 64 71 65 72 // Type-specific functions provided as a convenience to the user 66 float psCellGetValueF32( const psFPA *fpa, // The FPA that contains the cell73 float psCellGetValueF32(papFPA *fpa, // The FPA that contains the cell 67 74 const char *chipName, // The name of the chip 68 75 const char *cellName, // The name of the cell 69 76 const char *valueName // Name of value 70 77 ); 71 int psCellGetValueS32( const psFPA *fpa, // The FPA that contains the cell78 int psCellGetValueS32(papFPA *fpa, // The FPA that contains the cell 72 79 const char *chipName, // The name of the chip 73 80 const char *cellName, // The name of the cell 74 81 const char *valueName // Name of value 75 82 ); 76 double psCellGetValueF64( const psFPA *fpa, // The FPA that contains the cell83 double psCellGetValueF64(papFPA *fpa, // The FPA that contains the cell 77 84 const char *chipName, // The name of the chip 78 85 const char *cellName, // The name of the cell 79 86 const char *valueName // Name of value 80 87 ); 81 psString psCellGetValueString( const psFPA *fpa, // The FPA that contains the cell88 psString psCellGetValueString(papFPA *fpa, // The FPA that contains the cell 82 89 const char *chipName, // The name of the chip 83 90 const char *cellName, // The name of the cell … … 86 93 87 94 95 // Allocators and deallocators 96 papFPA *papFPAAlloc(psMetadata *fits, // FITS translation info 97 psMetadata *database, // Database lookup info 98 psMetadata *defaults, // Defaults info 99 psDB *db // Database handle 100 ); 101 void p_papFPAFree(papFPA *fpa); 102 103 papChip *papChipAlloc(papFPA *fpa, // FPA to which the chip belongs 104 const char *name // Name of the chip 105 ); 106 void p_papChipFree(papChip *chip); 107 108 papCell *papCellAlloc(papChip *chip, // Chip to which the cell belongs 109 const char *name, // Name of the cell 110 int nReadouts // Number of readouts contained 111 ); 112 void p_papCellFree(papCell *cell); 113 114 papReadout *papReadoutAlloc(papCell *cell, // Cell to which the readout belongs 115 int readoutNum, // Number of the readout 116 psImage *image, // The pixels 117 psList *overscans, // The overscan images 118 int col0, int row0, int colParity, int rowParity, int colBin, int rowBin // Data 119 ); 120 void p_papReadoutFree(papReadout *readout); 121 88 122 #endif -
trunk/archive/scripts/src/papStuff.c
r4092 r4309 2 2 #include <string.h> 3 3 #include "pslib.h" 4 #include "papStuff.h" 4 5 5 6 // Split string on given characters … … 23 24 } else { 24 25 // We're at the end of the word 25 char *word = psStringNCopy(&string[start], i - start);26 psString word = psStringNCopy(&string[start], i - start); 26 27 (void)psListAdd(values, PS_LIST_TAIL, word); 27 28 start = i + 1; … … 31 32 if (start < length) { 32 33 // Copy the last word 33 char *word = psStringNCopy(&string[start], length - start);34 psString word = psStringNCopy(&string[start], length - start); 34 35 (void)psListAdd(values, PS_LIST_TAIL, word); 35 36 } -
trunk/archive/scripts/src/papStuff.h
r4092 r4309 4 4 #include "pslib.h" 5 5 6 // psString is a psLib version of a char* 7 typedef char* psString; 8 6 9 // Split string on given characters 7 10 psList *papSplit(const char *string, const char *splitters); -
trunk/archive/scripts/src/pmCameraFromHeader.c
r4092 r4309 2 2 #include <string.h> 3 3 #include "pslib.h" 4 #include "p smodule.h"4 #include "papmodule.h" 5 5 6 6 // Work out what camera we have, based on the FITS header and a set of rules specified in the IPP … … 31 31 } else if (instrumentItem->type == PS_META_STR) { 32 32 psTrace(__func__, 5, "Reading instrument configuration for %s...\n", instrumentItem->name); 33 instrument = psMetadata ParseConfig(NULL, NULL, instrumentItem->data.V, true);33 instrument = psMetadataConfigParse(NULL, NULL, instrumentItem->data.V, true); 34 34 } 35 35 -
trunk/archive/scripts/src/pmFPAFromHeader.c
r4092 r4309 80 80 } 81 81 82 bool extIsChips; // Are the extensions chips (true) or cells (false)?83 82 if (strcmp(extType, "CHIP") == 0) { 84 extIsChips = true; // Extensions are chips 85 } else if (strcmp(extType, "CELL") == 0) { 86 extIsChips = false; // Extensions are cells 87 } else { 88 psError(PS_ERR_IO, false, "EXTENSIONS in camera definition is neither CHIP or CELL.\n"); 89 psFree(fpa); 90 return NULL; 91 } 92 93 // Iterate through the contents 94 psMetadataIterator *contentsIter = psMetadataIteratorAlloc(contents, PS_LIST_HEAD, NULL); 95 psMetadataItem *contentItem = NULL; // Item from the metadata 96 while (contentItem = psMetadataGetAndIncrement(contentsIter)) { 97 const char *extName = contentItem->name; // The name of the extension 98 99 if (extIsChips) { 100 // Content contains a list of cells 83 // Extensions are chips; Content contains a list of cells 84 psMetadataIterator *contentsIter = psMetadataIteratorAlloc(contents, PS_LIST_HEAD, NULL); 85 psMetadataItem *contentItem = NULL; // Item from the metadata 86 while (contentItem = psMetadataGetAndIncrement(contentsIter)) { 87 const char *extName = contentItem->name; // The name of the extension 88 101 89 if (contentItem->type != PS_META_STR) { 102 90 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", … … 120 108 psMetadataAdd(fpa, PS_LIST_TAIL, extName, PS_META_META, "", chip); 121 109 } 122 } else { 123 // Content contains a chip name and cell type 110 } 111 psFree(contentsIter); 112 113 } else if (strcmp(extType, "CELL") == 0) { 114 // Extensions are cells; Content contains a chip name and cell type 115 psMetadataIterator *contentsIter = psMetadataIteratorAlloc(contents, PS_LIST_HEAD, NULL); 116 psMetadataItem *contentItem = NULL; // Item from the metadata 117 while (contentItem = psMetadataGetAndIncrement(contentsIter)) { 118 const char *extName = contentItem->name; // The name of the extension 119 124 120 if (contentItem->type != PS_META_STR) { 125 121 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", … … 148 144 } 149 145 } 150 151 } // Type of extension 152 } // Iterating through contents 153 psFree(contentsIter); 146 } 147 psFree(contentsIter); 148 } else if (strcmp(extType, "NONE") == 0) { 149 // No extensions; Content contains metadata, each entry is a chip with its component cells 150 psMetadataIterator *contentsIter = psMetadataIteratorAlloc(contents, PS_LIST_HEAD, NULL); 151 psMetadataItem *contentItem = NULL; // Item from the metadata 152 while (contentItem = psMetadataGetAndIncrement(contentsIter)) { 153 const char *chipName = contentItem->name; // The name of the chip 154 155 if (contentItem->type != PS_META_STR) { 156 psLogMsg(__func__, PS_LOG_WARN, "Type of content item (%x) is not string: ignored\n", 157 contentItem->type); 158 } else { 159 const char *content = contentItem->data.V; // The content of the extension 160 psMetadata *chip = psMetadataAlloc(); // The chip 161 psList *cellNames = papSplit(content, ", "); // Split the list of cells 162 psListIterator *cellNamesIter = psListIteratorAlloc(cellNames, PS_LIST_HEAD, false); 163 char *cellName = NULL; // Name of the cell 164 while (cellName = psListGetAndIncrement(cellNamesIter)) { 165 psMetadata *cell = getCellData(camera, cellName); 166 psMetadataAdd(cell, PS_LIST_HEAD, "EXTENSION", PS_META_STR, "", "PHU"); 167 psMetadataAdd(chip, PS_LIST_TAIL, cellName, PS_META_META, "", cell); 168 } 169 psFree(cellNamesIter); 170 // Add the chip onto the FPA 171 psMetadataAdd(fpa, PS_LIST_TAIL, chipName, PS_META_META, "", chip); 172 } 173 } 174 psFree(contentsIter); 175 } else { 176 psError(PS_ERR_IO, false, "EXTENSIONS in camera definition is not CHIP, CELL or NONE.\n"); 177 psFree(fpa); 178 return NULL; 179 } // Type of extension 154 180 155 181 } else if (strcmp(phuType, "CHIP") == 0) { -
trunk/archive/scripts/src/psAdditionals.c
r4093 r4309 2 2 #include <string.h> 3 3 #include "pslib.h" 4 #include "p smodule.h"4 #include "papmodule.h" 5 5 6 6 … … 35 35 36 36 37 c onst char *psMetadataLookupString(bool *status, const psMetadata *md, const char *key)37 char *psMetadataLookupString(bool *status, const psMetadata *md, const char *key) 38 38 { 39 39 psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments 40 c onst char *value = NULL;// The value to return40 char *value = NULL; // The value to return 41 41 if (!item) { 42 42 // The given key isn't in the metadata … … 64 64 } 65 65 66 papChip *psMetadataLookupChip(bool *status, const psMetadata *md, const char *key) 67 { 68 psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments 69 papChip *value = NULL; // The value to return 70 if (!item) { 71 // The given key isn't in the metadata 72 if (status) { 73 *status = false; 74 } else { 75 psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n"); 76 } 77 } else if (item->type != PS_META_CHIP) { 78 // The value at the key isn't metadata 79 if (status) { 80 *status = false; 81 } else { 82 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_META_CHIP, as expected.\n"); 83 } 84 value = NULL; 85 } else { 86 // We have the requested metadata 87 if (status) { 88 *status = true; 89 } 90 value = item->data.V; // The requested metadata 91 } 92 return value; 93 } 94 95 papCell *psMetadataLookupCell(bool *status, const psMetadata *md, const char *key) 96 { 97 psMetadataItem *item = psMetadataLookup((psMetadata*)md, key); // The metadata with instruments 98 papCell *value = NULL; // The value to return 99 if (!item) { 100 // The given key isn't in the metadata 101 if (status) { 102 *status = false; 103 } else { 104 psError(PS_ERR_IO, true, "Couldn't find %s in the metadata.\n"); 105 } 106 } else if (item->type != PS_META_CELL) { 107 // The value at the key isn't metadata 108 if (status) { 109 *status = false; 110 } else { 111 psLogMsg(__func__, PS_LOG_WARN, "%s isn't of type PS_META_CHIP, as expected.\n"); 112 } 113 value = NULL; 114 } else { 115 // We have the requested metadata 116 if (status) { 117 *status = true; 118 } 119 value = item->data.V; // The requested metadata 120 } 121 return value; 122 } 66 123 67 124 void psMetadataPrint(psMetadata *md, int level) -
trunk/archive/scripts/src/psAdditionals.h
r4093 r4309 8 8 9 9 // Get a value from the metadata that we believe should be a string 10 const char *psMetadataLookupString(bool *status, const psMetadata *md, const char *key); 10 char *psMetadataLookupString(bool *status, const psMetadata *md, const char *key); 11 12 papChip *psMetadataLookupChip(bool *status, const psMetadata *md, const char *key); 13 papCell *psMetadataLookupCell(bool *status, const psMetadata *md, const char *key); 14 11 15 12 16 // Print out the metadata
Note:
See TracChangeset
for help on using the changeset viewer.
