Skip to content

Commit

Permalink
initial support for dataframes with metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
IKCAP committed Jul 5, 2024
1 parent 8d921a4 commit a0a60d4
Show file tree
Hide file tree
Showing 28 changed files with 1,214 additions and 8 deletions.
6 changes: 5 additions & 1 deletion pylipd/classes/archivetype.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ def to_data(self, data={}):
]
}
return data


def to_json(self):
data = self.label
return data

@classmethod
def from_synonym(cls, synonym):
if synonym.lower() in ArchiveType.synonyms:
Expand Down
81 changes: 81 additions & 0 deletions pylipd/classes/calibration.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,87 @@ def to_data(self, data={}):

return data

def to_json(self):
data = {
"@id": self.id
}

if self.dOI:
value_obj = self.dOI
obj = value_obj
data["doi"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["datasetRange"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["equationIntercept"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["equationR2"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["equationSlope"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["equationSlopeUncertainty"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["method"] = obj

if self.datasetRange:
value_obj = self.datasetRange
obj = value_obj
data["methodDetail"] = obj

if self.equation:
value_obj = self.equation
obj = value_obj
data["equation"] = obj

if self.notes:
value_obj = self.notes
obj = value_obj
data["notes"] = obj

if self.proxyDataset:
value_obj = self.proxyDataset
obj = value_obj
data["proxyDataset"] = obj

if self.seasonality:
value_obj = self.seasonality
obj = value_obj
data["hasSeasonality"] = obj

if self.targetDataset:
value_obj = self.targetDataset
obj = value_obj
data["targetDataset"] = obj

if self.uncertainty:
value_obj = self.uncertainty
obj = value_obj
data["uncertainty"] = obj

for key in self.misc:
value = self.misc[key]
data[key] = value

return data

def set_non_standard_property(self, key, value):
if key not in self.misc:
self.misc[key] = value
Expand Down
21 changes: 21 additions & 0 deletions pylipd/classes/changelog.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,27 @@ def to_data(self, data={}):

return data

def to_json(self):
data = {
"@id": self.id
}

if self.changes:
value_obj = self.changes
obj = value_obj
data["changes"] = obj

if self.notes:
value_obj = self.notes
obj = value_obj
data["notes"] = obj

for key in self.misc:
value = self.misc[key]
data[key] = value

return data

def set_non_standard_property(self, key, value):
if key not in self.misc:
self.misc[key] = value
Expand Down
29 changes: 29 additions & 0 deletions pylipd/classes/chrondata.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,35 @@ def to_data(self, data={}):

return data

def to_json(self):
data = {
"@id": self.id
}

if len(self.measurementTables):
data["measurementTable"] = []
for value_obj in self.measurementTables:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["measurementTable"].append(obj)

if len(self.modeledBy):
data["model"] = []
for value_obj in self.modeledBy:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["model"].append(obj)

for key in self.misc:
value = self.misc[key]
data[key] = value

return data

def set_non_standard_property(self, key, value):
if key not in self.misc:
self.misc[key] = value
Expand Down
21 changes: 21 additions & 0 deletions pylipd/classes/compilation.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ def to_data(self, data={}):

return data

def to_json(self):
data = {
"@id": self.id
}

if self.name:
value_obj = self.name
obj = value_obj
data["compilationName"] = obj

if self.version:
value_obj = self.version
obj = value_obj
data["compilationVersion"] = obj

for key in self.misc:
value = self.misc[key]
data[key] = value

return data

def set_non_standard_property(self, key, value):
if key not in self.misc:
self.misc[key] = value
Expand Down
142 changes: 142 additions & 0 deletions pylipd/classes/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,148 @@ def to_data(self, data={}):

return data

def to_json(self):
data = {
"@id": self.id
}

if len(self.chronData):
data["chronData"] = []
for value_obj in self.chronData:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["chronData"].append(obj)

if len(self.creators):
data["creator"] = []
for value_obj in self.creators:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["creator"].append(obj)

if len(self.fundings):
data["funding"] = []
for value_obj in self.fundings:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["funding"].append(obj)

if len(self.investigators):
data["investigator"] = []
for value_obj in self.investigators:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["investigator"].append(obj)

if len(self.paleoData):
data["paleoData"] = []
for value_obj in self.paleoData:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["paleoData"].append(obj)

if len(self.publications):
data["pub"] = []
for value_obj in self.publications:
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["pub"].append(obj)

if self.archiveType:
value_obj = self.archiveType
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["archiveType"] = obj

if self.changeLog:
value_obj = self.changeLog
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["changelog"] = obj

if self.collectionName:
value_obj = self.collectionName
obj = value_obj
data["collectionName"] = obj

if self.collectionYear:
value_obj = self.collectionYear
obj = value_obj
data["collectionYear"] = obj

if self.contributor:
value_obj = self.contributor
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["dataContributor"] = obj

if self.dataSource:
value_obj = self.dataSource
obj = value_obj
data["dataSource"] = obj

if self.datasetId:
value_obj = self.datasetId
obj = value_obj
data["datasetId"] = obj

if self.location:
value_obj = self.location
if hasattr(value_obj, "to_json"):
obj = value_obj.to_json()
else:
obj = value_obj
data["geo"] = obj

if self.name:
value_obj = self.name
obj = value_obj
data["dataSetName"] = obj

if self.notes:
value_obj = self.notes
obj = value_obj
data["notes"] = obj

if self.originalDataUrl:
value_obj = self.originalDataUrl
obj = value_obj
data["originalDataURL"] = obj

if self.spreadsheetLink:
value_obj = self.spreadsheetLink
obj = value_obj
data["googleSpreadSheetKey"] = obj

if self.version:
value_obj = self.version
obj = value_obj
data["dataSetVersion"] = obj

for key in self.misc:
value = self.misc[key]
data[key] = value

return data

def set_non_standard_property(self, key, value):
if key not in self.misc:
self.misc[key] = value
Expand Down
Loading

0 comments on commit a0a60d4

Please sign in to comment.