ioos / pyoos

A Python library for collecting Met/Ocean observations
GNU Lesser General Public License v3.0
34 stars 33 forks source link

NERRS Functionality #1

Closed CowanSM closed 11 years ago

CowanSM commented 11 years ago

Can create a Station object from nerrs by doing the following:

from pyoos.collectors.nerrs import NerrsWSDL

nerrs = NerrsWSDL()
station = nerrs.get_station(station_code, **kwargs)

Known kwargs:

site_id: the site id (id) of a station; basically a collection of stations - this may speed up request time as it limits the amount of info returned from NERRS
min_date: earliest date to query
max_date: latest date to query
observed_property: if you want only a specific measurement (like 'Temp')
test: boolean indicating whether or not the function should use local files instead of querying from url

To get a list of station_codes (uid for a station), you can do the following:

nerrs = NerrsWSDL()
list_of_stations = nerrs.get_metadata()

for st in list_of_stations:
  print st.code

Most NERRS functions have 'test' as an optional argument, this will mean that the function will try to read from a local file as opposed to going to the NERRS wsdl source. Local files are written when the DEBUG flag in nerrs.py is set to True and 'test' is not sent (or sent False) to the function. After an initial run of each function, with DEBUG set to True, then subsequent calls to the same function (with the same arguments) with 'test' set to True should allow the functions to read from the local files. If 'test' is set to True and needed local files do not exist (either because DEBUG is False or no initial run was made), the functions will fail.

kwilcox commented 11 years ago

I'm not entirely sure what the DEBUG variable and "test" parameters do. Just cache the WSDL responses to make subsequent tests faster?

CowanSM commented 11 years ago

Yes, the DEBUG and test parameters are for cacheing Nerrs responses so to make subsequent tests faster and to prevent putting unnecessary strain on Nerrs.

CowanSM commented 11 years ago

Addressed concerns. Removed caching (test and DEBUG no longer used).

kwilcox commented 11 years ago

The "Collector" should contact NERRS and query the data spatially, temporally, by siteid, etc. It should pass the resulting XML (minus any SOAP overhead) to the "Parser" that will create the pyoos station object. Look at the WQP (collector) and WQX (parser) for samples.

CowanSM commented 11 years ago

Forgot to say so in the commit. But it should address all open concerns for the pull request.

kwilcox commented 11 years ago

Rename the NERRS parser "folders/files" to match the functionality. They are "soap/nerrs_wsdl", but shouldn't be parsing any SOAP XML any longer. The collector should be stripping that all out.