Table of Contents

Class: madCalculator2Service madCalculator2Service.py

madCalculator2Service is a class that runs the Madrigal derivation engine for a time and random array of points in space.

Like all my python cgi scripts, madCalculator2Service has the following structure: the entire cgi is contained in one class, with a main function at the end which serves simply to call the __init__ function of the class. This __init__ function is responsible for calling all other class methods. It is made up of a single try block, with the purpose of reporting all exceptions in well-formatted text to both the user and the administrator. The __init__ function first makes sure the pythonlib can be found. It then calls setScriptState to validate the the cgi arguments, which are simply the arguments for the isprint command.

If any uncaught exception is thrown, its caught by the __init__ try block. If its an MadrigalError, additional information is available. The catch blocks attempt to display the error message on the screen by backing out of of large number of possible tags, which might prevent its display (in any case, the error message will always be available in the page source. The formatted error message is also sent to the email address given in the siteTab.txt metadata file.

This script is not meant to be used directly by a user, and thus is named Service. It is meant to be used by scripting languages such as Matlab that want to call madCalculator2 via the web

Input cgi arguments:

  1. year - int (required)

  2. month - int (required)

  3. day - int (required)

  4. hour - int (required)

  5. min - int (required)

  6. sec - int (required)

  7. lats - a comma-separated list of geodetic latitudes, -90 to 90 (required)

  8. longs - a comma-separated list of longitudes (required) Length must = lats

  9. alts - a comma-separated list of geodetic altitudes in km (required) Length must = lats

  10. parms - comma delimited string of Madrigal parameters desired (required)

  11. oneD - string in form <parm>,<value> This argument allows the user to set any number of one-D parameters to be used in the calculation. Value must be parameter name, comma, value as double. Example: &oneD=kinst,31.0&oneD=elm,45.0 (optional - 0 or more allowed)

    1. twoD=<parm>,<values> (optional - 0 or more allowed) This argument allows the user to set any number of two-D parameters to be used in the calculation. Value must be parameter name, comma, comma-separated values. Number of values must equal the number of points (or number of lats) Example: twoD=te,1000,1100,1200 twoD=ti,1000,1000,1000 where there are 3 inputs points

Returns comma-delimited data, one line for each lat, long, and alt, with the following fields:

  1. latitude

  2. longitude

  3. altitude

  4. Values for each Madrigal parameter listed in argument parms, separated by whitespace

Now directly calls madrigal._Madrec methods, because of problems with calling a separate command with a long command line.

If error, returns error description

Change history:

Written by Bill Rideout Feb. 6, 2004

$Id: madCalculator2Service_madCalculator2Service.py.html 3304 2011-01-17 15:25:59Z brideout $

Methods   
__init__
createObjects
madCalculator2
setScriptState
  __init__ 
__init__ ( self )

__init__ run the entire madCalculator2Service script. All other functions are private and called by __init__.

Inputs: None

Returns: void

Affects: Outputs madCalculator2 data as a service.

Exceptions: None.

  createObjects 
createObjects ( self )

  madCalculator2 
madCalculator2 ( self )

Exceptions   
ValueError, 'wrong number of values in %s' %( twoD )
  setScriptState 
setScriptState ( self )

Exceptions   
ValueError( 'Mismatched number of positions' )
ValueError, 'Illegal alt %f' %( alt )
ValueError, 'Illegal lat %f' %( lat )
ValueError, 'Illegal long %f' %( long )

Table of Contents

This document was automatically generated on Mon Aug 9 13:18:41 2010 by HappyDoc version r1_5