Talk:Server-side Functions: Difference between revisions

From OPeNDAP Documentation
⧼opendap2-jumptonavigation⧽
Line 46: Line 46:


[[User:RobDeAlmeida|RobDeAlmeida]] proposed two approaches: first, for simple requests use the standard DAP syntax for calling funtions; second, for complex requests, allow a user submitted script to be associated with a newly created function. This second suggestion is a bit controversial because it requires some client software (Ferret, eg) to be rewritten, or at least relinked with a HTTP library that allows POSTs. It also breaks a request in two separate steps. Following Roland Schweitzer's suggestion, the syntax should be tests with the [[Server Side Functions Use Cases]] proposed by Steve Hankin.
[[User:RobDeAlmeida|RobDeAlmeida]] proposed two approaches: first, for simple requests use the standard DAP syntax for calling funtions; second, for complex requests, allow a user submitted script to be associated with a newly created function. This second suggestion is a bit controversial because it requires some client software (Ferret, eg) to be rewritten, or at least relinked with a HTTP library that allows POSTs. It also breaks a request in two separate steps. Following Roland Schweitzer's suggestion, the syntax should be tests with the [[Server Side Functions Use Cases]] proposed by Steve Hankin.
==== Difference time series of the same area mean from two different datasets ====
Requires:
# area-average each of the variables over the same (or different) areas
# specify the vertical coordinate point on each in a geo-aware manner.  (i.e. not by vertical index)
# specify the time range; regrid the time series of one variable to match the other
# take a difference between the two time series
Using nested functions:
/dataset.dods?sub(grid(mean(mean(A,"lon",120,280),"lat",0,60),"0<z<100"),
                  grid(mean(mean(B,"lon",120,280),"lat",0,60),"0<z<100"))
Here I use the [http://rsg.opendap.org:8090/server-side-functions/templates/features.html#F-00 <code>grid</code>] function to specify the vertical coordinate. The <code>mean</code> function comes from the definition above. I also assume the existence of a hypothetical <code>sub</code> function which takes the difference between two variables, regridding the second to the grid of the first if necessary.


=== Standard list of functions ===
=== Standard list of functions ===

Revision as of 23:52, 17 November 2007

Tentative specification

This is a first tentative specification, just to see how far we can go with the ideas alreay in mind. Feel free to change, edit, adapt, modify or leave comments. --RobDeAlmeida

Capabilities introspection

The capabilities response is requested by accessing the URL /functions.xml. Perhaps it would be also a good idea to embed the response in the thredds catalog, or put at least a pointer to it?

Capabilities response

This is a plain old xml response, inspired by XINS. Parameters are positional, and always required:

<functions xmlns="http://xml.opendap.org/ns/SSF">
  <function name="mean">
    <description>Calculates mean over axis between two points.</description>
    <example>mean(sst,"lat",10,40)</example>
    <input type="Grid">
      <description>The name of the variable to be averaged.</description>
    </input>
    <input type="String">
      <description>The name of the axis.</description>
    </input>
    <input type="Float64">
      <description>The initial value of the averaging.</description>
    </input>
    <input type="Float64">
      <description>The last value of the averaging.</description>
    </input>
    <output type="Grid">
      <description>A new Grid with a degenerated axis.</description>
    </output>
  </function>
</functions>

Problem: how do we specify more than one type of input type allowed? I can think of:

<input type="Grid Array">

But the list could get big quickly if we want to list Int32, UInt16, etc. It would be nice to have a shortcut to the base types:

<input type="Array Base">

With Base meaning all the base types.

Syntax specification

RobDeAlmeida proposed two approaches: first, for simple requests use the standard DAP syntax for calling funtions; second, for complex requests, allow a user submitted script to be associated with a newly created function. This second suggestion is a bit controversial because it requires some client software (Ferret, eg) to be rewritten, or at least relinked with a HTTP library that allows POSTs. It also breaks a request in two separate steps. Following Roland Schweitzer's suggestion, the syntax should be tests with the Server Side Functions Use Cases proposed by Steve Hankin.

Difference time series of the same area mean from two different datasets

Requires:

  1. area-average each of the variables over the same (or different) areas
  2. specify the vertical coordinate point on each in a geo-aware manner. (i.e. not by vertical index)
  3. specify the time range; regrid the time series of one variable to match the other
  4. take a difference between the two time series

Using nested functions:

/dataset.dods?sub(grid(mean(mean(A,"lon",120,280),"lat",0,60),"0<z<100"),
                  grid(mean(mean(B,"lon",120,280),"lat",0,60),"0<z<100"))

Here I use the grid function to specify the vertical coordinate. The mean function comes from the definition above. I also assume the existence of a hypothetical sub function which takes the difference between two variables, regridding the second to the grid of the first if necessary.

Standard list of functions