Skip to content
Snippets Groups Projects
Commit c3f3b167 authored by Mads M. Pedersen's avatar Mads M. Pedersen
Browse files

update removed fatigue import from gtsdf toplevel module + Updated Hawc2io.py

parent 04edd375
No related branches found
No related tags found
No related merge requests found
......@@ -3,7 +3,6 @@ from builtins import zip
from builtins import range
from builtins import str
from future import standard_library
from wetb.fatigue_tools.fatigue import eq_load
standard_library.install_aliases()
import warnings
from wetb.gtsdf.unix_time import from_unix
......@@ -430,6 +429,7 @@ def _get_statistic(time, data, statistics=['min','mean','max','std','eq3','eq4',
if hasattr(np, stat):
return getattr(np,stat)(data,0)
elif (stat.startswith("eq") and stat[2:].isdigit()):
from wetb.fatigue_tools.fatigue import eq_load
m = float(stat[2:])
return [eq_load(sensor, 46, m, time[-1]-time[0]+time[1]-time[0])[0][0] for sensor in data.T]
return np.array([get_stat(stat) for stat in statistics]).T
......
......@@ -78,6 +78,8 @@ class ReadHawc2(object):
"""
# read *.sel hawc2 output file for result info
if self.FileName.lower().endswith('.sel'):
self.FileName = self.FileName[:-4]
fid = opent(self.FileName + '.sel', 'r')
Lines = fid.readlines()
fid.close()
......@@ -139,7 +141,7 @@ class ReadHawc2(object):
self.Freq = 1 / temp[1];
self.ScaleFactor = np.fromfile(fid, 'f', self.NrCh)
fid.seek(2 * 4 * self.NrCh + 48 * 2)
self.NrSc = len(np.fromfile(fid, 'int16')) / self.NrCh
self.NrSc = int(len(np.fromfile(fid, 'int16')) / self.NrCh)
self.Time = self.NrSc * temp[1]
self.t = np.arange(0, self.Time, temp[1])
fid.close()
......@@ -150,13 +152,14 @@ class ReadHawc2(object):
self.ReadOnly = ReadOnly
self.Iknown = [] # to keep track of what has been read all ready
self.Data = np.zeros(0)
if os.path.isfile(FileName + ".sel"):
if FileName.lower().endswith('.sel') or os.path.isfile(FileName + ".sel"):
self._ReadSelFile()
elif os.path.isfile(self.FileName + ".int"):
elif FileName.lower().endswith('.int') or os.path.isfile(self.FileName + ".int"):
self.FileFormat = 'FLEX'
self._ReadSensorFile()
elif os.path.isfile(self.FileName + ".hdf5"):
elif FileName.lower().endswith('.hdf5') or os.path.isfile(self.FileName + ".hdf5"):
self.FileFormat = 'GTSDF'
self.ReadAll()
else:
print ("unknown file: " + FileName)
################################################################################
......@@ -193,7 +196,7 @@ class ReadHawc2(object):
# Read results in GTSD format
def ReadGtsdf(self):
self.t, data, info = gtsdf.load(self.FileName + '.hdf5')
self.Time = self.t[-1]
self.Time = self.t
self.ChInfo = [info['attribute_names'],
info['attribute_units'],
info['attribute_descriptions']]
......
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