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

icoscp - fix getIdList() #198

Merged
merged 3 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading