Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed May 9, 2024
1 parent dae120a commit 7d264ce
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 21 deletions.
15 changes: 10 additions & 5 deletions pylipd/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@
# Load from local
lipd = LiPD()

# lipd.load("/Users/varun/git/pylipd/pylipd/data/ODP846.Lawrence.2006.lpd")
# series = lipd.to_lipd_series()
# print(series.get_all_variable_names())
# print(series.get_timeseries_essentials())

#lipd.load("/Users/varun/git/pylipd/pylipd/data/ODP846.Lawrence.2006.lpd")
lipd.load(local_lipd_dir + "/MS07LSPG.lpd")
print(lipd.get_all_dataset_names())
ts, ts_df = lipd.get_timeseries(lipd.get_all_dataset_names(), to_dataframe=True)
print(ts_df["archiveType"])
exit()
series = lipd.to_lipd_series()
print(series.get_all_variable_names())
print(series.get_timeseries_essentials())
exit()

# data_path = local_lipd_dir + '/Ocn-Palmyra.Nurhati.2011.lpd'
# lipd.load(data_path)
Expand Down
37 changes: 21 additions & 16 deletions pylipd/utils/rdf_to_lipd.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,36 +503,40 @@ def _collect_variables_by_id(self, item, arr) :

def _set_archive_type_label(self, ds, parent = None) :
if "hasArchiveType" in ds :
id = ds["hasArchiveType"]["@id"]
if id in RSYNONYMS:
ds["archiveType"] = RSYNONYMS[id]
if "@id" in ds["hasArchiveType"]:
id = ds["hasArchiveType"]["@id"]
if id in RSYNONYMS:
ds["archiveType"] = RSYNONYMS[id]
del ds["hasArchiveType"]
return ds


def _set_units_label(self, var, parent = None) :
if "hasUnits" in var :
id = var["hasUnits"]["@id"]
if id in RSYNONYMS:
var["units"] = RSYNONYMS[id]
if "@id" in var["hasUnits"]:
id = var["hasUnits"]["@id"]
if id in RSYNONYMS:
var["units"] = RSYNONYMS[id]
del var["hasUnits"]
return var


def _set_proxy_label(self, var, parent = None) :
if "hasProxy" in var :
id = var["hasProxy"]["@id"]
if id in RSYNONYMS:
var["proxy"] = RSYNONYMS[id]
if "@id" in var["hasProxy"]:
id = var["hasProxy"]["@id"]
if id in RSYNONYMS:
var["proxy"] = RSYNONYMS[id]
del var["hasProxy"]
return var


def _set_proxy_general_label(self, var, parent = None) :
if "hasProxyGeneral" in var :
id = var["hasProxyGeneral"]["@id"]
if id in RSYNONYMS:
var["proxyGeneral"] = RSYNONYMS[id]
if "@id" in var["hasProxyGeneral"]:
id = var["hasProxyGeneral"]["@id"]
if id in RSYNONYMS:
var["proxyGeneral"] = RSYNONYMS[id]
del var["hasProxyGeneral"]
return var

Expand All @@ -545,10 +549,11 @@ def _set_seasonality_labels(self, interp, parent = None) :
}
for pid in convs:
if pid in interp :
id = interp[pid]["@id"]
nid = convs[pid]
if id in RSYNONYMS:
interp[nid] = RSYNONYMS[id]
if "@id" in interp[pid]:
id = interp[pid]["@id"]
nid = convs[pid]
if id in RSYNONYMS:
interp[nid] = RSYNONYMS[id]
del interp[pid]
return interp

Expand Down

0 comments on commit 7d264ce

Please sign in to comment.