AstroGrid

Navigation
Log in


Forgot your password?
 

This website (www2.astrogrid.org) is now deprecated - please go to www.astrogrid.org for up to date information.

Document Actions

Example Uses

Remeber, in order to run this examples you will need the workbench running. You will get some errors if not.

Getting Help

Remeber that you can get help on the classes and methods using the standard Python help procedures, e.g. help(ConeSearch). If using IPython (recommended for interactive use) just type:

>>> ConeSearch?

Configuration

This step is optional. You can write configuration values into the file '~/.python-acr'. These are mine:

debug = True
verbose = True
autologin = True

[community]
username = *your username here*
password = *your password here*
community = *your community here*

With these values you will not need to login to your account, that will be handled automatically. Also all debug flags are on to see what is happening.

Example 3: Working with MySpace

The class 'MySpace' provides methods to work with MySpace:

>>> from astrogrid import MySpace
>>> m = MySpace()
>>> m.ls()
>>> m.rm('#test1')
ERRIR: Cannot delete a folder without first deleting all its children

>>> m.rm('#test1', recursive=True)
>>> data = m.readfile('#sdss1/data-0.fits')

Example 4: Running an application

For this example we are going to create a mosaic from 2MASS images using Montage. First we create an instance of the Applications class with the IVORN of the Montage application obtained from a registry search. The we fill in the app.inputs and app.outputs values and submit the application. Then we poll the status of the application until it is completed and we read the result which has been saved to MySpace.:

>>> from astrogrid import Applications, MySpace
>>> m = MySpace()                                     # We are going to use MySpace
>>> app = Applications('ivo://astrogrid.cam/Montage/prototype/2MASS-mosaic')
>>> app.inputs['ra']['value'] = 312.75           # We fill in the inputs. Information is
>>> app.inputs['dec']['value'] = 44.37           # available by printing app.info
>>> app.inputs['size']['value'] = 0.3
>>> app.inputs['band']['value'] = 'K'
>>> app.outputs['out.fits']['value'] = m.home()+'2mass/mosaic.fits'
>>> app.outputs['out.fits']['indirect'] = True
>>> thread = app.submit()                        # Submit the application
>>> thread.status()                              # and check status
'PENDING'
>>> thread.status()
'RUNNING'
>>> thread.status()
'COMPLETED'

After some minutes, we can read the results and save them to local disk:

>>> ofile = thread.results()[1]
>>> image = m.readfile(ofile)
>>> open('image.fits', 'w').write(image)
ic5070.jpg