Skip to content

Commit

Permalink
Merge pull request #198 from ICOS-Carbon-Portal/194-fix-station-getId…
Browse files Browse the repository at this point in the history
…List

icoscp - fix getIdList()
  • Loading branch information
ZogopZ authored Oct 11, 2024
2 parents 5615a56 + c79dd26 commit 20960ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions icoscp/src/icoscp/sparql/sparqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def station_query(filter: dict = None, return_filter: bool = False) -> str or (s
prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix cpmeta: <http://meta.icos-cp.eu/ontologies/cpmeta/>
prefix cpst: <http://meta.icos-cp.eu/ontologies/stationentry/>
select ?uri ?id ?name ?icosClass ?country ?lat ?lon ?elevation ?stationTheme ?firstName ?lastName ?email ?siteType
select distinct ?uri ?id ?name ?icosClass ?country ?lat ?lon ?elevation ?stationTheme ?firstName ?lastName ?email ?siteType
from <http://meta.icos-cp.eu/resources/icos/>
from <http://meta.icos-cp.eu/resources/extrastations/>
from <http://meta.icos-cp.eu/resources/cpmeta/>
Expand All @@ -461,7 +461,8 @@ def station_query(filter: dict = None, return_filter: bool = False) -> str or (s
?uri a ?stationTheme .
OPTIONAL{{
?memb cpmeta:atOrganization ?uri ; cpmeta:hasRole <http://meta.icos-cp.eu/resources/roles/PI> .
filter not exists {{?memb cpmeta:hasEndTime []}}
optional {{?memb cpmeta:hasEndTime ?membEnd}}
filter(!bound(?membEnd) || ?membEnd > now())
?pers cpmeta:hasMembership ?memb
}}
}}
Expand Down
3 changes: 2 additions & 1 deletion icoscp/src/icoscp/station/station.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ def get(stationId: str = None,
except:
stn = None

if not (isinstance(stn, pd.DataFrame) and not stn.empty):
if not isinstance(stn, pd.DataFrame) or stn.empty:
my_stn.stationId = stationId
my_stn.valid = False
return my_stn
Expand Down Expand Up @@ -715,6 +715,7 @@ def _get_id_list(filter: dict = {'project': 'ICOS', 'theme': ['AS', 'ES', 'OS']}

query = sparqls.station_query(filter=filter)
stn_df = RunSparql(query, 'pandas').run()
stn_df.drop_duplicates(inplace=True)

if not isinstance(stn_df, pd.DataFrame):
return stn_df
Expand Down

0 comments on commit 20960ab

Please sign in to comment.