> > |
%META:TOPICINFO{author="MarkClark" date="1182284460" format="1.0" version="1.1"}%
%META:TOPICPARENT{name="PythonKnowledge"}%
How might an astronomer learn and get use from python?
Do some interesting things?
A good book to start reading is [[][Learning Python]] which will provide
the regular language rules and uses. This page will concentrate on what
our installations here at Green Bank provides.
One of the strengths of python is the wealth of
standard and "extern"
libraries which may accessed via the import statement. For
example, if you need numerical methods then the numpy standard package
should have much to offer. For astronomical calculations, the
slalib extern
package is available.
There are, fortunately or unfortunately, several versions of python available
in Green Bank. The default as to this writing is 2.3.4, the sparrow installation
for running the GBT is 2.4.2, and our testing version for the BOS and DSS projects
is 2.4.4. The version may be determine via the command: python -V.
Which version to be used in the following examples will be specified.
The python installation that has both ipython and
slalib
available and may be accessed by setting up your environment by the command:
$ source /home/gbt7/galahad/McPython.{bash|csh}
Then enter:
$ ipython
You will get:
Total number of aliases: 15
Python 2.4.4 (#1, Mar 6 2007, 14:35:16)
Type "copyright", "credits" or "license" for more information.
IPython 0.7.3 -- An enhanced Interactive Python.
? -> Introduction to IPython's features.
%magic -> Information about IPython's 'magic' % functions.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.
In [1]:
Using ipython is recommended for "playing around" instead of python (which is also interactive)
because of the many help facilites, e.g., tab and '?' can provide a wealth of information.
So, let us try some stuff with slalib to get a feel:
In [1]:import slalib
In [2]:slalib.sla_airmas?
Type: builtin_function_or_method
Base Class: <type 'builtin_function_or_method'>
String Form: <built-in function sla_airmas>
Namespace: Interactive
Docstring:
Function signature:
sla_airmas = sla_airmas(zd)
Required arguments:
zd : input float
Return objects:
sla_airmas : float
The command followed by a '?' provides the "on-line" information available. This is
no substitute for the actual
documentation,
but it gives one clues and acts as reminder. So:
In [3]:slalib.sla_airmas(1.0)
Out[3]:1.8466910367945855
-- MarkClark - 19 Jun 2007
%META:FORM{name="WebForm"}%
%META:FIELD{name="TopicClassification" title="TopicClassification" value="NoDisclosure"}%
%META:FIELD{name="OperatingSystem" title="OperatingSystem" value=""}%
%META:FIELD{name="OsVersion" title="OsVersion" value=""}% |