Skip to content

Commit

Permalink
station - update station fetch query and get()
Browse files Browse the repository at this point in the history
  • Loading branch information
ZogopZ committed Oct 10, 2024
1 parent 5615a56 commit bec9872
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions icoscp/src/icoscp/sparql/sparqls.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,10 @@ def station_query(filter: dict = None, return_filter: bool = False) -> str or (s
{theme_filter}
?uri a ?stationTheme .
OPTIONAL{{
?memb cpmeta:atOrganization ?uri ; cpmeta:hasRole <http://meta.icos-cp.eu/resources/roles/PI> .
filter not exists {{?memb cpmeta:hasEndTime []}}
?memb cpmeta:atOrganization ?uri .
optional {{?memb cpmeta:hasEndTime ?membEnd}}
filter(!bound(?membEnd) || ?membEnd > now())
?memb cpmeta:hasRole <http://meta.icos-cp.eu/resources/roles/PI> .
?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 bec9872

Please sign in to comment.