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 with station.get #194

Closed
joe-pitt opened this issue Oct 1, 2024 · 6 comments · Fixed by #198
Closed

Error with station.get #194

joe-pitt opened this issue Oct 1, 2024 · 6 comments · Fixed by #198
Assignees
Labels
fix Fix something that is not working as intended icoscp

Comments

@joe-pitt
Copy link

joe-pitt commented Oct 1, 2024

I've just upgraded to icoscp-0.2.0 (from 0.1.17) and for now I am still using the legacy station.get() function. In general this is working, but when I try for the site "RGL" using the following:

from icoscp_core.icos import bootstrap
from icoscp import cpauth
from icoscp.station import station

cookie_token = ...
meta, data = bootstrap.fromCookieToken(cookie_token)
cpauth.init_by(data.auth)

stat = station.get(stationId="RGL")

I get the following error:

TypeError                                 Traceback (most recent call last)
Cell In[9], line 1
----> 1 stat = station.get(stationId="RGL")

File ~/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/icoscp/station/station.py:588, in get(stationId, station_df)
    586 if not stn[stn.project.str.upper() == "ICOS"].empty:
    587     if stn.lat.any():
--> 588         my_stn.lat = float(stn.lat[stn.project.str.upper() == 'ICOS'])
    589     if stn.lat.any():
    590         my_stn.lon = float(stn.lon[stn.project.str.upper() == 'ICOS'])

File ~/.conda/envs/openghg_dev_env/lib/python3.12/site-packages/pandas/core/series.py:248, in _coerce_method.<locals>.wrapper(self)
    240     warnings.warn(
    241         f"Calling {converter.__name__} on a single element Series is "
    242         "deprecated and will raise a TypeError in the future. "
   (...)
    245         stacklevel=find_stack_level(),
    246     )
    247     return converter(self.iloc[0])
--> 248 raise TypeError(f"cannot convert the series to {converter}")

TypeError: cannot convert the series to <class 'float'>

If I print "stn" just before this I find that it has 4 identical entries:

                                                  uri   id        name  \
234  http://meta.icos-cp.eu/resources/stations/AS_RGL  RGL  Ridge Hill   
235  http://meta.icos-cp.eu/resources/stations/AS_RGL  RGL  Ridge Hill   
236  http://meta.icos-cp.eu/resources/stations/AS_RGL  RGL  Ridge Hill   
237  http://meta.icos-cp.eu/resources/stations/AS_RGL  RGL  Ridge Hill   

    icosClass country      lat      lon elevation  \
234         2      GB  51.9975  -2.5399     207.0   
235         2      GB  51.9975  -2.5399     207.0   
236         2      GB  51.9975  -2.5399     207.0   
237         2      GB  51.9975  -2.5399     207.0   

                                    stationTheme firstName lastName  \
234  http://meta.icos-cp.eu/ontologies/cpmeta/AS    Kieran  Stanley   
235  http://meta.icos-cp.eu/ontologies/cpmeta/AS    Kieran  Stanley   
236  http://meta.icos-cp.eu/ontologies/cpmeta/AS    Kieran  Stanley   
237  http://meta.icos-cp.eu/ontologies/cpmeta/AS    Kieran  Stanley   

                         email    siteType project theme  
234  [email protected]  tall tower    ICOS    AS  
235  [email protected]  tall tower    ICOS    AS  
236  [email protected]  tall tower    ICOS    AS  
237  [email protected]  tall tower    ICOS    AS 

This doesn't seem to happen for other sites - is this a RGL-specific bug or am I doing something foolish?

@ZogopZ
Copy link
Member

ZogopZ commented Oct 4, 2024

Thank you for bringing this to our attention, @joe-pitt! We’re currently looking into it and will update you as soon as we have more information.

@joe-pitt
Copy link
Author

joe-pitt commented Oct 7, 2024

Not sure if this is related to attempts to fix this issue, but since 2024-10-04 station.get now retrieves no info for many sites:

from icoscp_core.icos import bootstrap
from icoscp import cpauth
from icoscp.station import station

cookie_token = ...
meta, data = bootstrap.fromCookieToken(cookie_token)
cpauth.init_by(data.auth)

station.get(stationId="BIK").info()

prints:

{'stationId': 'BIK',
 'name': None,
 'theme': None,
 'icosclass': None,
 'siteType': None,
 'lat': None,
 'lon': None,
 'eas': None,
 'firstName': None,
 'lastName': None,
 'email': None,
 'country': None,
 'project': None,
 'uri': None}

This means I can't retrieve data from these sites. Other sites (e.g. GAT) are still working fine.

@ukarst
Copy link
Contributor

ukarst commented Oct 7, 2024

Other users are currently experiencing the same problem.

@joe-pitt
Copy link
Author

joe-pitt commented Oct 7, 2024

OK thanks that's useful to know!

@ZogopZ ZogopZ self-assigned this Oct 10, 2024
@ZogopZ ZogopZ added fix Fix something that is not working as intended icoscp labels Oct 10, 2024
@ZogopZ ZogopZ linked a pull request Oct 10, 2024 that will close this issue
@ZogopZ
Copy link
Member

ZogopZ commented Oct 11, 2024

Hey @joe-pitt,

The two issues you were encountering were partially related. You shouldn't be getting duplicates of the same station, which was a bug, and the empty station information was due to a server-side request. Both issues are now fixed in the latest icoscp version.

  • If you are working locally, run: pip install icosp==0.2.1
  • If you are using ICOS Jupyter services, please restart your Jupyter instance using the instructions here.

@joe-pitt
Copy link
Author

Brilliant - thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fix Fix something that is not working as intended icoscp
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants