Skip to content
This repository has been archived by the owner on May 4, 2023. It is now read-only.

Commit

Permalink
Clean up and small updates
Browse files Browse the repository at this point in the history
  • Loading branch information
tyleresterly committed Nov 9, 2017
1 parent f1c2961 commit c555077
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions WDRT/ESSC.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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])
Expand All @@ -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
Expand Down Expand Up @@ -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('.'):
Expand Down Expand Up @@ -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)))

Expand Down Expand Up @@ -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')

Expand Down

0 comments on commit c555077

Please sign in to comment.