Changeset 404
- Timestamp:
- Apr 8, 2004, 1:22:10 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (19 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r397 r404 1 %%% $Id: psLibSDRS.tex,v 1.3 3 2004-04-08 02:13:17price Exp $1 %%% $Id: psLibSDRS.tex,v 1.34 2004-04-08 23:22:10 price Exp $ 2 2 \documentclass[panstarrs]{panstarrs} 3 3 … … 489 489 490 490 \subsubsection{Relation of Memory Management to Structures} 491 \label{sec:free} 491 492 492 493 In this document, we specify several C \code{struct}s. It is expected … … 2477 2478 const int id; ///< unique ID for this item 2478 2479 char *restrict name; ///< Name of item 2479 psMeta DataType type; ///< type of this item2480 psMeta DataFlags flags; ///< flags associated with this item2480 psMetadataType type; ///< type of this item 2481 psMetadataFlags flags; ///< flags associated with this item 2481 2482 const union { 2482 2483 double d; ///< double value … … 2486 2487 } val; ///< value of metadata 2487 2488 char *comment; ///< optional comment ("", not NULL) 2488 psDlist *restrict items; ///< list of psMeta DataItems with the same name2489 } psMeta DataItem;2489 psDlist *restrict items; ///< list of psMetadataItems with the same name 2490 } psMetadataItem; 2490 2491 \end{verbatim} 2491 2492 … … 2493 2494 shows that such tags are useful. 2494 2495 2495 The \code{psMeta DataType type} entry specifies the type of the data2496 The \code{psMetadataType type} entry specifies the type of the data 2496 2497 being represented; the possibilities are listed in section \ref{metadataTypes}. 2497 2498 … … 2500 2501 2501 2502 The possible types of metadata are identified by the enumerated type 2502 \code{psMeta DataType} (see also table \ref{tabMetaDataTypes}); the initial defined values are:2503 \code{psMetadataType} (see also table \ref{tabMetaDataTypes}); the initial defined values are: 2503 2504 \begin{verbatim} 2504 2505 /** Possible types of metadata. */ 2505 2506 typedef enum { ///< type of val is: 2506 PS_META_ITEM_SET = 0, ///< NULL; metadata is in psMeta DataType.items2507 PS_META_ITEM_SET = 0, ///< NULL; metadata is in psMetadataType.items 2507 2508 PS_META_FLOAT, ///< float (.f) 2508 2509 PS_META_INT, ///< int (.i) … … 2514 2515 PS_META_UNKNOWN, ///< other (.v) 2515 2516 PS_META_NTYPE ///< Number of types; must be last 2516 } psMeta DataType;2517 } psMetadataType; 2517 2518 \end{verbatim} 2518 2519 … … 2542 2543 /** A set of metadata */ 2543 2544 typedef struct { 2544 psDlist *restrict list; ///< list of psMeta DataItem2545 psDlist *restrict list; ///< list of psMetadataItem 2545 2546 psHash *restrict table; ///< hash table of the same metadata 2546 } psMeta DataSet;2547 \end{verbatim} 2548 2549 The type \code{psMeta DataSet} is a container class for metadata. Note2547 } psMetadata; 2548 \end{verbatim} 2549 2550 The type \code{psMetadata} is a container class for metadata. Note 2550 2551 that there are in fact \emph{two} representations of the metadata 2551 (each \code{psMeta DataItem} appears on both). The first2552 (each \code{psMetadataItem} appears on both). The first 2552 2553 representation employs a doubly-linked list that allows the order of 2553 2554 the metadata to be preserved (e.g., if FITS headers are read in a … … 2557 2558 2558 2559 When we refer to ``metadata'' (especially in the case of images), we 2559 generally mean a \code{psMeta DataSet}:2560 \begin{verbatim} 2561 typedef psMeta DataSetpsMetadata;2560 generally mean a \code{psMetadata}: 2561 \begin{verbatim} 2562 typedef psMetadata psMetadata; 2562 2563 \end{verbatim} 2563 2564 … … 2566 2567 for (int i = 0; i < 10; i += 5) { 2567 2568 float sqrti = sqrt(i); 2568 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_INT, &i, NULL, "const.%d", i));2569 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_FLOAT, &sqrti, "square root", "const.sqrt%d", i));2569 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_INT, &i, NULL, "const.%d", i)); 2570 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_FLOAT, &sqrti, "square root", "const.sqrt%d", i)); 2570 2571 } 2571 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_STR, "Bonjour", "French", "lang.hello"));2572 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_STR, "Bonjour", "French", "lang.hello")); 2572 2573 /* 2573 2574 * Remove a key 2574 2575 */ 2575 psMeta DataItemFree(psMetaDataRemove(ms, "lang.hello"));2576 psMetadataItemFree(psMetadataRemove(ms, "lang.hello")); 2576 2577 /* 2577 2578 * Print all metadata 2578 2579 */ 2579 2580 fprintf(stdout, "------\n"); 2580 psMeta DataSetIterator(ms);2581 while ((meta = psMeta DataGetNext(ms, NULL)) != NULL) {2582 psMeta DataItemPrint(stdout, meta, "");2581 psMetadataSetIterator(ms); 2582 while ((meta = psMetadataGetNext(ms, NULL)) != NULL) { 2583 psMetadataItemPrint(stdout, meta, ""); 2583 2584 } 2584 2585 /* … … 2587 2588 fprintf(stdout, "------\n"); 2588 2589 fprintf(stdout, "Looking up by name:\n"); 2589 meta = psMeta DataLookup(ms, "const.5");2590 meta = psMetadataLookup(ms, "const.5"); 2590 2591 if (meta != NULL) { 2591 psMeta DataItemPrint(stdout, meta, "");2592 psMetadataItemPrint(stdout, meta, ""); 2592 2593 } 2593 2594 \end{verbatim} 2594 2595 2595 \subsubsection{Naming convention for Meta Data}2596 2597 The \code{psMeta DataItem} struct includes a name. This name should be of2596 \subsubsection{Naming convention for Metadata} 2597 2598 The \code{psMetadataItem} struct includes a name. This name should be of 2598 2599 the form \code{name1.name2.name3}$\cdots$, e.g.\hfil\break 2599 2600 \null\qquad\qquad\code{IPP.phase1.ota12.biassec}. … … 2606 2607 2607 2608 \begin{verbatim} 2608 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,2609 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE, 2609 2610 "Bonjour", "French", "lang.hello")); 2610 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,2611 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE, 2611 2612 "Aloha", "Hawaiian", "lang.hello")); 2612 psMeta DataAppend(ms, psMetaDataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE,2613 psMetadataAppend(ms, psMetadataItemAlloc(PS_META_STR | PS_META_NON_UNIQUE, 2613 2614 "Good Morning", "English", "lang.hello")); 2614 2615 /* 2615 2616 * Print all metadata starting "lang" 2616 2617 */ 2617 psMeta DataSetIterator(ms);2618 while ((meta = psMeta DataGetNext(ms, "lang")) != NULL) {2619 psMeta DataItemPrint(stdout, meta, "");2618 psMetadataSetIterator(ms); 2619 while ((meta = psMetadataGetNext(ms, "lang")) != NULL) { 2620 psMetadataItemPrint(stdout, meta, ""); 2620 2621 } 2621 2622 \end{verbatim} … … 2623 2624 It is an unfortunate fact that certain metadata keywords (such as 2624 2625 \code{COMMENT} and \code{HISTORY} in a FITS header) may be repeated 2625 with different values. The \code{psMeta DataAppend} routine is2626 with different values. The \code{psMetadataAppend} routine is 2626 2627 required to check that all metadata names are unique unless the type 2627 2628 is qualified as \code{PS_META_NON_UNIQUE}; in this case a unique … … 2629 2630 may either delete individual element separately or as a complete set: 2630 2631 \begin{verbatim} 2631 psMeta DataItemFree(psMetaDataRemove(ms, "lang.hello.0"));2632 psMeta DataItemFree(psMetaDataRemove(ms, "lang.hello"));2633 \end{verbatim} 2634 2635 \subsubsection{Meta Data APIs}2632 psMetadataItemFree(psMetadataRemove(ms, "lang.hello.0")); 2633 psMetadataItemFree(psMetadataRemove(ms, "lang.hello")); 2634 \end{verbatim} 2635 2636 \subsubsection{Metadata APIs} 2636 2637 2637 2638 In this section, we explain the metadata APIs more fully. 2638 2639 2639 The allocator for \code{psMeta DataItem} returns a full2640 \code{psMeta DataItem} ready for insertion into the2641 \code{psMeta DataSet}. It is important to note that, in order to2640 The allocator for \code{psMetadataItem} returns a full 2641 \code{psMetadataItem} ready for insertion into the 2642 \code{psMetadata}. It is important to note that, in order to 2642 2643 support multiple types, the data being input must be a pointer, even 2643 2644 if it is a \code{float} or \code{int}, for example. The name of the 2644 \code{psMeta DataItem} takes a \code{sprintf} format string, with the2645 \code{psMetadataItem} takes a \code{sprintf} format string, with the 2645 2646 corresponding arguments following. 2646 2647 2647 Note that the destructor does not 2648 Note that the destructor for \code{psMetadataItem} must call the 2649 appropriate destructor for the \code{val} (recall that it is the duty 2650 of the \code{psMyTypeFree}s to decrement the \code{refCounter} and 2651 free the memory if and only if the new value of the \code{refCounter} 2652 is zero --- see \S\ref{sec:free}). 2648 2653 2649 2654 \begin{verbatim} 2650 2655 /** Constructor */ 2651 psMeta DataItem *psMetaDataItemAlloc(int typeFlags, ///< type of this piece of metadata + flags2656 psMetadataItem *psMetadataItemAlloc(int typeFlags, ///< type of this piece of metadata + flags 2652 2657 const void *val, ///< value of new item N.b. a pointer even if the item 2653 2658 ///< is of type e.g. int … … 2659 2664 2660 2665 /** Destructor */ 2661 void psMetaDataItemFree(psMetaDataItem *ms ///< piece of metadata to destroy 2662 ); 2666 void psMetadataItemFree(psMetadataItem *ms ///< piece of metadata to destroy 2667 ); 2668 \end{verbatim} 2669 2670 2671 The constructor for the collection of metadata, \code{psMetadata}, 2672 simply returns an empty metadata container (employing the constructors 2673 for the doubly-linked list and hash table). The destructor needs to 2674 free each of the \code{psMetadataItem}s using 2675 \code{psMetadataItemFree}. 2676 2677 \begin{verbatim} 2663 2678 /** Constructor */ 2664 psMeta DataSet *psMetaDataSetAlloc(void); ///< make a new set of metadata2679 psMetadata *psMetadataAlloc(void); ///< make a new set of metadata 2665 2680 2666 2681 /** Destructor */ 2667 void psMetaDataSetFree(psMetaDataSet *ms ///< destroy a set of metadata 2668 ); 2669 2670 /**** Utilities **********************************************************************/ 2671 2672 /// Add entry to the end of the metadata set 2673 psMetaDataItem *psMetaDataAppend(psMetaDataSet *restrict ms, ///< Metadata set to add to 2674 psMetaDataItem *restrict item ///< Metatdata to add 2675 ); 2676 2677 /// delete entry from the metadata set 2678 psMetaDataItem *psMetaDataRemove(psMetaDataSet *restrict ms, ///< Metadata set to delete from 2682 void psMetadataFree(psMetadata *md ///< destroy a set of metadata 2683 ); 2684 \end{verbatim} 2685 2686 2687 Items may be added to the metadata in one of two ways --- firstly, an 2688 item may be added by appending a \code{psMetadataItem} which has 2689 already been created; and secondly by directly providing the data to 2690 be appended. In both cases, the \code{psMetadataItem} that is 2691 appended to the metadata is returned. 2692 2693 \begin{verbatim} 2694 /// Add item to the end of the metadata 2695 psMetadataItem *psMetadataAppendItem(psMetadata *restrict md, ///< metadata to add to 2696 psMetadataItem *restrict item ///< Metatdata to add 2697 ); 2698 2699 /// Add item to the end of the metadata. Combines psMetadataItemAlloc and psMetadataAppendItem 2700 psMetadataItem *psMetadataAppend(psMetadata *restrict md, ///< Metadata to add to 2701 int typeFlags ///< type of this piece of metadata + flags 2702 const void *val, ///< value of new item N.b. a pointer even if the item 2703 ///< is of type e.g. int 2704 const char *comment, ///< comment associated with item 2705 const char *name, ///< name of new item of metadata (may be in sprintf 2706 ///< format) 2707 ... ///< possible arguments for name format 2708 ); 2709 \end{verbatim} 2710 2711 Items may be removed from the metadata by specifying a key. If the 2712 key matches a metadata item, the item is removed from the metadata and 2713 returned; otherwise, \code{NULL} is returned. If the key is not 2714 unique, then \emph{all} items corresponding to the key are removed, 2715 and the \tbd{first} item is returned. 2716 2717 \begin{verbatim} 2718 /// delete entry from the metadata 2719 psMetadataItem *psMetadataRemove(psMetadata *restrict md, ///< metadata to delete from 2679 2720 const char *restrict key ///< Key to delete 2680 2721 ); 2681 2722 \end{verbatim} 2723 2724 The metadata may be iterated over by (re-)setting the iterator for the 2725 appropriate \code{psMetadata}, and getting the next item. 2726 \code{psMetadataGetNext} has the ability to match the beginning of a 2727 key, e.g., if the user only wants to iterate through 2728 \code{IPP.machines.sky} and doesn't want to bother with 2729 \code{IPP.machines.detector}. 2730 2731 \begin{verbatim} 2682 2732 /// reset the iterator to the start of the list 2683 void psMeta DataSetIterator(psMetaDataSet *ms ///< Metadata setto set iterator for2733 void psMetadataSetIterator(psMetadata *md ///< metadata to set iterator for 2684 2734 ); 2685 2735 2686 2736 /// get the next entry in the sequence 2687 psMeta DataItem *psMetaDataGetNext(psMetaDataSet *restrict ms, ///< Metadata setto get from2737 psMetadataItem *psMetadataGetNext(psMetadata *restrict md, ///< metadata to get from 2688 2738 const char *restrict match ///< Match this 2689 2739 ); 2690 2740 \end{verbatim} 2741 2742 Items may be found within the metadata by providing a key. In the 2743 event that the key is non-unique, the first item is returned. 2744 2745 \begin{verbatim} 2691 2746 /// find the metadata with the specified key 2692 psMeta DataItem *psMetaDataLookup(const psMetaDataSet *restrict ms, ///< Metadata setto look up2747 psMetadataItem *psMetadataLookup(const psMetadata *restrict md, ///< metadata to look up 2693 2748 const char *restrict key ///< Key to find 2694 2749 ); 2695 2750 \end{verbatim} 2751 2752 Metadata items may be printed to an open file descriptor, optionally 2753 pre-pending a specified string. 2754 2755 \begin{verbatim} 2696 2756 /// print metadata item to the specified stream 2697 void psMeta DataItemPrint(FILE *fd, ///< file descriptor to write to2698 const psMeta DataItem *restrict ms, ///< item of metadata to print2757 void psMetadataItemPrint(FILE *fd, ///< file descriptor to write to 2758 const psMetadataItem *restrict md, ///< item of metadata to print 2699 2759 const char *prefix ///< print this at the beginning of each line 2700 2760 ); … … 3053 3113 psDlist *objects; ///< objects derived from cell 3054 3114 psImage *overscan; ///< bias region (subimage) of cell 3055 psMeta DataSet*md; ///< Readout-level metadata3115 psMetadata *md; ///< Readout-level metadata 3056 3116 } psReadout; 3057 3117 \end{verbatim} … … 3081 3141 ///< image, objects and overscan. 3082 3142 struct psReadout *readouts; ///< Readouts from the cell 3083 psMeta DataSet*md; ///< Cell-level metadata3143 psMetadata *md; ///< Cell-level metadata 3084 3144 3085 3145 psCoordXform *cellToChip; ///< Transformations from cell coordinates to chip coordinates … … 3111 3171 psCell *cells; ///< Cells in the Chip 3112 3172 3113 psMeta DataSet*md; ///< Chip-level metadata3173 psMetadata *md; ///< Chip-level metadata 3114 3174 psCoordXform *chipToFPA; ///< Transformations from chip coordinates to FPA coordinates 3115 3175 psCoordXform *FPAtoChip; ///< Transformations from FPA coordinates to chip … … 3147 3207 psChip *chips; ///< Chips in the Focal Plane Array 3148 3208 3149 psMeta DataSet*md; ///< FPA-level metadata3209 psMetadata *md; ///< FPA-level metadata 3150 3210 psDistortion *TPtoFP; ///< Transformation term from 3151 3211 psDistortion *FPtoTP; ///< Transformation term from
Note:
See TracChangeset
for help on using the changeset viewer.
