.. highlight:: none :linenothreshold: 1000 Introduction ============ The Kapteyn Package is a collection of Python modules and applications developed by the computer group of the `Kapteyn Astronomical Institute `_, University of Groningen, The Netherlands. The purpose of the package is to provide tools for the development of astronomical applications with Python. The package is suitable for both inexperienced and experienced users and developers and documentation is provided for both groups. The documentation also provides in-depth chapters about celestial transformations and spectral translations. Some of the package's features: * The handling of spatial and spectral coordinates, WCS projections and transformations between different sky systems. Spectral translations (e.g., between frequencies and velocities) are supported and also mixed coordinates. (Modules wcs and celestial) * Versatile tools for writing small and dedicated applications for the inspection of FITS headers, the extraction and display of (FITS) data, interactive inspection of this data (color editing) and for the creation of plots with world coordinate information. (Module maputils) As one example, a gallery of all-sky plots is provided. * A class for the efficient reading, writing and manipulating simple table-like structures in text files. (Module tabarray) * Utilities for use with Matplotlib such as obtaining coordinate information from plots, interactively modifiable colormaps and timer events (module mplutil); tools for parsing and interpreting coordinate information entered by the user (module positions). Overview -------- The following modules are included: - :mod:`wcs`, a binary module which handles spatial and spectral coordinates and provides WCS projections and transformations between different sky systems. Spectral translations (e.g., between frequencies and velocities) are supported and also mixed coordinates. - :mod:`celestial`, containing NumPy-based functions for creating matrices for transformation between different celestial systems. Also a number of other utility functions are included. - :mod:`wcsgrat`, for calculating parameters for WCS graticules. It does not require a plot package. - :mod:`maputils`. Provides methods for reading FITS files. It can extract 2-dim image data from data sets with three or more axes. A class is added which prepares FITS data to plot itself as an image with Matplotlib. - :mod:`positions`, enabling a user/programmer to specify positions in either pixel- or world coordinates. - :mod:`rulers`, defining a class for drawing rulers. - :mod:`shapes`, defining a class for interactively drawing shapes that define an area in an image. For each area a number of properties of the data is calculated. This module can duplicate a shape in different images using transformations to world coordinates. This enables one for instance to compare flux in two images with different WCS systems. - :mod:`mplutil`, utilities for use with Matplotlib. Classes AxesCallback, providing a more powerful mechanism for handling events from LocationEvent and derived classes than Matplotlib provides itself; TimeCallback for handling timer events and VariableColormap which implements a Matplotlib Colormap subclass with special methods that allow the colormap to be modified. - :mod:`kmpfit`, providing a class and a function for non-linear least-squares fitting, using the Levenberg-Marquardt technique. It is based on the implementation in C of Craig Markwardt's MPFIT. - :mod:`tabarray`, providing a class for the efficient reading, writing and manipulating simple table-like structures in text files. .. ascarray left out :mod:`ascarray`, a binary module containing the base function for module :mod:`tabarray`. .. index:: prerequisites, Python, NumPy, PyFITS, Astropy (for PyFITS only), Matplotlib Prerequisites ------------- To install the Kapteyn Package, at least Python_ 3.5 Version 3.4 has been built for Python 3.10. Further it depends on NumPy_, SciPy_ and Matplotlib_. To process FITS files, we used PyFITS_ but nowadays it is part of AstroPy_ and NumPy_ (both with header files) are required. Windows users may also need to install Readline_ or an equivalent package. Mark Calabretta's WCSLIB_ does not need to be installed separately. Its code is now included in the Kapteyn Package under the GNU Lesser General Public License. .. _Python: https://www.python.org/ .. _NumPy: https://numpy.org/ .. _SciPy: https://scipy.org/ .. _PyFITS: https://www.stsci.edu/resources/software_hardware/pyfits .. _Astropy: https://www.astropy.org/ .. _Matplotlib: https://matplotlib.org/ .. _Readline: https://newcenturycomputers.net/projects/readline.html .. _WCSLIB: https://www.atnf.csiro.au/people/mcalabre/WCS/ .. index:: download Download -------- The package can be downloaded as `https://www.astro.rug.nl/software/kapteyn/kapteyn-3.4.tar.gz `_. This is not necessary if you install the package with pip, see next section. .. index:: install An archive with all the examples and data used in the tutorials can downloaded from :download:`examples.tar.gz `. .. _installinstructions: Installing ---------- With pip ++++++++ You can install the Kapteyn Package 3.4 for Python with:: pip install https://www.astro.rug.nl/software/kapteyn/kapteyn-3.4.tar.gz If you don't have permission to install it because you don't have enough privileges, then try to install it as a user with:: pip install --user https://www.astro.rug.nl/software/kapteyn/kapteyn-3.4.tar.gz It will then be installed in a folder in your home directory called **.local**. The location will be inserted in your Python path which can be inspected with:: In [1]: import sys In [2]: print(sys.path) You can uninstall the Kapteyn Package in both cases with:: pip uninstall kapteyn Manually +++++++++ The recipes below we written for the older versions of the Kapteyn Package. For the current version you should use the pip command as described in the previous section. First unpack the downloaded .tar.gz or .zip file and go to the unpack directory. Then one of the following options can be followed: #. Install into your Python system (you could need root permission for this):: python setup.py install #. If you prefer not to modify your Python installation, you can create a directory under which to install the module e.g., *mydir*. Then install as follows:: python setup.py install --install-lib mydir To use the package you need to include *mydir* in your PYTHONPATH. .. index:: GIPSY #. GIPSY is the Groningen Image Processing System. It leans heavily on the kapteyn Package If you want to use and modify this package in the context of GIPSY, then download the tar file and untar it with ``tar -xvf kapteyn-3.4.tar.gz``. With a proper setup of your GIPSY environment, you can install it as follows:: pip install ./kapteyn-3.4 --upgrade --target=$gip_exe The GIPSY installation procedure normally does this automatically, so you will only need this if the GIPSY installation failed to install the Kapteyn Package. Windows installer ................. The most convenient way to go here is to install Anaconda3 from https://www.anaconda.com/distribution/. To build the C files, you need to install a compiler. We tried Visual studio, see: https://visualstudio.microsoft.com/vs/features/cplusplus/ It is important to at least install *Windows 10 SDK (10.0.16299.0) for Desktop C++* form the visual studio build tools. Open a so called Anaconda prompt (a terminal) and type the pip command from above to install the package:: pip install https://www.astro.rug.nl/software/kapteyn/kapteyn-3.4.tar.gz Mac OS X Compiler problem ......................... There is a known problem with Apple's llvm-gcc-4.2 compiler. This compiler is known to crash with an internal compiler error (Segmentation fault: 11) when WCSLIB routine wcserr.c is compiled. For this reason, setup.py tries to detect this compiler and use the clang compiler instead. If compilation still fails, one could try to prefix a shell variable definition to the install command like this:: export CC=CLANG; python setup.py install ... Contact ------- The authors can be reached at: | Kapteyn Astronomical Institute | Postbus 800 | NL-9700 AV Groningen | The Netherlands | Telephone: +31 50 363 4073 | E-mail: gipsy@astro.rug.nl ------------------ .. target-notes:: .. experiments: (remove leading blanks to activate) Epilogue -------- Suppose a droplet of liquid is placed in an external medium that exerts a pressure :math:`P` on the droplet. Then the work done by the droplet on expansion is empirically given by .. math:: dW=P\thinspace dV-\gamma\thinspace da where :math:`da` is the increase in the surface area of the droplet and :math:`\gamma` the coefficient of surface tension. The first law now takes the form .. math:: :label: firstlaw dU=dQ-P\thinspace dV+\gamma\thinspace da Integrating this, we obtain for the internal energy of a droplet of radius :math:`r` the expression .. math:: U={{4}\over {3}}\pi r^3u_\infty +4\pi \gamma r^2 where :math:`u_\infty` is the internal energy per unit volume of an infinite droplet. (Now we understand the first law :eq:`firstlaw` a lot better!) .. inline plot example .. plot:: from matplotlib.pyplot import plot plot(range(10)) .. plot:: rechtelijn.py :height: 300 (The End)