Changeset 296 for trunk/doc/pslib/psLibSDRS.tex
- Timestamp:
- Mar 23, 2004, 5:39:01 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (83 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r288 r296 1 %%% $Id: psLibSDRS.tex,v 1.9 2004-03-24 03:39:01 price Exp $ 1 2 \documentclass[panstarrs]{panstarrs} 2 3 %\documentclass[panstarrs]{panstarrs} … … 33 34 \pagenumbering{arabic} 34 35 35 %Here's a reference to another document:36 %\href{file:utils#psDlist}{utils.pdf}; the \code{#psDlist} points to37 %\CODE|\hlabel{psDlist}| in the file \file{utils.tex} (this is like38 %a regular \code{\label}, but defines the hyperlink too).39 40 36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 41 37 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 83 79 described here. 84 80 85 All of the memory management APIs should be provided in a header file86 \file{psMemory.h} which is included by \file{psUtils.h}.87 88 81 \subsubsection{Rationale} 89 82 … … 146 139 in the following struct definition: 147 140 \begin{verbatim} 148 typedef struct { 149 const unsigned long id; // a unique ID for this allocation 150 const char *file; // set from __FILE__ in e.g. p_psAlloc 151 const int lineno; // set from __LINE__ in e.g. p_psAlloc 152 int refcntr; // how many times pointer is referenced 153 const void *magic; // initialised to P_PS_MEMMAGIC 154 } psMemBlock; 141 typedef struct { 142 const void *magic0; //!< initialised to p_psMEMMAGIC 143 const unsigned long id; //!< a unique ID for this allocation 144 const char *file; //!< set from __FILE__ in e.g. p_psAlloc 145 const int lineno; //!< set from __LINE__ in e.g. p_psAlloc 146 int refCounter; //!< how many times pointer is referenced 147 const void *magic; //!< initialised to p_psMEMMAGIC 148 } psMemBlock; 155 149 \end{verbatim} 156 150 … … 161 155 \paragraph{APIs for using Memory Allocation Functions} 162 156 163 \begin{table} 164 \begin{verbatim} 165 void *psAlloc(size_t size); 166 void *psRealloc(void *ptr, size_t size); 167 void psFree(void *ptr); 168 169 void *p_psAlloc(size_t size, const char *file, int lineno); 170 void *p_psRealloc(void *ptr, size_t size, const char *file, int lineno); 171 void p_psFree(void *ptr, const char *file, int lineno); 172 157 The types and function prototypes for the part of the memory API 158 concerned with allocating and freeing memory are shown below. 159 160 \begin{verbatim} 161 /// Memory allocation. Underlying private function called by macro psAlloc. 162 void *p_psAlloc(size_t size, //!< Size required 163 const char *file, //!< File of call 164 int lineno //!< Line number of call 165 ); 166 167 /// Memory re-allocation. Underlying private function called by macro psRealloc. 168 void *p_psRealloc(void *ptr, //!< Pointer to re-allocate 169 size_t size, //!< Size required 170 const char *file, //!< File of call 171 int lineno //!< Line number of call 172 ); 173 174 /// Free memory. Underlying private function called by macro psFree. 175 void p_psFree(void *ptr, //!< Pointer to free 176 const char *file, //!< File of call 177 int lineno //!< Line number of call 178 ); 179 180 /// Memory allocation. psAlloc sends file and line number to p_psAlloc. 173 181 #define psAlloc(size) p_psAlloc(size, __FILE__, __LINE__) 182 183 /// Memory re-allocation. psRealloc sends file and line number to p_psRealloc. 174 184 #define psRealloc(ptr, size) p_psRealloc(ptr, size, __FILE__, __LINE__) 185 186 /// Free memory. psFree sends file and line number to p_psFree. 175 187 #define psFree(size) p_psFree(size, __FILE__, __LINE__) 176 188 \end{verbatim} 177 \begin{caption}{The APIs required to use the \PS{} memory allocation routines}178 \hlabel{tabUsageAPI}179 The APIs required to use the \PS{} memory allocation routines, and as180 provided by \file{psMemory.h}.181 \end{caption}182 \end{table}183 184 The types and function prototypes for the part of the memory API185 concerned with allocating and freeing memory are given in table186 \ref{tabUsageAPI}.187 189 188 190 N.b. … … 204 206 205 207 \item 206 The file \file{psMemory.h} shall take steps to ensure that 207 code calling the functions \code{malloc}, \code{calloc}, \code{realloc}, 208 or \code{free} shall not compile (\eg{} \code{#define malloc(S) for}) 209 unless the symbol \code{PS_ALLOC_MALLOC} is defined. 208 The header file (\file{psMemory.h}) shall take steps to ensure that 209 code calling the functions \code{malloc}, \code{calloc}, 210 \code{realloc}, or \code{free} shall not compile (\eg{} 211 \code{#define malloc(S) for}) unless the symbol 212 \code{PS_ALLOC_MALLOC} is defined. 210 213 211 214 \item … … 245 248 \hlabel{secMemAdvanced} 246 249 250 The types and function prototypes for this part of the memory API 251 are shown below. 252 247 253 \begin{table} 248 254 \begin{verbatim} 255 /// prototype of a basic callback used by memory functions 249 256 typedef int (*psMemCallback)(const psMemBlock *ptr); 250 typedef void (*psMemProblemCallback)(const psMemBlock *ptr, 251 const char *file, int lineno); 257 258 /// prototype of a callback used in error conditions 259 typedef void (*psMemProblemCallback)(const psMemBlock *ptr, const char *file, int lineno); 260 261 /// prototype of a callback used when memory runs out 252 262 typedef void *(*psMemExhaustedCallback)(size_t size); 253 263 254 psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func); 255 psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func); 256 257 psMemCallback psMemAllocateSetCB(psMemCallback func); 258 psMemCallback psMemFreeSetCB(psMemCallback func); 259 260 int psMemGetId(void); // get next memory ID 261 262 long psMemSetAllocateID(long id); // set p_psMemAllocateID to id 263 long psMemSetFreeID(long id); // set p_psMemFreeID to id 264 265 int psMemCheckLeaks( 266 int id0, // don't list blocks with id < id0 267 psMemBlock ***arr, // pointer to array of pointers to 268 //leaked blocks, or NULL 269 FILE *fd); // print list of leaks to fd (or NULL) 270 int psMemCheckCorruption(int abort_on_error); 271 \end{verbatim} 272 \begin{caption}{The APIs required to use the \PS{} memory allocation routines} 273 \hlabel{tabCallbackAPI} 274 The APIs required to use the callback and tracing facilities 275 in \PS{} memory allocation routines, as defined in \file{psMemory.h}. 276 \end{caption} 277 \end{table} 278 279 The types and function prototypes for this part of the memory API 280 are given in table \ref{tabCallbackAPI}. 264 /// Set callback for problems 265 psMemProblemCallback psMemProblemSetCB(psMemProblemCallback func //!< Function to run 266 ); 267 268 /// Set callback for out-of-memory 269 psMemExhaustedCallback psMemExhaustedSetCB(psMemExhaustedCallback func //!< Function to run 270 ); 271 272 /// Set call back for when a particular memory block is allocated 273 psMemCallback psMemAllocateSetCB(psMemCallback func //!< Function to run 274 ); 275 276 /// Set call back for when a particular memory block is freed 277 psMemCallback psMemFreeSetCB(psMemCallback func 278 ); 279 280 /// get next memory ID 281 int psMemGetId(void); 282 283 /// set p_psMemAllocateID to id 284 long psMemSetAllocateID(long id //!< ID to set 285 ); 286 287 /// set p_psMemFreeID to id 288 long psMemSetFreeID(long id //!< ID to set 289 ); 290 291 /// Check for memory leaks 292 int psMemCheckLeaks(int id0, //!< don't list blocks with id < id0 293 psMemBlock ***arr, //!< pointer to array of pointers to leaked blocks, or NULL 294 FILE *fd //!< print list of leaks to fd (or NULL) 295 ); 296 /// Check for memory corruption 297 int psMemCheckCorruption(int abort_on_error //!< Abort on detecting corruption? 298 ); 299 \end{verbatim} 281 300 282 301 \paragraph{Callback Routines} … … 381 400 The API for this field is: 382 401 \begin{verbatim} 383 int psMemGetRefCounter(void *vptr); // return refcounter 384 void *psMemIncrRefCounter(void *vptr); // increment refcounter and return vptr 385 void *psMemDecrRefCounter(void *vptr); // decrement refcounter and return vptr 402 /// Return reference counter 403 int psMemGetRefCounter(void *vptr //!< Pointer to get refCounter for 404 ); 405 406 /// Increment reference counter and return the pointer 407 void *psMemIncrRefCounter(void *vptr //!< Pointer to increment refCounter, and return 408 ); 409 410 /// Decrement reference counter and return the pointer 411 void *psMemDecrRefCounter(void *vptr //!< Pointer to decrement refCounter, and return 412 ); 386 413 \end{verbatim} 387 414 … … 391 418 \subsubsubsection{Rationale} 392 419 393 \begin{table} 420 The \code{psMemBlock.refcounter} is clearly useful for detecting 421 attempts to free memory that is already free. A more complex 422 application is for allowing pointers to complex data-objects (e.g.\ 423 images) to appear in more than one data structure simultaneously: 424 394 425 \begin{verbatim} 395 426 typedef struct { … … 417 448 } 418 449 \end{verbatim} 419 \caption{An example of reference counting} 420 \label{tabReferenceCounting} 421 \end{table} 422 423 The \code{psMemBlock.refcounter} is clearly useful for detecting 424 attempts to free memory that is already free. A more complex 425 application is for allowing pointers to complex data-objects (e.g. 426 images) to appear in more than one data structure simultaneously 427 (see table \ref{tabReferenceCounting}). 450 428 451 429 452 Because of the use of the \code{refcounter} field, we can safely put items of … … 456 479 \hlabel{psTrace} 457 480 458 \begin{table} 459 \begin{verbatim} 481 \begin{verbatim} 460 482 #if defined(PS_NTRACE) 461 483 # define psTrace(facil, level, ...) /* do nothing */ … … 465 487 #endif 466 488 467 void p_psTrace(const char *facil, int level, ...); 468 469 int psSetTraceLevel(const char *facil, // facilty of interest 470 int level); // desired trace level 471 int psGetTraceLevel(const char *name); // facilty of interest 472 473 void psTraceReset(void); // turn off all tracing, and free trace's allocated memory 474 475 void psPrintTraceLevels(void); // print trace levels 476 \end{verbatim} 477 \begin{caption}{The public API for the trace facility 478 from \file{psTrace.h}.} 479 \hlabel{tabTraceAPI} 480 \end{caption} 481 \end{table} 482 483 The public API for the trace facility (table \ref{tabTraceAPI}) 484 should be provided in a header file \file{psTrace.h} which 485 is included by \file{psUtils.h}. 489 /// Send a trace message 490 void p_psTrace(const char *facil, ///< facilty of interest 491 int level, ///< desired trace level 492 ... ///< trace message arguments 493 ); 494 495 /// Set trace level 496 int psSetTraceLevel(const char *facil, ///< facilty of interest 497 int level ///< desired trace level 498 ); 499 500 /// Get the trace level 501 int psGetTraceLevel(const char *name ///< facilty of interest 502 ); 503 504 /// turn off all tracing, and free trace's allocated memory 505 void psTraceReset(void); 506 507 /// print trace levels 508 void psPrintTraceLevels(void); 509 \end{verbatim} 486 510 487 511 \begin{itemize} … … 489 513 Logging is provided by the function \code{psTrace}, 490 514 which is actually a macro. When the macro \code{PS_NTRACE} 491 is defined, all occurrences of \code{psTrace} shall515 is defined, all occurrences of \code{psTrace} shall 492 516 be replaced by whitespace. 493 517 … … 536 560 \item 537 561 There is no requirement that \code{psTrace} be usable from 538 within the functions that implement \file{psTrace.h}539 or \file{psMemory.h}systems.562 within the functions that implement the tracing or memory 563 management systems. 540 564 541 565 \item … … 617 641 \hlabel{psLogMsg} 618 642 619 \begin{table} 620 \begin{verbatim} 621 enum { PS_LOG_ABORT = 0, PS_LOG_ERROR, PS_LOG_WARN, PS_LOG_INFO }; 622 623 enum { PS_LOG_TO_STDERR, PS_LOG_TO_STDOUT }; 624 625 void psLogMsg(const char *name, int level, const char *fmt, ...); 626 void p_psVLogMsg(const char *name, int level, const char *fmt, va_list ap); 627 628 int psSetLogDestination(int dest); 629 void psSetLogFormat(const char *fmt); 630 631 int psSetLogLevel(int level); 632 \end{verbatim} 633 \begin{caption}{API for message logging} 634 \hlabel{tabLogMsgAPI} 635 The API for message logging. 636 \end{caption} 637 \end{table} 638 639 The public API for the logging facility (table \ref{tabLogMsgAPI}) 640 should be provided in a header file \file{psLogMsg.h} which 641 is included by \file{psUtils.h}. 643 \begin{verbatim} 644 enum { PS_LOG_ABORT = 0, PS_LOG_ERROR, PS_LOG_WARN, PS_LOG_INFO }; //!< Status codes for log messages 645 646 enum { PS_LOG_TO_STDERR, PS_LOG_TO_STDOUT }; //!< Destinations for log messages 647 648 /// Logs a message 649 void psLogMsg(const char *name, int level, const char *fmt, ...); 650 651 /// Logs a message from varargs 652 void p_psVLogMsg(const char *name, int level, const char *fmt, va_list ap); 653 654 /// Sets the log destination 655 int psSetLogDestination(int dest); 656 657 /// Sets the log level 658 int psSetLogLevel(int level); 659 660 /// sets the log format 661 void psSetLogFormat(const char *fmt); 662 \end{verbatim} 642 663 643 664 The function \code{psSetLogLevel} may be used to set the current … … 702 723 \hlabel{psDlist} 703 724 704 Pan-STARRS supports doubly linked lists through a type \code{psDlist}. 705 The type is defined in the header file \file{psDlist.h}, and consists 706 of the following definitions: 707 708 \begin{verbatim} 725 \PS{} supports doubly linked lists through a type \code{psDlist}. The 726 type consists of the following definitions: 727 728 \begin{verbatim} 729 /** Doubly-linked list element */ 709 730 typedef struct psDlistElem { 710 struct psDlistElem *prev; //previous link in list711 struct psDlistElem *next; //next link in list712 void *data; //real data item731 struct psDlistElem *prev; //!< previous link in list 732 struct psDlistElem *next; //!< next link in list 733 void *data; //!< real data item 713 734 } psDlistElem; 714 735 736 /** Doubly-linked list */ 715 737 typedef struct { 716 int n; //number of elements on list717 psDlistElem *head; //first element on list (may be NULL)718 psDlistElem *tail; //last element on list (may be NULL)719 psDlistElem *iter; // iteration cursor; private738 int n; //!< number of elements on list 739 psDlistElem *head; //!< first element on list (may be NULL) 740 psDlistElem *tail; //!< last element on list (may be NULL) 741 psDlistElem *iter; //!< iteration cursor 720 742 } psDlist; 721 743 722 enum { // Special values of index into list 723 psDlistHead = 0, // at head 724 psDlistTail = -1, // at tail 725 psDlistUnknown = -2, // unknown position 726 psDlistPrev = -3, // previous element 727 psDlistNext = -4 // next element 744 /** Special values of index into list */ 745 enum { 746 PS_DLIST_HEAD = 0, //!< at head 747 PS_DLIST_TAIL = -1, //!< at tail 748 PS_DLIST_UNKNOWN = -2, //!< unknown position 749 PS_DLIST_PREV = -3, //!< previous element 750 PS_DLIST_NEXT = -4 //!< next element 728 751 }; 729 752 \end{verbatim} … … 732 755 733 756 \begin{verbatim} 734 psDlist *psDlistAlloc(void *data); // initial data item; may be NULL 735 736 void psDlistFree(psDlist *list, // list to destroy 737 void (*elemFree)(void *)); // destructor for list data, or NULL 738 739 /* 740 * List maintainence functions 741 */ 742 psDlist *psDlistAdd(psDlist *list, // list to add to (may be NULL) 743 void *data, // data item to add 744 int where); // index, psDlistHead, or psDlistTail 745 psDlist *psDlistAppend(psDlist *list, // list to append to (may be NULL) 746 void *data); // data item to add 747 void *psDlistRemove(psDlist *list, // list to remove element from 748 void *data, // data item to remove 749 int which); // index of item, or psDlistUnknown, 750 // or psDlistNext, or psDlistPrev 751 void *psDlistGet(const psDlist *list, // list to retrieve element from 752 int which); // index of item, or psDlistNext, 753 // or psDlistPrev 754 /* 755 * Conversions to/from arrays 756 */ 757 psVoidPtrArray *psDlistToArray(psDlist *dlist); 758 psDlist *psArrayToDlist(psVoidPtrArray *arr); 759 \end{verbatim} 760 761 All data items placed onto lists (e.g. with \code{psDlistAdd}) 762 shall have their reference counters (section \ref{secMemRefcounter}) incremented. 763 When elements 764 are removed from a list with \code{psDlistRemove}, they shall 765 have their reference counters decremented. The action of retrieving 766 data from a list (with \code{psDlistGet}) shall not affect 767 their reference counter. 757 /** Constructor */ 758 psDlist *psDlistAlloc(void *data //!< initial data item; may be NULL 759 ); 760 761 /** Destructor */ 762 void psDlistFree(psDlist *list, //!< list to destroy 763 void (*elemFree)(void *) //!< destructor for data on list 764 ); 765 766 /**** List maintainence functions ****/ 767 768 /** Add to list */ 769 psDlist *psDlistAdd(psDlist *list, //!< list to add to (may be NULL) 770 void *data, //!< data item to add 771 int where //!< index, PS_DLIST_HEAD, or PS_DLIST_TAIL 772 ); 773 774 /** Append to a list */ 775 psDlist *psDlistAppend(psDlist *list, //!< list to append to (may be NULL) 776 void *data //!< data item to add 777 ); 778 779 /** Remove from a list */ 780 void *psDlistRemove(psDlist *list, //!< list to remove element from 781 void *data, //!< data item to remove 782 int which //!< index of item, or PS_DLIST_UNKNOWN, or PS_DLIST_NEXT, or 783 //!< PS_DLIST_PREV 784 ); 785 /** Retrieve from a list */ 786 void *psDlistGet(const psDlist *list, //!< list to retrieve element from 787 int which //!< index of item, or PS_DLIST_NEXT, or PS_DLIST_PREV 788 ); 789 790 /** Convert doubly-linked list to an array */ 791 psVoidPtrArray *psDlistToArray(psDlist *dlist //!< List to convert 792 ); 793 794 /** Convert array to a doubly-linked list */ 795 psDlist *psArrayToDlist(psVoidPtrArray *arr //!< Array to convert 796 ); 797 \end{verbatim} 798 799 All data items placed onto lists (e.g. with \code{psDlistAdd}) shall 800 have their reference counters (section \ref{secMemRefcounter}) 801 incremented. When elements are removed from a list with 802 \code{psDlistRemove}, they shall have their reference counters 803 decremented. The action of retrieving data from a list (with 804 \code{psDlistGet}) shall not affect their reference counter. 768 805 769 806 If \code{psDlistFree}'s argument \code{elemFree} is NULL, the … … 773 810 Iteration over all elements of the list is provided by the functions: 774 811 \begin{verbatim} 775 void psDlistSetIterator(psDlist *list, int where, int which); 776 void *psDlistGetNext(psDlist *list, int which); 777 void *psDlistGetPrev(psDlist *list, int which); 812 /** Set the iterator */ 813 void psDlistSetIterator(psDlist *list, //!< list to retrieve element from 814 int where, //!< index, PS_DLIST_HEAD, or PS_DLIST_TAIL 815 int which //!< index of item, or PS_DLIST_UNKNOWN, or PS_DLIST_NEXT, or 816 //!< PS_DLIST_PREV 817 ); 818 819 /** Get next element */ 820 void *psDlistGetNext(psDlist *list, //!< list to retrieve element from 821 int which //!< index of item, or PS_DLIST_UNKNOWN, or PS_DLIST_NEXT, or 822 //!< PS_DLIST_PREV 823 ); 824 825 /** Get previous element */ 826 void *psDlistGetPrev(psDlist *list, //!< list to retrieve element from 827 int which //!< index of item, or PS_DLIST_UNKNOWN, or PS_DLIST_NEXT, or 828 //!< PS_DLIST_PREV 829 ); 778 830 \end{verbatim} 779 831 in which the \code{where} argument must be \code{PS_DLIST_HEAD} or \code{PS_DLIST_TAIL}, … … 815 867 is the number of elements allocated ($s \ge n$). 816 868 817 This type and functions may be declared and defined using two macros 818 from \file{psArray.h},\code{PS_DECLARE_ARRAY_TYPE(psType)} and869 This type and functions may be declared and defined using two macros, 870 \code{PS_DECLARE_ARRAY_TYPE(psType)} and 819 871 \code{PS_CREATE_ARRAY_TYPE(psType)}. The former defines the 820 872 \code{typedef} and declares the prototypes (and is thus suitable for … … 903 955 \code{array}s. 904 956 \begin{verbatim} 905 #include "ps Utils.h"957 #include "psLib.h" 906 958 907 959 typedef struct { … … 960 1012 \hlabel{psHash} 961 1013 962 \begin{table} 963 \begin{verbatim} 964 typedef struct HashTable psHash; 965 966 psHash *psHashAlloc(int nbucket); // initial number of buckets 967 void psHashFree(psHash *table, // hash table to be freed 968 void (*itemFree)(void *item)); // how to free hashed data; 969 // or NULL 970 971 void *psHashInsert(psHash *table, // table to insert in 972 const char *key, // key to use 973 void *data, // data to insert 974 void (*itemFree)(void *item)); // how to free hashed data; 975 // or NULL 976 void *psHashLookup(psHash *table, // table to lookup key in 977 const char *key); // key to lookup 978 979 void *psHashRemove(psHash *table, // table to lookup key in 980 const char *key); // key to lookup 981 \end{verbatim} 982 \begin{caption}{The public API for hash tables from \file{psHash.h}} 983 \hlabel{tabPsHash} 984 \end{caption} 985 \end{table} 986 987 The public API for the hash table (table \ref{tabPsHash}) 988 should be provided in a header file \file{psHash.h} which 989 is included by \file{psUtils.h}. 1014 The public APIs for the hash table (table \ref{tabPsHash}) are shown below. 990 1015 \footnote{ 991 1016 We choose not to use the posix function \code{hcreate}, 992 1017 \code{hdestroy}, and \code{hsearch} as they only support 993 1018 a single hash table at any one time.} 1019 1020 \begin{verbatim} 1021 typedef struct HashTable psHash; ///< Opaque type for a hash table 1022 1023 /// Allocate hash buckets in table. 1024 psHash *psHashAlloc(int nbucket ///< initial number of buckets 1025 ); 1026 1027 /// Free hash buckets from table. 1028 void psHashFree(psHash *table, ///< hash table to be freed 1029 void (*itemFree)(void *item) ///< how to free hashed data; or NULL 1030 ); 1031 1032 /// Insert entry into table. 1033 void *psHashInsert(psHash *table, ///< table to insert in 1034 const char *key, ///< key to use 1035 void *data, ///< data to insert 1036 void (*itemFree)(void *item) ///< how to free hashed data; or NULL 1037 ); 1038 1039 /// Lookup key in table. 1040 void *psHashLookup(psHash *table, ///< table to lookup key in 1041 const char *key ///< key to lookup 1042 ); 1043 1044 /// Remove key from table. 1045 void *psHashRemove(psHash *table, ///< table to lookup key in 1046 const char *key ///< key to lookup 1047 ); 1048 \end{verbatim} 1049 994 1050 995 1051 A hash table is an abstract type \code{psHash}. The argument … … 1016 1072 \subsection{Miscellaneous Utilities} 1017 1073 1018 \begin{table} 1019 \begin{verbatim} 1020 #define PS_CONCAT(A, B) A ## B // Expands to AB 1021 #define PS_CONCAT2(A, B) PS_CONCAT(A, B) // Also expands to AB 1022 #define PS_CONCAT3(A, B, C) A ## B ## C // Expands to ABC 1023 1074 \begin{verbatim} 1024 1075 #define PS_STRING(S) #S // converts argument S to string 1025 1076 1026 void psAbort(const char *name, const char *fmt, ...); 1027 void psError(const char *name, const char *fmt, ...); 1028 char *psStringCopy(const char *str); 1029 \end{verbatim} 1030 \begin{caption}{The utilities provided by \file{psMisc.h}} 1031 \hlabel{psMisc} 1032 \end{caption} 1033 \end{table} 1077 /// Prints an error message and aborts 1078 void psAbort(const char *name, ///< Category of code that caused the abort 1079 const char *fmt, ///< Format 1080 ... ///< Extra arguments to use format 1081 ); 1082 1083 /// Prints an error message and doesn't abort 1084 void psError(const char *name, ///< Category of code that caused the abort 1085 const char *fmt, ///< Format 1086 ... ///< Extra arguments to use format 1087 ); 1088 1089 /// Allocates and returns a copy of a string 1090 char *psStringCopy(const char *str ///< string to copy 1091 ); 1092 1093 /// Allocates nChar and returns a copy of the string or segment 1094 char *psStringNCopy(const char *str, ///< string to copy 1095 int nChar //!< Number of characters (including \0 ) 1096 ); 1097 \end{verbatim} 1034 1098 1035 1099 \code{psAbort} shall call \code{psMsgLog} with a level of \code{PS_LOG_ABORT}, … … 1141 1205 char *operator, ///< operator 1142 1206 void *in2 ///< second input 1143 );1207 ); 1144 1208 \end{verbatim} 1145 1209 … … 1151 1215 void *in, ///< input 1152 1216 char *operator, ///< operator 1153 );1217 ); 1154 1218 \end{verbatim} 1155 1219 … … 1182 1246 1183 1247 \begin{verbatim} 1248 /** private structure used to pass constant values into the math operators. */ 1184 1249 typedef struct { 1185 psType type; 1186 union { 1187 int i; 1188 float f; 1189 double d; 1190 complex float c; 1191 } 1250 psType type; ///< data type information 1251 union { 1252 int i; ///< integer value entry 1253 float f; ///< float value entry 1254 double d; ///< double value entry 1255 complex float c; ///< complex value entry 1256 } val; 1192 1257 } p_psScalar; 1193 1258 \end{verbatim} … … 1644 1709 /// basic image data structure. 1645 1710 typedef struct psImage { 1646 psType type; ///< image data type and dimension1647 int nx, ny; ///< size of image1648 int x0, y0; ///< data region relative to parent1711 psType type; ///< image data type and dimension 1712 int nx, ny; ///< size of image 1713 int x0, y0; ///< data region relative to parent 1649 1714 union { 1650 psF32 **rows; ///< == rows_f32 1651 psS8 **rows_s8; ///< pointers to psS8 data 1652 psS16 **rows_s16; ///< pointers to psS16 data 1653 psS32 **rows_s32; ///< pointers to psS32 data 1654 psU8 **rows_u8; ///< pointers to psU8 data 1655 psU16 **rows_u16; ///< pointers to psU16 data 1656 psU32 **rows_u32; ///< pointers to psU32 data 1657 psF32 **rows_f32; ///< pointers to psF32 data 1658 psF64 **rows_f64; ///< pointers to psF64 data 1715 psF32 **rows; ///< == rows_f32 1716 psS8 **rows_s8; ///< pointers to psS8 data 1717 psS16 **rows_s16; ///< pointers to psS16 data 1718 psS32 **rows_s32; ///< pointers to psS32 data 1719 psU8 **rows_u8; ///< pointers to psU8 data 1720 psU16 **rows_u16; ///< pointers to psU16 data 1721 psU32 **rows_u32; ///< pointers to psU32 data 1722 psF32 **rows_f32; ///< pointers to psF32 data 1723 psF64 **rows_f64; ///< pointers to psF64 data 1724 psComplex **rows_complex; //!< pointers to psComplex data 1659 1725 } rows; 1660 struct psImage *parent;///< parent, if a subimage1661 struct psImage *children; ///< children of this region1662 int Nchildren; ///< number of subimages1726 psImage *parent; ///< parent, if a subimage 1727 int Nchildren; ///< number of subimages 1728 psImage *children; ///< children of this region; array of Nchildren pointers 1663 1729 } psImage; 1664 1730 \end{verbatim} … … 1695 1761 outside of the parent image. 1696 1762 \begin{verbatim} 1763 /// Create a subimage of the specified area. 1697 1764 psImage * 1698 psImageSubset (psImage *image, ///< parent image 1699 int nx, ///< subimage width (<= image.nx - x0) 1700 int ny, ///< subimage width (<= image.ny - y0) 1701 int x0, ///< subimage x-offset (0 <= x0 < nx) 1702 int y0) ///< subimage y-offset (0 <= y0 < ny) 1765 psImageSubset(psImage *out, //!< Subimage to return, or NULL 1766 const psImage *image, ///< parent image 1767 int nx, ///< subimage width (<= image.nx - x0) 1768 int ny, ///< subimage width (<= image.ny - y0) 1769 int x0, ///< subimage x-offset (0 <= x0 < nx) 1770 int y0 ///< subimage y-offset (0 <= y0 < ny) 1771 ); 1703 1772 \end{verbatim} 1704 1773 … … 1730 1799 \begin{verbatim} 1731 1800 psImage * 1732 psImageCopy (psImage *output, ///< target structure for output image data 1733 psImage *input) ///< copy this image 1801 psImageCopy(psImage *output, ///< target structure for output image data 1802 const psImage *input ///< copy this image 1803 ); 1734 1804 \end{verbatim} 1735 1805 … … 1744 1814 \begin{verbatim} 1745 1815 psFloatArray * 1746 psImageSlice (psImage *input, ///< extract slice from this image 1747 int x, ///< starting x coord of region to slice 1748 int y, ///< starting y coord of region to slice 1749 int nx, ///< width of region in x 1750 int ny, ///< width of region in y 1751 int direction, ///< direction of vector along slice 1752 psStats *stats) ///< defines statistics used to find output values 1816 psImageSlice(psFloatArray *out, //!< Vector to output, or NULL 1817 const psImage *input, ///< extract slice from this image 1818 int x, ///< starting x coord of region to slice 1819 int y, ///< starting y coord of region to slice 1820 int nx, ///< width of region in x 1821 int ny, ///< width of region in y 1822 int direction, ///< direction of vector along slice 1823 const psStats *stats ///< defines statistics used to find output values 1824 ); 1753 1825 \end{verbatim} 1754 1826 … … 1764 1836 \begin{verbatim} 1765 1837 psFloatArray * 1766 psImageCut (psImage *input, ///< extract cut from this image 1767 float xs, ///< starting x coord of cut 1768 float ys, ///< starting y coord of cut 1769 float xe, ///< ending x coord of cut 1770 float ye, ///< ending y coord of cut 1771 float dw, ///< width of cut 1772 psStats *stats) ///< defines statistics used to find output values 1838 psImageCut(psFloatArray *out, //!< Vector to output, or NULL 1839 const psImage *input, ///< extract cut from this image 1840 float xs, ///< starting x coord of cut 1841 float ys, ///< starting y coord of cut 1842 float xe, ///< ending x coord of cut 1843 float ye, ///< ending y coord of cut 1844 float dw, ///< width of cut 1845 const psStats *stats ///< defines statistics used to find output values 1846 ); 1773 1847 \end{verbatim} 1774 1848 … … 1783 1857 \begin{verbatim} 1784 1858 psFloatArray * 1785 psImageRadialCut (psImage *input, ///< extract profile from this image 1786 float x, ///< center x coord of annulii 1787 float y, ///< center y coord of annulii 1788 float radius, ///< outer radius of annulii 1789 float dr, ///< radial step size of annulii 1790 psStats *stats) ///< defines statistics used to find output values 1791 \end{verbatim} 1792 1793 %/// Extract a 2-d contour from an image at the given threshold. 1794 %\begin{verbatim} 1795 %psFloatArray * 1796 %psImageContour (psImage *input, ///< create contour for this image 1797 % float threshold, ///< contour image at this threshold 1798 % int binning) ///< bin image by this value for contour calculation 1799 %\end{verbatim} 1859 psImageRadialCut(psFloatArray *out, //!< Vector to output, or NULL 1860 const psImage *input, ///< extract profile from this image 1861 float x, ///< center x coord of annulii 1862 float y, ///< center y coord of annulii 1863 float radius, ///< outer radius of annulii 1864 float dr, ///< radial step size of annulii 1865 const psStats *stats ///< defines statistics used to find output values 1866 ); 1867 \end{verbatim} 1800 1868 1801 1869 Rebin image to new scale. A new image is constructed in which the … … 1808 1876 \begin{verbatim} 1809 1877 psImage * 1810 psImageRebin (psImage *input, ///< rebin this image 1811 float scale, ///< rebinning scale: doutput = scale*dinput 1812 psStats *stats) ///< defines statistics used to find output values 1878 psImageRebin(psImage *out, //!< Image to output, or NULL 1879 const psImage *input, ///< rebin this image 1880 float scale, ///< rebinning scale: doutput = scale*dinput 1881 const psStats *stats ///< defines statistics used to find output values 1882 ); 1813 1883 \end{verbatim} 1814 1884 … … 1821 1891 \begin{verbatim} 1822 1892 psImage * 1823 psImageRotate (psImage *input, ///< rotate this image 1824 float angle) ///< rotate by this amount (degrees) 1893 psImageRotate(psImage *out, //!< Image to output, or NULL 1894 const psImage *input, ///< rotate this image 1895 float angle ///< rotate by this amount anti-clockwise (degrees) 1896 ); 1825 1897 \end{verbatim} 1826 1898 … … 1833 1905 \begin{verbatim} 1834 1906 psImage * 1835 psImageShift (psImage *input, ///< shift this image 1836 float dx, ///< shift by this amount in x 1837 float dy, ///< shift by this amount in y 1838 float exposed) ///< set exposed pixels to this value 1907 psImageShift(psImage *out, //!< Image to output, or NULL 1908 const psImage *input, ///< shift this image 1909 float dx, ///< shift by this amount in x 1910 float dy, ///< shift by this amount in y 1911 float exposed ///< set exposed pixels to this value 1912 ); 1839 1913 \end{verbatim} 1840 1914 … … 1844 1918 \begin{verbatim} 1845 1919 psImage * 1846 psImageRoll (psImage *input, ///< roll this image 1847 int dx, ///< roll this amount in x 1848 int dy) ///< roll this amount in y 1920 psImageRoll(psImage *out, //!< Image to output, or NULL 1921 const psImage *input, ///< roll this image 1922 int dx, ///< roll this amount in x 1923 int dy ///< roll this amount in y 1924 ); 1849 1925 \end{verbatim} 1850 1926 … … 1853 1929 \begin{verbatim} 1854 1930 psStats * 1855 psImageGetStats (psImage *input, ///< image (or subimage) to calculate stats 1856 psStats *stats) ///< defines statistics to be calculated 1931 psImageGetStats(const psImage *input, ///< image (or subimage) to calculate stats 1932 psStats *stats ///< defines statistics to be calculated & target 1933 ); 1857 1934 \end{verbatim} 1858 1935 … … 1861 1938 \begin{verbatim} 1862 1939 psHistogram * 1863 psImageHistogram (psHistogram *hist, ///< input histogram description & target 1864 psImage *input) ///< determine histogram of this image 1940 psImageHistogram(psHistogram *hist, ///< input histogram description & target 1941 const psImage *input ///< determine histogram of this image 1942 ); 1865 1943 \end{verbatim} 1866 1944 … … 1870 1948 \begin{verbatim} 1871 1949 psPolynomial2D * 1872 psImageFitPolynomial (psImage *input, ///< image to fit 1873 psPolynomial2D *coeffs) ///< coefficient structure carries in desired terms 1950 psImageFitPolynomial(const psImage *input, ///< image to fit 1951 psPolynomial2D *coeffs ///< coefficient structure carries in desired terms & target 1952 ); 1874 1953 \end{verbatim} 1875 1954 … … 1880 1959 \begin{verbatim} 1881 1960 int 1882 psImageEvalPolynomial (psImage *input, ///< image to fit 1883 psPolynomial2D *coeffs) ///< coefficient structure carries in desired terms 1961 psImageEvalPolynomial(const psImage *input, ///< image to fit 1962 const psPolynomial2D *coeffs ///< coefficient structure carries in desired terms 1963 ); 1884 1964 \end{verbatim} 1885 1965 … … 1900 1980 \begin{verbatim} 1901 1981 psImage * 1902 psImageReadSection (psImage *output, ///< place data in this structure for output 1903 int x, ///< starting x coord of region 1904 int y, ///< starting y coord of region 1905 int nx, ///< x size of region (-1 for full range) 1906 int ny, ///< y size of region (-1 for full range) 1907 int z, ///< plane of interest 1908 char *extname, ///< MEF extension name ("PHU" for primary header) 1909 int extnum, ///< MEF extension sequence number (-1 for PHU) 1910 char *filename) ///< file to read data from 1982 psImageReadSection(psImage *output, ///< place data in this structure for output 1983 int x, ///< starting x coord of region 1984 int y, ///< starting y coord of region 1985 int nx, ///< x size of region (-1 for full range) 1986 int ny, ///< y size of region (-1 for full range) 1987 int z, ///< plane of interest 1988 const char *extname, ///< MEF extension name ("PHU" for primary header) 1989 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 1990 const char *filename ///< file to read data from 1991 ); 1911 1992 \end{verbatim} 1912 1993 … … 1916 1997 \begin{verbatim} 1917 1998 psImage * 1918 psImageFReadSection (psImage *output, ///< place data in this structure for output 1919 int x, ///< starting x coord of region 1920 int y, ///< starting y coord of region 1921 int dx, ///< x size of region (-1 for full range) 1922 int dy, ///< y size of region (-1 for full range) 1923 int z, ///< plane of interest 1924 char *extname, ///< MEF extension name ("PHU" for primary header) 1925 FILE *f) ///< file descriptor to read data from 1999 psImageFReadSection(psImage *output, ///< place data in this structure for output 2000 int x, ///< starting x coord of region 2001 int y, ///< starting y coord of region 2002 int dx, ///< x size of region (-1 for full range) 2003 int dy, ///< y size of region (-1 for full range) 2004 int z, ///< plane of interest 2005 const char *extname, ///< MEF extension name ("PHU" for primary header) 2006 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 2007 FILE *f ///< file descriptor to read data from 2008 ); 1926 2009 \end{verbatim} 1927 2010 … … 1936 2019 \begin{verbatim} 1937 2020 psImage * 1938 psImageWriteSection (psImage *input, ///< image to write out 1939 int x, ///< starting x coord of region 1940 int y, ///< starting y coord of region 1941 int z, ///< plane of interest 1942 char *extname, ///< MEF extension name ("PHU" for primary header) 1943 char *filename) ///< file to write data to 2021 psImageWriteSection(psImage *input, ///< image to write out 2022 int x, ///< starting x coord of region 2023 int y, ///< starting y coord of region 2024 int z, ///< plane of interest 2025 const char *extname, ///< MEF extension name ("PHU" for primary header) 2026 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 2027 const char *filename ///< file to write data to 2028 ); 1944 2029 \end{verbatim} 1945 2030 … … 1947 2032 \begin{verbatim} 1948 2033 psImage * 1949 psImageFWriteSection(psImage *input, ///< image to write out 1950 int x, ///< starting x coord of region 1951 int y, ///< starting y coord of region 1952 int z, ///< plane of interest 1953 char *extname, ///< MEF extension name 1954 FILE *f) ///< file descriptor to write data to 2034 psImageFWriteSection(psImage *input, ///< image to write out 2035 int x, ///< starting x coord of region 2036 int y, ///< starting y coord of region 2037 int z, ///< plane of interest 2038 const char *extname, ///< MEF extension name 2039 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 2040 FILE *f ///< file descriptor to write data to 2041 ); 1955 2042 \end{verbatim} 1956 2043 … … 1961 2048 return an error. 1962 2049 \begin{verbatim} 1963 struct psMetadata * 1964 psImageReadHeader(struct psMetadata *output, ///< read data to this structure 1965 char *extname, ///< MEF extension name ("PHU" for primary header) 1966 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 1967 char *filename) ///< file to read from 2050 psMetadata * 2051 psImageReadHeader(psMetadata *output, ///< read data to this structure 2052 const char *extname, ///< MEF extension name ("PHU" for primary header) 2053 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 2054 const char *filename ///< file to read from 2055 ); 1968 2056 \end{verbatim} 1969 2057 … … 1971 2059 structure. 1972 2060 \begin{verbatim} 1973 struct psMetadata * 1974 psImageFReadHeader (struct psMetadata *output, ///< read data to this structure 1975 char *extname, ///< MEF extension name ("PHU" for primary header) 1976 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 1977 FILE *f) ///< file descriptor to read from 2061 psMetadata * 2062 psImageFReadHeader(psMetadata *output, ///< read data to this structure 2063 const char *extname, ///< MEF extension name ("PHU" for primary header) 2064 int extnum, ///< MEF extension number (-1 for "PHU", 0 : Nextend - 1) 2065 FILE *f ///< file descriptor to read from 2066 ); 1978 2067 \end{verbatim} 1979 2068 … … 1982 2071 \begin{verbatim} 1983 2072 psImage * 1984 psImageFFT (psImage *input, ///< image to FFT 1985 int direction) ///< FFT direction 2073 psImageFFT(psImage *output, //!< Output image 2074 const psImage *input, ///< image to FFT 2075 int direction ///< FFT direction 2076 ); 1986 2077 \end{verbatim} 1987 2078 … … 1991 2082 \begin{verbatim} 1992 2083 int 1993 psImageClip (psImage *input, ///< clip this image 1994 float min, ///< clip pixels with values < min 1995 float vmin, ///< set min-clipped pixels to vmin 1996 float max, ///< clip pixels with values > max 1997 float vmax) ///< set max-clipped pixels to vmax 2084 psImageClip(psImage *input, ///< clip this image 2085 float min, ///< clip pixels with values < min 2086 float vmin, ///< set min-clipped pixels to vmin 2087 float max, ///< clip pixels with values > max 2088 float vmax ///< set max-clipped pixels to vmax 2089 ); 1998 2090 \end{verbatim} 1999 2091 … … 2003 2095 \begin{verbatim} 2004 2096 int 2005 psImageClipNaN (psImage *input, ///< clip this image 2006 float value) ///< set nan pixels to this value 2097 psImageClipNaN(psImage *input, ///< clip this image & target 2098 float value ///< set nan pixels to this value 2099 ); 2007 2100 \end{verbatim} 2008 2101 … … 2016 2109 \begin{verbatim} 2017 2110 int 2018 psImageOverlaySection (psImage *image, ///< input image 2019 psImage *overlay, ///< image to overlay 2020 int x0, ///< x offset of overlay subimage 2021 int y0, ///< y offset of overlay subimage 2022 char *operator) ///< overlay operation 2023 \end{verbatim} 2111 psImageOverlaySection(psImage *image, ///< input image & target 2112 const psImage *overlay, ///< image to overlay 2113 int x0, ///< x offset of overlay subimage 2114 int y0, ///< y offset of overlay subimage 2115 const char *operator ///< overlay operation 2116 ); 2117 \end{verbatim} 2118 2119 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 2024 2120 2025 2121 \subsection{Astrometry} … … 2172 2268 typedef struct { 2173 2269 int nCells; ///< Number of Cells assigned 2174 struct psCell *cells;///< Cells in the Chip2175 2176 psMetaDataSet *md; ///< Chip-level metadata2270 psCell *cells; ///< Cells in the Chip 2271 2272 psMetaDataSet *md; ///< Chip-level metadata 2177 2273 psCoordXform *chipToFPA; ///< Transformations from chip coordinates to FPA coordinates 2178 2179 struct psFPA *parentFPA; ///< FPA which contains this chip 2274 psCoordXform *FPAtoChip; //!< Transformations from FPA coordinates to chip 2275 2276 struct psFPA *parentFPA; ///< FPA which contains this chip 2180 2277 } psChip; 2181 2278 \end{verbatim} … … 2207 2304 int nChips; ///< Number of Cells assigned 2208 2305 int nAlloc; ///< Number of Cells available 2209 struct psChip *chips;///< Chips in the Focal Plane Array2210 2211 psMetaDataSet *md; ///< FPA-level metadata2212 psDistortion *TPtoFP; ///< Transformation term from2213 psDistortion *FPtoTP; ///< Transformation term from2214 psFixedPattern *pattern; //!< Fixed pattern residual offsets2306 psChip *chips; ///< Chips in the Focal Plane Array 2307 2308 psMetaDataSet *md; ///< FPA-level metadata 2309 psDistortion *TPtoFP; ///< Transformation term from 2310 psDistortion *FPtoTP; ///< Transformation term from 2311 psFixedPattern *pattern; //!< Fixed pattern residual offsets 2215 2312 psExposure *exp; ///< information about this exposure 2216 2313 psPhotSystem colorPlus, colorMinus; ///< Colour reference … … 2230 2327 2231 2328 \begin{verbatim} 2232 /** Information needed (by SLAL IB) to convert Apparent to Observed Position */2329 /** Information needed (by SLALib) to convert Apparent to Observed Position */ 2233 2330 typedef struct { 2234 2331 double latitude; ///< geodetic latitude (radians) … … 2341 2438 /** returns Chip in FPA which contains the given FPA coordinate */ 2342 2439 psChip * 2343 psChipInFPA (psFPA *fpa, ///< FPA description 2344 psCoord *coord ///< coordinate in FPA 2345 ); 2440 psChipInFPA (psChip *out, //!< Chip to return, or NULL 2441 const psFPA *fpa, ///< FPA description 2442 const psCoord *coord ///< coordinate in FPA 2443 ); 2346 2444 \end{verbatim} 2347 2445 … … 2349 2447 /** returns Cell in Chip which contains the given chip coordinate */ 2350 2448 psCell * 2351 psCellInChip (psChip *chip, ///< chip description 2352 psCoord *coord ///< coordinate in chip 2353 ); 2449 psCellInChip(psCell *out, //!< Cell to return, or NULL 2450 const psChip *chip, ///< chip description 2451 const psCoord *coord ///< coordinate in chip 2452 ); 2354 2453 \end{verbatim} 2355 2454 … … 2361 2460 /** Return the cell in FPA which contains the given FPA coordinates */ 2362 2461 psCell * 2363 psCellInFPA(psCell *out, //!< Cell to return, or NULL2364 psFPA *fpa,//!< FPA description2365 psCoord *coord//!< Coordinate in FPA2366 );2462 psCellInFPA(psCell *out, //!< Cell to return, or NULL 2463 const psFPA *fpa, //!< FPA description 2464 const psCoord *coord //!< Coordinate in FPA 2465 ); 2367 2466 \end{verbatim} 2368 2467 … … 2398 2497 2399 2498 \begin{verbatim} 2400 /** returns Chip in FPA which contains the given FPA coordinate */2401 psChip *2402 psChipInFPA (psChip *out, //!< Chip to return, or NULL2403 psFPA *fpa, ///< FPA description2404 psCoord *coord ///< coordinate in FPA2405 );2406 \end{verbatim}2407 2408 \begin{verbatim}2409 /** returns Cell in Chip which contains the given chip coordinate */2410 psCell *2411 psCellInChip(psCell *out, //!< Cell to return, or NULL2412 psChip *chip, ///< chip description2413 psCoord *coord ///< coordinate in chip2414 );2415 \end{verbatim}2416 2417 \begin{verbatim}2418 /** Return the cell in FPA which contains the given FPA coordinates */2419 psCell *2420 psCellInFPA(psCell *out, //!< Cell to return, or NULL2421 psFPA *fpa, //!< FPA description2422 psCoord *coord //!< Coordinate in FPA2423 );2424 \end{verbatim}2425 2426 \begin{verbatim}2427 2499 /** Convert (RA,Dec) to cell and cell coordinates */ 2428 2500 psCoord * … … 2436 2508 /** Convert cell and cell coordinate to (RA,Dec) */ 2437 2509 psCoord * 2438 psCoordCellToSky(psCoord *out, //!< Coordinates to return, or NULL2439 const psCell *cell,//!< Cell to get coordinates for2440 psCoord *coord//!< cell coordinates to transform2441 );2510 psCoordCellToSky(psCoord *out, //!< Coordinates to return, or NULL 2511 const psCell *cell, //!< Cell to get coordinates for 2512 const psCoord *coord //!< cell coordinates to transform 2513 ); 2442 2514 \end{verbatim} 2443 2515 … … 2445 2517 /** Quick and dirty cell to (RA,Dec) --- employs cellToSky transformation */ 2446 2518 psCoord * 2447 psCoordCellToSkyQuick(psCoord *out, //!< Coordinates to return, or NULL2448 const psCell *cell, //!< Cell description2449 psCoord *coord//!< cell coordinates to transform2450 );2519 psCoordCellToSkyQuick(psCoord *out, //!< Coordinates to return, or NULL 2520 const psCell *cell, //!< Cell description 2521 const psCoord *coord //!< cell coordinates to transform 2522 ); 2451 2523 \end{verbatim} 2452 2524 … … 2454 2526 /** Convert (RA,Dec) to tangent plane coords */ 2455 2527 psCoord * 2456 psCoordSkyToTP(psCoord *out, //!< Coordinates to return, or NULL2457 psexposure *exp,//!< Exposure description2458 psCoord *coord//!< input Sky coordinate2459 );2528 psCoordSkyToTP(psCoord *out, //!< Coordinates to return, or NULL 2529 const psExposure *exp, //!< Exposure description 2530 const psCoord *coord //!< input Sky coordinate 2531 ); 2460 2532 \end{verbatim} 2461 2533 … … 2463 2535 /** Convert tangent plane coords to focal plane coordinates */ 2464 2536 psCoord * 2465 psCoordTPtoFPA(psCoord *out, //!< Coordinates to return, or NULL2466 const psFPA *fpa,//!< FPA description2467 psCoord *coord//!< input TP coordinate2468 );2537 psCoordTPtoFPA(psCoord *out, //!< Coordinates to return, or NULL 2538 const psFPA *fpa, //!< FPA description 2539 const psCoord *coord //!< input TP coordinate 2540 ); 2469 2541 \end{verbatim} 2470 2542 … … 2472 2544 /** converts the specified FPA coord to the coord on the given Chip */ 2473 2545 psCoord * 2474 psCoordFPAtoChip (psCoord *out, //!< Coordinates to return, or NULL 2475 psFPA *fpa, ///< FPA description 2476 psChip *chip, ///< Chip of interest 2477 psCoord *coord ///< input FPA coordinate 2478 ); 2546 psCoordFPAtoChip (psCoord *out, //!< Coordinates to return, or NULL 2547 const psChip *chip, ///< Chip of interest 2548 const psCoord *coord ///< input FPA coordinate 2549 ); 2479 2550 \end{verbatim} 2480 2551 … … 2482 2553 /** converts the specified Chip coord to the coord on the given Cell */ 2483 2554 psCoord * 2484 psCoordChiptoCell (psCoord *out, //!< Coordinates to return, or NULL 2485 psChip *chip, ///< Chip description 2486 psCell *cell, ///< Cell of interest 2487 psCoord *coord ///< input Chip coordinate 2488 ); 2555 psCoordChiptoCell (psCoord *out, //!< Coordinates to return, or NULL 2556 const psCell *cell, ///< Cell of interest 2557 const psCoord *coord ///< input Chip coordinate 2558 ); 2489 2559 \end{verbatim} 2490 2560 … … 2492 2562 /** converts the specified Cell coord to the coord on the parent Chip */ 2493 2563 psCoord * 2494 psCoordCelltoChip (psCoord *out, //!< Coordinates to return, or NULL2495 psCell *cell,///< Cell description2496 psCoord *coord///< input Cell coordinate2497 );2564 psCoordCelltoChip (psCoord *out, //!< Coordinates to return, or NULL 2565 const psCell *cell, ///< Cell description 2566 const psCoord *coord ///< input Cell coordinate 2567 ); 2498 2568 \end{verbatim} 2499 2569 … … 2501 2571 /** converts the specified Chip coord to the coord on the parent FPA */ 2502 2572 psCoord * 2503 psCoordChiptoFPA (psCoord *out, //!< Coordinates to return, or NULL2504 psChip *chip,///< Chip description2505 psCoord *coord///< input Chip coordinate2506 );2573 psCoordChiptoFPA (psCoord *out, //!< Coordinates to return, or NULL 2574 const psChip *chip, ///< Chip description 2575 const psCoord *coord ///< input Chip coordinate 2576 ); 2507 2577 \end{verbatim} 2508 2578 … … 2510 2580 /** Convert focal plane coords to tangent plane coordinates */ 2511 2581 psCoord * 2512 psCoordFPAToTP(psCoord *out, //!< Coordinates to return, or NULL2513 psFPA *fpa,//!< FPA description2514 psCoord *coord//!< input FPA coordinate2515 );2582 psCoordFPAToTP(psCoord *out, //!< Coordinates to return, or NULL 2583 const psFPA *fpa, //!< FPA description 2584 const psCoord *coord //!< input FPA coordinate 2585 ); 2516 2586 \end{verbatim} 2517 2587 … … 2519 2589 /** Convert tangent plane coords to (RA,Dec) */ 2520 2590 psCoord * 2521 psCoordTPtoSky(psCoord *out, //!< Coordinates to return, or NULL2522 psExposure *exp,//!< Exposure description2523 psCoord *coord//!< input TP coordinate2524 );2591 psCoordTPtoSky(psCoord *out, //!< Coordinates to return, or NULL 2592 const psExposure *exp, //!< Exposure description 2593 const psCoord *coord //!< input TP coordinate 2594 ); 2525 2595 \end{verbatim} 2526 2596 … … 2528 2598 /** Convert Cell coords to FPA coordinates */ 2529 2599 psCoord * 2530 psCoordCellToFPA(psCoord *out, //!< Coordinates to return, or NULL2531 psCell *cell,//!< Cell description2532 psCoord *coord//!< Input cell coordinates2533 );2600 psCoordCellToFPA(psCoord *out, //!< Coordinates to return, or NULL 2601 const psCell *cell, //!< Cell description 2602 const psCoord *coord //!< Input cell coordinates 2603 ); 2534 2604 \end{verbatim} 2535 2605 … … 2594 2664 fields: 2595 2665 \begin{verbatim} 2596 /* 2597 * A struct to define a single item of metadata 2598 */ 2666 /** A struct to define a single item of metadata */ 2599 2667 typedef struct { 2600 const int id; //unique ID for this item2601 2602 char *name; // Name ofitem2603 psMetaData Type type; // type ofthis item2668 const int id; //!< unique ID for this item 2669 char *restrict name; //!< Name of item 2670 psMetaDataType type; //!< type of this item 2671 psMetaDataFlags flags; //!< flags associated with this item 2604 2672 const union { 2605 float f; // floating value 2606 int i; // integer value 2607 void *v; // other type 2608 } val; // value of metadata 2609 char *comment; // optional comment ("", not NULL) 2673 float f; //!< floating value 2674 int i; //!< integer value 2675 void *v; //!< other type 2676 } val; //!< value of metadata 2677 char *comment; //!< optional comment ("", not NULL) 2678 psDlist *restrict items; //!< list of psMetaDataItems with the same name 2610 2679 } psMetaDataItem; 2611 2680 \end{verbatim} … … 2623 2692 \code{psMetaDataType} (see also table \ref{tabMetaDataTypes}); the initial defined values are: 2624 2693 \begin{verbatim} 2625 /* 2626 * Possible types of metadata. 2627 */ 2628 typedef enum { // type of val is: 2629 psMetaFloat, // float (.f) 2630 psMetaInt, // int (.i) 2631 psMetaStr, // string (.v) 2632 psMetaImg, // image (.v) 2633 psMetaJPEG, // JPEG (.v) 2634 psMetaPNG, // PNG (.v) 2635 psMetaAstrom, // astrometric coefficients (.v) 2636 psMetaUnknown, // other (.v) 2637 psMetaNType // Number of types; must be last 2694 /** Possible types of metadata. */ 2695 typedef enum { //!< type of val is: 2696 PS_META_ITEM_SET = 0, //!< NULL; metadata is in psMetaDataType.items 2697 PS_META_FLOAT, //!< float (.f) 2698 PS_META_INT, //!< int (.i) 2699 PS_META_STR, //!< string (.v) 2700 PS_META_IMG, //!< image (.v) 2701 PS_META_JPEG, //!< JPEG (.v) 2702 PS_META_PNG, //!< PNG (.v) 2703 PS_META_ASTROM, //!< astrometric coefficients (.v) 2704 PS_META_UNKNOWN, //!< other (.v) 2705 PS_META_NTYPE //!< Number of types; must be last 2638 2706 } psMetaDataType; 2639 2707 \end{verbatim} … … 2643 2711 \textbf{Value} & \textbf{Type} & \textbf{member of union} & \textbf{Comments}\\ 2644 2712 \hline 2645 psMetaFloat& float & f & value, not pointer, is stored \\2646 psMetaInt& int & i & value, not pointer, is stored \\2647 psMetaStr& string & v & value, not pointer to original, is stored \\2648 psMetaImg& psImage & v & \\2649 psMetaJPEG & JPEG & v & \\2650 psMetaPNG & PNG & v & \\2651 psMetaAstrom& psAstrom & v & \\2652 psMetaUnknown& other & v & \\2653 psMetaNType& (none) & & The number of types defined2713 PS_META_FLOAT & float & f & value, not pointer, is stored \\ 2714 PS_META_INT & int & i & value, not pointer, is stored \\ 2715 PS_META_STR & string & v & value, not pointer to original, is stored \\ 2716 PS_META_IMG & psImage & v & \\ 2717 PS_META_JPEG & JPEG & v & \\ 2718 PS_META_PNG & PNG & v & \\ 2719 PS_META_ASTROM & psAstrom & v & \\ 2720 PS_META_UNKNOWN & other & v & \\ 2721 PS_META_NTYPE & (none) & & The number of types defined 2654 2722 \end{tabular} 2655 2723 \begin{caption}{Supported Metadata Types} … … 2662 2730 2663 2731 \begin{verbatim} 2732 /** A set of metadata */ 2664 2733 typedef struct { 2665 psDlist * list; //list of psMetaDataItem2666 psHash * table; //hash table of the same metadata2734 psDlist *restrict list; //!< list of psMetaDataItem 2735 psHash *restrict table; //!< hash table of the same metadata 2667 2736 } psMetaDataSet; 2668 2737 \end{verbatim} … … 2745 2814 2746 2815 \begin{verbatim} 2747 psMetaDataItem *psMetaDataItemAlloc( 2748 psMetaDataType type, // type of this piece of metadata 2749 const void *val, // value of new item 2750 // N.b. a pointer even if the item 2751 // is of type e.g. int 2752 const char *comment, // comment associated with item 2753 const char *name, // name of new item of metadata (may be an sprintf format) 2754 ...); // possible arguments for name format 2755 2756 void psMetaDataItemFree(psMetaDataItem *ms); // piece of metadata to destroy 2757 2758 psMetaDataSet *psMetaDataSetAlloc(void); // make a new set of metadata 2759 void psMetaDataSetDel(psMetaDataSet *ms); // destroy a set of metadata 2760 2761 /*****************************************************************************/ 2762 /* 2763 * Utilities 2764 */ 2765 psMetaDataItem *psMetaDataAppend(psMetaDataSet *restrict ms, psMetaDataItem *restrict item); 2766 psMetaDataItem *psMetaDataRemove(psMetaDataSet *restrict ms, const char *restrict key); 2767 2768 void psMetaDataSetIterator(psMetaDataSet *ms); 2769 psMetaDataItem *psMetaDataGetNext(psMetaDataSet *ms); 2770 psMetaDataItem *psMetaDataLookup(const psMetaDataSet *ms, const char *key); 2771 2772 void psMetaDataItemPrint(FILE *fd, // file descriptor to write to 2773 const psMetaDataItem *ms); // item of metadata to print 2816 /** Constructor */ 2817 psMetaDataItem *psMetaDataItemAlloc(int typeFlags, //!< type of this piece of metadata + flags 2818 const void *val, //!< value of new item N.b. a pointer even if the item 2819 //!< is of type e.g. int 2820 const char *comment, //!< comment associated with item 2821 const char *name, //!< name of new item of metadata (may be in sprintf 2822 //!< format) 2823 ... //!< possible arguments for name format 2824 ); 2825 2826 /** Destructor */ 2827 void psMetaDataItemFree(psMetaDataItem *ms //!< piece of metadata to destroy 2828 ); 2829 /** Constructor */ 2830 psMetaDataSet *psMetaDataSetAlloc(void); //!< make a new set of metadata 2831 2832 /** Destructor */ 2833 void psMetaDataSetFree(psMetaDataSet *ms //!< destroy a set of metadata 2834 ); 2835 2836 /**** Utilities **********************************************************************/ 2837 2838 /// Add entry to the end of the metadata set 2839 psMetaDataItem *psMetaDataAppend(psMetaDataSet *restrict ms, //!< Metadata set to add to 2840 psMetaDataItem *restrict item //!< Metatdata to add 2841 ); 2842 2843 /// delete entry from the metadata set 2844 psMetaDataItem *psMetaDataRemove(psMetaDataSet *restrict ms, //!< Metadata set to delete from 2845 const char *restrict key //!< Key to delete 2846 ); 2847 2848 /// reset the iterator to the start of the list 2849 void psMetaDataSetIterator(psMetaDataSet *ms //!< Metadata set to set iterator for 2850 ); 2851 2852 /// get the next entry in the sequence 2853 psMetaDataItem *psMetaDataGetNext(psMetaDataSet *restrict ms, //!< Metadata set to get from 2854 const char *restrict match //!< Match this 2855 ); 2856 2857 /// find the metadata with the specified key 2858 psMetaDataItem *psMetaDataLookup(const psMetaDataSet *restrict ms, //!< Metadata set to look up 2859 const char *restrict key //!< Key to find 2860 ); 2861 2862 /// print metadata item to the specified stream 2863 void psMetaDataItemPrint(FILE *fd, //!< file descriptor to write to 2864 const psMetaDataItem *restrict ms, //!< item of metadata to print 2865 const char *prefix //!< print this at the beginning of each line 2866 ); 2774 2867 \end{verbatim} 2775 2868 … … 2834 2927 \begin{verbatim} 2835 2928 /** apply the coordinate transformation to the given coordinate */ 2836 psCoord *psCoordXformApply (psCoordXform *frame, ///< coordinate transformation 2837 psCoord *coords) ///< input coordiate 2838 ; 2929 psCoord *psCoordXformApply (psCoord *out, //!< Output coordinates, or NULL 2930 const psCoordXform *frame, ///< coordinate transformation 2931 const psCoord *coords ///< input coordiate 2932 ); 2839 2933 \end{verbatim} 2840 2934 2841 2935 \begin{verbatim} 2842 2936 /** apply the optical distortion to the given coordinate, magnitude, color */ 2843 psCoord *psDistortionApply (psDistortion *pattern, ///< optical distortion pattern 2844 psCoord *coords, ///< input coordinate 2845 float mag, ///< magnitude of object 2846 float color) ///< color of object 2847 ; 2937 psCoord *psDistortionApply (psCoord *out, //!< Output coordinates, or NULL 2938 const psdistortion *pattern, ///< optical distortion pattern 2939 const psCoord *coords, ///< input coordinate 2940 float mag, ///< magnitude of object 2941 float color ///< color of object 2942 ); 2848 2943 \end{verbatim} 2849 2944 … … 2858 2953 psCoord * 2859 2954 psGetOffset(const psCoord *restrict position1, //!< Position 1 2860 const psCoord *restrict position2, //!< Position 22861 const char *type//!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc2955 const psCoord *restrict position2, //!< Position 2 2956 const char *type //!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc 2862 2957 ); 2863 2958 \end{verbatim} … … 2867 2962 psCoord * 2868 2963 psApplyOffset(const psCoord *restrict position, //!< Position 2869 const psCoord *restrict offset, //!< Offset2870 const char *type//!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc2964 const psCoord *restrict offset, //!< Offset 2965 const char *type //!< Type of offset: Linear, Spherical/Arcsec, Spherical/Degreees etc 2871 2966 ); 2872 2967 \end{verbatim} … … 2881 2976 /** Get Sun Position */ 2882 2977 psCoord * 2883 psGetSunPos(float mjd )//!< MJD to get position for2884 ;2978 psGetSunPos(float mjd //!< MJD to get position for 2979 ); 2885 2980 \end{verbatim} 2886 2981 … … 2888 2983 /** Get Moon position */ 2889 2984 psCoord * 2890 psGetMoonPos(float mjd, //!< MJD to get position for2891 double latitude,//!< Latitude for apparent position2892 double longitude)//!< Longitude for apparent position2893 ;2985 psGetMoonPos(float mjd, //!< MJD to get position for 2986 double latitude, //!< Latitude for apparent position 2987 double longitude //!< Longitude for apparent position 2988 ); 2894 2989 \end{verbatim} 2895 2990 … … 2897 2992 /** Get Moon phase */ 2898 2993 float 2899 psGetMoonPhase(float mjd )//!< MJD to get phase for2900 ;2994 psGetMoonPhase(float mjd //!< MJD to get phase for 2995 ); 2901 2996 \end{verbatim} 2902 2997 … … 2904 2999 /** Get Planet positions */ 2905 3000 psCoord * 2906 psGetSolarSystemPos(c har *solarSystemObject, //!< Named S.S. object2907 float mjd)//!< MJD to get position for2908 ;3001 psGetSolarSystemPos(const char *solarSystemObject, //!< Named S.S. object 3002 float mjd //!< MJD to get position for 3003 ); 2909 3004 \end{verbatim} 2910 3005 … … 2917 3012 /** Convert ICRS to Ecliptic */ 2918 3013 psCoord * 2919 psCoordinatesItoE(const psCoord *restrict coordinates )//!< ICRS coordinates to convert2920 ;3014 psCoordinatesItoE(const psCoord *restrict coordinates //!< ICRS coordinates to convert 3015 ); 2921 3016 \end{verbatim} 2922 3017 … … 2924 3019 /** Convert Ecliptic to ICRS */ 2925 3020 psCoord * 2926 psCoordinatesEtoI(const psCoord *restrict coordinates )//!< Ecliptic coordinates to convert2927 ;3021 psCoordinatesEtoI(const psCoord *restrict coordinates //!< Ecliptic coordinates to convert 3022 ); 2928 3023 \end{verbatim} 2929 3024 … … 2931 3026 /** Convert ICRS to Galactic */ 2932 3027 psCoord * 2933 psCoordinatesItoG(const psCoord *restrict coordinates )//!< ICRS coordinates to convert2934 ;3028 psCoordinatesItoG(const psCoord *restrict coordinates //!< ICRS coordinates to convert 3029 ); 2935 3030 \end{verbatim} 2936 3031 … … 2938 3033 /** Convert Galactic to ICRS */ 2939 3034 psCoord * 2940 psCoordinatesGtoI(const psCoord *restrict coordinates )//!< Galactic coordinates to convert2941 ;3035 psCoordinatesGtoI(const psCoord *restrict coordinates //!< Galactic coordinates to convert 3036 ); 2942 3037 \end{verbatim} 2943 3038
Note:
See TracChangeset
for help on using the changeset viewer.
