Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coops Get Observations as Collections #31

Open
DanielJMaher opened this issue May 20, 2014 · 4 comments
Open

Coops Get Observations as Collections #31

DanielJMaher opened this issue May 20, 2014 · 4 comments

Comments

@DanielJMaher
Copy link

When attempting to Get Coop Observations, pyoos encounters an issue:
Because Coops does not support xml generation for a collection of observations, the collector can not properly collect the data. The solution would either be to allow the parsing and collecting of CSV/TSV files, or to get observations from Coop as several single observation.

@birdage
Copy link

birdage commented May 20, 2014

@DanielJMaher i get round this by making a separate get request, and parsing the xml, the following creates a dict of station in that bounding box

url=(sos_urls[0].split("?")[0]+'?'
     'service=SOS&request=GetObservation&version=1.0.0&'
     'observedProperty=%s&offering=urn:ioos:network:NOAA.NOS.CO-OPS:WaterLevelActive&'
     'featureOfInterest=BBOX:%s&responseFormat=text/tab-separated-values&eventTime=%s') % (sos_name,box_str,iso_end)

r = requests.get(url)
data = r.text
#get the headers for the cols
data = data.split("\n")
headers =  data[0]
station_list_dict = dict()
#parse the headers so i can create a dict
c = 0
for h in headers.split("\t"):
    field = h.split(":")[0].split(" ")[0]
    station_list_dict[field] = {"id":c}
    c+=1
#create dict of stations
station_list = []
for i in range(1,len(data)):
    station_info = data[i].split("\t")
    station = dict()
    for field in station_list_dict.keys():        
        col = station_list_dict[field]["id"]
        if col < len(station_info):
            station[field] = station_info[col]     
    station_list.append(station)     

@DanielJMaher
Copy link
Author

@birdage I don't think you are using pyoos at all in your work around. I think you are on the right track here though. Once we grab the data we don't need to use etree to parse the xml. instead we can parse the data how we want.

@dpsnowden
Copy link

Let's bring Mohammed into the conversation. I think they implemented collection support and it may be a syntax issue. @mchaouchi can you clarify?

@mchaouchi
Copy link

CO-OPS implemented collection support for CSV, TSV, and KML.

In the next release (in 2 to 3 months from now), the SWE common implementation will have collection support for XML.

Date: Tue, 20 May 2014 13:19:05 -0700
From: [email protected]
To: [email protected]
CC: [email protected]
Subject: Re: [pyoos] Coops Get Observations as Collections (#31)

Let's bring Mohammed into the conversation. I think they implemented collection support and it may be a syntax issue. @mchaouchi can you clarify?


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants