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

error pyoscar get_station_report_summary when retrieving 0-76-0-5208707000000007 #773

Open
maaikelimper opened this issue Sep 18, 2024 · 6 comments
Assignees
Milestone

Comments

@maaikelimper
Copy link
Collaborator

Hi Tom,

When getting metadata station 0-76-0-5208707000000007 we encounter an error originating in pyoscar, could you have look?

wis2box metadata station get 0-76-0-5208707000000007

Traceback (most recent call last):
  File "/usr/local/bin/wis2box", line 33, in <module>
    sys.exit(load_entry_point('wis2box', 'console_scripts', 'wis2box')())
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/usr/local/lib/python3.10/dist-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/usr/local/lib/python3.10/dist-packages/click/decorators.py", line 33, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/app/wis2box/metadata/station.py", line 470, in get
    station = client.get_station_report(wsi, format_='XML', summary=True)
  File "/usr/local/lib/python3.10/dist-packages/pyoscar/__init__.py", line 226, in get_station_report
    return self.get_station_report_summary(response)
  File "/usr/local/lib/python3.10/dist-packages/pyoscar/__init__.py", line 257, in get_station_report_summary
    station, '//wmdr:ObservingFacility/gml:identifier').split(',')[0]  # noqa
AttributeError: 'NoneType' object has no attribute 'split'
@tomkralidis
Copy link
Collaborator

tomkralidis commented Sep 19, 2024

Reproduced locally via:

pyoscar station "0-76-0-3170206000000036" -s -f XML

Interestingly enough, pyoscar station "0-76-0-3170206000000036" -s works fine (however we are explicitly asking for the WMDR XML output in wis2box). I've reached out to OSCAR/Surface and will report back on their response. cc @david-i-berry

@david-i-berry
Copy link
Member

WIS2box, via pyoscar, accesses the following link:

https://oscar.wmo.int/oai/provider?verb=GetRecord&metadataPrefix=wmdr&identifier=0-76-0-3170206000000036

This works and returns the XML via the browser.

@david-i-berry
Copy link
Member

the following command also works:

pyoscar station "0-76-0-3170206000000036" --format=XML --env=prod

and returns the XML as expected.

@david-i-berry
Copy link
Member

david-i-berry commented Sep 20, 2024

A bit more investigation:

import json
from pyoscar import OSCARClient
client = OSCARClient(env='prod')
station = client.get_station_report("0-76-0-3170206000000036", format_='XML', summary=True)
print(json.dumps(station, indent = 4))

gives the following output:

{
    "station_name": "UBERLANDIA",
    "wigos_station_identifier": "0-76-0-3170206000000036",
    "facility_type": "landFixed",
    "wmo_region": "southAmerica",
    "territory_name": "BRA",
    "latitude": -18.916944,
    "longitude": -48.255556,
    "elevation": 874.8,
    "barometer_height": 870.5
}

Using the WSI "0-76-0-5208707000000007" also works correctly.

This is the line from the wis2box-api where we fetch from OSCAR:

https://github.com/wmo-im/wis2box-api/blob/b351aa45fb67e69138c210b7b93158c09d459d32/wis2box_api/plugins/process/oscar2feature.py#L112

The error either occurs after here or there are network problems.

@maaikelimper
Copy link
Collaborator Author

José reported that the problem fixed itself after one day. This was the second day station where Brazil updated the primary wigos-id during the training, failed to import it into wis2box, then repeat the import one day later and it works.

We suspect that there is something about the way that OSCAR/Surface works, whereby an update does not immediately translate into the station being available for import into the wis2box, but can be imported one day later ...

@tomkralidis
Copy link
Collaborator

From OSCAR/Surface, for reference:

The OAI-PMH works with primary WIGOS IDs.
For the station 0-76-0-3170206000000036 the primary WSI is 0-20000-0-86776
So if you try:
https://oscardepl.wmo.int/oai/provider?verb=GetRecord&metadataPrefix=wmdr&identifier=0-20000-0-86776
you will get the file.

For the new system (OSCAR nextGen) we will make sure that WMDR XML files will be available also via non-primary WSI IDs.

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

3 participants