From 7d264ce1655d6e1f2fe2f5d6caa9876a76925c99 Mon Sep 17 00:00:00 2001 From: Varun Ratnakar Date: Thu, 9 May 2024 08:03:03 +0530 Subject: [PATCH] Fix --- pylipd/usage.py | 15 ++++++++++----- pylipd/utils/rdf_to_lipd.py | 37 +++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 21 deletions(-) diff --git a/pylipd/usage.py b/pylipd/usage.py index e080a85..282845c 100644 --- a/pylipd/usage.py +++ b/pylipd/usage.py @@ -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) diff --git a/pylipd/utils/rdf_to_lipd.py b/pylipd/utils/rdf_to_lipd.py index 8965954..988355a 100644 --- a/pylipd/utils/rdf_to_lipd.py +++ b/pylipd/utils/rdf_to_lipd.py @@ -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 @@ -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