r10 - 18 Jul 2006 - 15:59:08 - NoelWinstanleyYou are here: TWiki >  Astrogrid Web  >  AgWorkshops > AgTechWorkshopJan06 > MakingAppsVOAwareWorksheet
Out of Date - move a polished copy of this to Plone.

Making Applications VO-Aware

Reading Material

  • Presentation (.odp, .pdf).
  • Zip of example scripts & recipes, illustrating how to connect to the ACR from various programming languages.
    • The page AcrRecipes give recipes for other languages.

The Exercise

You will write a script that uses the ACR to
  • retrieve a list of SIAP image services from the registry.
  • query a SIAP service by specifying a position, retreiving a VOTABLE of metadata about images
  • parse the metadata and present the results as a web page

SIAP, VOTABLE, Registry, etc are described further in the IVOA specifications in the references section

Procedure.

  1. Start the AstroGridWorkbench
  2. Download the tutorial python script tutorial.py
    • due to a wiki oddness, you'll need to rename the file ending from .py.txt to .py
    • Run the script to test your ACR installation. Suggested commandline is python -i tutorial.py. -i causes the python interpreter to remain open once the script has completed - which makes it easier to inspect the value of variables and experiment with function calls.
    • If you see errors in python about failing to import modules, you will need to install the python xml extension package : http://sourceforge.net/project/showfiles.php?group_id=6473
  3. the script is divided into a series of steps.
    • work through each step in turn
    • the majority of the python programming is done for you - all that is needed is to add calls to ACR functions at the places marked TODO. Explore the *API documentation for XMLRPC* and *Full API documentation* to determine which function to call
    • re-run the script at each step.
    • after each step there's a raise statement, which causes the script to halt. This is to stop the script running straight though and failing noisily due to being incomplete. Once you've completed one step, remove the next raise statement to proceed onto the next step.
    • If stuck, take a look at the solution for that step

*NB* if you prefer to work in another language, translate the script to your language-of-choice using the AcrRecipes page

Taking it further.

Here's a larger example:

Other Possibilities

Alternatively, develop your own script or ACR-enabled application. Some examples to get you started are:

Administration

Everyday administration tasks you can do as a sysadmin or as a user through the ACR:
  • List files in MySpace on the commandline
  • Back up your MySpace files to your local machine
  • Batch upload files to MySpace
  • Delete files matching a pattern from the commandline
  • Delete any cancelled or completed jobs
  • Given a file listing users and passwords, move all their files from one FileStore? to another

Further Ideas for Applications

Some ideas for the sort of thing you can do with the ACR:
  • Any application that loads and saves files from local disk can load and save to MySpace
  • An application that queries a database for parameters of interest, sends the data to a remote CEA application that picks out the outliers. The application queries image servers and thumbnails of the outliers are then shown to the user.
    • As above, but the database is selected through the registry browser
    • As above, but instead of orchestrating the services itself, the application simply submits a workflow to JES.
  • An application for colour-colour plots (or color-magnitude): upload images from local folders (or from mySpace), call a remote source extractor, a remote cross matching tool, then plot the results
    • As above, but the colour-magnitude tool first uses the ACR to find and search an xray catalogues for likely galaxy clusters.
    • As above, but the tool queries an image server for the images.
  • Astrometric calibration tool - load the user's image from disk (or myspace), enter approximate coordinates. The tool sends the image to a remote source extraction service, queries a catalogue for cross matching with the extracted sources, calls a remote cross matching service, and calculates the correct WCS coords for the user's image.

Pseudocode Examples

vorip - Copy entire contents of homespace to local disk

make ACR connection
get homespace root ivorn from ACR
CALL copyFolder(home root ivorn, current local folder)

FUNCTION copyFolder(myspace folder ivorn, local folder)
   get myspace folder info from ACR for given ivorn
   IF folder is not of type 'folder'
      RAISE error as user has called this function with a file by mistake
   ENDIF
   get myspace folder name from folder info
   make new subfolder s in current local folder with myspace folder name
   get contents of myspace folder from ACR (as a list of ivorns)
   FOR each item in myspace folder contents
      get fileinfo for item from ACR
      IF item is of type 'file'
         get url of file contents from ACR
         create new local file in subfolder s
         copy contents of url to local file
      ELSE
         CALL copyFolder(item's ivorn,  s)
      END IF
   END FOR
END FUNCTION

volaz - Restore the contents of the local folder to MySpace

make ACR connection
get ivorn of root folder in home MySpace
get current local folder pwd
CALL  copyFolder(pwd, home ivorn)

FUNCTION copyFolder(localFolder, remoteFolder):
    get folderInfo from acr for remoteFolder
    IF remoteFolder is not of type 'folder' or localFolder is not a folder
        RAISE error // This function should be called with folders as args
    ENDIF
    get contents of localFolder
    FOR f in contents:
        IF f is a file
                use acr to create a file in remoteFolder with same name as f
                use acr to copy contents of f to new file
        ELSE        
                use acr to create a folder in remoteFolder with same name as f
                copyFolder(localFolder/f, remoteDir)
        END IF
    END FOR
END FUNCTION

vols (list myspace folder contents - simplified)

make ACR connection
IF number of arguments is zero
   get ivorn of home myspace from acr
ELSE
   use first argument as ivorn
END IF
get info for ivorn from ACR
IF ivorn is a file
   list_of_ivorns = supplied ivorn
ELSE
   list_of_ivorns = get list of child ivorns from ACR
END IF
FOR each ivorn in list_of_ivorns
   get info from ACR
   PRINT file name
END FOR

References

VOTech Report

Supporting docs & apps

toggleopenShow attachmentstogglecloseHide attachments
Topic attachments
I Attachment Action Size Date Who Comment
elseodp application-vo-aware.odp manage 806.8 K 24 Jan 2006 - 17:46 NoelWinstanley Open Office Presentation
pdfpdf application-vo-aware.pdf manage 984.0 K 24 Jan 2006 - 17:48 NoelWinstanley PDF version of presentation
txttxt run-sdss.py.txt manage 3.1 K 01 Feb 2006 - 14:07 NoelWinstanley science by python and astogrid.
elsecss maven-base.css manage 2.2 K 01 Feb 2006 - 14:13 NoelWinstanley  
htmlhtml xmlrpc.html manage 106.0 K 01 Feb 2006 - 14:17 NoelWinstanley documentation for api
Edit | Attach | Printable | Raw View | Backlinks: Web, All Webs | History: r10 < r9 < r8 < r7 < r6 | More topic actions
 
AstroGrid Service Click here for the
AstroGrid Service Web
This is the AstroGrid
Development Wiki
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback