Commit 634dce89 authored by ALVISET's avatar ALVISET
Browse files

Included basin feature

parent bda471a5
......@@ -262,6 +262,15 @@ def map_file_to_prov(file, file_uri, cycle_uri, wrapper, files_info, dac_uri):
# def add_prov_triples(wrapper, prov):
# for
def retrieve_cycle_basins(cycleId):
basins = []
cycleInfo = requests.get("https://dataselection.euro-argo.eu/api/find-by-id/" + str(cycleId))
if cycleInfo != None and cycleInfo.text != None:
cycleInfo = json.loads(cycleInfo.text)
for basin in cycleInfo["basins"]:
basins.append(basin)
return basins
if __name__ == "__main__":
......@@ -471,6 +480,21 @@ if __name__ == "__main__":
except:
continue
groups = []
# Fetch the basin of the first and last cycles. If it is different, then make a search on each cycle.
first_basin = retrieve_cycle_basins(cycleIds[1])
last_basin = retrieve_cycle_basins(cycleIds[float_info["latestCycle"]["id"]])
print(first_basin)
print(last_basin)
fetch_basins = False
if set(first_basin) == len(set(first_basin).symmetric_difference(set(last_basin))) != 0:
fetch_basins = True
cycleInfo = requests.get("https://dataselection.euro-argo.eu/api/find-by-id/" + str(cycleIds[1]))
# if cycleInfo != None and cycleInfo.text != None:
# cycleInfo = json.loads(cycleInfo.text)
# for basin in cycleInfo["basins"]:
# first_basin.append()
for cycle in float_info["cycles"]:
nb = int(cycle["id"])
file_nb = (3 - len(str(nb))) * "0" + str(nb)
......@@ -486,11 +510,15 @@ if __name__ == "__main__":
# print("Float {}, cycle {} does not have cycle files ?".format(afloat, file_nb))
continue
# cycleInfo = requests.get("https://dataselection.euro-argo.eu/api/find-by-id/"+str(cycleIds[nb]))
# if cycleInfo != None and cycleInfo.text != None:
# cycleInfo = json.loads(cycleInfo.text)
# for basin in cycleInfo["basins"]:
# argo_graph.add_triple((cycle_uri, ARGO.basin, Literal(basin)))
if fetch_basins:
cycleInfo = requests.get("https://dataselection.euro-argo.eu/api/find-by-id/"+str(cycleIds[nb]))
if cycleInfo != None and cycleInfo.text != None:
cycleInfo = json.loads(cycleInfo.text)
for basin in cycleInfo["basins"]:
argo_graph.add_triple(cycle_uri, ARGO.basin, Literal(basin))
else:
for basin in first_basin:
argo_graph.add_triple(cycle_uri, ARGO.basin, Literal(basin))
argo_graph.add_triple(afloat_uri, ARGO.cycle, cycle_uri)
argo_graph.add_triples({
......@@ -523,9 +551,9 @@ if __name__ == "__main__":
argo_graph.add_triple(cycle_uri, GEO.longitude, Literal(cycle["lon"]))
adjusted_Params = {} # Keep profile params in memory to avoid duplicates
for group in groups:
argo_graph.add_triple(group["uri"], ARGO.handbookVersion, group["handbook"])
# argo_graph.add_triple(group["uri"], ARGO.handbookVersion, group["handbook"])
for step in group["steps"]:
argo_graph.add_triple(group["uri"], ARGO.step, (NERC, "R12/current/", step))
argo_graph.add_triple(group["uri"], ARGO.historyStep, (NERC, "R12/current/", step))
for datastate in group["datastate"]:
argo_graph.add_triple(group["uri"], ARGO.dataState, (NERC, "R06/current/", datastate))
for software in group["softwares"]:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment