Skip to content
Snippets Groups Projects
Commit 2b29f67d authored by David Verelst's avatar David Verelst Committed by Mads M. Pedersen
Browse files

hawc2.htc: do not lower string values when reading from HTC file

parent d316449a
No related branches found
No related tags found
No related merge requests found
Pipeline #7388 passed
...@@ -45,6 +45,8 @@ class AEFile(object): ...@@ -45,6 +45,8 @@ class AEFile(object):
1.00000000000000000e+00 1.00000000000000006e-01 1.00000000000000000e+01 1 1.00000000000000000e+00 1.00000000000000006e-01 1.00000000000000000e+01 1
""" """
cols = ['radius', 'chord', 'relative_thickness', 'setnr']
def __init__(self, filename=None): def __init__(self, filename=None):
self.ae_sets = {} self.ae_sets = {}
if filename is not None: if filename is not None:
......
...@@ -258,7 +258,7 @@ class HTCLine(HTCContents): ...@@ -258,7 +258,7 @@ class HTCLine(HTCContents):
("", "\t" + self.comments)[bool(self.comments.strip())]) ("", "\t" + self.comments)[bool(self.comments.strip())])
def str_values(self): def str_values(self):
return " ".join([str(v).lower() for v in self.values]) return " ".join([str(v) for v in self.values])
def __getitem__(self, key): def __getitem__(self, key):
try: try:
......
...@@ -16,7 +16,7 @@ standard_library.install_aliases() ...@@ -16,7 +16,7 @@ standard_library.install_aliases()
import numpy as np import numpy as np
stcols = "r m x_cg y_cg ri_x ri_y x_sh y_sh E G I_x I_y I_p k_x k_y A pitch x_e y_e" stc = "r m x_cg y_cg ri_x ri_y x_sh y_sh E G I_x I_y I_p k_x k_y A pitch x_e y_e"
class StFile(object): class StFile(object):
...@@ -69,7 +69,16 @@ class StFile(object): ...@@ -69,7 +69,16 @@ class StFile(object):
>>> print (st.E(radius=36, mset=1, set=2)) # Same for stiff blade set >>> print (st.E(radius=36, mset=1, set=2)) # Same for stiff blade set
8.722924514652648e+17 8.722924514652648e+17
""" """
def __init__(self, filename):
cols = stc.split()
def __init__(self, filename=None):
# in case the user wants to create a new non-existing st file
if filename is None:
self.main_data_sets = {}
return
with open (filename) as fid: with open (filename) as fid:
txt = fid.read() txt = fid.read()
# Some files starts with first set ("#1...") with out specifying number of sets # Some files starts with first set ("#1...") with out specifying number of sets
...@@ -87,7 +96,7 @@ class StFile(object): ...@@ -87,7 +96,7 @@ class StFile(object):
set_data_dict[set_nr] = np.array([set_lines[i].split() for i in range(1, no_rows + 1)], dtype=np.float) set_data_dict[set_nr] = np.array([set_lines[i].split() for i in range(1, no_rows + 1)], dtype=np.float)
self.main_data_sets[mset_nr] = set_data_dict self.main_data_sets[mset_nr] = set_data_dict
for i, name in enumerate(stcols.split()): for i, name in enumerate(self.cols):
setattr(self, name, lambda radius=None, mset=1, set=1, setattr(self, name, lambda radius=None, mset=1, set=1,
column=i: self._value(radius, column, mset, set)) column=i: self._value(radius, column, mset, set))
...@@ -111,8 +120,8 @@ class StFile(object): ...@@ -111,8 +120,8 @@ class StFile(object):
"""Save all data defined in main_data_sets to st file. """Save all data defined in main_data_sets to st file.
""" """
colwidth = len(precision % 1) colwidth = len(precision % 1)
sep = '='*colwidth*len(stcols) + '\n' sep = '='*colwidth*len(self.cols) + '\n'
colhead = ''.join([k.center(colwidth) for k in stcols.split()]) + '\n' colhead = ''.join([k.center(colwidth) for k in self.cols]) + '\n'
nsets = len(self.main_data_sets) nsets = len(self.main_data_sets)
......
This diff is collapsed.
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