Changeset 652
- Timestamp:
- 09/29/08 13:31:05 (2 months ago)
- Files:
-
- trunk/pywcs/doc/docstrings.py (modified) (1 diff)
- trunk/pywcs/pywcs/__init__.py (modified) (1 diff)
- trunk/pywcs/pywcs/pywcs.py (modified) (7 diffs)
- trunk/pywcs/setup.py (modified) (3 diffs)
- trunk/pywcs/src/pywcs.c (modified) (1 diff)
- trunk/pywcs/src/sip_wrap.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/pywcs/doc/docstrings.py
r643 r652 890 890 """ 891 891 892 pywcs = """893 Pywcs provides transformations following the SIP conventions, Paper IV894 table lookup distortion, and the core WCS functionality provided by895 wcslib. Each of these transformations can be used independently or896 together in a standard pipeline.897 898 The basic workflow is as follows:899 900 1. C{import pywcs}901 902 2. Call the C{pywcs.WCS} constructor with a PyFITS header object.903 904 3. Optionally, if the FITS file uses any deprecated or905 non-standard features, you may need to call one of the C{fix}906 methods on the object.907 908 4. Use one of the following transformation methods:909 910 - all_pix2sky: Perform all three transformations from pixel to911 sky coords.912 913 - wcs_pix2sky: Perform just the core WCS transformation from914 pixel to sky coords.915 916 - wcs_sky2pix: Perform just the core WCS transformation from917 sky to pixel coords.918 919 - sip_pix2foc: Convert from pixel to focal plane coords using920 the SIP polynomial coefficients.921 922 - sip_foc2pix: Convert from focal plane to pixel coords using923 the SIP polynomial coefficients.924 925 - p4_pix2foc: Convert from pixel to focal plane coords using926 the table lookup distortion method described in Paper IV.927 """928 929 892 radesys = """ 930 893 The equatorial or ecliptic coordinate system type, C{RADESYSa}. trunk/pywcs/pywcs/__init__.py
r643 r652 42 42 43 43 from pywcs import * 44 import pywcs 44 45 import _pywcs 45 46 46 __doc__ = __doc__ % _pywcs.__doc__47 __doc__ = __doc__ % pywcs.__doc__ trunk/pywcs/pywcs/pywcs.py
r643 r652 1 # Copyright (C) 2008 Association of Universities for Research in Astronomy (AURA) 2 1 # Copyright (C) 2008 Association of Universities for Research in 2 # Astronomy (AURA) 3 # 3 4 # Redistribution and use in source and binary forms, with or without 4 # modification, are permitted provided that the following conditions are met: 5 6 # 1. Redistributions of source code must retain the above copyright 7 # notice, this list of conditions and the following disclaimer. 8 5 # modification, are permitted provided that the following conditions 6 # are met: 7 # 8 # 1. Redistributions of source code must retain the above 9 # copyright notice, this list of conditions and the following 10 # disclaimer. 11 # 9 12 # 2. Redistributions in binary form must reproduce the above 10 13 # copyright notice, this list of conditions and the following 11 # disclaimer in the documentation and/or other materials provided12 # with the distribution.13 14 # disclaimer in the documentation and/or other materials 15 # provided with the distribution. 16 # 14 17 # 3. The name of AURA and its representatives may not be used to 15 18 # endorse or promote products derived from this software without 16 19 # specific prior written permission. 17 18 # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED 19 # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 # DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, 22 # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 23 # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 24 # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 26 # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 27 # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 28 # DAMAGE. 20 # 21 # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR 22 # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 24 # ARE DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, 25 # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 # OF THE POSSIBILITY OF SUCH DAMAGE. 32 """ 33 Pywcs provides transformations following the SIP conventions, Paper IV 34 table lookup distortion, and the core WCS functionality provided by 35 wcslib. Each of these transformations can be used independently or 36 together in a standard pipeline. 37 38 The basic workflow is as follows: 39 40 1. C{import pywcs} 41 42 2. Call the C{pywcs.WCS} constructor with a PyFITS header object. 43 44 3. Optionally, if the FITS file uses any deprecated or 45 non-standard features, you may need to call one of the C{fix} 46 methods on the object. 47 48 4. Use one of the following transformation methods: 49 50 - all_pix2sky: Perform all three transformations from pixel to 51 sky coords. 52 53 - wcs_pix2sky: Perform just the core WCS transformation from 54 pixel to sky coords. 55 56 - wcs_sky2pix: Perform just the core WCS transformation from 57 sky to pixel coords. 58 59 - sip_pix2foc: Convert from pixel to focal plane coords using 60 the SIP polynomial coefficients. 61 62 - sip_foc2pix: Convert from focal plane to pixel coords using 63 the SIP polynomial coefficients. 64 65 - p4_pix2foc: Convert from pixel to focal plane coords using 66 the table lookup distortion method described in Paper IV. 67 """ 29 68 30 69 __docformat__ = "epytext" … … 40 79 DistortionLookupTable = _pywcs.DistortionLookupTable 41 80 Sip = _pywcs.Sip 81 Wcsprm = _pywcs._Wcsprm 42 82 43 83 # A wrapper around the C WCS type 44 84 class WCS(WCSBase): 85 """ 86 WCS objects correct for SIP and Paper IV table-lookup distortions 87 and transform pixel to/from sky coordinates, based on the WCS 88 keywords and data in a FITS file. 89 """ 90 45 91 def __init__(self, header=None, fobj=None, key=' ', relax=False, naxis=2): 46 92 """ 47 93 WCS(header=None, fobj=None, key=' ', relax=False, naxis=2) 48 49 WCS objects correct for SIP and Paper IV table-lookup50 distortions and transform pixel to/from sky coordinates, based51 on the WCS keywords and data in a FITS file.52 94 53 95 @param header: A PyFITS header object. If header is not … … 86 128 """ 87 129 if naxis != 2: 88 raise ValueError("Only 2 axes are supported") ;130 raise ValueError("Only 2 axes are supported") 89 131 self.naxis = naxis 90 132 91 133 if header is None: 92 wcsprm = _pywcs._Wcsprm(header=None, key=key, relax=relax, naxis=naxis) 134 wcsprm = _pywcs._Wcsprm(header=None, key=key, 135 relax=relax, naxis=naxis) 93 136 # Set some reasonable defaults. 94 137 wcsprm.crpix = numpy.zeros((self.naxis,), numpy.double) … … 114 157 """ 115 158 if dist == 'CPDIS': 116 d_kw = 'DP'159 d_kw = 'DP' 117 160 else: 118 161 d_kw = 'DQ' … … 125 168 if dis == 'lookup': 126 169 assert isinstance(fobj, pyfits.NP_pyfits.HDUList), \ 127 'A pyfits HDUList is required for Lookup table distortion.'170 'A pyfits HDUList is required for Lookup table distortion.' 128 171 dp = d_kw+str(i) 129 172 d_extver = header[dp+'.EXTVER'] … … 133 176 d_crval = (d_header['CRVAL1'], d_header['CRVAL2']) 134 177 d_cdelt = (d_header['CDELT1'], d_header['CDELT2']) 135 d_lookup = DistortionLookupTable(d_data, d_crpix, d_crval, d_cdelt) 178 d_lookup = DistortionLookupTable(d_data, d_crpix, 179 d_crval, d_cdelt) 136 180 tables[i] = d_lookup 137 181 else: … … 335 379 if self.wcs is None: 336 380 raise ValueError("No basic WCS settings were created.") 337 return self._array_converter(lambda x: self.wcs.s2p_fits(x)['pixel'], *args) 381 return self._array_converter(lambda x: self.wcs.s2p_fits(x)['pixel'], 382 *args) 338 383 wcs_sky2pix_fits.__doc__ = """ 339 384 wcs_sky2pix_fits(*args) -> pixel trunk/pywcs/setup.py
r643 r652 32 32 except ImportError: 33 33 print "WARNING: PyFITS must be installed to use pywcs." 34 print " Since this is not a build-time dependency, the build will proceed." 34 print " Since this is not a build-time dependency, the " 35 print " build will proceed." 35 36 36 37 ###################################################################### … … 111 112 fd.write("""/* This file is autogenerated by setup.py. To edit its contents 112 113 edit doc/docstrings.py 113 */""") 114 */ 115 116 """) 114 117 for key in keys: 115 118 if key.startswith('__'): … … 158 161 undef_macros=undef_macros 159 162 ) 160 ]163 ] 161 164 ) trunk/pywcs/src/pywcs.c
r644 r652 562 562 PyObject* m; 563 563 564 m = Py_InitModule3("_pywcs", NULL, doc_pywcs);564 m = Py_InitModule3("_pywcs", NULL, NULL); 565 565 566 566 if (m == NULL) trunk/pywcs/src/sip_wrap.c
r643 r652 97 97 } 98 98 99 crpix = (PyArrayObject*)PyArray_ContiguousFromAny(py_crpix, PyArray_DOUBLE, 1, 1); 99 crpix = (PyArrayObject*)PyArray_ContiguousFromAny(py_crpix, PyArray_DOUBLE, 100 1, 1); 100 101 if (crpix == NULL) { 101 102 result = -1; … … 314 315 PySip_get_bp_order(PySip* self, void* closure) { 315 316 return get_int("bp_order", self->x.bp_order); 317 } 318 319 static PyObject* 320 PySip_get_crpix(PySip* self, void* closure) { 321 Py_ssize_t naxis = 2; 322 323 return get_double_array("crpix", self->x.crpix, 1, &naxis, (PyObject*)self); 316 324 } 317 325 … … 325 333 {"bp", (getter)PySip_get_bp, NULL, (char *)doc_bp}, 326 334 {"bp_order", (getter)PySip_get_bp_order, NULL, (char *)doc_bp_order}, 335 {"crpix", (getter)PySip_get_crpix, NULL, (char *)doc_crpix}, 327 336 {NULL} 328 337 };
