1.1 HOW-TO Use the awe-prompt (Python Interpreter)

1.1.1 Introduction

Working with the Astro-WISE software involves working with a command line interface. The interface is in fact the standard interactive http://www.python.org/doc/Intros.htmlPython interpreter, customized to facilitate our needs. It is assumed that you have followed the steps in http://www.test.astro-wise.org/portal/howtos/man_howto_start/man_howto_start.shtmlGetting started. now start the interpreter:

> awe
This will print a message such as the following:
Python 2.7.6 (default, Jan  8 2014, 14:02:13)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.

               Welcome to the Astro-WISE Environment

|       You are running the AWBASE version

Importing Astro-WISE packages. Please wait...

Distributed Processing Unit: dpu.hpc.rug.astro-wise.org
Dataserver: ds.astro.rug.astro-wise.org

Current profile:
- username : <your database username>
- database : db.astro.rug.astro-wise.org
- project  : <your active project>
- current privileges : 1 (MyDB)

At this point most (all?) of the classes/modules that you need are automatically imported. As this happens, the consistency of those parts of the code that are relevant to the database and that you may have in your personal version is checked. This takes several seconds. You can see all defined variables (including the classes and modules) in the current so-called namespace by typing:
awe> dir()
In fact, to get insight in classes, arguments etc., always rely on the combination of:
awe> dir(<module, class, attribute or method>)
awe> help(<module, class, attribute or method>)
awe> <module,class,attribute>.__doc__>
For example:
awe> PhotometricParameters.zeropnt.__doc__
'The response of the instrumental setup [mag]'
or if you have an instantation pp of the class PhotometricParameters already:
awe> pp.__class__.zeropnt.__doc__
'The response of the instrumental setup [mag]'

The type(<object>) command returns the type of the object. For example

awe> a=1
awe> type(a)
<type 'int'>
awe> photcat=PhotSrcCatalog()
awe> type(photcat)
<class 'astro.main.PhotSrcCatalog.PhotSrcCatalog'>

1.1.2 Key combinations

The awe-prompt includes functionality from the ``readline'' library. This library is used in Linux shells and Emacs. Here is a non-exhaustive list of its functionality:

  • Tab: Command completion
  • Ctrl-a: Go to beginning of line
  • Ctrl-e: Go to end of line
  • Ctrl-k: Delete in front of cursor to end of line
  • Ctrl-u: Delete behind cursor to beginning of line
  • Ctrl-p or Up: History search backward (and History up)
  • Ctrl-n or Down: History search forward (and History down)

1.1.3 Imported package: pylab (plotting)

Along with Astro-WISE packages, pylab (matplotlib) is automatically imported. Matplotlib is a powerful Python plotting tool, with close ties to MatLab. Plots can be made for example as follows:

awe> x = range(10)
awe> y = [3*i**2 + 10 for i in x]
awe> pylab.scatter(x,y)
awe> pylab.plot(x,y)
again, use
awe> help(pylab.scatter)
awe> help(pylab.plot)
to get help with the syntax.

For more information on matplotlib, see the manual at http://matplotlib.sourceforge.net/http://matplotlib.sourceforge.net/.

1.1.4 Imported package: numpy (numerical Python)

Operations on large arrays and matrices is the speciality of the numpy package. For example:

awe> a = numpy.arange(1000000, dtype='float').reshape((1000,1000))
awe> b = numpy.arange(1000000, dtype='float').reshape((1000,1000))
awe> b = b.transpose()
awe> c = a/b

1.1.5 Imported package: eclipse

See §[*] for more information on this package.

1.1.6 Imported packages: os, sys, glob (standard Python)

Along with the above application oriented packages, several standard Python modules are also imported. Two major functionalities of these modules are: System commands

With the os module, system commands can be executed for example as follows:

awe> os.system('pwd')
awe> os.system('ls') Filename lists

With the glob module, lists of (existing) files can be easily created using the standard Linux shell wildcards:

awe> filenames = glob.glob('OMEGACAM.2014*.fits')
awe> filenames = glob.glob('OMEGACAM.2014-0[3-9]*_?.fits')

1.1.7 Started: Distributed Processing Unit interface

When the awe-prompt starts, an instance of the class ``Processor'' is created. Using this class, you can start jobs (tasks) on a remote cluster. See §[*] and §[*] for information on how to use this class.

page generated Tue Nov 21 10:29:06 CET 2017