diff --git a/icoscp/src/icoscp/sparql/sparqls.py b/icoscp/src/icoscp/sparql/sparqls.py index 414c433..2359785 100644 --- a/icoscp/src/icoscp/sparql/sparqls.py +++ b/icoscp/src/icoscp/sparql/sparqls.py @@ -446,7 +446,7 @@ def station_query(filter: dict = None, return_filter: bool = False) -> str or (s prefix xsd: prefix cpmeta: prefix cpst: - 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 from from @@ -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 . - filter not exists {{?memb cpmeta:hasEndTime []}} + optional {{?memb cpmeta:hasEndTime ?membEnd}} + filter(!bound(?membEnd) || ?membEnd > now()) ?pers cpmeta:hasMembership ?memb }} }} diff --git a/icoscp/src/icoscp/station/station.py b/icoscp/src/icoscp/station/station.py index e2ccc0a..89ffed7 100644 --- a/icoscp/src/icoscp/station/station.py +++ b/icoscp/src/icoscp/station/station.py @@ -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 @@ -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