Commit bda471a5 authored by ALVISET's avatar ALVISET
Browse files

Included dmqc operator

parent 4ef2afc5
......@@ -96,8 +96,10 @@ def profile_get_netcdf_info(file, data_type):
steps = {"steps":[]}
states = {"datastate":[]}
softwares = {"softwares":[]}
params_qc = {"paramsqc": {}}
dmqc = {"dmqc": None}
params = netcdf_getparams(rootgrp, rootgrp.dimensions["N_PROF"].size, rootgrp.dimensions["N_PARAM"].size)
params_qc = {"paramsqc":{}}
for j in range(0, rootgrp.dimensions["N_PROF"].size):
state = netcdf_extract_variable_cell(rootgrp, "DATA_STATE_INDICATOR", j)
if state != '' and state not in states["datastate"] and state != False:
......@@ -121,6 +123,12 @@ def profile_get_netcdf_info(file, data_type):
except KeyError:
# print("{} has no N_HISTORY param?".format(file))
break
try:
dmqc["dmqc"] = rootgrp.getncattr('comment_dmqc_operator')
# print(dmqc)
except AttributeError:
pass
infos.update(dmqc)
infos.update(steps)
infos.update(states)
infos.update(softwares)
......@@ -140,7 +148,7 @@ def compare_prov_infos(prov, adjustedGroups, wmo):
if len(adjustedGroups) == 0:
adjustedGroups.append({"handbook":prov["handbook"], "steps":set(prov["steps"]), "datastate":set(prov["datastate"]),
"softwares":set(prov["softwares"]), "paramsqc":prov["paramsqc"],
"uri":ARGO["{}group0".format(wmo)]})
"uri":ARGO["{}group0".format(wmo)], "dmqc":prov["dmqc"]})
else:
is_identical = False
for i in range(0, len(groups)):
......@@ -189,10 +197,10 @@ def compare_prov_infos(prov, adjustedGroups, wmo):
# print(group["steps"])
if is_identical:
return i
adjustedGroups.append({"handbook":prov["handbook"], "steps":set(prov["steps"]), "datastate":set(prov["datastate"]),
"softwares":set(prov["softwares"]), "paramsqc":prov["paramsqc"],
"softwares":set(prov["softwares"]), "paramsqc":prov["paramsqc"], "dmqc":prov["dmqc"],
"uri":ARGO["{}group{}".format(wmo,len(groups))]})
return len(adjustedGroups)-1
def map_filetype_and_datamode(cycle_files):
......@@ -350,6 +358,7 @@ if __name__ == "__main__":
argo_graph.add_triple(ARGO[dac], RDFS.label, Literal(dac, datatype=XSD.string))
print("DAC: {}".format(dac))
a = 1
dmqc_ops = {}
for afloat in floats_folders:
if args.float != None:
......@@ -529,6 +538,17 @@ if __name__ == "__main__":
argo_graph.add_triple(adjusted_Params[duo], ARGO.param, (NERC, "R03/current/", param))
argo_graph.add_triple(adjusted_Params[duo], ARGO.qc, (NERC, "RP2/current/", group["paramsqc"][param]))
argo_graph.add_triple(group["uri"], ARGO.profileParam, adjusted_Params[duo])
if group["dmqc"] != None:
dmqc_infos = group["dmqc"].split("|")
dmqc_name = dmqc_infos[2].split(",")[0].lower().strip()
if dmqc_name.lower() not in dmqc_ops.keys():
dmqc_uri = GraphWrapper.create_uri(ARGO, "dmqc", dmqc_name)
print(dmqc_uri)
dmqc_ops[dmqc_name] = dmqc_uri
argo_graph.add_triple(dmqc_uri, RDF.type, PROV.Agent)
argo_graph.add_triple(dmqc_uri, RDF.type, FOAF.Person)
argo_graph.add_triple(dmqc_uri, DCTERMS.identifier, dmqc_infos[1].strip())
argo_graph.add_triple(group["uri"], PROV.wasAttributedTo, dmqc_ops[dmqc_name])
print("Number of groups: " + str(len(groups)))
print("Number of files: " + str(len(cycle_files)))
a += 1
......@@ -547,5 +567,4 @@ if __name__ == "__main__":
ttl.write("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n")
ttl.write(argo_graph.serialize(format="turtle").decode("utf-8"))
ftp_access.close()
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