Welcome to AstroPython

The purpose of this web site is to act as a community knowledge base for performing astronomy research with Python. It provides lists of useful resources, a forum for general discussion, advice, or relevant news items, collecting users' code snippets or scripts, and longer tutorials on specific topics. The topics within these pages are presented in a list view with the ability to sort by date or topic. A traditional "blog" view of the most recently posted topics is visible from the site Home page.

Contribute

Contributions from the community are strongly encouraged. If you are interested please contact the AstroPython team via the Contribute page. We can either post material on your behalf or give you an astropython.org user account to allow your own postings.

RECENT ACTIVITY

Blog: Caution with numpy float32 images

There is an interesting thread on the numpy discussion group about an unexpected result of taking the mean (or sum) of a large array of 32-bit floating point numbers.  If you exceed the 32-big float precision then you will get the wrong answer on some platforms.  Takeaway: use float64 or specify the precision of the accumulator.

Here are some examples:

In [1]: d = np.ones((1000, 1000), dtype ...

Posted by aldcroft

Blog: Moving from IDL

Please enter your text here.

In a blog post at scicoder, Demitri Muna has offered to provide, in the scicoder website, answers to specific questions that fall under the broad category:

"What would it take to move you away from IDL?"

The following is extracted from the scicoder blog post:

I'd like to hear from you what the core things you do in IDL are (please be ...

Posted by phn

Snippet: Skipping inconsistent rows in asciitable

The asciitable module provides a way to deal with tables that have one or more lines which don't match the format of the rest of the file.  This is done by overriding the asciitable.BaseReader.inconsistent_handler function with your own custom function.  The very simplest action is to just ignore the line entirely by returning None.  This mimics the behavior of the IDL readcol routine.  Another possibility ...

Posted by aldcroft

Resource: PyAST

Description: Starlink AST wrapper for Python
Homepage URL: dsberry.github.com/starlink/pyast.html

PyAST provides wrappers for the starlink AST library.  AST provides a comprehensive range of facilities for attaching world co-ordinate systems to astronomical data, for retrieving and interpreting that information in a variety of formats, including FITS-WCS, and for generating graphical output based on it (annotated coordinate grids, etc). AST provides the WCS facilities for ...

Posted by aldcroft

Blog: HPC examples with Python

AstroPython reader Moritz writes:

While looking for good way to define a banded matrix in Python I stumbled on the following tutorial:

HPC Techreport: A brief introduction to Python

After the standard introduction to basic Python concepts, I quite like the way different HPC solutions are built up in the end (numpy, scipy, weave, Cython) to lead to one example implemented with very different approaches.

In the end ...

Posted by aldcroft