From 7609e2a1c05725e4e8d11c3e0b7af129c412d569 Mon Sep 17 00:00:00 2001 From: Florian Obersteiner Date: Wed, 23 Feb 2022 15:04:32 +0100 Subject: [PATCH] updated calculation of number of normal comment lines --- src/icartt/dataset.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/icartt/dataset.py b/src/icartt/dataset.py index 02c9f4a..43f834b 100644 --- a/src/icartt/dataset.py +++ b/src/icartt/dataset.py @@ -208,10 +208,11 @@ class KeywordComment: class StandardNormalComments(collections.UserList): @property def nlines(self): - # "+ 1" -> shortnames line, and keywords might be multiline... - return ( - len(self.freeform) + 1 + sum([len(k.data) for k in self.keywords.values()]) - ) + n = 1 # shortnames line, and keywords might be multiline... + n += len(self.freeform) + n += sum(len(k.data) or 1 for k in self.keywords.values()) + # was: len(self.freeform) + 1 + sum([len(k.data) for k in self.keywords.values()]) + return n @property def data(self): @@ -652,7 +653,7 @@ class Dataset: # this section of the header along with the relevant data listed after the # colon. For key words where information is not needed or applicable, simply # enter N/A.). - rawNcom = [f.readline(doSplit=False) for i in range(0, nncom)] + rawNcom = [f.readline(doSplit=False) for _ in range(nncom)] self.normalComments.ingest(rawNcom) self.nHeaderFile = f.line @@ -786,6 +787,7 @@ class Dataset: # Variable names and units (Short variable name and units are required, and optional long descriptive name, in that order, and separated by commas. If the variable is unitless, enter the keyword "none" for its units. Each short variable name and units (and optional long name) are entered on one line. The short variable name must correspond exactly to the name used for that variable as a column header, i.e., the last header line prior to start of data.). for DVAR in self.dependentVariables.values(): write_to_file(DVAR.desc(delimiter)) + if self.format == Formats.FFI2110: # Number of variables (Integer value showing the number of dependent variables: the total number of columns of data is this value plus one.). write_to_file(len(self.auxiliaryVariables)) @@ -805,7 +807,6 @@ class Dataset: for AUXVAR in self.auxiliaryVariables.values(): write_to_file(AUXVAR.desc(delimiter)) - # Number of SPECIAL comment lines (Integer value indicating the number of lines of special comments, NOT including this line.). write_to_file(f"{len(self.specialComments)}") # Special comments (Notes of problems or special circumstances unique to this file. An example would be comments/problems associated with a particular flight.). -- GitLab