From c555077d6faef0c6796cbc4a68d9375ed3e2a5d0 Mon Sep 17 00:00:00 2001 From: Esterly Date: Thu, 9 Nov 2017 14:18:50 -0700 Subject: [PATCH] Clean up and small updates --- WDRT/ESSC.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/WDRT/ESSC.py b/WDRT/ESSC.py index c481262..1ace02b 100644 --- a/WDRT/ESSC.py +++ b/WDRT/ESSC.py @@ -2789,6 +2789,9 @@ def __fetchNDBC(self, proxy): savePath : string Relative path to place directory with data files. ''' + maxRecordedDateValues = 4 + + numLines = 0 numCols = 0 numDates = 0 @@ -2844,7 +2847,7 @@ def __fetchNDBC(self, proxy): if float(currentLine[numDates+1]) < 999: numLines += 1 - for j in range(4): + for j in range(maxRecordedDateValues): dateVals.append(currentLine[j]) for j in range(numCols - numDates): spectralVals.append(currentLine[j + numDates]) @@ -2853,7 +2856,7 @@ def __fetchNDBC(self, proxy): dateValues = np.array(dateVals, dtype=np.int) spectralValues = np.array(spectralVals, dtype=np.float) - dateValues = np.reshape(dateValues, (numLines, 4)) + dateValues = np.reshape(dateValues, (numLines, maxRecordedDateValues)) spectralValues = np.reshape(spectralValues, (numLines, (numCols - numDates))) numLines = 0 @@ -2893,6 +2896,7 @@ def loadFromText(self, dirPath = None): dateVals = [] spectralVals = [] numLines = 0 + maxRecordedDateValues = 4 if dirPath is None: for dirpath, subdirs, files in os.walk('.'): @@ -2926,14 +2930,14 @@ def loadFromText(self, dirPath = None): currentLine = line.split() if float(currentLine[numTimeVals + 1]) < 999: numLines += 1 - for i in range(4): + for i in range(maxRecordedDateValues): dateVals.append(currentLine[i]) for i in range(numCols - numTimeVals): spectralVals.append(currentLine[i + numTimeVals]) dateValues = np.array(dateVals, dtype=np.int) spectralValues = np.array(spectralVals, dtype=np.double) - dateValues = np.reshape(dateValues, (numLines, numTimeVals)) + dateValues = np.reshape(dateValues, (numLines, maxRecordedDateValues)) spectralValues = np.reshape( spectralValues, (numLines, (numCols - numTimeVals))) @@ -3139,6 +3143,8 @@ def _saveData(self, fileObj): f_T.attrs['description'] = 'energy period' f_dateNum = gbd.create_dataset('dateNum', data=self.dateNum) f_dateNum.attrs['description'] = 'datenum' + f_dateList = gbd.create_dataset('dateList', data=self.dateList) + f_dateList.attrs['description'] = 'date list' else: RuntimeError('Buoy object contains no data')