Changeset 4242 for trunk/doc/pslib/psLibSDRS.tex
- Timestamp:
- Jun 13, 2005, 4:19:36 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (46 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r4239 r4242 1 %%% $Id: psLibSDRS.tex,v 1.27 5 2005-06-13 22:41:59price Exp $1 %%% $Id: psLibSDRS.tex,v 1.276 2005-06-14 02:19:36 price Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 790 790 \subsubsection{Type information} 791 791 792 We need to be able to specify two different sorts of types. 793 794 The first, for use with math structures (\S\ref{sec:mathStructures}), 795 defines a numerical type; e.g., short integer, double-precision 796 floating point, etc: 797 798 \begin{datatype} 799 typedef enum { 800 PS_TYPE_S8, ///< Character 801 PS_TYPE_S16, ///< Short integer 802 PS_TYPE_S32, ///< Integer 803 PS_TYPE_S64, ///< Long integer 804 PS_TYPE_U8, ///< Unsigned character 805 PS_TYPE_U16, ///< Unsigned short integer 806 PS_TYPE_U32, ///< Unsigned integer 807 PS_TYPE_U64, ///< Unsigned long integer 808 PS_TYPE_F32, ///< Floating point 809 PS_TYPE_F64, ///< Double-precision floating point 810 PS_TYPE_C32, ///< Complex numbers consisting of floats 811 PS_TYPE_C64, ///< Complex numbers consisting of doubles 812 PS_TYPE_BOOL ///< Boolean value 813 } psElemType; 814 \end{datatype} 815 816 817 The second, primarily for use with the metadata 818 (\S\ref{sec:metadata}), defines a data structure; e.g., list, array, 819 FITS file: 820 821 \begin{datatype} 822 typedef enum { ///< type of item.data is: 823 PS_DATA_S32 = PS_TYPE_S32, ///< psS32 824 PS_DATA_F32 = PS_TYPE_F32, ///< psF32 825 PS_DATA_F64 = PS_TYPE_F64, ///< psF64 826 PS_DATA_BOOL = PS_TYPE_BOOL, ///< psBool 827 PS_DATA_STRING = 0x10000, ///< String (char *) 828 PS_DATA_ARRAY, ///< psArray 829 PS_DATA_BITSET, ///< psBitSet 830 PS_DATA_CELL, ///< psCell 831 PS_DATA_CHIP, ///< psChip 832 PS_DATA_CUBE, ///< psCube 833 PS_DATA_FITS, ///< psFits 834 PS_DATA_HASH, ///< psHash 835 PS_DATA_HISTOGRAM, ///< psHistogram 836 PS_DATA_IMAGE, ///< psImage 837 PS_DATA_KERNEL, ///< psKernel 838 PS_DATA_LIST, ///< psList 839 PS_DATA_LOOKUPTABLE, ///< psLookupTable 840 PS_DATA_METADATA, ///< psMetadata 841 PS_DATA_METADATAITEM, ///< psMetadataItem 842 PS_DATA_MINIMIZATION, ///< psMinimization 843 PS_DATA_PIXELS, ///< psPixels 844 PS_DATA_PLANE, ///< psPlane 845 PS_DATA_PLANEDISTORT, ///< psPlaneDistort 846 PS_DATA_PLANETRANSFORM, ///< psPlaneTransform 847 PS_DATA_POLYNOMIAL1D, ///< psPolynomial1D 848 PS_DATA_POLYNOMIAL2D, ///< psPolynomial2D 849 PS_DATA_POLYNOMIAL3D, ///< psPolynomial3D 850 PS_DATA_POLYNOMIAL4D, ///< psPolynomial4D 851 PS_DATA_PROJECTION, ///< psProjection 852 PS_DATA_READOUT, ///< psReadout 853 PS_DATA_REGION, ///< psRegion 854 PS_DATA_SCALAR, ///< psScalar 855 PS_DATA_SPHERE, ///< psSphere 856 PS_DATA_SPHERETRANSFORM, ///< psSphereTransform 857 PS_DATA_SPLINE1D, ///< psSpline1D 858 PS_DATA_STATS, ///< psStats 859 PS_DATA_TIME, ///< psTime 860 PS_DATA_VECTOR, ///< psVector 861 PS_DATA_UNKNOWN, ///< Other data of an unknown type 862 PS_DATA_METADATA_MULTI ///< Used internally for metadata; not a 'real' type 863 } psDataType; 864 \end{datatype} 865 866 Here we have not included every type of structure used in PSLib, but 867 only those we expect will be frequently carried around in containers. 868 We include \code{PS_DATA_S32, PS_DATA_F32, PS_DATA_F64} and 869 \code{PS_DATA_BOOL} since the metadata use these, and we set them to 870 the same values as in \code{psElemType}. 871 872 The other values are offset from these ``primitive'' types so that 873 they can be identified easily. A macro, 874 \code{PS_DATA_IS_PRIMITIVE(type)}, shall return \code{true} if the 875 type is one of the numerical data types (S32, F32, F64, bool). In 876 such a case, the data value is directly available from the metadata. 877 Otherwise, a pointer to the data is available. 878 879 \code{PS_DATA_METADATA_MULTI} is used by the metadata, so the user 880 should not use this type. 881 882 \subsubsection{Type checking} 883 792 884 Several of the collections contain data using a \code{void*} pointer. 793 885 This makes it difficult to ensure that data coming off a collection is … … 802 894 803 895 \begin{prototype} 896 psDataType psMemGetType(psPtr ptr); 897 \end{prototype} 898 804 899 bool psMemCheckArray(psPtr ptr); 805 900 bool psMemCheckBitSet(psPtr ptr); … … 842 937 843 938 \begin{prototype} 844 bool psMemCheckType(psType type, psPtr ptr); 845 \end{prototype} 846 847 \tbd{Need to define psType.} 939 bool psMemCheckType(psDataType type, psPtr ptr); 940 \end{prototype} 941 942 The reason for having functions that check the type instead of 943 returning the type is that the check is quick and the result is clean, 944 while returning the type involves descending through a case statement. 848 945 849 946 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 2072 2169 const psS32 id; ///< unique ID for this item 2073 2170 char *name; ///< Name of item 2074 ps MetadataType type;///< type of this item2171 psDataType type; ///< type of this item 2075 2172 const union { 2076 2173 psS32 S32; ///< integer data … … 2094 2191 \code{comment}. The \code{type} entry specifies how to interpret the 2095 2192 type of the data being represented, given by the enumerated type 2096 \code{psMetadataType}: 2097 % 2098 \filbreak 2099 \begin{datatype} 2100 typedef enum { ///< type of item.data is: 2101 PS_META_S32 = PS_TYPE_S32, ///< psS32 primitive data. 2102 PS_META_F32 = PS_TYPE_F32, ///< psF32 primitive data. 2103 PS_META_F64 = PS_TYPE_F64, ///< psF64 primitive data. 2104 PS_META_BOOL = PS_TYPE_BOOL, ///< psBool primitive data. 2105 PS_META_LIST = 0x10000, ///< List data (Stored as item.data.list). 2106 PS_META_STR, ///< String data (Stored as item.data.V). 2107 PS_META_META, ///< Metadata (Stored as item.data.md). 2108 PS_META_VEC, ///< Vector data (Stored as item.data.V). 2109 PS_META_IMG, ///< Image data (Stored as item.data.V). 2110 PS_META_HASH, ///< Hash data (Stored as item.data.V). 2111 PS_META_LOOKUPTABLE, ///< Lookup table data (Stored as item.data.V). 2112 PS_META_JPEG, ///< JPEG data (Stored as item.data.V). 2113 PS_META_PNG, ///< PNG data (Stored as item.data.V). 2114 PS_META_ASTROM, ///< Astrometric coefficients (Stored as item.data.V). 2115 PS_META_TIME, ///< psTime object (Stored as item.data.V). 2116 PS_META_UNKNOWN, ///< Other data (Stored as item.data.V). 2117 PS_META_MULTI ///< Used internally, do not create a metadata item of this type. 2118 } psMetadataType; 2119 \end{datatype} 2120 The macro \code{PS_META_IS_PRIMITIVE(psMetadataType.type)} returns 2121 true if the type is one of the primitive data types (S32, F64, etc). 2122 In such a case, the data value is directly available. Otherwise, a 2123 pointer to the data is available. 2193 \code{psDataType}. 2124 2194 2125 2195 A collection of metadata is represented by the \code{psMetadata} structure: … … 2146 2216 \code{psMetadata.hash} entries, which are required to have unique 2147 2217 keys, would have a single entry with the keyword of the repeated key, 2148 with the value of \code{ps MetadataType} set to \code{PS_META_MULTI},2218 with the value of \code{psDataType} set to \code{PS_DATA_METADATA_MULTI}, 2149 2219 and the \code{psMetadataItem.data} element pointing to a \code{psList} 2150 2220 containing the actual entries. If \code{psMetadataItemAlloc} is 2151 called with the type set to \code{PS_ META_MULTI}, such a repeated key2221 called with the type set to \code{PS_DATA_METADATA_MULTI}, such a repeated key 2152 2222 is created. In this case, the data value passed to 2153 2223 \code{psMetadataItemAlloc} (the quantity in ellipsis) must be … … 2163 2233 psMetadataItem* psMetadataItemAllocS32(const char* name, const char* comment, psS32 value); 2164 2234 psMetadataItem* psMetadataItemAllocBool(const char* name, const char* comment, bool value); 2165 psMetadataItem* psMetadataItemAllocPtr(const char* name, ps MetadataType type, const char* comment, psPtr value);2235 psMetadataItem* psMetadataItemAllocPtr(const char* name, psDataType type, const char* comment, psPtr value); 2166 2236 \end{prototype} 2167 2237 … … 2178 2248 2179 2249 \begin{prototype} 2180 psMetadataItem *psMetadataItemAlloc(const char *name, ps MetadataType type, const char *comment, ...);2181 psMetadataItem *psMetadataItemAllocV(const char *name, ps MetadataType type, const char *comment, va_list list);2250 psMetadataItem *psMetadataItemAlloc(const char *name, psDataType type, const char *comment, ...); 2251 psMetadataItem *psMetadataItemAllocV(const char *name, psDataType type, const char *comment, va_list list); 2182 2252 \end{prototype} 2183 2253 … … 2215 2285 the \code{psList}. The entry \code{mode} for \code{psMetadataAddItem} 2216 2286 is a bit mask constructed by OR-ing the allowed option flags (eg, 2217 \code{PS_ META_REPLACE}) which specify minor variations on the2287 \code{PS_DATA_REPLACE}) which specify minor variations on the 2218 2288 behavior. The \code{format} entry, which specifies both the metadata 2219 2289 type and the optional flags, is constructed by bit-wise OR-ing the 2220 appropriate \code{ps MetadataType} and allowed option flags. Care2290 appropriate \code{psDataType} and allowed option flags. Care 2221 2291 should be taken not to leak memory when appending an item for which 2222 2292 the key already exists in the metadata (and is not 2223 \code{PS_ META_MULTI}).2293 \code{PS_DATA_METADATA_MULTI}). 2224 2294 % 2225 2295 … … 2235 2305 The functions above take option flags which modify the behavior when 2236 2306 metadata items are added to the metadata list. These flags must be 2237 bit-exclusive of those used above for the \code{ps MetadataTypes}. The2307 bit-exclusive of those used above for the \code{psDataTypes}. The 2238 2308 flags have the following meanings: 2239 2309 2240 2310 \code{PS_META_DEFAULT}: This is the zero bit mask, to allow the 2241 2311 default behavior for \code{psMetadataAddItem} above. If this is OR-ed 2242 with a \code{ps MetadataType}, the result is as if no OR-ing took2312 with a \code{psDataType}, the result is as if no OR-ing took 2243 2313 place. 2244 2314 … … 2248 2318 2249 2319 \code{PS_META_DUPLICATE_OK}: Allow the new metadata item key to be a 2250 duplicate (ie, \code{PS_META_MULTI}). If an existing item with the 2251 same key is already \code{PS_META_MULTI}, the new item is added to the 2252 \code{PS_META_MULTI} list. If the existing item is not 2253 \code{PS_META_MULTI}, a \code{PS_META_MULTI} list is created to 2254 contain both the existing item and the new item. The original entry's 2255 location on the psMetadata.list must be maintained. 2256 2257 \code{PS_META_NULL}: Indicates that \code{psMetadataItem.data} should be 2258 ignored and that the the current value is ``NULL'' or undefined. The 2259 \code{psMetadataItem} must have a proper \code{type} set and it's \code{data} 2260 field shall have a valid value. e.g. A \code{type} of \code{PS_META_STR} would 2261 require that 's \code{data} is set to \code{NULL}. 2320 duplicate (ie, \code{PS_DATA_METADATA_MULTI}). If an existing item 2321 with the same key is already \code{PS_DATA_METADATA_MULTI}, the new 2322 item is added to the \code{PS_DATA_METADATA_MULTI} list. If the 2323 existing item is not \code{PS_DATA_METADATA_MULTI}, a 2324 \code{PS_DATA_METADATA_MULTI} list is created to contain both the 2325 existing item and the new item. The original entry's location on the 2326 psMetadata.list must be maintained. 2327 2328 \code{PS_META_NULL}: Indicates that \code{psMetadataItem.data} should 2329 be ignored and that the the current value is ``NULL'' or undefined. 2330 The \code{psMetadataItem} must have a proper \code{type} set and it's 2331 \code{data} field shall have a valid value. e.g. A \code{type} of 2332 \code{PS_DATA_STR} would require that its \code{data} is set to 2333 \code{NULL}. 2262 2334 2263 2335 There are several of cases to handle for duplication of an existing … … 2265 2337 must also be handled: 2266 2338 2267 If the new key already exists, but is not \code{PS_META_MULTI}, and 2268 the new item is not flagged as either \code{PS_META_DUPLICATE_OK} or 2269 \code{PS_META_REPLACE}, an error is raised. 2339 If the new key already exists, but is not 2340 \code{PS_DATA_METADATA_MULTI}, and the new item is not flagged as 2341 either \code{PS_META_DUPLICATE_OK} or \code{PS_META_REPLACE}, an error 2342 is raised. 2270 2343 2271 2344 If the new key already exists, and the existing item is 2272 \code{PS_META_MULTI}, the new item is added to the MULTI list. Note 2273 that if the new item is also of type \code{PS_META_MULTI}, no action 2274 is taken, but a successful exit status is returned (the action of 2275 adding a \code{PS_META_MULTI} item to the metadata is equivalent to 2276 setting that key to be tagged as \code{PS_META_MULTI}. If it is 2277 {\em already} \code{PS_META_MULTI}, this effect has already been 2278 achieved). 2345 \code{PS_DATA_METADATA_MULTI}, the new item is added to the MULTI 2346 list. Note that if the new item is also of type 2347 \code{PS_DATA_METADATA_MULTI}, no action is taken, but a successful 2348 exit status is returned (the action of adding a 2349 \code{PS_DATA_METADATA_MULTI} item to the metadata is equivalent to 2350 setting that key to be tagged as \code{PS_DATA_METADATA_MULTI}. If it 2351 is {\em already} \code{PS_DATA_METADATA_MULTI}, this effect has 2352 already been achieved). 2279 2353 2280 2354 An example of code to use these metadata APIs to generate the … … 2284 2358 md = psMetadataAlloc(); 2285 2359 2286 psMetadataAdd(md, PS_LIST_TAIL, "SIMPLE", PS_ META_BOOL, "basic fits", TRUE);2287 psMetadataAdd(md, PS_LIST_TAIL, "BLANK", PS_ META_S32, "invalid pixel data", -32768);2288 psMetadataAdd(md, PS_LIST_TAIL, "DATE-OBS", PS_ META_STR, "observing date UT", " 2004-6-16");2289 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_ META_LIST, "head of comment block", NULL);2290 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_ META_STR, "", "DATA");2291 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_ META_STR, "", "PARAMS");2292 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_ META_F32, "exposure time (sec)", 1.05);2293 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_ META_STR, "", "FOO");2360 psMetadataAdd(md, PS_LIST_TAIL, "SIMPLE", PS_DATA_BOOL, "basic fits", TRUE); 2361 psMetadataAdd(md, PS_LIST_TAIL, "BLANK", PS_DATA_S32, "invalid pixel data", -32768); 2362 psMetadataAdd(md, PS_LIST_TAIL, "DATE-OBS", PS_DATA_STR, "observing date UT", " 2004-6-16"); 2363 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_DATA_LIST, "head of comment block", NULL); 2364 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_DATA_STR, "", "DATA"); 2365 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_DATA_STR, "", "PARAMS"); 2366 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_DATA_F32, "exposure time (sec)", 1.05); 2367 psMetadataAdd(md, PS_LIST_TAIL, "COMMENT", PS_DATA_STR, "", "FOO"); 2294 2368 2295 2369 cell = psMetadataAlloc(); 2296 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_ META_STR, "", "CCD00");2297 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_ META_STR, "", "BSEC-00");2298 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_ META_STR, "", "CHIP.00");2299 psMetadataAdd(md, PS_LIST_TAIL, "CELL.00", PS_ META_META, "", cell);2370 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_DATA_STR, "", "CCD00"); 2371 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_DATA_STR, "", "BSEC-00"); 2372 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_DATA_STR, "", "CHIP.00"); 2373 psMetadataAdd(md, PS_LIST_TAIL, "CELL.00", PS_DATA_META, "", cell); 2300 2374 2301 2375 cell = psMetadataAlloc(); 2302 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_ META_STR, "", "CCD01");2303 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_ META_STR, "", "BSEC-01");2304 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_ META_STR, "", "CHIP.01");2305 psMetadataAdd(md, PS_LIST_TAIL, "CELL.01", PS_ META_META, "", cell);2376 psMetadataAdd(cell, PS_LIST_TAIL, "EXTNAME", PS_DATA_STR, "", "CCD01"); 2377 psMetadataAdd(cell, PS_LIST_TAIL, "BIASNAME", PS_DATA_STR, "", "BSEC-01"); 2378 psMetadataAdd(cell, PS_LIST_TAIL, "CHIP", PS_DATA_STR, "", "CHIP.01"); 2379 psMetadataAdd(md, PS_LIST_TAIL, "CELL.01", PS_DATA_META, "", cell); 2306 2380 \end{verbatim} 2307 2381 2308 2382 The following code shows how to use the APIs to replace one of these values: 2309 2383 \begin{verbatim} 2310 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_ META_F32 | PS_REPLACE, "new exposure time (sec)", 2.05);2384 psMetadataAdd(md, PS_LIST_TAIL, "EXPTIME", PS_DATA_F32 | PS_REPLACE, "new exposure time (sec)", 2.05); 2311 2385 \end{verbatim} 2312 2386 … … 2320 2394 bool psMetadataAddF64(psMetadata* md, psS32 location, const char* name, const char* comment, psF64 value); 2321 2395 bool psMetadataAddBool(psMetadata* md, psS32 location, const char* name, const char* comment, bool value); 2322 bool psMetadataAddPtr(psMetadata* md, psS32 location, const char* name, ps MetadataType type,2396 bool psMetadataAddPtr(psMetadata* md, psS32 location, const char* name, psDataType type, 2323 2397 const char* comment, psPtr value); 2324 2398 \end{prototype} … … 2383 2457 with \code{IPP.machines.detector}. The iterator should iterate over 2384 2458 every item in the metadata list, even those that are contained in a 2385 \code{PS_ META_LIST}. The value \code{iterator} specifies the iterator2459 \code{PS_DATA_LIST}. The value \code{iterator} specifies the iterator 2386 2460 to be used. In setting the iterator, the position of the iterator is 2387 2461 defined by \code{location}, which follows the conventions of the … … 2586 2660 should construct a \code{psMetadata} container and fill it with 2587 2661 \code{psMetadataItems} having the names \code{EXTNAME, BIASSEC, CHIP}, 2588 with type \code{PS_ META_STR}, but data allocated. When it next2662 with type \code{PS_DATA_STR}, but data allocated. When it next 2589 2663 encounters an entry of type \code{CELL}, it should then use the given 2590 2664 name (e.g., \code{CELL.00}) for the \code{psMetadataItem}, and copy … … 2766 2840 2767 2841 \section{Mathematical Structures} 2842 \label{sec:mathStructures} 2768 2843 2769 2844 Throughout PSLib, we require a variety of structures which correspond … … 2798 2873 determine the type of the data on the basis of the data. 2799 2874 Supported data types must be defined by a structure in which 2800 the first element is always of type \code{ps Type}:2875 the first element is always of type \code{psMathType}: 2801 2876 \begin{datatype} 2802 2877 typedef struct { 2803 2878 psDimen dimen; ///< The dimensionality 2804 psElemType type; ///< The type 2805 } psType; 2806 \end{datatype} 2807 where \code{psDimen dimen} defines the dimensionality of the data and 2808 \code{psElemType type} defines the data type of each element. These 2809 two variable types are defined as: 2879 psElemType type; ///< The type 2880 } psMathType; 2881 \end{datatype} 2882 where \code{psDimen dimen} defines the dimensionality of the data: 2810 2883 \begin{datatype} 2811 2884 typedef enum { … … 2817 2890 } psDimen; 2818 2891 \end{datatype} 2819 and 2820 \begin{datatype} 2821 typedef enum { 2822 PS_TYPE_S8, ///< Character 2823 PS_TYPE_S16, ///< Short integer 2824 PS_TYPE_S32, ///< Integer 2825 PS_TYPE_S64, ///< Long integer 2826 PS_TYPE_U8, ///< Unsigned character 2827 PS_TYPE_U16, ///< Unsigned short integer 2828 PS_TYPE_U32, ///< Unsigned integer 2829 PS_TYPE_U64, ///< Unsigned long integer 2830 PS_TYPE_F32, ///< Floating point 2831 PS_TYPE_F64, ///< Double-precision floating point 2832 PS_TYPE_C32, ///< Complex numbers consisting of floats 2833 PS_TYPE_C64, ///< Complex numbers consisting of doubles 2834 PS_TYPE_BOOL ///< Boolean value 2835 } psElemType; 2836 \end{datatype} 2837 We discuss the application of \code{psType} in more detail in 2892 \code{psElemType type}, which defines the data type of each element, has 2893 already been defined 2894 2895 We discuss the application of \code{psMathType} in more detail in 2838 2896 section~\ref{sec:arithmetic}. 2839 2897 … … 2849 2907 \begin{datatype} 2850 2908 typedef struct { 2851 ps Type type;///< data type information2909 psMathType type; ///< data type information 2852 2910 } psMath; 2853 2911 \end{datatype} … … 2863 2921 \begin{datatype} 2864 2922 typedef struct { 2865 ps Type type;///< data type information2923 psMathType type; ///< data type information 2866 2924 union { 2867 2925 psS8 S8; ///< bye value entry … … 2882 2940 psScalar *psScalarCopy(const psScalar *value); 2883 2941 \end{prototype} 2884 The first creates a \code{ps Type}-ed structure from a constant value,2885 casting it as appropriate based on the \code{type}. The second2942 The first creates a \code{psMathType}-ed structure from a constant 2943 value, casting it as appropriate based on the \code{type}. The second 2886 2944 copies the provided \code{psScalar} value. This latter function is 2887 2945 necessary to keep a copy of an existing \code{psScalar} value, since … … 2900 2958 \begin{datatype} 2901 2959 typedef struct { 2902 ps Type type;///< vector data type and dimension2960 psMathType type; ///< vector data type and dimension 2903 2961 long n; ///< size of vector 2904 2962 const long nalloc; ///< allocated data block … … 2926 2984 union \code{data} which consists of pointers to each of the defined 2927 2985 primitive data types. Note the parallelism in the names of the types, 2928 union elements, and the psElemType names. This parallelism allows us2929 to use automatic construction mechanisms effectively. The data type2930 is defined by the first element, \code{psType}. The structure is 2931 associated with a constructor and reallocator:2986 union elements, and the \code{psElemType} names. This parallelism 2987 allows us to use automatic construction mechanisms effectively. The 2988 data type is defined by the first element, \code{psMathType}. The 2989 structure is associated with a constructor and reallocator: 2932 2990 % 2933 2991 \begin{prototype} … … 3012 3070 \begin{datatype} 3013 3071 typedef struct psImage { 3014 ps Type type;///< image data type and dimension3072 psMathType type; ///< image data type and dimension 3015 3073 const psU32 numCols; ///< Number of columns in image 3016 3074 const psU32 numRows; ///< Number of rows in image. … … 3039 3097 3040 3098 This structure represents an image consisting of a 2-D array of 3041 pixels. The size of this array is given by the elements \code{(numRows,3042 numCols)}. The data type of the pixel is defined in the \code{psType 3043 t ype} entry (specifically, the \code{psElemType} member, \code{type};3044 see \ref{sec:arithmetic}). (n.b. that for FITS images, these values 3045 are restricted to the datatypes equivalent to the valid BITPIX values 3046 8, 16, 32, -32, -64). The image represented in the data structure may 3047 represent a subset of the pixels in a complete array, in which case 3048 the image is considered to be the child of that parent array. The3049 offset of the \code{(0,0)} pixel in this array relative to the parent 3050 array is given by the elements \code{(col0,row0)}: \code{col0} isthe3051 starting column number in the parent image while \code{row0} is the 3052 starting row number. The structure may include references to 3053 s ubrasters (\code{children}) and/or to a containing array3054 (\code{parent}). Unless this image is a child of another image 3055 (represents a subset of the pixels of another image), the image data 3056 i s allocated in a contiguous block. We define the following3057 supporting functions, which are valid for data types \code{psS8, 3058 psS16, psU8, psU16, psF32, psF64, psC32, psC64}.3099 pixels. The size of this array is given by the elements 3100 \code{(numRows, numCols)}. The data type of the pixel is defined in 3101 the \code{psMathType type} entry (specifically, the 3102 \code{psElemType} member, \code{type}; see \ref{sec:arithmetic}). 3103 (n.b. that for FITS images, these values are restricted to the 3104 datatypes equivalent to the valid BITPIX values 8, 16, 32, -32, -64). 3105 The image represented in the data structure may represent a subset of 3106 the pixels in a complete array, in which case the image is considered 3107 to be the child of that parent array. The offset of the \code{(0,0)} 3108 pixel in this array relative to the parent array is given by the 3109 elements \code{(col0,row0)}: \code{col0} is the starting column number 3110 in the parent image while \code{row0} is the starting row number. The 3111 structure may include references to subrasters (\code{children}) 3112 and/or to a containing array (\code{parent}). Unless this image is a 3113 child of another image (represents a subset of the pixels of another 3114 image), the image data is allocated in a contiguous block. We define 3115 the following supporting functions, which are valid for data types 3116 \code{psS8, psS16, psU8, psU16, psF32, psF64, psC32, psC64}. 3059 3117 3060 3118 \begin{prototype} … … 3073 3131 psU32 numCols, ///< the desired number of columns in image 3074 3132 psU32 numRows, ///< the desired number of rows in image 3075 const psElemType type ///< the desired datatype of the image3133 const psElemType type ///< the desired datatype of the image 3076 3134 ); 3077 3135 \end{prototype} … … 3239 3297 3240 3298 \begin{datatype} 3241 typedef struct {3242 MYSQL *mysql;3243 } psDB;3299 typedef struct { 3300 MYSQL *mysql; 3301 } psDB; 3244 3302 \end{datatype} 3245 3303 … … 3247 3305 3248 3306 \begin{prototype} 3249 // wraps mysql_init() & mysql_real_connect() 3250 psDB *psDBInit(const char *host, const char *user, const char *passwd, const char *dbname); 3251 3252 // wraps mysql_close() 3253 void psDBCleanup(psDB *dbh); 3254 3255 // wraps mysql_create_db() 3256 bool psDBCreate(psDB *dbh, const char *dbname); 3257 3258 // wraps mysql_select_db() 3259 bool psDBChange(psDB *dbh, const char *dbname); 3260 3261 // wraps mysql_drop_db() 3262 bool psDBDrop(psDB *dbh, const char *dbname); 3263 \end{prototype} 3264 3265 For MySQL support, \code{psDBInit()} wraps \code{mysql_init()} and 3266 \code{mysql_real_connect()} in order to initialize a psDB structure and 3307 psDB *psDBInit(const char *host, const char *user, const char *passwd, const char *dbname); 3308 void psDBCleanup(psDB *dbh); 3309 bool psDBCreate(psDB *dbh, const char *dbname); 3310 bool psDBChange(psDB *dbh, const char *dbname); 3311 bool psDBDrop(psDB *dbh, const char *dbname); 3312 \end{prototype} 3313 3314 For MySQL support, \code{psDBInit} wraps \code{mysql_init} and 3315 \code{mysql_real_connect} in order to initialize a psDB structure and 3267 3316 establish a database connection. A null pointer should be returned on 3268 3317 failure. … … 3272 3321 would be ignored while \code{dbname} would specify the path to the 3273 3322 SQLite db file. 3323 3324 \code{psDBCleanup} shall wrap \code{mysql_close}. \code{psDBCreate} 3325 shall wrap \code{mysql_create_db}. \code{psDBChange} shall wrap 3326 \code{mysql_select_db}. \code{psDBDrop} shall wrap 3327 \code{mysql_drop_db}. 3274 3328 3275 3329 \subsubsection{Interacting with Database Tables} … … 3287 3341 3288 3342 \begin{prototype} 3289 bool psDBCreateTable(psDB *dbh, const char *tableName, const psMetadata *md);3343 bool psDBCreateTable(psDB *dbh, const char *tableName, const psMetadata *md); 3290 3344 \end{prototype} 3291 3345 … … 3297 3351 given by the \code{psMetadataItem.type} entry. A lookup table should 3298 3352 be used to convert from PSLib types into MySQL compatible SQL data 3299 types. For example, a \code{PS_ META_STR} would map to an SQL993300 varchar. If the value of \code{type} is \code{PS_ META_STR} then the3353 types. For example, a \code{PS_DATA_STR} would map to an SQL99 3354 varchar. If the value of \code{type} is \code{PS_DATA_STR} then the 3301 3355 \code{psMetadataItem.data} element is set to a string with the length 3302 3356 for the field written as a text string. The value of the 3303 3357 \code{psMetadataItem.data} element is unused for the 3304 \code{PS_ META_PRIMITIVE} types. Other metadata types beyond3305 \code{PS_ META_STR} and \code{PS_META_PRIMITIVE} are not allowed in a3358 \code{PS_DATA_PRIMITIVE} types. Other metadata types beyond 3359 \code{PS_DATA_STR} and \code{PS_DATA_PRIMITIVE} are not allowed in a 3306 3360 table definition metadata collection. 3307 3361 … … 3314 3368 3315 3369 \begin{prototype} 3316 bool psDBDropTable(psDB *dbh, const char *tableName);3370 bool psDBDropTable(psDB *dbh, const char *tableName); 3317 3371 \end{prototype} 3318 3372 … … 3320 3374 3321 3375 \begin{prototype} 3322 bool p_psDBRunQuery(psDB *dbh, const char *query);3376 bool p_psDBRunQuery(psDB *dbh, const char *query); 3323 3377 \end{prototype} 3324 3378 … … 3328 3382 3329 3383 \begin{prototype} 3330 psArray *psDBSelectColumn(psDB *dbh, const char *tableName, const char *col, unsigned long limit); 3331 psVector *psDBSelectColumnNum(psDB *dbh, const char *tableName, const char *col, psElemType type, unsigned long limit); 3384 psArray *psDBSelectColumn(psDB *dbh, const char *tableName, const char *col, unsigned long limit); 3385 psVector *psDBSelectColumnNum(psDB *dbh, const char *tableName, const char *col, 3386 psElemType type, unsigned long limit); 3332 3387 \end{prototype} 3333 3388 … … 3340 3395 3341 3396 \begin{prototype} 3342 psArray *psDBSelectRows(psDB *dbh, const char *tableName, const psMetadata *where, unsigned long limit);3397 psArray *psDBSelectRows(psDB *dbh, const char *tableName, const psMetadata *where, unsigned long limit); 3343 3398 \end{prototype} 3344 3399 … … 3353 3408 3354 3409 \begin{prototype} 3355 bool psDBInsertOneRow(psDB *dbh, const char *tableName, const psMetadata *row);3410 bool psDBInsertOneRow(psDB *dbh, const char *tableName, const psMetadata *row); 3356 3411 \end{prototype} 3357 3412 … … 3361 3416 3362 3417 \begin{prototype} 3363 bool psDBInsertRows(psDB *dbh, const char *tableName, const psArray *rowSet);3418 bool psDBInsertRows(psDB *dbh, const char *tableName, const psArray *rowSet); 3364 3419 \end{prototype} 3365 3420 … … 3368 3423 3369 3424 \begin{prototype} 3370 psArray *psDBDumpRows(psDB *dbh, const char *tableName);3425 psArray *psDBDumpRows(psDB *dbh, const char *tableName); 3371 3426 \end{prototype} 3372 3427 … … 3374 3429 3375 3430 \begin{prototype} 3376 psMetadata *psDBDumpCols(psDB *dbh, const char *tableName);3431 psMetadata *psDBDumpCols(psDB *dbh, const char *tableName); 3377 3432 \end{prototype} 3378 3433 … … 3382 3437 3383 3438 \begin{prototype} 3384 psS64 psDBUpdateRows(psDB *dbh, const char *tableName, const psMetadata *where, const psMetadata *values); 3439 psS64 psDBUpdateRows(psDB *dbh, const char *tableName, const psMetadata *where, 3440 const psMetadata *values); 3385 3441 \end{prototype} 3386 3442 … … 3393 3449 3394 3450 \begin{prototype} 3395 psS64 psDBDeleteRows(psDB *dbh, const char *tableName, const psMetadata *where);3451 psS64 psDBDeleteRows(psDB *dbh, const char *tableName, const psMetadata *where); 3396 3452 \end{prototype} 3397 3453 … … 3922 3978 typedef struct { 3923 3979 psPolynomialType type; ///< Polynomial type 3924 psElemType ctype;///< Polynomial precision3980 psElemType ctype; ///< Polynomial precision 3925 3981 int n; ///< Number of terms 3926 3982 union { … … 3940 3996 typedef struct { 3941 3997 psPolynomialType type; ///< Polynomial type 3942 psElemType ctype;///< Polynomial precision3998 psElemType ctype; ///< Polynomial precision 3943 3999 int nX, nY; ///< Number of terms in x and y 3944 4000 union { 3945 psF32 **F32; ///< Coefficients3946 psF64 **F64; ///< Coefficients4001 psF32 **F32; ///< Coefficients 4002 psF64 **F64; ///< Coefficients 3947 4003 } coeff; 3948 4004 union { 3949 psF32 **F32; ///< Error in coefficients3950 psF64 **F64; ///< Error in coefficients4005 psF32 **F32; ///< Error in coefficients 4006 psF64 **F64; ///< Error in coefficients 3951 4007 } coeffErr; 3952 4008 char *mask; ///< Coefficient mask … … 4887 4943 4888 4944 \begin{prototype} 4889 ps Type *psBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2);4890 ps Type *psUnaryOp(psPtr out, const psPtr in, const char *op);4945 psMathType *psBinaryOp(psPtr out, const psPtr in1, const char *op, const psPtr in2); 4946 psMathType *psUnaryOp(psPtr out, const psPtr in, const char *op); 4891 4947 \end{prototype} 4892 4948 These functions determine the type of the operands on the basis of 4893 their \code{ps Type} elements, which always are the first elements.4949 their \code{psMathType} elements, which always are the first elements. 4894 4950 Note that these functions return a pointer to the appropriate type for 4895 the operation. Since the result may be cast to \code{ps Type}, the4951 the operation. Since the result may be cast to \code{psMathType}, the 4896 4952 resulting type may be determined by examining the return value. It is 4897 4953 expected that the implementation of these functions will employ
Note:
See TracChangeset
for help on using the changeset viewer.
