Changeset 3315 for trunk/doc/pslib/psLibSDRS.tex
- Timestamp:
- Feb 23, 2005, 3:31:03 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/doc/pslib/psLibSDRS.tex (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/doc/pslib/psLibSDRS.tex
r3248 r3315 1 %%% $Id: psLibSDRS.tex,v 1.18 2 2005-02-17 02:34:56price Exp $1 %%% $Id: psLibSDRS.tex,v 1.183 2005-02-24 01:31:03 price Exp $ 2 2 \documentclass[panstarrs,spec]{panstarrs} 3 3 … … 1787 1787 polar motion vector as a function of date. 1788 1788 1789 One of the key functionalities of a lookup table is to read data from 1790 an ordinary text file into an array of vectors. This functionality is 1791 generally useful, and so we specify a separate function that may be 1792 called independently: 1793 \begin{verbatim} 1794 psArray *psVectorsReadFromFile(const char *filename, const char *format); 1795 \end{verbatim} 1796 \code{psVectorsReadFromFile} shall return an array of 1797 \code{psVector}s, read from the specified \code{filename}. The file 1798 shall be plain text, consisting of an identical number of columns on 1799 each line, with the values separated by whitespace. Lines commencing 1800 with a comment character (the pound sign, \code{#}) and blank lines 1801 shall be ignored. The \code{format} is a \code{scanf}-like format 1802 which specifies the number of columns in the file, as well as their 1803 types. The following formats shall be defined: \code{\%d} for psS32, 1804 \code{\%ld} for psS64, \code{\%f} for psF32, and \code{\%lf} for 1805 psF64. A star (\code{*}) in the format shall indicate that the column 1806 is to be skipped. 1807 1808 1789 1809 \begin{verbatim} 1790 1810 typedef struct { 1811 const char *filename; ///< File from which data is to be read 1812 const char *format; ///< scanf-like format string for file 1813 unsigned int indexCol; ///< Column of the index vector (starting at zero) 1791 1814 psVector *index; ///< Index values 1792 1815 psArray *values; ///< Corresponding values: an array of vectors 1793 const char *filename; ///< File from which table was read1794 1816 const psF64 validFrom, validTo; ///< Range of validity 1795 1817 } psLookupTable; 1796 1818 \end{verbatim} 1797 1819 1798 \code{index} shall contain the index values, which shall be sorted in 1799 increasing order. The \code{values} shall consist of an array of 1800 vectors, each of the same length as the \code{index} vector. The 1801 vectors (including the \code{index} and all vectors in the 1802 \code{values} array) may be any numerical type except complex types. 1803 The \code{filename} shall specify the file from which the table is to 1804 be read. The \code{validFrom} and \code{validTo} shall specify the 1805 range of valid values for the index; in most cases, these will simply 1806 be the first and last indices. 1820 \code{filename} shall specify the file from which the lookup table 1821 data is to be read. \code{format} shall contain a \code{scanf}-like 1822 format string specifying how the columns are to be interpreted (see 1823 \code{psVectorsReadFromFile}). \code{indexCol} shall specify the 1824 index of the column (with the first column having an index of zero) 1825 that will form the index values. \code{index} shall contain the index 1826 values, which shall be sorted in increasing order. The \code{values} 1827 shall consist of an array of vectors, each of the same length as the 1828 \code{index} vector. The vectors (including the \code{index} and all 1829 vectors in the \code{values} array) may be any numerical type except 1830 complex types. The \code{validFrom} and \code{validTo} shall specify 1831 the range of valid values for the index; in most cases, these will 1832 simply be the first and last indices. 1807 1833 1808 1834 The constructor shall be: 1809 1835 \begin{verbatim} 1810 psLookupTable *psLookupTableAlloc(const char *filename, int numValues); 1811 \end{verbatim} 1812 Here the \code{filename} indicates the file from which the table 1813 shall be read when \code{psLookupTableRead} is 1814 called. \code{numValues} indicates the number of vectors in the 1815 \code{values} array. 1816 1817 The destructor shall also free the components. 1836 psLookupTable *psLookupTableAlloc(const char *filename, ///< File from which to read 1837 const char *format ///< scanf-like format string 1838 int indexCol ///< Column of the index vector (starting at zero) 1839 ); 1840 \end{verbatim} 1841 This function shall allocate a \code{psLookupTable}, and set the 1842 appropriate values, but it shall not read the lookup table. This is 1843 so that the lookup table can be specified at the initialisation of a 1844 program, but not read unless required. 1845 1846 The destructor shall free all the components. 1847 1848 \begin{verbatim} 1849 psLookupTable *psLookupTableImport(psLookupTable *table, ///< Lookup table into which to import 1850 const psArray *vectors, ///< Array of vectors 1851 int indexCol ///< Index of the index vector in the array of vectors 1852 ); 1853 \end{verbatim} 1854 \code{psLookupTableImport} shall import an array of vectors into a 1855 \code{table}. If \code{table} is \code{NULL}, a new 1856 \code{psLookupTable} shall be allocated and returned. The array of 1857 \code{vectors}, which was likely generated by 1858 \code{psVectorsReadFromFile}, are imported by setting the 1859 \code{table->index} to the vector specified by the \code{indexCol}, 1860 and pointing the \code{table->values} array data to the remaining 1861 vectors in \code{vectors}. Reference counters for the vectors shall 1862 be incremented as appropriate. The \code{validFrom} and 1863 \code{validTo} members of the \code{table} shall be set to the first 1864 and last values in the index vector. If the \code{index} vector is 1865 not sorted in the file, the lookup table shall be sorted prior to the 1866 function returning. 1818 1867 1819 1868 \begin{verbatim} 1820 1869 int psLookupTableRead(psLookupTable *table); 1821 1870 \end{verbatim} 1822 \code{psLookupTableRead} shall read the \code{table} from the 1823 appropriate file and import the data into the \code{table}, and set 1824 the \code{validFrom} and \code{validTo} on the basis of the first and 1825 last values in the \code{table}. Sufficient memory shall be allocated 1826 to hold all the data in the specified file. The file shall be plain 1827 text, with index and values on separate lines, separated by 1828 whitespace. Lines commencing with a comment character (the pound 1829 sign, \code{#}) and blank lines shall be ignored. 1830 \code{table->values->n} in addition to the index shall be read on each 1831 line. If the \code{index} vector is not sorted in the file, the 1832 lookup table shall be sorted prior to the function returning, but no 1833 sort shall be performed if the indices were sorted in the file. If 1834 the input \code{table} has already been read from a file, the file 1835 shall be re-read, and the contents replaced. The function shall 1836 return the number of lines read (not including ignored lines). 1871 \code{psLookupTableRead} combines \code{psVectorsReadFromFile} and 1872 \code{psLookupTableImport} to read the appropriate file and import the 1873 data into the extant \code{table}. If the input \code{table} has 1874 already been read from a file, the file shall be re-read, and the 1875 contents replaced. The function shall return the number of lines read 1876 (not including ignored lines). 1837 1877 1838 1878 Interpolation on a lookup table is performed by the following 1839 1879 functions: 1840 1880 \begin{verbatim} 1841 psF64 psLookupTableInterpolate( psLookupTable *table, psF64 index, int column);1842 psVector *psLookupTableInterpolateAll( psLookupTable *table, psF64 index);1881 psF64 psLookupTableInterpolate(const psLookupTable *table, psF64 index, int column); 1882 psVector *psLookupTableInterpolateAll(const psLookupTable *table, psF64 index); 1843 1883 \end{verbatim} 1844 1884 Both functions shall interpolate the \code{table} at the provided … … 1851 1891 and \code{psLookupTableInterpolateAll} shall return \code{NULL} --- 1852 1892 that is, no attempt is made at extrapolation. 1853 1854 1855 1856 1857 1893 1858 1894 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Note:
See TracChangeset
for help on using the changeset viewer.
