Changeset 652

Show
Ignore:
Timestamp:
09/29/08 13:31:05 (2 months ago)
Author:
mdroe
Message:

Minor code/documentation cleanup.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/pywcs/doc/docstrings.py

    r643 r652  
    890890""" 
    891891 
    892 pywcs = """ 
    893 Pywcs provides transformations following the SIP conventions, Paper IV 
    894 table lookup distortion, and the core WCS functionality provided by 
    895 wcslib.  Each of these transformations can be used independently or 
    896 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 or 
    905        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 to 
    911          sky coords. 
    912  
    913        - wcs_pix2sky: Perform just the core WCS transformation from 
    914          pixel to sky coords. 
    915  
    916        - wcs_sky2pix: Perform just the core WCS transformation from 
    917          sky to pixel coords. 
    918  
    919        - sip_pix2foc: Convert from pixel to focal plane coords using 
    920          the SIP polynomial coefficients. 
    921  
    922        - sip_foc2pix: Convert from focal plane to pixel coords using 
    923          the SIP polynomial coefficients. 
    924  
    925        - p4_pix2foc: Convert from pixel to focal plane coords using 
    926          the table lookup distortion method described in Paper IV. 
    927 """ 
    928  
    929892radesys = """ 
    930893The equatorial or ecliptic coordinate system type, C{RADESYSa}. 
  • trunk/pywcs/pywcs/__init__.py

    r643 r652  
    4242 
    4343from pywcs import * 
     44import pywcs 
    4445import _pywcs 
    4546 
    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
    34# 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
    912#     2. Redistributions in binary form must reproduce the above 
    1013#       copyright notice, this list of conditions and the following 
    11 #       disclaimer in the documentation and/or other materials provided 
    12 #       with the distribution. 
    13  
     14#       disclaimer in the documentation and/or other materials 
     15#       provided with the distribution. 
     16
    1417#     3. The name of AURA and its representatives may not be used to 
    1518#       endorse or promote products derived from this software without 
    1619#       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""" 
     33Pywcs provides transformations following the SIP conventions, Paper IV 
     34table lookup distortion, and the core WCS functionality provided by 
     35wcslib.  Each of these transformations can be used independently or 
     36together in a standard pipeline. 
     37 
     38The 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""" 
    2968 
    3069__docformat__ = "epytext" 
     
    4079DistortionLookupTable = _pywcs.DistortionLookupTable 
    4180Sip = _pywcs.Sip 
     81Wcsprm = _pywcs._Wcsprm 
    4282 
    4383# A wrapper around the C WCS type 
    4484class 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 
    4591    def __init__(self, header=None, fobj=None, key=' ', relax=False, naxis=2): 
    4692        """ 
    4793        WCS(header=None, fobj=None, key=' ', relax=False, naxis=2) 
    48  
    49         WCS objects correct for SIP and Paper IV table-lookup 
    50         distortions and transform pixel to/from sky coordinates, based 
    51         on the WCS keywords and data in a FITS file. 
    5294 
    5395        @param header: A PyFITS header object.  If header is not 
     
    86128        """ 
    87129        if naxis != 2: 
    88             raise ValueError("Only 2 axes are supported"); 
     130            raise ValueError("Only 2 axes are supported") 
    89131        self.naxis = naxis 
    90132 
    91133        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) 
    93136            # Set some reasonable defaults. 
    94137            wcsprm.crpix = numpy.zeros((self.naxis,), numpy.double) 
     
    114157        """ 
    115158        if dist == 'CPDIS': 
    116             d_kw= 'DP' 
     159            d_kw = 'DP' 
    117160        else: 
    118161            d_kw = 'DQ' 
     
    125168                if dis == 'lookup': 
    126169                    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.' 
    128171                    dp = d_kw+str(i) 
    129172                    d_extver = header[dp+'.EXTVER'] 
     
    133176                    d_crval = (d_header['CRVAL1'], d_header['CRVAL2']) 
    134177                    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) 
    136180                    tables[i] = d_lookup 
    137181                else: 
     
    335379        if self.wcs is None: 
    336380            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) 
    338383    wcs_sky2pix_fits.__doc__ = """ 
    339384        wcs_sky2pix_fits(*args) -> pixel 
  • trunk/pywcs/setup.py

    r643 r652  
    3232except ImportError: 
    3333    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." 
    3536 
    3637###################################################################### 
     
    111112fd.write("""/* This file is autogenerated by setup.py.  To edit its contents 
    112113   edit doc/docstrings.py 
    113 */""") 
     114*/ 
     115 
     116""") 
    114117for key in keys: 
    115118    if key.startswith('__'): 
     
    158161                  undef_macros=undef_macros 
    159162                  ) 
    160      
     163       
    161164      ) 
  • trunk/pywcs/src/pywcs.c

    r644 r652  
    562562  PyObject* m; 
    563563 
    564   m = Py_InitModule3("_pywcs", NULL, doc_pywcs); 
     564  m = Py_InitModule3("_pywcs", NULL, NULL); 
    565565 
    566566  if (m == NULL) 
  • trunk/pywcs/src/sip_wrap.c

    r643 r652  
    9797  } 
    9898 
    99   crpix = (PyArrayObject*)PyArray_ContiguousFromAny(py_crpix, PyArray_DOUBLE, 1, 1); 
     99  crpix = (PyArrayObject*)PyArray_ContiguousFromAny(py_crpix, PyArray_DOUBLE, 
     100                                                    1, 1); 
    100101  if (crpix == NULL) { 
    101102    result = -1; 
     
    314315PySip_get_bp_order(PySip* self, void* closure) { 
    315316  return get_int("bp_order", self->x.bp_order); 
     317} 
     318 
     319static PyObject* 
     320PySip_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); 
    316324} 
    317325 
     
    325333  {"bp", (getter)PySip_get_bp, NULL, (char *)doc_bp}, 
    326334  {"bp_order", (getter)PySip_get_bp_order, NULL, (char *)doc_bp_order}, 
     335  {"crpix", (getter)PySip_get_crpix, NULL, (char *)doc_crpix}, 
    327336  {NULL} 
    328337};