diff --git a/README.md b/README.md index e25631872818474101cd511cbe7ca4e2971e98f1..a3ea44ebbbeb1321afcb47accf8836c9ee7829a4 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# ICARTT reader +# ICARTT file format reader and writer diff --git a/icartt/dataset.py b/icartt/dataset.py index 3d64ad6ac539ce23be97295b460218683cd987c8..c13dfab9ed5cc3c49374de6b758c90503a19d560 100644 --- a/icartt/dataset.py +++ b/icartt/dataset.py @@ -7,12 +7,16 @@ class Variable: ''' @property def desc(self): + ''' + Return variable description string as it appears in an ICARTT file + ''' return self.splitChar.join( [self.name, self.units, self.units ] ) def __init__(self, name, units, scale=1.0, miss=-9999999): self.name = name self.units = units self.scale = scale self.miss = str(miss) + self.splitChar = ',' class Dataset: ''' @@ -114,17 +118,22 @@ class Dataset: nul = [ prnt(self.splitChar.join( [ str(y) for y in x ] )) for x in self.data ] def make_filename(self): + ''' + Create ICARTT-compliant file name based on the information contained in the dataset + ''' return self.dataID + "_" +self.locationID + "_" +datetime.datetime.strftime(self.dateValid, '%Y%m%d') + "_" +"R" + self.revision + ".ict" # sanitize function def __readline(self, do_split=True): dmp = self.input_fhandle.readline().replace('\n', '').replace('\r','') if do_split: - dmp = [word.strip(' ') for word in dmp.split(self.splitChar)] + dmp = [word.strip(' ') for word in dmp.split(self.splitChar) ] return dmp def read_header(self): - + ''' + Read the ICARTT header (from file) + ''' if self.input_fhandle.closed: self.input_fhandle = open(self.input_fhandle.name) @@ -248,7 +257,9 @@ class Dataset: return [ float(x.replace(self.VAR[i].miss, 'NaN')) for i, x in enumerate(raw) ] def read_data(self): - + ''' + Read ICARTT data (from file) + ''' if self.input_fhandle.closed: self.input_fhandle = open(self.input_fhandle.name) @@ -259,7 +270,10 @@ class Dataset: self.input_fhandle.close() def read_first_and_last(self): - + ''' + Read first and last ICARTT data line (from file). Useful for quick estimates e.g. of the time extent + of big ICARTT files, without having to read the whole thing, which would be slow. + ''' if self.input_fhandle.closed: self.input_fhandle = open(self.input_fhandle.name)