• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • You already know Dokkio is an AI-powered assistant to organize & manage your digital files & messages. Very soon, Dokkio will support Outlook as well as One Drive. Check it out today!


Python for Astronomers

Page history last edited by Nathan De Lee 12 years, 5 months ago

1. Overview


This page is a work in progress and will fill up with links and tips in course of "Python for Astronomers" over the next weeks. Feel free to comment and edit any of the linked pages. Participate actively, at least on Questions and Answers.


Outline, history and next weeks topics


Help yourself - how to get help in a Python shell.


Installing Python Modules (PyFits) - How to install downloaded Python modules, here with PyFits as an example


Parallel Python - how to make use of multiple CPUs (it is easy, believe me)


Python on Accre - how to get numpy, scipy, pyfits and matplotlib on Accre


PfA - Index - all links at a glimpse


Commenting Python Code - A detailed tutorial on commenting your python code with docstrings and Doxygen


2. Getting Started


You may use (and want to) python on your own PC. Feel free to do so. However, I have set up a reference installation on Estrella, including all modules needed and and the Eclipse IDE (Integrated Development Environment). If you have Python 2.5 or higher on your PC, you are fine and can install everything on your PC - I will later explain how, when I know how many of you would want to. If you have Python 2.4 or lower, your are fine as well, but will not be able to use the Eclipse IDE on your PC. I highly recommend to give Eclipse a shot and the most convenient way for you to do so is using the reference installation on Estrella - one of the links below will explain how.


No matter what, you might want to read the Getting started page. It explains a few things - how to use the tab-expand and how to get help for example - that apply to every Python, no matter which version. In addition you might want to try the Interactive Python (ipython) shell. It comes with some really convenient additions to the usual Python shell. ipython might not be installed on your PC, so Estrella might be the only way to check it out before you install it.


The most convenient way to learn Python is using the Eclipse reference installation on Estrella. While Eclipse is already installed, you need to set it up for Python which is explained in Getting started with Eclipse. Even vi and emacs purits might want to scroll to the very and think about if all this automatic completion on <Return> and help might be useful and save a lot of time, especially while learning. 



3. Useful Links


Laurens introduction: Spring 2011: Lauren Palladino - Python


The official Python 2.5 documentation. Python actually is a language that comes with a good online documentation. Check it out.


Beginning to actively write programs comes often with "What was it what Lauren said last week?" Aside of her own pages (Lauren please link here) this short reminder is a very helpful reminder for first steps: Python Scripting at a Glimpse.


You already know how to do it in Perl, Ruby or PHP but how the heck do it in Python? Check out this.  The first column in this cheat sheet links to a detailed explanation for the topic. Very useful for "cross-learning"! If anyone knows about a similar IDL-Python cheat sheet, please let me know and link it here.


The IDL to Python Converter  - tested with the IDL Astronomy Users Library from Goddard Space Flight Center - might come in handy fro those who want to convert IDL sources to Python code. I have not tested it yet and would not expect that you get rid of 100% of source code editing, but the converter might free you from a big chunk of the conversion. And that it has been tested with the IDL astrolib from Goddard - used frequently in our IDL programs - might be a reason for some optimism.



4. Special Pages


The morespam riddle resolved


Comments (0)

You don't have permission to comment on this page.