Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stecf.org/software/PYTHONtools/astroasciidata/
Дата изменения: Unknown
Дата индексирования: Sun Apr 10 00:21:51 2016
Кодировка:

Поисковые слова: п п п п п п п п п п п п п р п р п р п р п р п р п р п р п р п р п р п р п
AstroAsciiData
Browse to http://www.esa.int Browse to http://www.eso.org




asciidata astrolib

What is AstroAsciiData

AstroAsciiData is a Python module to handle ASCII tables. Features:

  • Imports all reasonably well-formed Ascii tables
  • Column-first access
  • Easy creation and manipulation of tables, columns, rows and attached comments
  • Retains formatting of data values
  • Support for SExtractor style headers
  • Column sorting
  • Interchangeable comment character, column delimiter and null value
  • Exports data to:
    • Ascii
    • Numpy/Numarray
    • FITS table
    • HTML table format
    • LaTeX table format

The idea to develop this Python module emerged from the fact that ASCII tables continue to be one of the most popular and widely used data exchange formats in astronomy and probably science in general. Moreover the Python language is developing into some kind of standard programming language in astronomy, and being able to handle this major data exchange format in a nice way within it would would be very advantageous.

The development of the AstroAsciiData module is taking place as part of the AstroLib project, an open source effort to develop general astronomical utilities akin to those available in the IDL ASTRON package.

The prime focus of the module is not computational speed, since the ASCII tables used in astronomy are rather small (<10MB) and thus very easy to handle for modern day computers. The main effort was clearly to maximize the convenience for the user to keep the threshold for installing and using the AstroAsciiData module as low as possible.

Examples

This section contains some example of how the AstroAsciiData module might be used. With these examples also some of the basic functionality of the module is explained. More example can be found in Section 3 of the User Manual.

  • Imagine you would like to work with the file "webexa.txt":

    #
    # Some objects on the sky
    #
    J02994.34+62.4844 189.2207323 62.2357983 231.9 521.8 26.87 0.1
    J09234.54+62.9485 189.1408929 62.2376331 720.4 962.1 24.97 0.1
    J09267.65+62.8293 189.1409453 62.1696844 927.1 327.9 25.30 0.1
    J09738.55+62.4327 188.9014716 62.2037839 223.7 192.5 25.95 0.1

  • To load this ASCII table, go into Python, load the AstroAsciiData module and read in the table with:

    >>> import asciidata
    >>> demo = asciidata.open('webexa.txt')
    >>> print demo
    #
    # Some objects on the sky
    #
    J02994.34+62.4844 189.2207323 62.2357983 231.9 521.8 26.87 0.1
    J09234.54+62.9485 189.1408929 62.2376331 720.4 962.1 24.97 0.1
    J09267.65+62.8293 189.1409453 62.1696844 927.1 327.9 25.30 0.1
    J09738.55+62.4327 188.9014716 62.2037839 223.7 192.5 25.95 0.1

    The print command at the end was just to confirm the correct reading of the file.
  • Let's assume that column4 and 5 contain object coordinates. You would like to compute and store the distance to the distances to the image center at (x,y)=(500.0,500.0):

    >>> import math
    >>> xcen=500.0
    >>> ycen=500.0
    >>> for index in range(demo.nrows):
    ... demo['distance'][index] = \
    math.sqrt((demo[3][index]-xcen)**2+(demo[4][index]-ycen)**2)
    ...
    >>> print demo
    #
    # Some objects on the sky
    #
    J02994.34+62.4844 189.2207323 62.2357983 231.9 521.8 26.87 0.1 2.689849e+02
    J09234.54+62.9485 189.1408929 62.2376331 720.4 962.1 24.97 0.1 5.119693e+02
    J09267.65+62.8293 189.1409453 62.1696844 927.1 327.9 25.30 0.1 4.604702e+02
    J09738.55+62.4327 188.9014716 62.2037839 223.7 192.5 25.95 0.1 4.133980e+02

    As the print command reveals, there is now a new column with the computed values.
  • Now you would like to save the result:

    >>> demo.flush()
    >>>
    work>more webexa.txt
    #
    # Some objects on the sky
    #
    J02994.34+62.4844 189.2207323 62.2357983 231.9 521.8 26.87 0.1 2.689849e+02
    J09234.54+62.9485 189.1408929 62.2376331 720.4 962.1 24.97 0.1 5.119693e+02
    J09267.65+62.8293 189.1409453 62.1696844 927.1 327.9 25.30 0.1 4.604702e+02
    J09738.55+62.4327 188.9014716 62.2037839 223.7 192.5 25.95 0.1 4.133980e+02

    The new column was saved back to the file!

Download

The AstroAsciiData module was developed on the basis of Python 2.4. This or any later version of Python is sufficient for loading and working with the module.

Users who only want to work with ASCII tables neeed no further python modules. For the transformation to numpy or numarray objects the corresponding module (numpy or numarray). The transformation of ASCII tables to FITS format requires the numpy and the PyFITS package.

The AstroAsciiData module is available for download here:

The installation requires the "usual" unpack and setup actions:

> gunzip asciidata-1.1.1.tar.gz
> tar -xvf asciidata-1.1.1.tar
> cd asciidata-1.1.1
> python setup.py install

The installation includes a fair amount of Unit Tests. To run them on the already installed module, please execute:

> python setup.py test

Further information on how to work with the AstroAsciiData module is given in the Documentation below.

Documentation

The AstroAsciiData User Manual gives a detailed insight into all aspects of the module. The Manual is available for browsing as well as for download in various formats:

Future development

With respect to 1.0, there were only minor improvements and bugfixes to be done for version 1.1.1 (see the Manual for details). The module does currently everything we developed it for, and according to our needs we will add new features to it.

The features for the next release will concentrate on:

  • To make it even more Pythonic
  • Support for more external formats
  • ?? (We are open for suggestions)

We would love more user feedback for additions to the module, so we invite everyone to try AstroAsciiData with their favourite tabulated data and mail questions, criticisms and improvement suggestions to:

AstroAsciiData@stecf.org

People

The AstroAsciiData module is developed and maintained by a team from the ST-ECF composed of:

Martin Kümmel Martin.Kuemmel@eso.org
Jonas Haase Jonas.Haase@eso.org

Maintained by Martin Kuemmel <mkuemmel@eso.org>