Skip to content
Snippets Groups Projects
Commit abdefd26 authored by David Verelst's avatar David Verelst
Browse files

matrix reader for HS2, rename hs2_control_tuning to ReadControlTuning

parent fe350d51
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -442,7 +442,7 @@ class Sims(object): ...@@ -442,7 +442,7 @@ class Sims(object):
""" """
Read a HAWCStab2 controller tuning file and return as tags Read a HAWCStab2 controller tuning file and return as tags
""" """
tuning = hs2.hs2_control_tuning() tuning = hs2.ReadControlTuning()
tuning.read_parameters(fpath) tuning.read_parameters(fpath)
tune_tags = {} tune_tags = {}
......
...@@ -15,9 +15,6 @@ from future import standard_library ...@@ -15,9 +15,6 @@ from future import standard_library
standard_library.install_aliases() standard_library.install_aliases()
from builtins import object from builtins import object
import unittest
import os import os
import re import re
...@@ -28,8 +25,8 @@ from wetb.prepost import mplutils ...@@ -28,8 +25,8 @@ from wetb.prepost import mplutils
class dummy(object): class dummy(object):
def __init__(self): def __init__(self, name='dummy'):
pass self.__name__ = name
def ReadFileHAWCStab2Header(fname, widths): def ReadFileHAWCStab2Header(fname, widths):
...@@ -172,6 +169,66 @@ class results(object): ...@@ -172,6 +169,66 @@ class results(object):
'T_aero'] 'T_aero']
self.operation = pd.DataFrame(operation, columns=cols) self.operation = pd.DataFrame(operation, columns=cols)
def load_matrices(self, fpath, basename, operating_point=1,
control_mat=False, local_wind_mat=False):
"""Load HAWCStab2 State Space system matrices
The general file name format is:
BASENAMETYPE_ase_ops_OPERATING_POINT_NUMBER.dat
Where TYPE can be of the following:
* amat, bmat, bvmat, cmat, dmat, dvmat, emat, fmat, fvmat
Additionally, when including the control matrices:
* BASENAMETYPE_ops_OPERATING_POINT_NUMBER.dat
* TYPE: acmat, bcmat, ccmat, dcmat
Or when including local wind speed
* BASENAMETYPE_ase_ops_OPERATING_POINT_NUMBER.dat
* TYPE: bvmat_loc_v, dvmat_loc_v, fvmat_loc_v
Parameters
----------
fpath : str
basename : str
operating_point : int, default=1
Returns
-------
matrices : dict
"""
mnames = ['amat', 'bmat', 'bvmat', 'cmat', 'dmat', 'dvmat', 'emat',
'fmat', 'fvmat']
mnames_c = ['acmat', 'bcmat', 'ccmat', 'dcmat']
mnames_v = ['bvmat_loc_v', 'dvmat_loc_v', 'fvmat_loc_v']
if control_mat:
mnames += mnames_c
if local_wind_mat:
mnames += mnames_v
matrices = {}
ase_template = '{:s}{:s}_ase_ops_{:d}.dat'
ops_template = '{:s}{:s}_ops_{:d}.dat'
for mname in mnames:
rpl = (basename, mname, operating_point)
template = ase_template
if mname in mnames_c:
template = ops_template
fname = os.path.join(fpath, template.format(*rpl))
matrices[mname] = np.loadtxt(fname)
return matrices
def write_ae_sections_h2(self): def write_ae_sections_h2(self):
""" """
Get the aerosection positions from the HS2 ind result file and Get the aerosection positions from the HS2 ind result file and
...@@ -237,7 +294,7 @@ class results(object): ...@@ -237,7 +294,7 @@ class results(object):
print('done!') print('done!')
class hs2_control_tuning(object): class ReadControlTuning(object):
def __init__(self): def __init__(self):
""" """
...@@ -293,4 +350,4 @@ class hs2_control_tuning(object): ...@@ -293,4 +350,4 @@ class hs2_control_tuning(object):
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() pass
...@@ -15,7 +15,7 @@ import os ...@@ -15,7 +15,7 @@ import os
import numpy as np import numpy as np
from wetb.prepost.hawcstab2 import results, hs2_control_tuning from wetb.prepost.hawcstab2 import results, ReadControlTuning
class Tests(unittest.TestCase): class Tests(unittest.TestCase):
...@@ -49,7 +49,7 @@ class Tests(unittest.TestCase): ...@@ -49,7 +49,7 @@ class Tests(unittest.TestCase):
def test_linear_file(self): def test_linear_file(self):
hs2 = hs2_control_tuning() hs2 = ReadControlTuning()
hs2.read_parameters(self.fpath_linear) hs2.read_parameters(self.fpath_linear)
self.assertEqual(hs2.pi_gen_reg1.K, 0.108313E+07) self.assertEqual(hs2.pi_gen_reg1.K, 0.108313E+07)
...@@ -69,7 +69,7 @@ class Tests(unittest.TestCase): ...@@ -69,7 +69,7 @@ class Tests(unittest.TestCase):
def test_quadratic_file(self): def test_quadratic_file(self):
hs2 = hs2_control_tuning() hs2 = ReadControlTuning()
hs2.read_parameters(self.fpath_quad) hs2.read_parameters(self.fpath_quad)
self.assertEqual(hs2.pi_gen_reg1.K, 0.108313E+07) self.assertEqual(hs2.pi_gen_reg1.K, 0.108313E+07)
......
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