Changeset 4021
- Timestamp:
- May 24, 2005, 1:44:45 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (282 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r3992 r4021 1 %%% $Id: psLibSDRS.tex,v 1.23 1 2005-05-20 00:43:57 priceExp $1 %%% $Id: psLibSDRS.tex,v 1.232 2005-05-24 23:44:45 jhoblitt Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 195 195 as determined from CVS tags. 196 196 197 \begin{ verbatim}197 \begin{prototype} 198 198 const char *psLibVersion(void); 199 \end{ verbatim}199 \end{prototype} 200 200 201 201 \subsection{Initialization} … … 211 211 212 212 The prototype is: 213 \begin{ verbatim}213 \begin{prototype} 214 214 void psLibInit(const char *timeConfig); 215 \end{ verbatim}215 \end{prototype} 216 216 217 217 \code{timeConfig} specifies the filename of the configuration file … … 220 220 \subsection{Finalization} 221 221 222 \begin{ verbatim}222 \begin{prototype} 223 223 void psFinalize(void); 224 \end{ verbatim}224 \end{prototype} 225 225 226 226 \code{psLibFinalize} shall free memory that was allocated by … … 327 327 follows: 328 328 % 329 \filbreak330 \begin{ verbatim}329 %\filbreak 330 \begin{datatype} 331 331 typedef struct { 332 332 const void* startblock; ///< initialised to p_psMEMMAGIC … … 347 347 typedef unsigned long psMemoryId; 348 348 typedef unsigned long psReferenceCount; 349 \end{ verbatim}349 \end{datatype} 350 350 % 351 351 The PSLib memory management system must maintain the collection of … … 421 421 blocks: 422 422 % 423 \begin{ verbatim}423 \begin{prototype} 424 424 void *psAlloc(size_t size); 425 425 void *psRealloc(void *ptr, size_t size); 426 426 void *psFree(void *ptr); 427 \end{ verbatim}427 \end{prototype} 428 428 % 429 429 From the user's perspective, the functions \code{psAlloc}, … … 433 433 preprocessor macros which call the following private functions: 434 434 % 435 \begin{ verbatim}435 \begin{prototype} 436 436 void *p_psAlloc(size_t size, const char *file, int line); 437 437 void *p_psRealloc(void *ptr, size_t size, const char *file, int line); 438 438 void p_psFree(void *ptr, const char *file, int line); 439 \end{ verbatim}439 \end{prototype} 440 440 % 441 441 In these function calls, \code{size} is the number of bytes required … … 480 480 usually insufficient. 481 481 482 \begin{ verbatim}482 \begin{prototype} 483 483 void psMemSetDeallocator(void* ptr, psFreeFcn freeFcn); 484 484 psFreeFcn psMemGetDeallocator(void* ptr); 485 \end{ verbatim}485 \end{prototype} 486 486 487 487 A free function handles any deallocation procedures of an object … … 551 551 following form: 552 552 % 553 \begin{ verbatim}553 \begin{datatype} 554 554 typedef void (*psMemExhaustedCallback)(size_t size); 555 \end{datatype} 556 557 \begin{prototype} 555 558 psMemExhaustedCallback psMemExhaustedCallbackSet(psMemExhaustedCallback func); 556 \end{ verbatim}559 \end{prototype} 557 560 % 558 561 The callback function is called with the attempted size and is … … 569 572 has the following form: 570 573 % 571 \begin{ verbatim}574 \begin{datatype} 572 575 typedef void (*psMemProblemCallback)(psMemBlock *ptr, char *file, int lineno); 576 \end{datatype} 577 578 \begin{prototype} 573 579 psMemProblemCallback psMemProblemCallbackSet(psMemProblemCallback func); 574 \end{ verbatim}580 \end{prototype} 575 581 % 576 582 This callback may be used to report the error and other status … … 595 601 following two functions: 596 602 % 597 \begin{ verbatim}603 \begin{prototype} 598 604 psMemoryId psMemAllocateCallbackSetID(psMemoryId id); 599 605 psMemoryId psMemFreeCallbackSetID(psMemoryId id); 600 \end{ verbatim}606 \end{prototype} 601 607 % 602 608 The corresponding callbacks have the following form: 603 609 % 604 \begin{ verbatim}610 \begin{datatype} 605 611 typedef psMemoryId (*psMemAllocateCallback)(const psMemBlock *ptr); 612 \end{datatype} 613 614 \begin{prototype} 606 615 psMemAllocateCallback psMemAllocateCallbackSet(psMemAllocateCallback func); 616 \end{prototype} 617 618 \begin{datatype} 607 619 typedef psMemoryId (*psMemFreeCallback)(const psMemBlock *ptr); 620 \end{datatype} 621 622 \begin{prototype} 608 623 psMemFreeCallback psMemFreeCallbackSet(psMemFreeCallback func); 609 624 psMemoryId psMemGetId(void); 610 \end{ verbatim}625 \end{prototype} 611 626 % 612 627 The callback functions are called with a pointer to the corresponding … … 633 648 this part of the memory API are shown below. 634 649 % 635 \begin{ verbatim}650 \begin{prototype} 636 651 int psMemCheckLeaks(psMemoryId id0, psMemBlock ***array, FILE *fd, bool persistence); 637 652 int psMemCheckCorruption(bool abort_on_error); 638 \end{ verbatim}653 \end{prototype} 639 654 % 640 655 The routine \code{psMemCheckLeaks} may be used to check for memory … … 687 702 APIs are: 688 703 % 689 \begin{ verbatim}704 \begin{prototype} 690 705 psReferenceCount psMemGetRefCounter(const void *vptr); 691 706 void *psMemIncrRefCounter(const void *vptr); 692 707 void *psMemDecrRefCounter(void *vptr); 693 \end{ verbatim}708 \end{prototype} 694 709 % 695 710 The functions all take a pointer to the start of a user block of … … 812 827 its trace level and facility, is: 813 828 % 814 \begin{ verbatim}829 \begin{prototype} 815 830 void psTrace(const char *facil, int myLevel,...); 816 \end{ verbatim}831 \end{prototype} 817 832 % 818 833 where the last argument is a printf-style formatting code and possible … … 826 841 following function: 827 842 % 828 \begin{ verbatim}843 \begin{prototype} 829 844 int psTraceSetLevel(const char *facil, int level); 830 \end{ verbatim}845 \end{prototype} 831 846 % 832 847 where \code{level} specifies the current trace level for the facility … … 834 849 facility may be determined by the function: 835 850 % 836 \begin{ verbatim}851 \begin{prototype} 837 852 int psTraceGetLevel(const char *facil); 838 \end{ verbatim}853 \end{prototype} 839 854 % 840 855 which returns the trace level of the named facility following the … … 849 864 levels of all facilities: 850 865 % 851 \begin{ verbatim}866 \begin{prototype} 852 867 void psTracePrintLevels(void); 853 \end{ verbatim}.868 \end{prototype} 854 869 % 855 870 This function prints the hierarchy of trace facilities along with the … … 914 929 The trace may optionally be written to a file on specifying a filename 915 930 with \code{psTraceSetDestination}: 916 \begin{ verbatim}931 \begin{prototype} 917 932 void psTraceSetDestination(FILE *fp); 918 \end{ verbatim}933 \end{prototype} 919 934 If the \code{fp} is \code{NULL}, then the trace is sent to standard 920 935 output, otherwise it is sent to the specified file pointer. … … 940 955 A log message is placed in the code with the command: 941 956 % 942 \begin{ verbatim}957 \begin{prototype} 943 958 void psLogMsg(const char *name, int myLevel, const char *fmt, ...); 944 959 void psLogMsgV(const char *name, int myLevel, const char *fmt, va_list ap); 945 \end{ verbatim}960 \end{prototype} 946 961 where \code{name} is a word to describe the source of the message, 947 962 \code{myLevel} is the severity level of this message, and \code{fmt} … … 954 969 the first 4 levels are associated with symbolic names: 955 970 % 956 \begin{ verbatim}971 \begin{datatype} 957 972 enum { PS_LOG_ABORT = 0, PS_LOG_ERROR, PS_LOG_WARN, PS_LOG_INFO }; 958 \end{ verbatim}973 \end{datatype} 959 974 % 960 975 … … 962 977 above which log messages are ignored, using the function: 963 978 % 964 \begin{ verbatim}979 \begin{prototype} 965 980 int psLogSetLevel(int level); 966 \end{ verbatim}981 \end{prototype} 967 982 % 968 983 This function returns the previous log level. A specific message … … 974 989 Log messages are sent to the destination most recently set using: 975 990 % 976 \begin{ verbatim}991 \begin{prototype} 977 992 bool psLogSetDestination(const char *dest); 978 \end{ verbatim}993 \end{prototype} 979 994 % 980 995 The destination string consists of a URL in the form … … 990 1005 The output format is controlled with the function: 991 1006 % 992 \begin{ verbatim}1007 \begin{prototype} 993 1008 bool psLogSetFormat(const char *fmt); 994 \end{ verbatim}1009 \end{prototype} 995 1010 % 996 1011 which expects a string consisting of the letters \code{H} (host), … … 1043 1058 \code{psError} prints an error message and doesn't abort, but instead 1044 1059 returns the error code. 1045 \begin{ verbatim}1060 \begin{prototype} 1046 1061 psErrorCode p_psError(const char *file, int lineno, const char *func, psErrorCode code, bool new, 1047 1062 const char *fmt, ...); 1063 \end{prototype} 1064 \begin{datatype} 1048 1065 #define psError(code, new, fmt, ...) psError(__FILE__, __LINE__, __func__, code, new, fmt, __VA_ARGS__) 1049 \end{ verbatim}1066 \end{datatype} 1050 1067 1051 1068 \code{psError} is a macro definition that allows the filename, line … … 1066 1083 1067 1084 The errors on the error stack are defined as the following: 1068 \begin{ verbatim}1085 \begin{datatype} 1069 1086 typedef struct { 1070 1087 char *name; ///< category of code that caused the error … … 1072 1089 char *msg; ///< the message associated with the error 1073 1090 } psErr; 1074 \end{ verbatim}1091 \end{datatype} 1075 1092 1076 1093 The last error reported is available from \code{psErrorLast}; if no … … 1081 1098 The error stack may be completely cleared with \code{psErrorClear}. 1082 1099 % 1083 \begin{ verbatim}1100 \begin{prototype} 1084 1101 unsigned int psErrorGetStackSize(void); 1085 1102 const psErr *psErrorGet(int which); 1086 1103 const psErr *psErrorLast(void); 1087 1104 void psErrorClear(void); 1088 \end{ verbatim}1105 \end{prototype} 1089 1106 1090 1107 \code{psErrorGetStackSize} shall return the number of errors on the … … 1099 1116 \code{psErrorStackPrintV} must not invoke \code{va_end}. 1100 1117 % 1101 \begin{ verbatim}1118 \begin{prototype} 1102 1119 void psErrorStackPrint(FILE *fd, const char *fmt, ...); 1103 1120 void psErrorStackPrintV(FILE *fd, const char *fmt, va_list va); 1104 \end{ verbatim}1121 \end{prototype} 1105 1122 1106 1123 Any \code{errorCode}s less then or equal to \code{PS_ERR_BASE} (see … … 1111 1128 The routine \code{psErrorCodeString} returns the string associated 1112 1129 with an error code: 1113 \begin{ verbatim}1130 \begin{prototype} 1114 1131 const char *psErrorCodeString(psErrorCode code); 1115 \end{ verbatim}1132 \end{prototype} 1116 1133 1117 1134 \subsubsection{Error Codes} … … 1128 1145 error codes and associated message strings. An array of error codes 1129 1146 may be registered with the PSLib error handler using the function: 1130 \begin{ verbatim}1147 \begin{prototype} 1131 1148 void psErrorRegister(const psErrorDescription *errors, int nerror); 1132 \end{ verbatim}1149 \end{prototype} 1133 1150 where the errors are represented internally as follows: 1134 \begin{ verbatim}1151 \begin{datatype} 1135 1152 typedef struct { 1136 1153 psErrorCode code; ///< An error code 1137 1154 const char *descrip; ///< the associated description 1138 1155 } psErrorDescription; 1139 \end{ verbatim}1156 \end{datatype} 1140 1157 PSLib internal errors must be registered with the function 1141 1158 \code{psErrorRegister}, which should be called as part of the … … 1179 1196 enumerated type \code{psErrorCode} with elements \code{PS_ERR_NAME} 1180 1197 and values as specified in \file{psErrorCodes.dat}, e.g. 1181 \begin{ verbatim}1198 \begin{datatype} 1182 1199 #if !defined(PS_ERROR_CODES_H) 1183 1200 #define PS_ERROR_CODES_H … … 1193 1210 } psErrorCode; 1194 1211 #endif 1195 \end{ verbatim}1212 \end{datatype} 1196 1213 1197 1214 Any \code{errorCode}s less then or equal to \code{PS_ERR_BASE} must be … … 1208 1225 \code{PS_LOG_ABORT}, and then call \code{abort}. 1209 1226 1210 \begin{ verbatim}1227 \begin{prototype} 1211 1228 void psAbort(const char *name, const char *fmt,...); 1212 \end{ verbatim}1229 \end{prototype} 1213 1230 1214 1231 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 1260 1277 Supported data types must be defined by a structure in which 1261 1278 the first element is always of type \code{psType}: 1262 \begin{ verbatim}1279 \begin{datatype} 1263 1280 typedef struct { 1264 1281 psDimen dimen; ///< The dimensionality 1265 1282 psElemType type; ///< The type 1266 1283 } psType; 1267 \end{ verbatim}1284 \end{datatype} 1268 1285 where \code{psDimen dimen} defines the dimensionality of the data and 1269 1286 \code{psElemType type} defines the data type of each element. These 1270 1287 two variable types are defined as: 1271 \begin{ verbatim}1288 \begin{datatype} 1272 1289 typedef enum { 1273 1290 PS_DIMEN_SCALAR, ///< Scalar … … 1277 1294 PS_DIMEN_OTHER ///< Not supported for arithmetic 1278 1295 } psDimen; 1279 \end{ verbatim}1296 \end{datatype} 1280 1297 and 1281 \begin{ verbatim}1298 \begin{datatype} 1282 1299 typedef enum { 1283 1300 PS_TYPE_S8, ///< Character … … 1295 1312 PS_TYPE_BOOL ///< Boolean value 1296 1313 } psElemType; 1297 \end{ verbatim}1314 \end{datatype} 1298 1315 We discuss the application of \code{psType} in more detail in 1299 1316 section~\ref{sec:arithmetic}. … … 1305 1322 which interpret the data type from the structure when deciding how to 1306 1323 perform an operation. The basic scalar structure is: 1307 \begin{ verbatim}1324 \begin{datatype} 1308 1325 typedef struct { 1309 1326 psType type; ///< data type information … … 1319 1336 } data; 1320 1337 } psScalar; 1321 \end{ verbatim}1338 \end{datatype} 1322 1339 1323 1340 In addition, we specify two functions for working with \code{psScalar} data: 1324 \begin{ verbatim}1341 \begin{prototype} 1325 1342 psScalar *psScalarAlloc(psC64 value, psElemType dataType); 1326 1343 psScalar *psScalarCopy(const psScalar *value); 1327 \end{ verbatim}1344 \end{prototype} 1328 1345 The first creates a \code{psType}-ed structure from a constant value, 1329 1346 casting it as appropriate based on the \code{dataType}. The second … … 1340 1357 single structure, \code{psVector} to represent these concepts: 1341 1358 % 1342 \begin{ verbatim}1359 \begin{datatype} 1343 1360 typedef struct { 1344 1361 psType type; ///< vector data type and dimension … … 1360 1377 } data; 1361 1378 } psVector; 1362 \end{ verbatim}1379 \end{datatype} 1363 1380 % 1364 1381 In this structure, the argument \code{n} is the length of the array … … 1372 1389 associated with a constructor and reallocator: 1373 1390 % 1374 \begin{ verbatim}1391 \begin{prototype} 1375 1392 psVector *psVectorAlloc(int nalloc, psElemType type); 1376 1393 psVector *psVectorRealloc(psVector *vector, int nalloc); 1377 1394 psVector *psVectorRecycle(psVector *vector, int nalloc, psElemType type); 1378 \end{ verbatim}1395 \end{prototype} 1379 1396 % 1380 1397 In these functions, \code{nalloc} is the number of elements to … … 1396 1413 shall be allocated and returned. 1397 1414 1398 \begin{ verbatim}1415 \begin{prototype} 1399 1416 psVector *psVectorExtend(psVector *vector, int delta, int nExtend); 1400 \end{ verbatim}1417 \end{prototype} 1401 1418 1402 1419 This function increments \code{psVector.n}, the number of elements in … … 1408 1425 Here is an example of how \code{psVectorExtend} is used to 1409 1426 automatically increment the vector length. 1410 \begin{ verbatim}1427 \begin{datatype} 1411 1428 // create data vector 1412 1429 psVector *y = psVectorAlloc (100); … … 1419 1436 // increments n by 1, extends length if needed by 100 1420 1437 } 1421 \end{ verbatim}1438 \end{datatype} 1422 1439 Note that the specification that the allocation always be greater than 1423 1440 the number of elements by twice the number of new elements implies … … 1425 1442 elements, as in this example. 1426 1443 1427 \begin{ verbatim}1444 \begin{prototype} 1428 1445 psVector *psVectorCopy(psVector *output, const psVector *input, psElemType type); 1429 \end{ verbatim}1446 \end{prototype} 1430 1447 1431 1448 \code{psVectorCopy} shall copy the elements in the \code{input} vector … … 1441 1458 value. We require a basic image data type: 1442 1459 1443 \begin{ verbatim}1460 \begin{datatype} 1444 1461 typedef struct psImage { 1445 1462 psType type; ///< image data type and dimension … … 1463 1480 psArray *children; ///< children of this region 1464 1481 } psImage; 1465 \end{ verbatim}1482 \end{datatype} 1466 1483 1467 1484 This structure represents an image consisting of a 2-D array of … … 1485 1502 psS16, psU8, psU16, psF32, psF64, psC32, psC64}. 1486 1503 1487 \begin{ verbatim}1504 \begin{prototype} 1488 1505 psImage *psImageAlloc (int width, int height, psElemType type); 1489 1506 psImage* psImageRecycle(psImage* old, int numCols, int numRows, const psElemType type); 1490 \end{ verbatim}1507 \end{prototype} 1491 1508 1492 1509 \code{psImageAlloc} shall create an image of a specified \code{width}, \code{height}, and data … … 1501 1518 shall be allocated and returned. 1502 1519 1503 \begin{ verbatim}1520 \begin{prototype} 1504 1521 int psImageFreeChildren(psImage* image); 1505 \end{ verbatim}1522 \end{prototype} 1506 1523 1507 1524 \code{psImageFreeChildren} shall free all child images of the given … … 1515 1532 data type testing may be safely performed. 1516 1533 1517 \begin{ verbatim}1534 \begin{datatype} 1518 1535 typedef struct { 1519 1536 psType type; ///< data type information 1520 1537 } psMath; 1521 \end{ verbatim}1538 \end{datatype} 1522 1539 1523 1540 \subsection{Simple Arrays} … … 1526 1543 define \code{psArray} to carry such a collection: 1527 1544 % 1528 \begin{ verbatim}1545 \begin{datatype} 1529 1546 typedef struct { 1530 1547 const int n; ///< size of array … … 1532 1549 void **data; ///< pointer to data block 1533 1550 } psArray; 1534 \end{ verbatim}1551 \end{datatype} 1535 1552 % 1536 1553 In this structure, the argument \code{n} is the length of the array … … 1540 1557 destructor: 1541 1558 % 1542 \begin{ verbatim}1559 \begin{prototype} 1543 1560 psArray *psArrayAlloc(int nalloc); 1544 1561 psArray *psArrayRealloc(const psArray *array, int nalloc); 1545 \end{ verbatim}1562 \end{prototype} 1546 1563 % 1547 1564 In these functions, \code{nalloc} is the number of elements to … … 1558 1575 error. 1559 1576 1560 \begin{ verbatim}1577 \begin{prototype} 1561 1578 psArray *psArrayAdd(psArray *array, int delta, const void *value); 1562 \end{ verbatim}1579 \end{prototype} 1563 1580 1564 1581 This function adds a value to the end of an array. If the current … … 1568 1585 value is less than 1, 10 shall be used). 1569 1586 1570 \begin{ verbatim}1587 \begin{prototype} 1571 1588 psBool psArrayRemove(psArray *array, const psPtr value); 1572 \end{ verbatim}1589 \end{prototype} 1573 1590 1574 1591 This function removes all entries of \code{value} in the \code{array}, … … 1577 1594 \code{FALSE}. 1578 1595 1579 \begin{ verbatim}1596 \begin{prototype} 1580 1597 psBool psArraySet(psArray* in, psU32 position, const void* value); 1581 1598 void* psArrayGet(const psArray* in, psU32 position); 1582 \end{ verbatim}1599 \end{prototype} 1583 1600 1584 1601 These accessor functions are provided as a convenience to the user. … … 1588 1605 specified \code{position}. 1589 1606 1590 \begin{ verbatim}1607 \begin{prototype} 1591 1608 psArray *psArraySort(psArray *array, int (*compare)(const void **a, const void **b) ); 1592 \end{ verbatim}1609 \end{prototype} 1593 1610 An array may be sorted using \code{psArraySort}, which requires the 1594 1611 specification of a comparison function to specify how the objects on … … 1602 1619 \PS{} shall support doubly linked lists through a type \code{psList}: 1603 1620 % 1604 \begin{ verbatim}1621 \begin{datatype} 1605 1622 typedef struct { 1606 1623 unsigned int size; ///< number of elements on list … … 1610 1627 pthread_mutex_t lock; ///< mutex to lock a node during changes 1611 1628 } psList; 1612 \end{ verbatim}1629 \end{datatype} 1613 1630 % 1614 1631 The type \code{psList} represents the container of the list. It has a … … 1621 1638 The elements of the list are defined by the type \code{psListElem}: 1622 1639 % 1623 \begin{ verbatim}1640 \begin{datatype} 1624 1641 typedef struct psListElem { 1625 1642 struct psListElem *prev; ///< previous link in list … … 1627 1644 void *data; ///< real data item 1628 1645 } psListElem; 1629 \end{ verbatim}1646 \end{datatype} 1630 1647 % 1631 1648 which includes a pointer to the next element in the list … … 1634 1651 element. The following supporting functions are required: 1635 1652 1636 \begin{ verbatim}1653 \begin{prototype} 1637 1654 psList *psListAlloc(const void *data); 1638 \end{ verbatim}1655 \end{prototype} 1639 1656 Create a list. This function may take a pointer to a data item, or it 1640 1657 may take \code{NULL}. The allocator creates both the \code{psList} … … 1656 1673 Iteration on the list shall be achieved by means of a list iterator 1657 1674 type: 1658 \begin{ verbatim}1675 \begin{datatype} 1659 1676 typedef struct { 1660 1677 psList *list; ///< List iterator works on … … 1664 1681 bool mutable; ///< Is it permissible to modify the list? 1665 1682 } psListIterator; 1666 \end{ verbatim}1683 \end{datatype} 1667 1684 The \code{psListIterator} keeps track of which list element the 1668 1685 iterator \code{cursor} is currently pointing at. \code{index} is the … … 1678 1695 1679 1696 The corresponding constructor shall be: 1680 \begin{ verbatim}1697 \begin{prototype} 1681 1698 psListIterator *psListIteratorAlloc(const psList *list, int location, bool mutable); 1682 \end{ verbatim}1699 \end{prototype} 1683 1700 Here, \code{list} is the \code{psList} on which the iterator will 1684 1701 iterate, and \code{location} is the initial starting point, and may be … … 1696 1713 A list \code{iterator} shall be set to a specific \code{location} on 1697 1714 the list upon calling \code{psListIteratorSet}: 1698 \begin{ verbatim}1715 \begin{prototype} 1699 1716 bool psListIteratorSet(psListIterator *iterator, int location); 1700 \end{ verbatim}1717 \end{prototype} 1701 1718 Again, the \code{location} may be a numerical index or it may be one 1702 1719 of the special values: \code{PS_LIST_HEAD} or \code{PS_LIST_TAIL}, … … 1706 1723 otherwise. 1707 1724 1708 \begin{ verbatim}1725 \begin{prototype} 1709 1726 bool psListAdd(psList *list, int location, const void *data); 1710 1727 bool psListAddAfter(psListIterator *iterator, const void *data); 1711 1728 bool psListAddBefore(psListIterator *iterator, const void *data); 1712 \end{ verbatim}1729 \end{prototype} 1713 1730 the first function, \code{psListAdd}, adds an entry to the \code{list} 1714 1731 and returns a boolean giving the success or failure of the … … 1724 1741 cursor position of the \code{iterator}. 1725 1742 1726 \begin{ verbatim}1743 \begin{prototype} 1727 1744 void *psListGet(psList *list, int location); 1728 1745 void *psListGetAndIncrement(psListIterator *iterator); 1729 1746 void *psListGetAndDecrement(psListIterator *iterator); 1730 \end{ verbatim}1747 \end{prototype} 1731 1748 A data item may be retrieved from the list with these functions. The 1732 1749 first function, \code{psListGet} simply returns the value specified by … … 1754 1771 longer off the end of the list. 1755 1772 1756 \begin{ verbatim}1773 \begin{prototype} 1757 1774 bool psListRemove(psList *list, int location) 1758 1775 bool psListRemoveData(psList *list, const void *data); 1759 \end{ verbatim}1776 \end{prototype} 1760 1777 A data item may be removed from the list with these functions. For 1761 1778 \code{psListRemove}, the value of \code{location} may be the numerical … … 1773 1790 \code{false}. 1774 1791 1775 \begin{ verbatim}1792 \begin{prototype} 1776 1793 psArray *psListToArray(const psList *list); 1777 1794 psList *psArrayToList(const psArray *array); 1778 \end{ verbatim}1795 \end{prototype} 1779 1796 These two functions are available to convert between the 1780 1797 \code{psList} and \code{psArray} containers. These functions do not … … 1782 1799 increment the reference counter for each of the elements. 1783 1800 1784 \begin{ verbatim}1801 \begin{prototype} 1785 1802 psList *psListSort(psList *list, int (*compare)(const void **a, const void **b) ); 1786 \end{ verbatim}1803 \end{prototype} 1787 1804 A list may be sorted using \code{psListSort}, which requires the 1788 1805 specification of a comparison function to specify how the objects on … … 1814 1831 table at any one time.} 1815 1832 % 1816 \begin{ verbatim}1833 \begin{datatype} 1817 1834 typedef struct { 1818 1835 int nbucket; ///< number of buckets 1819 1836 psHashBucket **buckets; ///< the buckets themselves 1820 1837 } psHash; 1821 \end{ verbatim}1838 \end{datatype} 1822 1839 % 1823 1840 where \code{nbucket} is the number of buckets defined for the hash … … 1825 1842 individual buckets, each of which is defined by: 1826 1843 % 1827 \begin{ verbatim}1844 \begin{datatype} 1828 1845 typedef struct psHashBucket { 1829 1846 char *key; ///< key for this item of data … … 1831 1848 struct psHashBucket *next; ///< list of other possible keys 1832 1849 } psHashBucket; 1833 \end{ verbatim}1850 \end{datatype} 1834 1851 where each bucket contains the value of the \code{key}, a pointer to 1835 1852 the \code{data}, and a pointer to the \code{next} list entry in the … … 1837 1854 1838 1855 A hash table is created with the following function: 1839 \begin{ verbatim}1856 \begin{prototype} 1840 1857 psHash *psHashAlloc(int nbuckets); 1841 \end{ verbatim}1858 \end{prototype} 1842 1859 which allocates the space for the hash table, creating and 1843 1860 initializing \code{nbuckets} hash buckets. … … 1846 1863 1847 1864 A data item may be added to the hash table with the function: 1848 \begin{ verbatim}1865 \begin{prototype} 1849 1866 bool psHashAdd(psHash *table, const char *key, const void *data); 1850 \end{ verbatim}1867 \end{prototype} 1851 1868 In this function, the value of the string \code{key} is used to 1852 1869 construct the hash value, find the appropriate bucket set, and add the … … 1857 1874 1858 1875 The data associated with a given key may be found with the function: 1859 \begin{ verbatim}1876 \begin{prototype} 1860 1877 void *psHashLookup(const psHash *table, const char *key); 1861 \end{ verbatim}1878 \end{prototype} 1862 1879 which returns the data value pointed to by the element associated with 1863 1880 \code{key}, or the value \code{NULL} if no match is found. Similarly, 1864 1881 a specific key may be removed (deleted) with the function: 1865 \begin{ verbatim}1882 \begin{prototype} 1866 1883 bool psHashRemove(psHash *table, const char *key); 1867 \end{ verbatim}1884 \end{prototype} 1868 1885 The function returns a value of \code{true} if the operation was 1869 1886 successfull, and \code{false} otherwise. 1870 1887 1871 1888 The function 1872 \begin{ verbatim}1889 \begin{prototype} 1873 1890 psList *psHashKeyList(const psHash *table); 1874 \end{ verbatim}1891 \end{prototype} 1875 1892 returns the complete list of defined keys associated with the 1876 1893 \code{psHash} table as a linked list. 1877 1894 1878 \begin{ verbatim}1895 \begin{prototype} 1879 1896 psArray *psHashToArray(const psHash *hash); 1880 \end{ verbatim}1897 \end{prototype} 1881 1898 This function places the data in a \code{psHash} into a \code{psArray} 1882 1899 container. This function does not free the elements or destroy the … … 1896 1913 generally useful, and so we specify a separate function that may be 1897 1914 called independently: 1898 \begin{ verbatim}1915 \begin{prototype} 1899 1916 psArray *psVectorsReadFromFile(const char *filename, const char *format); 1900 \end{ verbatim}1917 \end{prototype} 1901 1918 \code{psVectorsReadFromFile} shall return an array of 1902 1919 \code{psVector}s, read from the specified \code{filename}. The file … … 1911 1928 is to be skipped. 1912 1929 1913 1914 \begin{verbatim} 1930 \begin{datatype} 1915 1931 typedef struct { 1916 1932 const char *filename; ///< File from which data is to be read … … 1921 1937 const psF64 validFrom, validTo; ///< Range of validity 1922 1938 } psLookupTable; 1923 \end{ verbatim}1939 \end{datatype} 1924 1940 1925 1941 \code{filename} shall specify the file from which the lookup table … … 1938 1954 1939 1955 The constructor shall be: 1940 \begin{ verbatim}1956 \begin{prototype} 1941 1957 psLookupTable *psLookupTableAlloc(const char *filename, ///< File from which to read 1942 1958 const char *format ///< scanf-like format string 1943 1959 int indexCol ///< Column of the index vector (starting at zero) 1944 1960 ); 1945 \end{ verbatim}1961 \end{prototype} 1946 1962 This function shall allocate a \code{psLookupTable}, and set the 1947 1963 appropriate values, but it shall not read the lookup table. This is … … 1951 1967 The destructor shall free all the components. 1952 1968 1953 \begin{ verbatim}1969 \begin{prototype} 1954 1970 psLookupTable *psLookupTableImport(psLookupTable *table, ///< Lookup table into which to import 1955 1971 const psArray *vectors, ///< Array of vectors 1956 1972 int indexCol ///< Index of the index vector in the array of vectors 1957 1973 ); 1958 \end{ verbatim}1974 \end{prototype} 1959 1975 \code{psLookupTableImport} shall import an array of vectors into a 1960 1976 \code{table}. If \code{table} is \code{NULL}, a new … … 1971 1987 function returning. 1972 1988 1973 \begin{ verbatim}1989 \begin{prototype} 1974 1990 int psLookupTableRead(psLookupTable *table); 1975 \end{ verbatim}1991 \end{prototype} 1976 1992 \code{psLookupTableRead} combines \code{psVectorsReadFromFile} and 1977 1993 \code{psLookupTableImport} to read the appropriate file and import the … … 1983 1999 Interpolation on a lookup table is performed by the following 1984 2000 functions: 1985 \begin{ verbatim}2001 \begin{prototype} 1986 2002 psF64 psLookupTableInterpolate(const psLookupTable *table, psF64 index, int column, psLookupStatusType *status); 1987 2003 psVector *psLookupTableInterpolateAll(const psLookupTable *table, psF64 index, psVector *stats); 1988 \end{ verbatim}2004 \end{prototype} 1989 2005 Both functions shall interpolate the \code{table} at the provided 1990 2006 \code{index}. For \code{psLookupTableInterpolate}, only the value in … … 2029 2045 \code{ceil(n/8)} bytes must be allocated. The bitset structure is 2030 2046 define by: 2031 \begin{ verbatim}2047 \begin{datatype} 2032 2048 typedef struct { 2033 2049 int n; ///< Number of chars that form the bitset 2034 2050 char *bits; ///< The bits 2035 2051 } psBitSet; 2036 \end{ verbatim}2052 \end{datatype} 2037 2053 2038 2054 We also require the corresponding constructor and destructor: 2039 \begin{ verbatim}2055 \begin{prototype} 2040 2056 psBitSet *psBitSetAlloc(int n); 2041 \end{ verbatim}2057 \end{prototype} 2042 2058 where \code{n} is the requested number of bits. 2043 2059 … … 2051 2067 The corresponding APIs are defined below: 2052 2068 2053 \begin{ verbatim}2069 \begin{prototype} 2054 2070 psBitSet *psBitSetSet(psBitSet *myBits, int bit); 2055 2071 psBitSet* psBitSetClear(psBitSet* inBits, int bit); … … 2058 2074 bool psBitSetTest(const psBitSet *checkBits, int bit); 2059 2075 char *psBitSetToString(const pBitSet* bits); 2060 \end{ verbatim}2076 \end{prototype} 2061 2077 2062 2078 \code{psBitSetSet} sets the specified \code{bit} in the … … 2095 2111 psF64}. The input and output vectors must have the same type. 2096 2112 2097 \begin{ verbatim}2113 \begin{prototype} 2098 2114 psVector *psVectorSort(psVector *out, const psVector *in); 2099 \end{ verbatim}2115 \end{prototype} 2100 2116 2101 2117 We also require the ability to sort one vector based on another. For … … 2109 2125 input types \code{psS8, psU16, psF32, psF64}. 2110 2126 2111 \begin{ verbatim}2127 \begin{prototype} 2112 2128 psVector *psVectorSortIndex(psVector *out; const psVector *in); 2113 \end{ verbatim}2129 \end{prototype} 2114 2130 2115 2131 The sorted vectors may be accessed in the following manner: … … 2153 2169 function: 2154 2170 2155 \begin{ verbatim}2171 \begin{prototype} 2156 2172 psStats *psVectorStats(psStats *stats, 2157 2173 const psVector *in, … … 2160 2176 unsigned int maskVal 2161 2177 ); 2162 \end{ verbatim}2178 \end{prototype} 2163 2179 % 2164 2180 This function takes the input data in \code{in} (with optional … … 2192 2208 desired statistical quantities: 2193 2209 2194 \begin{ verbatim}2210 \begin{datatype} 2195 2211 /** generic statistics structure */ 2196 2212 typedef struct { … … 2218 2234 psStatsOptions options; ///< bitmask of calculated values 2219 2235 } psStats; 2220 \end{ verbatim}2236 \end{datatype} 2221 2237 where \code{psStatsOptions} is defined with entries to turn on the 2222 2238 calculation of each of the statistics: 2223 2239 2224 \begin{ verbatim}2240 \begin{datatype} 2225 2241 /** statistics which may be calculated */ 2226 2242 typedef enum { … … 2241 2257 PS_STAT_USE_BINSIZE = 0x004000 2242 2258 } psStatsOptions; 2243 \end{ verbatim}2259 \end{datatype} 2244 2260 2245 2261 A constructor is also required: 2246 2262 % 2247 \begin{ verbatim}2263 \begin{prototype} 2248 2264 psStats *psStatsAlloc(psStatsOptions options); 2249 \end{ verbatim}2265 \end{prototype} 2250 2266 2251 2267 \subsubsection{Histograms} … … 2255 2271 upper and lower bounds for each of the bins. We define the following 2256 2272 data structure to represent a histogram: 2257 \begin{ verbatim}2273 \begin{datatype} 2258 2274 typedef struct { 2259 2275 const psVector *bounds; ///< Bounds for the bins … … 2262 2278 bool uniform; ///< Is it a uniform distribution? 2263 2279 } psHistogram; 2264 \end{ verbatim}2280 \end{datatype} 2265 2281 In this structure, the vector \code{bounds} specifies the boundaries 2266 2282 of the histogram bins, and must of type \code{psF32}, while … … 2277 2293 with the size of the bins. 2278 2294 2279 \begin{ verbatim}2295 \begin{prototype} 2280 2296 psHistogram *psHistogramAlloc(float lower, float upper, int n); 2281 \end{ verbatim}2297 \end{prototype} 2282 2298 where \code{lower} specifies the lower bound of the histogram range, 2283 2299 \code{upper} specified the upper bound of the histogram range, and … … 2287 2303 A histogram with a more flexible bin set may be constructed with the 2288 2304 following constructor: 2289 \begin{ verbatim}2305 \begin{prototype} 2290 2306 psHistogram *psHistogramAllocGeneric(const psVector *bounds); 2291 \end{ verbatim}2307 \end{prototype} 2292 2308 where the \code{psVector *bounds} (of type \code{psF32}) is defined by 2293 2309 the user to specify the boundaries of the histogram bins. This … … 2297 2313 vector (\code{values}), and optionally the \code{errors} in the input 2298 2314 values. It alters and returns the histogram \code{out} structure. 2299 \begin{ verbatim}2315 \begin{prototype} 2300 2316 psHistogram *psVectorHistogram(psHistogram *out, 2301 2317 const psVector *values, … … 2303 2319 const psVector *mask, 2304 2320 unsigned int maskVal); 2305 \end{ verbatim}2321 \end{prototype} 2306 2322 The \code{values} vector may be of types \code{psU8, psU16, psF32, 2307 2323 psF64}, with the \code{errors} vector of the corresponding type. … … 2330 2346 This leads us to define the following polynomial types: 2331 2347 2332 \begin{ verbatim}2348 \begin{datatype} 2333 2349 /** One-dimensional polynomial */ 2334 2350 typedef struct { … … 2339 2355 char *mask; ///< Coefficient mask 2340 2356 } psPolynomial1D; 2341 \end{ verbatim}2342 2343 \begin{ verbatim}2357 \end{datatype} 2358 2359 \begin{datatype} 2344 2360 /** Two-dimensional polynomial */ 2345 2361 typedef struct { … … 2350 2366 char **mask; ///< Coefficients mask 2351 2367 } psPolynomial2D; 2352 \end{ verbatim}2368 \end{datatype} 2353 2369 2354 2370 etc., up to four dimensions. \code{psPolynomialType} is an … … 2356 2372 or Chebyshev: 2357 2373 2358 \begin{ verbatim}2374 \begin{datatype} 2359 2375 typedef enum { 2360 2376 PS_POLYNOMIAL_ORD, ///< Ordinary polynomial 2361 2377 PS_POLYNOMIAL_CHEB ///< Chebyshev polynomial 2362 2378 } psPolynomialType; 2363 \end{ verbatim}2379 \end{datatype} 2364 2380 2365 2381 We also define double-precision versions of the polynomials: 2366 2382 2367 \begin{ verbatim}2383 \begin{datatype} 2368 2384 /** Double-precision one-dimensional polynomial */ 2369 2385 typedef struct { … … 2374 2390 char *mask; ///< Coefficient mask 2375 2391 } psDPolynomial1D; 2376 \end{ verbatim}2377 2378 \begin{ verbatim}2392 \end{datatype} 2393 2394 \begin{datatype} 2379 2395 /** Double-precision two-dimensional polynomial */ 2380 2396 typedef struct { … … 2385 2401 char **mask; ///< Coefficients mask 2386 2402 } psDPolynomial2D; 2387 \end{ verbatim}2403 \end{datatype} 2388 2404 2389 2405 etc. In what follows, we only show the version for double-precision … … 2392 2408 2393 2409 The constructor is: 2394 \begin{ verbatim}2410 \begin{prototype} 2395 2411 psDPolynomial2D *psDPolynomial2DAlloc(int nX, int nY, psPolynomialType type); 2396 \end{ verbatim}2412 \end{prototype} 2397 2413 where \code{nX} and \code{nY} are the number of terms in x and y 2398 2414 respectively. The coefficients, errors and masks are set initially to … … 2400 2416 2401 2417 To evaluate the polynomials at specific coordinates, we define: 2402 \begin{ verbatim}2418 \begin{prototype} 2403 2419 double psDPolynomial2DEval(const psDPolynomial2D *myPoly, double x, double y); 2404 \end{ verbatim}2420 \end{prototype} 2405 2421 2406 2422 In the event that several evaluations are required, we also define: 2407 \begin{ verbatim}2423 \begin{prototype} 2408 2424 psVector *psDPolynomial2DEvalVector(const psDPolynomial2D *myPoly, const psVector *x, const psVector *y); 2409 \end{ verbatim}2425 \end{prototype} 2410 2426 If the \code{x} and \code{y} vectors do not match the precision of the 2411 2427 polynomial, the function shall generate a warning, and convert the … … 2425 2441 incorporated into PSLib: 2426 2442 2427 \begin{ verbatim}2443 \begin{datatype} 2428 2444 typedef struct { 2429 2445 int n; ///< Number of spline pieces … … 2431 2447 psVector *knots; ///< The boundaries between each spline piece. Size is n+1. 2432 2448 } psSpline1D; 2433 \end{ verbatim}2449 \end{datatype} 2434 2450 2435 2451 The \code{psSpline1D} structure consists of an array of \code{n} … … 2444 2460 2445 2461 Of course, we require the appropriate constructors and destructor: 2446 \begin{ verbatim}2462 \begin{prototype} 2447 2463 psSpline1D *psSpline1DAlloc(int n, int order, float min, float max); 2448 2464 psSpline1D *psSpline1DAllocGeneric(const psVector *bounds, int order); 2449 \end{ verbatim}2465 \end{prototype} 2450 2466 2451 2467 \code{psSpline1DAlloc} shall allocate and return a \code{psSpline1D}, … … 2469 2485 for an input vector of ordinates. 2470 2486 2471 \begin{ verbatim}2487 \begin{prototype} 2472 2488 float psSpline1DEval(const psSpline1D *spline, float x); 2473 2489 psVector *psSpline1DEvalVector(const psSpline1D *spline, const psVector *x); 2474 \end{ verbatim}2490 \end{prototype} 2475 2491 2476 2492 \subsubsection{Gaussians} … … 2481 2497 2482 2498 The Gaussian evaluation is provide by: 2483 \begin{ verbatim}2499 \begin{prototype} 2484 2500 float psGaussian(float x, float mean, float sigma, bool normal); 2485 \end{ verbatim}2501 \end{prototype} 2486 2502 which evaluates a Gaussian with the given \code{mean} and \code{sigma} 2487 2503 at the given coordinate \code{x}. If \code{normal} is true, the … … 2517 2533 (\code{lastDelta}). 2518 2534 2519 \begin{ verbatim}2535 \begin{datatype} 2520 2536 typedef struct { 2521 2537 const int maxIter; ///< Maximum number of iterations … … 2525 2541 float lastDelta; ///< Last change before quitting 2526 2542 } psMinimization; 2527 \end{ verbatim}2543 \end{datatype} 2528 2544 2529 2545 The corresponding allocator is: 2530 \begin{ verbatim}2546 \begin{prototype} 2531 2547 psMinimization *psMinimizationAlloc(int maxIter, float tol); 2532 \end{ verbatim}2548 \end{prototype} 2533 2549 2534 2550 \subsubsection{Levenberg-Marquardt} … … 2539 2555 parameters and coordinate vectors, along with the derivatives of the 2540 2556 function with respect to each of the parameters, \code{deriv}: 2541 \begin{ verbatim}2557 \begin{datatype} 2542 2558 typedef float (*psMinimizeLMChi2Func)(psVector *deriv, const psVector *params, const psVector *x); 2543 \end{ verbatim}2559 \end{datatype} 2544 2560 2545 2561 Then \code{psMinimizeLMChi2} shall fit the specified function, … … 2547 2563 Levenberg-Marquardt method: 2548 2564 2549 \begin{ verbatim}2565 \begin{prototype} 2550 2566 bool psMinimizeLMChi2(psMinimization *min, psImage *covar, psVector *params, 2551 2567 const psVector *paramMask, const psArray *x, const psVector *y, 2552 2568 const psVector *yErr, psMinimizeLMChi2Func func); 2553 \end{ verbatim}2569 \end{prototype} 2554 2570 2555 2571 The function shall return \code{false} in the event that there was an … … 2594 2610 %% minimization, used for the purpose of performing $\chi^2$ fitting: 2595 2611 2596 %% \begin{ verbatim}2612 %% \begin{prototype} 2597 2613 %% psMinimizeLMChi2Func psMinimizeLMChi2Gauss1D; 2598 2614 %% psMinimizeLMChi2Func psMinimizeLMChi2Gauss2D; 2599 %% \end{ verbatim}2615 %% \end{prototype} 2600 2616 2601 2617 %% \code{psMinimizeChi2LMGauss1D} shall take as \code{params}, the … … 2620 2636 the parameters and coordinate vectors, but now the derivatives are not 2621 2637 known: 2622 \begin{ verbatim}2638 \begin{datatype} 2623 2639 typedef float (*psMinimizePowellFunc)(const psVector *params, const psArray *coords); 2624 \end{ verbatim}2640 \end{datatype} 2625 2641 2626 2642 Then \code{psMinimizePowell} shall minimize the specified function, 2627 2643 \code{func}, using the Powell method: 2628 2644 2629 \begin{ verbatim}2645 \begin{prototype} 2630 2646 bool psMinimizePowell(psMinimization *min, psVector *params, const psVector *paramMask, 2631 2647 const psArray *coords, psMinimizePowellFunc func); 2632 \end{ verbatim}2648 \end{prototype} 2633 2649 2634 2650 The inputs and general behavior of this function is the same as for … … 2641 2657 general functions to data. 2642 2658 2643 \begin{ verbatim}2659 \begin{datatype} 2644 2660 typedef psVector* (*psMinimizeChi2PowellFunc)(const psVector *params, const psArray *coords); 2645 2661 \end{datatype} 2662 2663 \begin{prototype} 2646 2664 bool psMinimizeChi2Powell(psMinimization *min, psVector *params, const psVector *paramMask, 2647 2665 const psArray *coords, const psVector *value, const psVector *error, 2648 2666 psMinimizeChi2PowellFunc model); 2649 \end{ verbatim}2667 \end{prototype} 2650 2668 2651 2669 The inputs and general behavior of \code{psMinimizeChi2Powell} is … … 2672 2690 \subsubsection{Analytical fits} 2673 2691 2674 \begin{ verbatim}2692 \begin{prototype} 2675 2693 psPolynomial1D *psVectorFitPolynomial1D(psPolynomial1D *myPoly, const psVector *x, const psVector *y, 2676 2694 const psVector *yErr); 2677 \end{ verbatim}2695 \end{prototype} 2678 2696 \code{psVectorFitPolynomial1d} returns the polynomial that best fits the 2679 2697 observations. The input parameters are a polynomial that specifies … … 2686 2704 function must be valid only for types \code{psF32}, \code{psF64}. 2687 2705 2688 \begin{ verbatim}2706 \begin{prototype} 2689 2707 psSpline1D *psVectorFitSpline1D(const psVector *x, const psVector *y, int nKnots); 2690 \end{ verbatim}2708 \end{prototype} 2691 2709 \code{psVectorFitSpline1D} shall return the spline that best fits the 2692 2710 given combination of ordinates (\code{x}) and coordinates (\code{y}). … … 2710 2728 In many places, we need to refer to a rectangular area. We define a 2711 2729 structure to represent a rectangle: 2712 \begin{ verbatim}2730 \begin{datatype} 2713 2731 typedef struct { 2714 2732 float x0; … … 2717 2735 float y1; 2718 2736 } psRegion; 2719 \end{ verbatim}2737 \end{datatype} 2720 2738 This structure is used in psLib as an abbreviation for the four 2721 2739 floats, and is defined statically. Functions which accept or return a … … 2731 2749 \code{psRegion} to the corresponding IRAF description. 2732 2750 2733 \begin{ verbatim}2751 \begin{prototype} 2734 2752 psRegion psRegionSet(float x0, float x1, float y0, float y1); 2735 2753 psRegion psRegionFromString(const char *region); 2736 2754 char *psRegionToString(const psRegion region); 2737 \end{ verbatim}2755 \end{prototype} 2738 2756 2739 2757 All functions which use a psRegion must interpret the definition of … … 2748 2766 \subsubsection{Image Structure Manipulation} 2749 2767 2750 \begin{ verbatim}2768 \begin{prototype} 2751 2769 psImage *psImageSubset(psImage *image, psRegion region); 2752 \end{ verbatim}2770 \end{prototype} 2753 2771 Define a subimage of the specified area of the given image. This 2754 2772 function must raise an error if the requested subset area lies outside … … 2766 2784 \code{psF32}, \code{psF64}, \code{psC32}, \code{psC64}. 2767 2785 2768 \begin{ verbatim}2786 \begin{prototype} 2769 2787 psImage *psImageCopy(psImage *output, const psImage *input, psElemType type); 2770 \end{ verbatim}2788 \end{prototype} 2771 2789 Create a copy of the specified image, converting the type in the 2772 2790 process. If the output target pointer is not \code{NULL}, place the … … 2778 2796 \code{psF32}, \code{psF64}, \code{psC32}, \code{psC64}. 2779 2797 2780 \begin{ verbatim}2798 \begin{prototype} 2781 2799 psImage *psImageTrim(psImage *image, psRegion region); 2782 \end{ verbatim}2800 \end{prototype} 2783 2801 Trim the specified \code{image} in-place, which involves shuffling the 2784 2802 pixels around in memory. The region to be kept is defined by the … … 2797 2815 \subsubsection{Image Pixel Extractions} 2798 2816 2799 \begin{ verbatim}2817 \begin{datatype} 2800 2818 typedef enum { 2801 2819 PS_CUT_X_POS, ///< Cut in positive x direction … … 2804 2822 PS_CUT_Y_NEG ///< Cut in negative y direction 2805 2823 } psImageCutDirection; 2806 2824 \end{datatype} 2825 2826 \begin{prototype} 2807 2827 psVector *psImageSlice(psVector *out, 2808 2828 psVector *coords, … … 2813 2833 psImageCutDirection direction, 2814 2834 const psStats *stats); 2815 \end{ verbatim}2835 \end{prototype} 2816 2836 Extract pixels from rectilinear region to a vector (array of floats). 2817 2837 The output vector contains either \code{region.x1-region.x0} or … … 2839 2859 \code{psF32}, \code{psF64}. 2840 2860 2841 \begin{ verbatim}2861 \begin{prototype} 2842 2862 psVector *psImageCut(psVector *out, 2843 2863 psVector *coords, … … 2848 2868 unsigned int nSamples, 2849 2869 psImageInterpolateMode mode); 2850 \end{ verbatim}2870 \end{prototype} 2851 2871 Extract pixels along a line segment, \code{(region.x0,region.y0)} to 2852 2872 \code{(region.x1,region.y1)}, on the image to a vector of the same … … 2860 2880 \code{psS8}, \code{psU16}, \code{psF32}, \code{psF64}. 2861 2881 2862 \begin{ verbatim}2882 \begin{prototype} 2863 2883 psVector *psImageRadialCut(psVector *out, 2864 2884 const psImage *input, … … 2869 2889 const psVector *radii, 2870 2890 const psStats *stats); 2871 \end{ verbatim}2891 \end{prototype} 2872 2892 Extract radial region data to a vector. A vector is constructed where 2873 2893 each vector elements is derived from the statistics of the pixels … … 2889 2909 specification of the interpolation scheme to be used. This 2890 2910 information is carried by the following enum: 2891 \begin{ verbatim}2911 \begin{datatype} 2892 2912 typedef enum { 2893 2913 PS_INTERPOLATE_FLAT, … … 2901 2921 PS_INTERPOLATE_LANCZOS4_VARIANCE 2902 2922 } psImageInterpolateMode mode; 2903 \end{ verbatim}2923 \end{datatype} 2904 2924 2905 2925 The first five are fairly straightforward. The last four, however, … … 2912 2932 the noise (adding in quadrature). 2913 2933 2914 \begin{ verbatim}2934 \begin{prototype} 2915 2935 psImage *psImageRebin(psImage *out, const psImage *in, 2916 2936 const psImage *mask, 2917 2937 unsigned int maskVal, 2918 2938 int scale, const psStats *stats); 2919 \end{ verbatim}2939 \end{prototype} 2920 2940 Rebin image to new scale. A new image is constructed in which the 2921 2941 dimensions are reduced by a factor of \code{1 / scale}. The … … 2935 2955 \code{psU16}, \code{psF32} and \code{psF64}. 2936 2956 2937 \begin{ verbatim}2957 \begin{prototype} 2938 2958 psImage *psImageResample(psImage *out, const psImage *in, 2939 2959 int scale, psImageInterpolateMode mode); 2940 \end{ verbatim}2960 \end{prototype} 2941 2961 Resample image to new scale. A new image is constructed in which the 2942 2962 dimensions are increased by a factor of \code{scale}. The … … 2946 2966 pixels using the specified interpolation method (\code{mode}). 2947 2967 2948 \begin{ verbatim}2968 \begin{prototype} 2949 2969 psImage *psImageRotate(psImage *out, const psImage *input, float angle, 2950 2970 psC64 exposed, psImageInterpolateMode mode); 2951 \end{ verbatim}2971 \end{prototype} 2952 2972 Rotate the input image by given angle, specified in radians. The 2953 2973 output image must contain all of the pixels from the input image in … … 2960 2980 \code{psF32}, \code{psF64}, \code{psC32}, \code{psC64}. 2961 2981 2962 \begin{ verbatim}2982 \begin{prototype} 2963 2983 psImage *psImageShift(psImage *out, const psImage *input, 2964 2984 float dx, float dy, psC64 exposed, psImageInterpolateMode mode); 2965 \end{ verbatim}2985 \end{prototype} 2966 2986 Shift image by an arbitrary number of pixels (\code{dx,dy}) in either 2967 2987 direction. If the shift values are fractional, the output pixel … … 2974 2994 \code{psF64}, \code{psC32}, \code{psC64}. 2975 2995 2976 \begin{ verbatim}2996 \begin{prototype} 2977 2997 psImage *psImageRoll(psImage *out, const psImage *input, int dx, int dy); 2978 \end{ verbatim}2998 \end{prototype} 2979 2999 Roll image by an integer number of pixels (\code{dx,dy}) in either 2980 3000 direction. The output image is the same dimensions as the input … … 2984 3004 \code{psC32}, \code{psC64}. 2985 3005 2986 \begin{ verbatim}3006 \begin{prototype} 2987 3007 psImage *psImageTransform(psImage *output, 2988 3008 psArray **blankPixels, … … 2995 3015 psImageInterpolateMode mode, 2996 3016 double exposedValue); 2997 \end{ verbatim}3017 \end{prototype} 2998 3018 Transform the \code{input} image according the supplied 2999 3019 transformation. The size of the transformed image is defined by the … … 3027 3047 \subsubsection{Image Statistical Functions} 3028 3048 3029 \begin{ verbatim}3049 \begin{prototype} 3030 3050 psStats *psImageStats(psStats *stats, 3031 3051 const psImage *in, 3032 3052 const psImage *mask, 3033 3053 unsigned int maskVal); 3034 \end{ verbatim}3054 \end{prototype} 3035 3055 Determine statistics for image (or subimage). The statistics to be 3036 3056 determined are specified by \code{stats}. The \code{mask} allows … … 3040 3060 \code{psF64}. 3041 3061 3042 \begin{ verbatim}3062 \begin{prototype} 3043 3063 psHistogram *psImageHistogram(psHistogram *out, 3044 3064 const psImage *in, 3045 3065 const psImage *mask, 3046 3066 unsigned int maskVal); 3047 \end{ verbatim}3067 \end{prototype} 3048 3068 Construct a histogram from an image (or subimage). The histogram to 3049 3069 generate is specified by \code{psHistogram hist} (see … … 3054 3074 \code{psF64}. 3055 3075 3056 \begin{ verbatim}3076 \begin{prototype} 3057 3077 psPolynomial2D *psImageFitPolynomial(psPolynomial2D *coeffs, const psImage *input); 3058 \end{ verbatim}3078 \end{prototype} 3059 3079 Fit a 2-D Chebychev polynomial surface to an image. The input 3060 3080 structure \code{coeffs} contains the desired order and terms of … … 3062 3082 following types: \code{psS8}, \code{psU16}, \code{psF32}, \code{psF64}. 3063 3083 3064 \begin{ verbatim}3084 \begin{prototype} 3065 3085 psImage *psImageEvalPolynomial(psImage *input, const psPolynomial2D *coeffs); 3066 \end{ verbatim}3086 \end{prototype} 3067 3087 Evaluate a 2-D polynomial surface for the image pixels. Given the 3068 3088 input polynomial coefficients, set the image pixel values on the basis … … 3070 3090 following types: \code{psS8}, \code{psU16}, \code{psF32}, \code{psF64}. 3071 3091 3072 \begin{ verbatim}3092 \begin{prototype} 3073 3093 psC64 psImagePixelInterpolate(const psImage *input, float x, float y, 3074 3094 const psImage *mask, unsigned int maskVal, 3075 3095 psC64 unexposedValue, psImageInterpolateMode mode); 3076 \end{ verbatim}3096 \end{prototype} 3077 3097 Perform interpolation of image pixel values to the given fractional 3078 3098 coordinate \code{x,y}. The function returns the interpolated value of … … 3087 3107 \subsubsection{Image Pixel Manipulations} 3088 3108 3089 \begin{ verbatim}3109 \begin{prototype} 3090 3110 int psImageClip(psImage *input, double min, double vmin, double max, double vmax); 3091 \end{ verbatim}3111 \end{prototype} 3092 3112 Clip image values outside of range to given values. All pixels with 3093 3113 values \code{< min} are set to the value \code{vmin}. All pixels with … … 3106 3126 0.0 for the imaginary component. 3107 3127 3108 \begin{ verbatim}3128 \begin{prototype} 3109 3129 int psImageClipComplexRegion(psImage *input, complex double min, complex double vmin, 3110 3130 complex double max, complex double vmax); 3111 \end{ verbatim}3131 \end{prototype} 3112 3132 Clip image values outside of range to given values. All pixels with 3113 3133 values \code{< min} are set to the value \code{vmin}. All pixels with … … 3124 3144 \code{min} or \code{max} to be out of range. 3125 3145 3126 \begin{ verbatim}3146 \begin{prototype} 3127 3147 int psImageClipNaN(psImage *input, float value); 3128 \end{ verbatim}3148 \end{prototype} 3129 3149 Clip \code{NaN} image pixels to given value. Pixels with \code{NaN}, 3130 3150 \code{+Inf} or \code{-Inf} values are set to the specified value. … … 3135 3155 set to the specified value. 3136 3156 3137 \begin{ verbatim}3157 \begin{prototype} 3138 3158 int psImageOverlaySection(psImage *image, const psImage *overlay, 3139 3159 int x0, int y0, const char *op); 3140 \end{ verbatim}3160 \end{prototype} 3141 3161 Overlay subregion of image with another image. Replace the pixels in 3142 3162 the \code{image} which correspond to the pixels in \code{overlay} with … … 3154 3174 \subsubsection{Mask operations} 3155 3175 3156 \begin{ verbatim}3176 \begin{prototype} 3157 3177 psImage *psImageGrowMask(psImage *out, const psImage *in, unsigned int maskVal, 3158 3178 unsigned int growSize, unsigned int growValue); 3159 \end{ verbatim}3179 \end{prototype} 3160 3180 3161 3181 \code{psImageGrowMask} grows specified values on the input mask image, … … 3184 3204 through an entire mask image checking each pixel. 3185 3205 3186 \begin{ verbatim}3206 \begin{datatype} 3187 3207 typedef struct { 3188 3208 int x; // x coordinate … … 3195 3215 psPixelCoord *data; // The pixel coordinates 3196 3216 } psPixels; 3197 \end{ verbatim}3198 3199 \begin{ verbatim}3217 \end{datatype} 3218 3219 \begin{prototype} 3200 3220 psPixels *psPixelsAlloc(int nalloc); 3201 3221 psPixels *psPixelsRealloc(psPixels *pixels, int nalloc); 3202 \end{ verbatim}3222 \end{prototype} 3203 3223 3204 3224 \code{psPixelsAlloc} and \code{psPixelsRealloc} provide dynamic … … 3206 3226 by \code{psVectorAlloc} and \code{psVectorRealloc}. 3207 3227 3208 \begin{ verbatim}3228 \begin{prototype} 3209 3229 psImage *psPixelsToMask(psImage *out, const psPixels *pixels, const psRegion region, unsigned int maskVal); 3210 3230 psPixels *psPixelsFromMask(psPixels *out, const psImage *mask, unsigned int maskVal); 3211 \end{ verbatim}3231 \end{prototype} 3212 3232 3213 3233 \code{psPixelsToMask} shall return an image of type U8 with the … … 3228 3248 \code{NULL}. 3229 3249 3230 \begin{ verbatim}3250 \begin{prototype} 3231 3251 psPixels *psPixelsCopy(psPixels *out, const psPixels *pixels); 3232 3252 psPixels *psPixelsConcatenate(psPixels *out, const psPixels *pixels); 3233 \end{ verbatim}3253 \end{prototype} 3234 3254 3235 3255 \code{psPixelsCopy} shall copy the contents of \code{pixels} to the … … 3259 3279 specify two generic APIs for the binary and unary operations. 3260 3280 3261 \begin{ verbatim}3281 \begin{prototype} 3262 3282 psType *psBinaryOp(void *out, const void *in1, const char *op, const void *in2); 3263 3283 psType *psUnaryOp(void *out, const void *in, const char *op); 3264 \end{ verbatim}3284 \end{prototype} 3265 3285 These functions determine the type of the operands on the basis of 3266 3286 their \code{psType} elements, which always are the first elements. … … 3359 3379 In the event of an error, the matrix functions shall return \code{NULL}. 3360 3380 3361 \begin{ verbatim}3381 \begin{prototype} 3362 3382 psImage *psMatrixLUD(psImage *out, psVector **perm, const psImage *in); 3363 3383 psVector *psMatrixLUSolve(psVector *out, const psImage *LU, const psVector *RHS, const psVector *perm); 3364 \end{ verbatim}3384 \end{prototype} 3365 3385 The above functions decompose a matrix, \code{in}, into its $LU$ 3366 3386 representation (\code{psMatrixLUD}, which returns the decomposed … … 3378 3398 \code{NULL} on calling \code{psMatrixLUD}. 3379 3399 3380 \begin{ verbatim}3400 \begin{prototype} 3381 3401 psImage *psMatrixInvert(psImage *out, const psImage *in, float *determinant); 3382 \end{ verbatim}3402 \end{prototype} 3383 3403 \code{psMatrixInvert} returns the inverse of the specified matrix 3384 3404 (\code{in}), along with the \code{determinant}, if the \code{float} … … 3390 3410 the specified matrix, \code{in}. This function is specified for data 3391 3411 types \code{psF32, psF64}. 3392 \begin{ verbatim}3412 \begin{prototype} 3393 3413 float psMatrixDeterminant(const psImage *in); 3394 \end{ verbatim}3414 \end{prototype} 3395 3415 3396 3416 Matrix multiplication is supported through \code{psMatrixMultiply}. This function is 3397 3417 specified for data types \code{psF32, psF64}. 3398 \begin{ verbatim}3418 \begin{prototype} 3399 3419 psImage *psMatrixMultiply(psImage *out, const psImage *in1, const psImage *in2); 3400 \end{ verbatim}3420 \end{prototype} 3401 3421 3402 3422 The transpose of an input matrix, \code{in}, is returned by 3403 3423 \code{psMatrixTranspose}, optionally into the provided matrix 3404 3424 \code{out}. This function is specified for data types \code{psF32,psF64}. 3405 \begin{ verbatim}3425 \begin{prototype} 3406 3426 psImage *psMatrixTranspose(psImage *out, const psImage *in); 3407 \end{ verbatim}3427 \end{prototype} 3408 3428 3409 3429 Eigenvectors of a matrix are calculated by 3410 3430 \code{psMatrixEigenvectors}. This function is specified for data 3411 3431 types \code{psF32, psF64}. Input and output data types should match. 3412 \begin{ verbatim}3432 \begin{prototype} 3413 3433 psImage *psMatrixEigenvectors(psImage *out, const psImage *in); 3414 \end{ verbatim}3434 \end{prototype} 3415 3435 \tbd{Should this return an array of vectors? Specified here as 3416 3436 currently implemented by MHPCC.} … … 3422 3442 for data types \code{psF32, psF64}. Input and output data types 3423 3443 should match. 3424 \begin{ verbatim}3444 \begin{prototype} 3425 3445 psVector *psMatrixToVector(psVector *out, const psImage *in); 3426 3446 psImage *psVectorToMatrix(psImage *out, const psVector *in); 3427 \end{ verbatim}3447 \end{prototype} 3428 3448 3429 3449 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 3436 3456 library. We define the following APIs to support FFT operations on vectors: 3437 3457 3438 \begin{ verbatim}3458 \begin{prototype} 3439 3459 psVector *psVectorFFT(psVector *out, const psVector *in, psFFTFlags direction); 3440 3460 psVector *psVectorReal(psVector *out, const psVector *in); … … 3443 3463 psVector *psVectorConjugate(psVector *out, const psVector *in); 3444 3464 psVector *psVectorPowerSpectrum(psVector *out, const psVector *in); 3445 \end{ verbatim}3465 \end{prototype} 3446 3466 3447 3467 The forward and reverse FFT is calculated using \code{psVectorFFT}, … … 3471 3491 by an enumerated type, \code{psFFTFlags}: 3472 3492 3473 \begin{ verbatim}3493 \begin{datatype} 3474 3494 /** Specify direction of FFT, and if the result is real or not */ 3475 3495 typedef enum { … … 3480 3500 ///< parameter should appear as PS_FFT_REVERSE+PS_FFT_REAL_RESULT. 3481 3501 } psFFTFlags; 3482 \end{ verbatim}3502 \end{datatype} 3483 3503 3484 3504 The entry \code{PS_FFT_REAL_RESULT} means that the output of an … … 3496 3516 In analogy with the vector FFT operations, we also define matching 3497 3517 image operations as follows: 3498 \begin{ verbatim}3518 \begin{prototype} 3499 3519 psImage *psImageFFT(psImage *out, const psImage *image, psFFTFlags direction); 3500 3520 psImage *psImageReal(psImage *out, const psImage *in); … … 3503 3523 psImage *psImageConjugate(psImage *out, const psImage *in); 3504 3524 psImage *psImagePowerSpectrum(psImage *out, const psImage *in); 3505 \end{ verbatim}3525 \end{prototype} 3506 3526 3507 3527 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% … … 3528 3548 \code{psImage} operations. We define a \code{psKernel}: 3529 3549 3530 \begin{ verbatim}3550 \begin{datatype} 3531 3551 /** A convolution kernel */ 3532 3552 typedef struct { … … 3537 3557 float **p_kernelRows; ///< Pointer to the rows of the kernel data 3538 3558 } psKernel; 3539 \end{ verbatim}3559 \end{datatype} 3540 3560 3541 3561 The kernel data is carried primarily by the \code{data} member which … … 3557 3577 3558 3578 Of course, we require the appropriate constructor: 3559 \begin{ verbatim}3579 \begin{prototype} 3560 3580 psKernel *psKernelAlloc(int xMin, int xMax, int yMin, int yMax); 3561 \end{ verbatim}3581 \end{prototype} 3562 3582 3563 3583 \code{psKernelAlloc} shall allocate a kernel. In the event that one … … 3571 3591 guiding), \code{psKernelGenerate} shall return the appropriate kernel. 3572 3592 The API shall be the following: 3573 \begin{ verbatim}3593 \begin{prototype} 3574 3594 psKernel *psKernelGenerate(const psVector *tShifts, const psVector *xShifts, 3575 3595 const psVector *yShifts, bool relative); 3576 \end{ verbatim}3596 \end{prototype} 3577 3597 3578 3598 The vectors \code{xShifts} and \code{yShifts}, which are a list of … … 3595 3615 \code{in}, with the kernel, \code{kernel} and return the convolved 3596 3616 image, \code{out}. The API shall be the following: 3597 \begin{ verbatim}3617 \begin{prototype} 3598 3618 psImage *psImageConvolve(psImage *out, const psImage *in, const psKernel *kernel, bool direct); 3599 \end{ verbatim}3619 \end{prototype} 3600 3620 3601 3621 Two methods shall be available for the convolution: if \code{direct} … … 3625 3645 expansion in the future, depending upon user requirements. 3626 3646 3627 \begin{ verbatim}3647 \begin{datatype} 3628 3648 typedef enum { 3629 3649 PS_RANDOM_TAUS ///< A maximally equidistributed combined Tausworthe generator … … 3634 3654 gsl_rng *gsl; ///< The RNG itself 3635 3655 } psRandom; 3636 \end{ verbatim}3656 \end{datatype} 3637 3657 3638 3658 We require the ability to seed the random number generator (RNG) with … … 3640 3660 may be reproduced. 3641 3661 3642 \begin{ verbatim}3662 \begin{prototype} 3643 3663 psRandom *psRandomAlloc(psRandomType type, unsigned long seed); 3644 3664 void psRandomReset(psRandom *rand, unsigned long seed); 3645 \end{ verbatim}3665 \end{prototype} 3646 3666 3647 3667 \code{psRandomAlloc} shall construct a new instance of \code{psRandom} … … 3653 3673 \code{psLogMsg} with a level of \code{PS_LOG_INFO}. 3654 3674 3655 \begin{ verbatim}3675 \begin{prototype} 3656 3676 double psRandomUniform(const psRandom *r); 3657 3677 double psRandomGaussian(const psRandom *r); 3658 3678 double psRandomPoisson(const psRandom *r, double mean); 3659 \end{ verbatim}3679 \end{prototype} 3660 3680 3661 3681 \code{psRandomUniform} shall return random numbers uniformly … … 3785 3805 We define an item of metadata with the following structure: 3786 3806 \filbreak 3787 \begin{ verbatim}3807 \begin{datatype} 3788 3808 typedef struct { 3789 3809 const psS32 id; ///< unique ID for this item … … 3800 3820 char *comment; ///< optional comment ("", not NULL) 3801 3821 } psMetadataItem; 3802 \end{ verbatim}3822 \end{datatype} 3803 3823 3804 3824 The \code{id} is a unique identifier for this item of metadata; … … 3814 3834 % 3815 3835 \filbreak 3816 \begin{ verbatim}3836 \begin{datatype} 3817 3837 typedef enum { ///< type of item.data is: 3818 3838 PS_META_S32 = PS_TYPE_S32, ///< psS32 primitive data. … … 3834 3854 PS_META_MULTI ///< Used internally, do not create a metadata item of this type. 3835 3855 } psMetadataType; 3836 \end{ verbatim}3856 \end{datatype} 3837 3857 The macro \code{PS_META_IS_PRIMITIVE(psMetadataType.type)} returns 3838 3858 true if the type is one of the primitive data types (S32, F64, etc). … … 3841 3861 3842 3862 A collection of metadata is represented by the \code{psMetadata} structure: 3843 \begin{ verbatim}3863 \begin{datatype} 3844 3864 typedef struct { 3845 3865 psList *list; ///< list of psMetadataItem 3846 3866 psHash *table; ///< hash table of the same metadata 3847 3867 } psMetadata; 3848 \end{ verbatim}3868 \end{datatype} 3849 3869 The type \code{psMetadata} is a container class for metadata. Note 3850 3870 that there are in fact \emph{two} representations of the metadata … … 3873 3893 As a convenience to the user, the following type-specific functions are 3874 3894 also defined: 3875 \begin{ verbatim}3895 \begin{prototype} 3876 3896 psMetadataItem* psMetadataItemAllocStr(const char* name, const char* comment, const char* value); 3877 3897 psMetadataItem* psMetadataItemAllocF32(const char* name, const char* comment, psF32 value); … … 3879 3899 psMetadataItem* psMetadataItemAllocS32(const char* name, const char* comment, psS32 value); 3880 3900 psMetadataItem* psMetadataItemAllocBool(const char* name, const char* comment, psBool value); 3881 \end{ verbatim}3901 \end{prototype} 3882 3902 3883 3903 \subsubsection{Metadata APIs} 3884 3904 3885 \begin{ verbatim}3905 \begin{prototype} 3886 3906 psMetadata *psMetadataAlloc(void); 3887 \end{ verbatim}3907 \end{prototype} 3888 3908 3889 3909 The constructor for the collection of metadata, \code{psMetadata}, … … 3892 3912 free each of the \code{psMetadataItem}s. 3893 3913 3894 \begin{ verbatim}3914 \begin{prototype} 3895 3915 psMetadataItem *psMetadataItemAlloc(const char *name, psMetadataType type, const char *comment, ...); 3896 3916 psMetadataItem *psMetadataItemAllocV(const char *name, psMetadataType type, const char *comment, va_list list); 3897 \end{ verbatim}3917 \end{prototype} 3898 3918 3899 3919 The allocator for \code{psMetadataItem} returns a full … … 3911 3931 in the function. 3912 3932 3913 \begin{ verbatim}3933 \begin{prototype} 3914 3934 bool psMetadataAddItem(psMetadata *md, const psMetadataItem *item, int location, int mode); 3915 3935 bool psMetadataAdd(psMetadata *md, int location, const char *name, int format, const char *comment, ...); 3916 3936 bool psMetadataAddV(psMetadata *md, int location, const char *name, int format, const char *comment, 3917 3937 va_list list); 3918 \end{ verbatim}3938 \end{prototype} 3919 3939 3920 3940 Items may be added to the metadata in one of two ways --- firstly, an … … 3939 3959 % 3940 3960 3941 \begin{ verbatim}3961 \begin{datatype} 3942 3962 typedef enum { ///< option flags for psMetadata functions 3943 3963 PS_META_DEFAULT, ///< default behavior (0x0000) for use in mode above … … 3945 3965 PS_META_DUPLICATE_OK, ///< allow entry to be replaced 3946 3966 } psMetadataFlags; 3947 \end{ verbatim}3967 \end{datatype} 3948 3968 3949 3969 The functions above take option flags which modify the behavior when … … 4021 4041 As a convenience to the user, the following type-specific functions 4022 4042 are specified: 4023 \begin{ verbatim}4043 \begin{prototype} 4024 4044 psBool psMetadataAddS32(psMetadata* md, psS32 location, const char* name, const char* comment, psS32 value); 4025 4045 psBool psMetadataAddF32(psMetadata* md, psS32 location, const char* name, const char* comment, psF32 value); … … 4041 4061 psBool psMetadataAddMetadata(psMetadata* md, psS32 location, const char* name, const char* comment, 4042 4062 const psMetadata* value); 4043 \end{ verbatim}4063 \end{prototype} 4044 4064 4045 4065 … … 4054 4074 returned. 4055 4075 % 4056 \begin{ verbatim}4076 \begin{prototype} 4057 4077 bool psMetadataRemove(psMetadata *md, int location, const char *key); 4058 \end{ verbatim}4078 \end{prototype} 4059 4079 4060 4080 Items may be found within the metadata by providing a key. In the 4061 4081 event that the key is non-unique, the first item is returned. 4062 \begin{ verbatim}4082 \begin{prototype} 4063 4083 psMetadataItem *psMetadataLookup(const psMetadata *md, const char *key); 4064 \end{ verbatim}4084 \end{prototype} 4065 4085 4066 4086 Several utility functions are provided for simple cases. These … … 4069 4089 found. If the pointer value of \code{status} is not \code{NULL}, it 4070 4090 is set to reflect the success or failure of the lookup. 4071 \begin{ verbatim}4091 \begin{prototype} 4072 4092 void *psMetadataLookupPtr(bool *status, const psMetadata *md, const char *key); 4073 4093 psS32 psMetadataLookupS32(bool *status, const psMetadata *md, const char *key); 4074 4094 psF32 psMetadataLookupF32(bool *status, const psMetadata *md, const char *key); 4075 4095 psF64 psMetadataLookupF64(bool *status, const psMetadata *md, const char *key); 4076 \end{ verbatim}4096 \end{prototype} 4077 4097 4078 4098 Items may be retrieved from the metadata by their entry position. The 4079 4099 value of which specifies the desired entry in the fashion of 4080 4100 \code{psList}. 4081 \begin{ verbatim}4101 \begin{prototype} 4082 4102 psMetadataItem *psMetadataGet(const psMetadata *md, int location); 4083 \end{ verbatim}4103 \end{prototype} 4084 4104 4085 4105 The metadata list component may be iterated over by using a 4086 4106 \code{psMetadataIterator} in a fashion equivalent to the 4087 4107 \code{psListIterator}: 4088 \begin{ verbatim}4108 \begin{datatype} 4089 4109 typedef struct { 4090 4110 psListIterator* iter; ///< iterator for the psMetadata's psList 4091 4111 regex_t* regex; ///< the subsetting regular expression 4092 4112 } psMetadataIterator; 4093 \end{ verbatim}4113 \end{datatype} 4094 4114 4095 4115 The iterator may be set to a location in the \code{psMetadata} list, … … 4104 4124 defined by \code{location}, which follows the conventions of the 4105 4125 \code{psList} iterators. 4106 \begin{ verbatim}4126 \begin{prototype} 4107 4127 psMetadataIterator *psMetadataIteratorAlloc(psMetadata *md, int location, const char *regex); 4108 4128 bool psMetadataIteratorSet(psMetadataIterator *iterator, int location); 4109 4129 psMetadataItem *psMetadataGetAndIncrement(psMetadataIterator *iterator); 4110 4130 psMetadataItem *psMetadataGetAndDecrement(psMetadataIterator *iterator); 4111 \end{ verbatim}4131 \end{prototype} 4112 4132 4113 4133 Metadata items may be printed to an open file descriptor based on a … … 4119 4139 for a string (\%s type of command). If the metadata type is any other 4120 4140 data type, printing is not allowed. 4121 \begin{ verbatim}4141 \begin{prototype} 4122 4142 bool psMetadataItemPrint(FILE *fd, const char *format, const psMetadataItem *md); 4123 \end{ verbatim}4143 \end{prototype} 4124 4144 4125 4145 \subsubsection{Configuration files} … … 4131 4151 function \code{psMetadataConfigParse}, as described below. 4132 4152 4133 \begin{ verbatim}4153 \begin{prototype} 4134 4154 psMetadata *psMetadataConfigParse(psMetadata *md, int *nFail, const char *filename, bool overwrite); 4135 \end{ verbatim}4155 \end{prototype} 4136 4156 4137 4157 Given a metadata container, \code{md}, and the name of a configuration … … 4150 4170 configuration. 4151 4171 4152 \begin{ verbatim}4172 \begin{prototype} 4153 4173 char *psMetadataConfigFormat(psMetadata *md); 4154 4174 bool psMetadataConfigWrite(psMetadata *md, const char *filename); 4155 \end{ verbatim}4175 \end{prototype} 4156 4176 4157 4177 The \code{psMetadataConfigFormat} function converts a \code{psMetadata} … … 4365 4385 document in memory. We wrap the \code{libxml2} version of an XML 4366 4386 document pointer for now: 4367 \begin{ verbatim}4387 \begin{datatype} 4368 4388 typedef xmlDocPtr psXMLDoc; 4389 \end{datatype} 4390 4391 \begin{prototype} 4369 4392 void psXMLDocFree(psXMLDoc *doc); 4370 \end{ verbatim}4393 \end{prototype} 4371 4394 4372 4395 The next pair of functions convert a \code{psMetadata} data structure 4373 4396 to a complete \code{psXMLDoc} (in memory) and vice versa: 4374 \begin{ verbatim}4397 \begin{prototype} 4375 4398 psXMLDoc *psMetadataToXMLDoc(const psMetadata *metadata); 4376 4399 psMetadata *psXMLDocToMetadata(const psXMLDoc *doc); 4377 \end{ verbatim}4400 \end{prototype} 4378 4401 4379 4402 The next pair of functions loads the data in a named file into a 4380 4403 complete \code{psXMLDoc} (in memory) and write out the \code{psXMLDoc} 4381 4404 to a named file: 4382 \begin{ verbatim}4405 \begin{prototype} 4383 4406 psXMLDoc *psXMLParseFile(const char *filename); 4384 4407 int psXMLDocToFile(const psXMLDoc *doc, const char *filename); 4385 \end{ verbatim}4408 \end{prototype} 4386 4409 4387 4410 The next pair of functions accepts a block of memory and parses it 4388 4411 into a complete \code{psXMLDoc} (also in memory), and vice versa: 4389 \begin{ verbatim}4412 \begin{prototype} 4390 4413 psXMLDoc *psXMLParseMemory(const char *buffer, const int size); 4391 4414 int psXMLDocToMemory(const psXMLDoc *doc, char *buffer); 4392 \end{ verbatim}4415 \end{prototype} 4393 4416 4394 4417 The next pair of functions read from and write to a file descriptor. … … 4396 4419 (also in memory), the second writes the \code{psXMLDoc} to the file 4397 4420 descriptor: 4398 \begin{ verbatim}4421 \begin{prototype} 4399 4422 psXMLDoc *psXMLParseFD(int fd); 4400 4423 int psXMLDocToFD(const psXMLDoc *doc, int fd); 4401 \end{ verbatim}4424 \end{prototype} 4402 4425 4403 4426 \subsection{Database Functions} … … 4428 4451 database connection: 4429 4452 4430 \begin{ verbatim}4453 \begin{datatype} 4431 4454 typedef struct { 4432 4455 MYSQL *mysql; 4433 4456 } psDB; 4434 \end{ verbatim}4457 \end{datatype} 4435 4458 4436 4459 The following collection of functions provides basic database functionality: 4437 4460 4438 \begin{ verbatim}4461 \begin{prototype} 4439 4462 // wraps mysql_init() & mysql_real_connect() 4440 4463 psDB *psDBInit(const char *host, const char *user, const char *passwd, const char *dbname); … … 4451 4474 // wraps mysql_drop_db() 4452 4475 bool psDBDrop(psDB *dbh, const char *dbname); 4453 \end{ verbatim}4476 \end{prototype} 4454 4477 4455 4478 For MySQL support, \code{psDBInit()} wraps \code{mysql_init()} and … … 4476 4499 table and as part of the query restrictions. 4477 4500 4478 \begin{ verbatim}4501 \begin{prototype} 4479 4502 bool psDBCreateTable(psDB *dbh, const char *tableName, const psMetadata *md); 4480 \end{ verbatim}4503 \end{prototype} 4481 4504 4482 4505 This function generates and executes the SQL needed to create a table … … 4503 4526 whitespace. The \code{comment} field is otherwise ignored. 4504 4527 4505 \begin{ verbatim}4528 \begin{prototype} 4506 4529 bool psDBDropTable(psDB *dbh, const char *tableName); 4507 \end{ verbatim}4530 \end{prototype} 4508 4531 4509 4532 This function deletes the specified table. 4510 4533 4511 \begin{ verbatim}4534 \begin{prototype} 4512 4535 bool p_psDBRunQuery(psDB *dbh, const char *query); 4513 \end{ verbatim}4536 \end{prototype} 4514 4537 4515 4538 This function will execute a string as a raw SQL query. No additional … … 4517 4540 dialect is provided. 4518 4541 4519 \begin{ verbatim}4542 \begin{prototype} 4520 4543 psArray *psDBSelectColumn(psDB *dbh, const char *tableName, const char *col, const psU64 limit); 4521 4544 psVector *psDBSelectColumnNum(psDB *dbh, const char *tableName, const char *col, psMetadataType type, const psU64 limit); 4522 \end{ verbatim}4545 \end{prototype} 4523 4546 4524 4547 These functions generates and executes the SQL needed to select an entire … … 4529 4552 (NULL) if the requested field is not a numerical type. 4530 4553 4531 \begin{ verbatim}4554 \begin{prototype} 4532 4555 psArray *psDBSelectRows(psDB *dbh, const char *tableName, psMetadata *where, const psU64 limit); 4533 \end{ verbatim}4556 \end{prototype} 4534 4557 4535 4558 This function returns rows from the specified table which match … … 4542 4565 \code{psArray} of \code{psMetadata} values, one per row. 4543 4566 4544 \begin{ verbatim}4567 \begin{prototype} 4545 4568 bool psDBInsertOneRow(psDB *dbh, const char *tableName, const psMetadata *row); 4546 \end{ verbatim}4569 \end{prototype} 4547 4570 4548 4571 Insert the data from \code{row} into \code{tableName}. It should be noted in … … 4550 4573 in \code{tablename}, the insert will fail. 4551 4574 4552 \begin{ verbatim}4575 \begin{prototype} 4553 4576 bool psDBInsertRows(psDB *dbh, const char *tableName, const psArray *rowSet); 4554 \end{ verbatim}4577 \end{prototype} 4555 4578 4556 4579 Similar to \code{psDBInsertOneRow()}, this function inserts many rows at once 4557 4580 and is atomic for the complete set of rows. 4558 4581 4559 \begin{ verbatim}4582 \begin{prototype} 4560 4583 psArray *psDBDumpRows(psDB *dbh, const char *tableName); 4561 \end{ verbatim}4584 \end{prototype} 4562 4585 4563 4586 Fetch all rows as an psArray of psMetadata. 4564 4587 4565 \begin{ verbatim}4588 \begin{prototype} 4566 4589 psMetadata *psDBDumpCols(psDB *dbh, const char *tableName); 4567 \end{ verbatim}4590 \end{prototype} 4568 4591 4569 4592 Fetch all columns, as either a psVector or a psArray depending on whether or not … … 4571 4594 psMetadataItem.name contains the column's name. 4572 4595 4573 \begin{ verbatim}4596 \begin{prototype} 4574 4597 psS64 psDBUpdateRows(psDB *dbh, const char *tableName, const psMetadata *where, const psMetadata *values); 4575 \end{ verbatim}4598 \end{prototype} 4576 4599 4577 4600 Update the columns contained in \code{values} in the row(s) that have a field … … 4582 4605 an additional constraint. e.g. ``where foo = x and where bar = y'' 4583 4606 4584 \begin{ verbatim}4607 \begin{prototype} 4585 4608 psS64 psDBDeleteRows(psDB *dbh, const char *tableName, const psMetadata *where); 4586 \end{ verbatim}4609 \end{prototype} 4587 4610 4588 4611 Delete the rows that are matched by \code{where} using the same semantics for … … 4603 4626 be the most basic versions. 4604 4627 4605 \begin{ verbatim}4628 \begin{datatype} 4606 4629 typedef struct { 4607 4630 fitsfile fd; 4608 4631 } psFits; 4609 \end{ verbatim}4632 \end{datatype} 4610 4633 We begin by defining a datatype to wrap the CFITSIO \code{fitsfile} 4611 4634 structure. This is necessary to allow repeated access to the data in … … 4614 4637 \subsubsection{FITS File Manipulations} 4615 4638 4616 \begin{ verbatim}4639 \begin{prototype} 4617 4640 psFits *psFitsAlloc(const char *filename); 4618 \end{ verbatim}4641 \end{prototype} 4619 4642 4620 4643 Opens a FITS file at positions the pointer to the PHU. 4621 4644 4622 \begin{ verbatim}4645 \begin{prototype} 4623 4646 bool psFitsMoveExtName(psFits *fits, const char *extname); 4624 \end{ verbatim}4647 \end{prototype} 4625 4648 4626 4649 Positions the pointer to the beginning of the specified … … 4628 4651 shall fail. 4629 4652 4630 \begin{ verbatim}4653 \begin{prototype} 4631 4654 bool psFitsMoveExtNum(psFits* fits, int extnum, bool relative); 4632 \end{ verbatim}4655 \end{prototype} 4633 4656 4634 4657 Moves the pointer to the beginning of the specified HDU number. If … … 4637 4660 extended data segments start at number 1. 4638 4661 4639 \begin{ verbatim}4662 \begin{prototype} 4640 4663 int psFitsGetExtNum(psFits* fits); 4641 \end{ verbatim}4664 \end{prototype} 4642 4665 4643 4666 Returns the current HDU number (i.e., file position). 4644 4667 4645 \begin{ verbatim}4668 \begin{prototype} 4646 4669 int psFitsGetSize(psFits* fits); 4647 \end{ verbatim}4670 \end{prototype} 4648 4671 4649 4672 Returns the number of HDUs in the file. 4650 4673 4651 \begin{ verbatim}4674 \begin{prototype} 4652 4675 psFitsType psFitsGetExtType(psFits* fits); 4653 \end{ verbatim}4676 \end{prototype} 4654 4677 4655 4678 Gets the current HDU's type (table or image). 4656 4679 4657 \begin{ verbatim}4680 \begin{prototype} 4658 4681 char *psFitsGetExtName(psFits* fits); 4659 4682 bool psFitsSetExtName(psFits* fits, const char* name); 4660 \end{ verbatim}4683 \end{prototype} 4661 4684 4662 4685 \code{psFitsGetExtName} shall return the name of the current extension … … 4668 4691 \subsubsection{FITS Header I/O Functions} 4669 4692 4670 \begin{ verbatim}4693 \begin{prototype} 4671 4694 psMetadata *psFitsReadHeader(psMetadata *out, psFits *fits); 4672 \end{ verbatim}4695 \end{prototype} 4673 4696 Read header data into a \code{psMetadata} structure. The data is read 4674 4697 from the current HDU pointed at by the \code{psFits *fits} entry. If 4675 4698 \code{out} is \code{NULL}, a new psMetadata is created. 4676 4699 4677 \begin{ verbatim}4700 \begin{prototype} 4678 4701 psMetadata *psFitsReadHeaderSet (psFits *fits); 4679 \end{ verbatim}4702 \end{prototype} 4680 4703 Load a complete set of headers from the \code{psFits} file pointer. 4681 4704 This function loads the headers from all extensions into a … … 4688 4711 called. 4689 4712 4690 \begin{ verbatim}4713 \begin{prototype} 4691 4714 bool psFitsWriteHeader(psMetadata *output, psFits *fits); 4692 \end{ verbatim}4715 \end{prototype} 4693 4716 Write metadata into the header of a FITS image file. The header is 4694 4717 written at the current HDU. … … 4696 4719 \subsubsection{FITS Image I/O Functions} 4697 4720 4698 \begin{ verbatim}4721 \begin{prototype} 4699 4722 psImage *psFitsReadImage(psImage *output, psFits *fits, psRegion region, int z); 4700 \end{ verbatim}4723 \end{prototype} 4701 4724 Read an image or subimage from the \code{psFits} file pointer. This 4702 4725 function is a wrapper to the CFITSIO library function. The input … … 4715 4738 type as needed with \code{psImageCopy}. 4716 4739 4717 \begin{ verbatim}4740 \begin{prototype} 4718 4741 bool psFitsUpdateImage(psFits *fits, const psImage *input, psRegion region, int z); 4719 \end{ verbatim}4742 \end{prototype} 4720 4743 Write an image section to the open \code{psFits} file pointer. This 4721 4744 operation may write a portion of an image over the existing bytes of … … 4732 4755 successful operation and 1 for an error. 4733 4756 4734 \begin{ verbatim}4757 \begin{prototype} 4735 4758 bool psFitsWriteImage(psFits *fits, const psMetadata *header, const psImage *input, int depth); 4736 \end{ verbatim}4759 \end{prototype} 4737 4760 Create a new image based on the dimensions specified for the image and 4738 4761 the requested depth. The header and image data segments are written … … 4746 4769 \subsubsection{FITS Table I/O Functions} 4747 4770 4748 \begin{ verbatim}4771 \begin{prototype} 4749 4772 psMetadata *psFitsReadTableRow (psFits *fits, int row); 4750 \end{ verbatim}4773 \end{prototype} 4751 4774 This function reads a single row of the table in the extension pointed 4752 4775 at by the \code{psFits} file pointer. The row number to be read is … … 4760 4783 the file pointer location, for that matter).} 4761 4784 4762 \begin{ verbatim}4785 \begin{prototype} 4763 4786 void *psFitsReadTableRowRaw (int *nBytes, psFits *fits, int row); 4764 \end{ verbatim}4787 \end{prototype} 4765 4788 This function reads a single row of the table in the extension pointed 4766 4789 at by the \code{psFits} file pointer. The row number to be read is … … 4773 4796 somewhere (and the file pointer location, for that matter).} 4774 4797 4775 \begin{ verbatim}4798 \begin{prototype} 4776 4799 psArray *psFitsReadTableColumn (psFits *fits, const char *colname); 4777 \end{ verbatim}4800 \end{prototype} 4778 4801 This function reads a single column of the table in the extension 4779 4802 pointed at by the \code{psFits} file pointer. The column is specified … … 4782 4805 column per array element. 4783 4806 4784 \begin{ verbatim}4807 \begin{prototype} 4785 4808 psVector *psFitsReadTableColumnNum (psFits *fits, const char *colname); 4786 \end{ verbatim}4809 \end{prototype} 4787 4810 This function reads a single column of the table in the extension 4788 4811 pointed at by the \code{psFits} file pointer. The column is specified … … 4792 4815 per array element. 4793 4816 4794 \begin{ verbatim}4817 \begin{prototype} 4795 4818 psArray *psFitsReadTableRaw (int *nBytes, psFits *fits); 4796 \end{ verbatim}4819 \end{prototype} 4797 4820 This function reads the entire data block from a table into the a 4798 4821 \code{psArray}, with one element of the array per row. The number of … … 4801 4824 description of the table data in the table header. 4802 4825 4803 \begin{ verbatim}4826 \begin{prototype} 4804 4827 psArray *psFitsReadTable (psFits *fits); 4805 \end{ verbatim}4828 \end{prototype} 4806 4829 This function reads the entire data block from a table into the a 4807 4830 \code{psArray}, with one element of the array per row. Each row is … … 4809 4832 \code{psFitsReadTableRow}. 4810 4833 4811 \begin{ verbatim}4834 \begin{prototype} 4812 4835 bool psFitsWriteTable(psFits* fits, const psMetadata *header, const psArray* table); 4813 \end{ verbatim}4836 \end{prototype} 4814 4837 Accepts a \code{psArray} of \code{psMetadata} and writes it to the 4815 4838 current HDU. If the current HDU is not a table type, this will fail 4816 4839 and return FALSE. 4817 4840 4818 \begin{ verbatim}4841 \begin{prototype} 4819 4842 bool psFitsUpdateTable(psFits* fits, const psMetadata* data, int row); 4820 \end{ verbatim}4843 \end{prototype} 4821 4844 Writes the \code{psMetadata} data to a FITS table at the specified row 4822 4845 in the current HDU. If the current HDU is not a table type, this will … … 4859 4882 \subsubsection{Data Types} 4860 4883 4861 \begin{ verbatim}4884 \begin{datatype} 4862 4885 typedef enum { 4863 4886 PS_TIME_TAI, ///< seconds since 1970-01-01T00:00:00Z (Gregorian), SI seconds … … 4878 4901 psTimeType type; ///< type of time 4879 4902 } psTime; 4880 \end{ verbatim}4903 \end{datatype} 4881 4904 4882 4905 \subsubsection{Constructors} … … 4884 4907 To allocate a new, initialized to zero, \code{psTime}: 4885 4908 4886 \begin{ verbatim}4909 \begin{prototype} 4887 4910 psTime *psTimeAlloc(psTimeType type); 4888 \end{ verbatim}4911 \end{prototype} 4889 4912 4890 4913 To allocate a new \code{psTime} set to the current time (in the given system): 4891 4914 4892 \begin{ verbatim}4915 \begin{prototype} 4893 4916 psTime *psTimeGetNow(psTimeType type); 4894 \end{ verbatim}4917 \end{prototype} 4895 4918 4896 4919 \subsubsection{Time Conversion} … … 4898 4921 Converting between the \code{psTime} time systems is done with: 4899 4922 4900 \begin{ verbatim}4923 \begin{prototype} 4901 4924 psTime *psTimeConvert(psTime *time, psTimeType type); 4902 \end{ verbatim}4925 \end{prototype} 4903 4926 4904 4927 This function may be used to convert between the various \code{psTimeType} time … … 4913 4936 positive East of Greenwich) as well: 4914 4937 4915 \begin{ verbatim}4938 \begin{prototype} 4916 4939 psF64 *psTimeToLMST(psTime *time, psF64 longitude); 4917 \end{ verbatim}4940 \end{prototype} 4918 4941 4919 4942 The function may accept any of the \code{psTimeType} types with … … 4926 4949 extract the value of $UT1-UTC$ from the IERS Time Tables: 4927 4950 4928 \begin{ verbatim}4951 \begin{prototype} 4929 4952 double psTimeGetUT1Delta(const psTime *time, psTimeBulletin bulletin); 4930 \end{ verbatim}4953 \end{prototype} 4931 4954 4932 4955 The following function provides tidal corrections to UT1-UTC, using 4933 4956 the Ray model of Simon et al (REF). 4934 \begin{ verbatim}4957 \begin{prototype} 4935 4958 psTime *psTime_TideUT1Corr(const psTime *time); 4936 \end{ verbatim}4959 \end{prototype} 4937 4960 4938 4961 Leap seconds are added to UTC in order to keep it within $0.9s$ of UT1 … … 4941 4964 the absolute number of leap seconds different between two times. 4942 4965 4943 \begin{ verbatim}4966 \begin{prototype} 4944 4967 long psTimeLeapSecondDelta(const psTime *time1, const psTime *time2); 4945 \end{ verbatim}4968 \end{prototype} 4946 4969 4947 4970 The following function accepts \code{PS_TIME_UTC} objects and … … 4949 4972 \code{TRUE} if so. 4950 4973 4951 \begin{ verbatim}4974 \begin{prototype} 4952 4975 bool psTimeIsLeapSecond(const psTime *utc); 4953 \end{ verbatim}4976 \end{prototype} 4954 4977 4955 4978 \subsubsection{External Date and Time Formats} … … 4962 4985 \code{NULL} pointer to be returned.} 4963 4986 4964 \begin{ verbatim}4987 \begin{prototype} 4965 4988 psF64 psTimeToJD(const psTime *time); 4966 4989 psF64 psTimeToMJD(const psTime *time); 4967 4990 char *psTimeToISO(const psTime *time); 4968 4991 timeval *psTimeToTimeval(const psTime *time); 4969 \end{ verbatim}4992 \end{prototype} 4970 4993 4971 4994 The \code{psTimeToISO()} function converts \code{PS_TIME_UTC} objects … … 4978 5001 \code{psTime} type. 4979 5002 4980 \begin{ verbatim}5003 \begin{prototype} 4981 5004 psTime *psTimeFromJD(psF64 input); 4982 5005 psTime *psTimeFromMJD(psF64 input); … … 4985 5008 psTime *psTimeFromUTC(psS64 sec, psU32 nsec, bool leapsecond); 4986 5009 psTime *psTimeFromTT(psS64 sec, psU32 nsec); 4987 \end{ verbatim}5010 \end{prototype} 4988 5011 4989 5012 Where \code{psTimeFromUTC()} will validate that it is possible for the input … … 4993 5016 \subsubsection{Date and Time Math} 4994 5017 4995 \begin{ verbatim}5018 \begin{prototype} 4996 5019 psTime *psTimeMath(const psTime *time, psF64 delta); 4997 5020 psF64 psTimeDelta(const psTime *time1, const psTime *time2); 4998 \end{ verbatim}5021 \end{prototype} 4999 5022 5000 5023 \code{psTimeMath} adds the \code{delta} (in seconds; may be negative) to a … … 5158 5181 \code{psCube} to represent such an element. 5159 5182 % 5160 \begin{ verbatim}5183 \begin{datatype} 5161 5184 typedef struct { 5162 5185 double x; ///< x position … … 5181 5204 double zErr; ///< Error in z 5182 5205 } psCube; 5183 \end{ verbatim}5206 \end{datatype} 5184 5207 5185 5208 Three major classes of coordinate transformations are necessary. … … 5204 5227 5205 5228 Constructors for these are straight-forward: 5206 \begin{ verbatim}5229 \begin{prototype} 5207 5230 psPlane *psPlaneAlloc(void); 5208 5231 psSphere *psSphereAlloc(void); 5209 5232 psCube *psCubeAlloc(void); 5210 \end{ verbatim}5233 \end{prototype} 5211 5234 Initialization of the structures is not necessary. 5212 5235 … … 5226 5249 of these transformations: 5227 5250 5228 \begin{ verbatim}5251 \begin{datatype} 5229 5252 typedef struct { 5230 5253 psDPolynomial2D *x; 5231 5254 psDPolynomial2D *y; 5232 5255 } psPlaneTransform; 5233 \end{ verbatim}5256 \end{datatype} 5234 5257 5235 5258 The \code{psDPolynomial2D} structures represent polynomials of … … 5253 5276 lowest two terms are the $x$ and $y$ axis of the target system. The 5254 5277 higher two terms may represent color and magnitude terms. 5255 \begin{ verbatim}5278 \begin{datatype} 5256 5279 typedef struct { 5257 5280 psDPolynomial4D *x; 5258 5281 psDPolynomial4D *y; 5259 5282 } psPlaneDistort; 5260 \end{ verbatim}5283 \end{datatype} 5261 5284 5262 5285 Like \code{psPlaneTransform}, \code{psPlaneDistort} contains two … … 5286 5309 dimension. Both the \code{x} and \code{y} polynomials shall be have 5287 5310 the same dimensions. 5288 \begin{ verbatim}5311 \begin{prototype} 5289 5312 psPlaneTransform *psPlaneTransformAlloc(int n1, int n2); 5290 5313 psPlaneDistort *psPlaneDistortAlloc(int n1, int n2, int n3, int n4); 5291 \end{ verbatim}5314 \end{prototype} 5292 5315 5293 5316 We require corresponding functions to apply the transformations to a 5294 5317 specified coordinate \code{coords}: 5295 5318 % 5296 \begin{ verbatim}5319 \begin{prototype} 5297 5320 psPlane *psPlaneTransformApply(psPlane *out, 5298 5321 const psPlaneTransform *transform, … … 5302 5325 const psPlane *coords, 5303 5326 float mag, float color); 5304 \end{ verbatim}5327 \end{prototype} 5305 5328 5306 5329 5307 5330 The following functions perform operations on transformations: 5308 5331 5309 \begin{ verbatim}5332 \begin{prototype} 5310 5333 psPlaneTransform *psPlaneTransformInvert(psPlaneTransform *out, const psPlaneTransform *in, 5311 5334 psRegion region, int nSamples); … … 5315 5338 bool psPlaneTransformFit(psPlaneTransform *trans, const psArray *source, const psArray *dest, 5316 5339 int nRejIter, float sigmaClip); 5317 \end{ verbatim}5340 \end{prototype} 5318 5341 5319 5342 \code{psPlaneTransformInvert} shall return the transformation that … … 5361 5384 transformation with respect to each coordinate. 5362 5385 5363 \begin{ verbatim}5386 \begin{prototype} 5364 5387 psPlane *psPlaneTransformDeriv(psPlane *out, const psPlaneTransform *transformation, const psPlane *coord); 5365 \end{ verbatim}5388 \end{prototype} 5366 5389 5367 5390 \code{psPlaneTransformDeriv} shall return the derivatives of the … … 5374 5397 \code{NULL}. 5375 5398 5376 \begin{ verbatim}5399 \begin{prototype} 5377 5400 psPixels *psPixelsTransform(psPixels *out, const psPixels *input, const psPlaneTransform *inToOut); 5378 \end{ verbatim}5401 \end{prototype} 5379 5402 5380 5403 \code{psPixelsTransform} shall generate a list of pixels in the output … … 5414 5437 way. 5415 5438 5416 \begin{ verbatim}5439 \begin{datatype} 5417 5440 typedef struct { 5418 5441 double q0; … … 5421 5444 double q3; 5422 5445 } psSphereRot; 5423 \end{ verbatim}5446 \end{datatype} 5424 5447 5425 5448 The constructor is defined as follows: 5426 \begin{ verbatim}5449 \begin{prototype} 5427 5450 psSphereRot *psSphereRotAlloc(double alphaP, double deltaP, double phiP); 5428 \end{ verbatim}5451 \end{prototype} 5429 5452 where \code{alphaP} and \code{deltaP} define the coordinates in the 5430 5453 input system of the axis of rotation (the north pole of the output … … 5436 5459 The \code{psSphereRot} may also be constructed by supplying the 5437 5460 elements of the quaternion to the following function: 5438 \begin{ verbatim}5461 \begin{prototype} 5439 5462 psSphereRot *psSphereRotQuat(double q0, double q1, double q2, double q3); 5440 \end{ verbatim}5463 \end{prototype} 5441 5464 This function normalizes the quaternion, so the input elements need 5442 5465 not be normalized. … … 5447 5470 if \code{NULL}, is allocated by the function. 5448 5471 5449 \begin{ verbatim}5472 \begin{prototype} 5450 5473 psSphere *psSphereRotApply(psSphere *out, const psSphereRot *transform, const psSphere *coord); 5451 \end{ verbatim}5474 \end{prototype} 5452 5475 5453 5476 The following function combines two rotations, to produce a single … … 5456 5479 allocated if \code{NULL}. 5457 5480 5458 \begin{ verbatim}5481 \begin{prototype} 5459 5482 psSphereRot *psSphereRotCombine(psSphereRot *out, const psSphereRot *rot1, const psSphereRot *rot2) 5460 \end{ verbatim}5483 \end{prototype} 5461 5484 5462 5485 The following function changes the given rotation to its inverse: 5463 5486 5464 \begin{ verbatim}5487 \begin{prototype} 5465 5488 psSphereRot *psSphereRotInvert(psSphereRot *rot) 5466 \end{ verbatim}5489 \end{prototype} 5467 5490 5468 5491 The 3-vector representation of the angles (\code{psCube}) is needed to … … 5470 5493 well. Two utility functions are provided to convert between the 5471 5494 angular and 3-vector representations: 5472 \begin{ verbatim}5495 \begin{prototype} 5473 5496 psSphere *psCubeToSphere(const psCube *cube); 5474 5497 psCube *psSphereToCube(const psSphere *sphere); 5475 \end{ verbatim}5498 \end{prototype} 5476 5499 5477 5500 \subsubsection{Offsets} … … 5488 5511 the offset only. 5489 5512 5490 \begin{ verbatim}5513 \begin{prototype} 5491 5514 psSphere *psSphereGetOffset(const psSphere *position1, 5492 5515 const psSphere *position2, … … 5498 5521 psSphereOffsetMode mode, 5499 5522 psSphereOffsetUnit unit); 5500 5523 \end{prototype} 5524 5525 \begin{datatype} 5501 5526 typedef enum { 5502 5527 PS_SPHERICAL; ///< Offset on a sphere … … 5510 5535 PS_RADIAN; ///< Radians 5511 5536 } psSphereOffsetUnit; 5512 \end{ verbatim}5537 \end{datatype} 5513 5538 Note that these should propagate the errors appropriately. 5514 5539 … … 5520 5545 constructors as well as the above \code{psSphereRotAlloc}. 5521 5546 % 5522 \begin{ verbatim}5547 \begin{prototype} 5523 5548 psSphereRot *psSphereRotICRSToEcliptic(const psTime *time); 5524 5549 psSphereRot *psSphereRotEclipticToICRS(const psTime *time); 5525 5550 psSphereRot *psSphereRotICRSToGalactic(void); 5526 5551 psSphereRot *psSphereRotGalacticToICRS(void); 5527 \end{ verbatim}5552 \end{prototype} 5528 5553 5529 5554 \subsection{Earth Orientation Calculations} … … 5581 5606 star, given its \code{actual} position and the velocity vector of the 5582 5607 observer, represented as a speed and a direction: 5583 \begin{ verbatim}5608 \begin{prototype} 5584 5609 psSphere *psAberration(psSphere *apparent, const psSphere *actual, const psSphere *direction, double speed); 5585 \end{ verbatim}5610 \end{prototype} 5586 5611 The \code{actual} and \code{apparent} positions are represented as 5587 5612 \code{psSphere} entries, as is the \code{direction} of motion. The … … 5595 5620 The following function calculates the \code{apparent} position of a 5596 5621 star, given its \code{actual} position and the position of the sun: 5597 \begin{ verbatim}5622 \begin{prototype} 5598 5623 psSphere *psGravityDeflection(psSphere *apparent, psSphere *actual, psSphere *sun); 5599 \end{ verbatim}5624 \end{prototype} 5600 5625 The \code{actual} and \code{apparent} positions are represented as 5601 5626 \code{psSphere} entries, as is position of the sun. If the value of … … 5605 5630 \paragraph{Parallax} 5606 5631 5607 \begin{ verbatim}5632 \begin{prototype} 5608 5633 double psEOC_ParallaxFactor(const psSphere *coords, const psTime *time); 5609 \end{ verbatim}5634 \end{prototype} 5610 5635 Calculate the parallax factor for the given position and time. 5611 5636 … … 5618 5643 representation may be converted to a rotation between the frames. 5619 5644 5620 \begin{ verbatim}5645 \begin{datatype} 5621 5646 typedef struct { 5622 5647 double x; … … 5624 5649 double s; 5625 5650 } psEarthPole; 5626 \end{ verbatim}5651 \end{datatype} 5627 5652 5628 5653 \paragraph{Precession/Nutation} … … 5632 5657 IAU2000A precession \& nutation model: 5633 5658 % 5634 \begin{ verbatim}5659 \begin{prototype} 5635 5660 psEarthPole *psEOC_PrecessionModel(const psTime *time) 5636 \end{ verbatim}5661 \end{prototype} 5637 5662 % 5638 5663 The input to this function is the desired \code{time}, which may be … … 5645 5670 by the IERS, just as it does for UT1 and polar motion. 5646 5671 5647 \begin{ verbatim}5672 \begin{prototype} 5648 5673 psEarthPole *psEOC_PrecessionCorr(const psTime *time, psTimeBulletin bulletin); 5649 \end{ verbatim}5674 \end{prototype} 5650 5675 5651 5676 The polar correction is applied to the $X$ and $Y$ elements of the 5652 5677 rotation to provide higher accuracy. The spherical rotation term is 5653 5678 generated by providing the polar coordinate to the following function: 5654 \begin{ verbatim}5679 \begin{prototype} 5655 5680 psSphereRot *psSphereRot_CEOtoGCRS(const psEarthPole *pole) 5656 \end{ verbatim}5681 \end{prototype} 5657 5682 This function constructs the rotation element as described in the ADD ( 5658 5683 The resulting \code{psSphereRot} may be used to determine the rotation … … 5663 5688 5664 5689 The following routine calculates the rotation of the Earth about the CIP: 5665 \begin{ verbatim}5690 \begin{prototype} 5666 5691 psSphereRot *psSphereRot_TEOtoCEO(const psTime *time) 5667 \end{ verbatim}5692 \end{prototype} 5668 5693 The IERS code to create the comparable rotation is embedded in 5669 5694 T2C2000, with the Earth Rotation Angle calculated by ERA2000. … … 5673 5698 The following function provides interpolated values of the polar 5674 5699 motion components, $x_p$ and $y_p$, extracted from the IERS tables. 5675 \begin{ verbatim}5700 \begin{prototype} 5676 5701 psEarthPole *psEOC_GetPolarMotion(const psTime *time, psTimeBulletin bulletin); 5677 \end{ verbatim}5702 \end{prototype} 5678 5703 5679 5704 The following function provides tidal corrections to the polar motion 5680 5705 components, $x_p$ and $y_p$, using the Ray model of Simon et al (see 5681 5706 ADD). 5682 \begin{ verbatim}5707 \begin{prototype} 5683 5708 psEarthPole *psEOC_PolarTideCorr(const psTime *time); 5684 \end{ verbatim}5709 \end{prototype} 5685 5710 5686 5711 The following function provides the additional corrections due to nutation 5687 5712 terms with periods less than or equal to two days, as well as the 5688 5713 correction to the $s'$ component of the polar motion: 5689 \begin{ verbatim}5714 \begin{prototype} 5690 5715 psEarthPole *psEOC_NutationCorr(psTime *time); 5691 \end{ verbatim}5716 \end{prototype} 5692 5717 5693 5718 The following function converts the polar motion corrections to a 5694 5719 spherical rotation using the prescription in the ADD: 5695 \begin{ verbatim}5720 \begin{prototype} 5696 5721 psSphereRot *psSphereRot_ITRStoTEO(const psEarthPole *motion); 5697 \end{ verbatim}5722 \end{prototype} 5698 5723 This function should give identical results to the IERS POM2000 5699 5724 subroutine. … … 5705 5730 for either time, it is assumed to have the reference equinox value of 5706 5731 J2000. 5707 \begin{ verbatim}5732 \begin{prototype} 5708 5733 psSphere *psSpherePrecess(const psTime *fromTime, const psTime *toTime, psPrecessMethod mode); 5709 \end{ verbatim}5734 \end{prototype} 5710 5735 The mode argument is used to specify the level of detail used in the 5711 5736 calculation. 5712 5737 5713 \begin{ verbatim}5738 \begin{datatype} 5714 5739 typedef enum { 5715 5740 PS_PRECESS_ROUGH, … … 5717 5742 PS_PRECESS_IAU2000A, 5718 5743 } psPrecessMethod; 5719 \end{ verbatim}5744 \end{datatype} 5720 5745 5721 5746 \subsection{Atmospheric Effects} … … 5740 5765 pre-calculated entries and a separate structure for ATM effect?} 5741 5766 5742 \begin{ verbatim}5767 \begin{datatype} 5743 5768 typedef struct { 5744 5769 const double latitude; ///< geodetic latitude (radians) … … 5754 5779 const double siderealTime; ///< local apparent sidereal time (radians) 5755 5780 } psGrommit; 5756 \end{ verbatim}5781 \end{datatype} 5757 5782 5758 5783 The \code{psGrommit} is calculated from telescope information for the 5759 5784 particular exposure, \code{exp}: 5760 \begin{ verbatim}5785 \begin{prototype} 5761 5786 psGrommit *psGrommitAlloc(const psExposure *exp); 5762 \end{ verbatim}5787 \end{prototype} 5763 5788 5764 5789 \tbd{these functions probably need to take the ATM structure} … … 5769 5794 the atmospheric refraction. 5770 5795 5771 \begin{ verbatim}5796 \begin{prototype} 5772 5797 float psGetAirmass(const psSphere *coord, psTime *lst, float height); 5773 \end{ verbatim}5798 \end{prototype} 5774 5799 which returns the airmass for a given position and local sidereal time 5775 5800 (\code{lst}). 5776 5801 5777 \begin{ verbatim}5802 \begin{prototype} 5778 5803 float psGetParallactic(const psSphere *coord, double siderealTime); 5779 \end{ verbatim}5804 \end{prototype} 5780 5805 which returns the parallactic angle for a given position and sidereal time. 5781 5806 5782 \begin{ verbatim}5807 \begin{prototype} 5783 5808 float psGetRefraction(float colour, ///< Colour of object 5784 5809 psPhotSystem colorPlus, ///< Colour reference 5785 5810 psPhotSystem colorMinus, ///< Colour reference 5786 5811 const psExposure *exp); ///< Telescope pointing information 5787 \end{ verbatim}5812 \end{prototype} 5788 5813 which provides an estimate of the atmospheric refraction, along the parallactic angle. 5789 5814 … … 5800 5825 grid. 5801 5826 5802 \begin{ verbatim}5827 \begin{datatype} 5803 5828 typedef struct { 5804 5829 int nX, nY; ///< Number of elements in x and y … … 5807 5832 double **x, **y; ///< The grid of offsets in x and y 5808 5833 } psFixedPattern; 5809 \end{ verbatim}5834 \end{datatype} 5810 5835 5811 5836 The constructor for \code{psFixedPattern} shall be: 5812 \begin{ verbatim}5837 \begin{prototype} 5813 5838 psFixedPattern *psFixedPatternAlloc(double x0, double y0, 5814 5839 double xScale, double yScale, 5815 5840 const psImage *x, const psImage *y); 5816 \end{ verbatim}5841 \end{prototype} 5817 5842 Here, \code{x0}, \code{y0}, \code{xScale} and \code{yScale} have the 5818 5843 same meaning as in the \code{psFixedPattern} structure. Note that the … … 5838 5863 We specify the following structure \code{psProjection} to define the 5839 5864 parameters of the projection: 5840 \begin{ verbatim}5865 \begin{datatype} 5841 5866 typedef struct { 5842 5867 double R, D; ///< coordinates of projection center … … 5844 5869 psProjectionType type; ///< projection type 5845 5870 } psProjection; 5846 \end{ verbatim}5871 \end{datatype} 5847 5872 5848 5873 The projection type is defined by the following enumerated type \code{psProjectionType}: 5849 \begin{ verbatim}5874 \begin{datatype} 5850 5875 typedef enum { ///< type of val is: 5851 5876 PS_PROJ_TAN, ///< Tangent projection … … 5855 5880 PS_PROJ_NTYPE ///< Number of types; must be last 5856 5881 } psProjectionType; 5857 \end{ verbatim}5882 \end{datatype} 5858 5883 5859 5884 The constructor is straight-forward: 5860 \begin{ verbatim}5885 \begin{prototype} 5861 5886 psProjection *psProjectionAlloc(double R, double D, double Xs, double Ys, psProjectionType type); 5862 \end{ verbatim}5887 \end{prototype} 5863 5888 5864 5889 The following functions will project and deproject (respectively) 5865 5890 spherical coordinates: 5866 5891 5867 \begin{ verbatim}5892 \begin{prototype} 5868 5893 psPlane *psProject(const psSphere *coord, const psProjection *projection); 5869 5894 psSphere *psDeproject(const psPlane *coord, const psProjection *projection); 5870 \end{ verbatim}5895 \end{prototype} 5871 5896 5872 5897 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 … … 5892 5917 a specific camera/detector/filter combination can be associated with 5893 5918 those components. 5894 \begin{ verbatim}5919 \begin{datatype} 5895 5920 typedef struct { 5896 5921 const int ID; ///< ID number for this photometric system … … 5900 5925 const char *detector; ///< Detector used for photometric system 5901 5926 } psPhotSystem; 5902 \end{ verbatim}5927 \end{datatype} 5903 5928 5904 5929 The following structure defines the transformation between two 5905 5930 photometric systems. 5906 \begin{ verbatim}5931 \begin{datatype} 5907 5932 typedef struct { 5908 5933 psPhotSystem src; ///< Source photometric system … … 5913 5938 psPolynomial3D transform; ///< Transformation from source to destination 5914 5939 } psPhotTransform; 5915 \end{ verbatim}5940 \end{datatype} 5916 5941 5917 5942 The transformation between two photometric systems may depend on the … … 5955 5980 objects, as well as Lunar phase. 5956 5981 5957 \begin{ verbatim}5982 \begin{prototype} 5958 5983 psSphere *psSunGetPos(psTime *time); 5959 5984 psTime *psSunGetRise (psTime *twi15, psTime *twi18, const psTime *time); … … 5968 5993 psTime *psPlanetGetRise (psTime *twi15, psTime *twi18, psTime *time); 5969 5994 psTime *psPlanetGetSet (psTime *twi15, psTime *twi18, psTime *time); 5970 \end{ verbatim}5995 \end{prototype} 5971 5996 5972 5997 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note:
See TracChangeset
for help on using the changeset viewer.
