Skip to content
Snippets Groups Projects
Commit 405c44f7 authored by Florian Obersteiner's avatar Florian Obersteiner
Browse files

__str__ for Dataset

parent 4f5c45d6
No related branches found
No related tags found
1 merge request!22towards release
......@@ -317,7 +317,6 @@ class StandardNormalComments(collections.UserList):
self.keywords["UNCERTAINTY"].naAllowed = False
self.keywords["REVISION"].naAllowed = False
def __str__(self):
return "\n".join(f"{str(v)}" for v in self.keywords.values())
......@@ -962,12 +961,18 @@ class Dataset:
if not self.inputFhandle.closed:
self.inputFhandle.close()
def __repr__(self):
# TODO: this could be more meaningful
return "icartt.Dataset()"
def __str__(self):
return f"ICARTT Dataset {self.makeFileName()}"
s = [
f"ICARTT Dataset {self.makeFileName()}, format index {self.format.value}",
f"data ID: {self.dataID}",
f"location ID: {self.locationID}",
f"PI: {self.PIName}",
f"Affiliation: {self.PIAffiliation}",
f"Mission: {self.missionName}",
f"Collection date, Revision date: {self.dateOfCollection}, {self.dateOfRevision}",
f"Variables ({len(self.variables)}):\n{', '.join(x for x in self.variables)}",
]
return "\n".join(s)
def __init__(
self,
......@@ -991,7 +996,7 @@ class Dataset:
"""
self.format = format
self.version = None # TODO: should this be 2.0 by default?
self.version = None # TODO: should this be 2.0 by default?
self.dataID = "dataID"
self.locationID = "locationID"
......@@ -1038,12 +1043,11 @@ class Dataset:
if not self.isValidFileName(pathlib.Path(f).name):
warnings.warn(f"{pathlib.Path(f).name} is not a valid ICARTT filename")
else: # try to obtain dataID and locationID from file name
else: # try to obtain dataID and locationID from file name
parts = pathlib.Path(f).name.split("_")
if len(parts) > 2:
self.dataID = parts[0]
self.dataID = parts[1]
# TODO: else -> split on "_", then the first part should be dataID, second part locationID
self.locationID = parts[1]
self.readHeader(delimiter)
if loadData:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment