HOW-TO Use the awe-prompt¶
Introduction¶
Working with the Astro-WISE software involves working with a command line interface. The interface is in fact the standard interactive Python interpreter, customized to facilitate our needs. It is assumed that you have followed the steps in HOW-TO Get started. You may need to set a number of environment variables again with the following command though:
module load awe
now start the interpreter:
awe
This will print a message such as the following:
Python 3.5.1 (default, Oct 15 2017, 09:47:37)
[GCC 4.8.5] on linux
Type "help", "copyright", "credits" or "license" for more information.
Welcome to the Astro-WISE Environment
| You are running the master 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 : <username>
- database : db.astro.rug.astro-wise.org
- project : <project>
- current privileges : 1 (MyDB)
awe>
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>)
and
awe> help(<module, class, attribute or method>)
and
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'>
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)
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)
or
awe> pylab.plot(x,y)
again, use
awe> help(pylab.scatter)
and
awe> help(pylab.plot)
to get help with the syntax.
For more information on matplotlib, see the manual at https://matplotlib.org/
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
Imported package: eclipse¶
See Eclipse interface for more information on this package.
Imported packages: os, sys, glob (standard Python)¶
Along with the above application oriented packages, several standard Pythonmodules 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')
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 HOW-TO Process data in a distributed (parallel) way and Parallel processing for information on how to use this class.