Skip to content

Commit 4598d80

Browse files
committed
adding dirname to default caero path
1 parent 1816993 commit 4598d80

File tree

2 files changed

+23
-32
lines changed

2 files changed

+23
-32
lines changed

pyNastran/f06/test/test_f06_utils.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,8 @@ def test_plot_flutter_0012(self):
220220
221221
has issues with writing the subcase...
222222
"""
223-
f06_filename = AERO_PATH / '2_mode_flutter' / '0012_flutter.f06'
223+
dirname = AERO_PATH / '2_mode_flutter'
224+
f06_filename = dirname / '0012_flutter.f06'
224225
#log = get_logger(log=None, level=None, encoding='utf-8')
225226
log = get_logger(log=None, level=False, encoding='utf-8')
226227

@@ -240,10 +241,10 @@ def test_plot_flutter_0012(self):
240241
f06_units='si', out_units=None,
241242
plot_vg=True, plot_vg_vf=True, plot_root_locus=True,
242243
plot_kfreq_damping=True,
243-
export_csv_filename='nastran.csv',
244-
export_f06_filename='nastran.f06',
245-
export_veas_filename='nastran.veas',
246-
export_zona_filename='zona.f06',
244+
export_csv_filename=dirname/'nastran.csv',
245+
export_f06_filename=dirname/'nastran.f06',
246+
export_veas_filename=dirname/'nastran.veas',
247+
export_zona_filename=dirname/'zona.f06',
247248
vg_filename='vg_subcase_%i.png',
248249
vg_vf_filename='vg_vf_subcase_%i.png',
249250
kfreq_damping_filename='kfreq_damping_subcase_%i.png',
@@ -267,10 +268,10 @@ def test_plot_flutter_0012(self):
267268
os.remove('kfreq_damping_subcase_1.png')
268269
os.remove('root_locus_subcase_1.png')
269270

270-
os.remove('nastran.csv')
271-
os.remove('nastran.f06')
272-
os.remove('nastran.veas')
273-
os.remove('zona.f06')
271+
os.remove(dirname/'nastran.csv')
272+
os.remove(dirname/'nastran.f06')
273+
os.remove(dirname/'nastran.veas')
274+
os.remove(dirname/'zona.f06')
274275

275276
with self.assertRaises(NotImplementedError):
276277
plot_flutter_f06(
@@ -723,6 +724,7 @@ def test_opt_mdb200(self):
723724
show=True)
724725

725726
def test_f06_trim_bwb(self):
727+
"""tests f06_to_pressure_loads"""
726728
bdf_filename = MODEL_PATH / 'bwb' / 'bwb_saero_trim.bdf'
727729
aerobox_caero_filename = MODEL_PATH / 'bwb' / 'bwb_saero_trim.caero.bdf'
728730
f06_filename = MODEL_PATH / 'bwb' / 'bwb_saero_trim.f06'
@@ -761,14 +763,13 @@ def test_f06_trim_bwb(self):
761763
'f06', 'plot_144', str(f06_filename),
762764
'--caero', str(aerobox_caero_filename)]
763765
log = get_logger(log=None, level=None, encoding='utf-8')
764-
cmd_line_f06(argv=argv, # plot=IS_MATPLOTLIB,
766+
cmd_line_f06(argv=argv, plot=IS_MATPLOTLIB,
765767
show=False, log=log)
766768

767769
argv = ['f06', 'plot_144', str(f06_filename)]
768-
cmd_line_f06(argv=argv, # plot=IS_MATPLOTLIB,
770+
cmd_line_f06(argv=argv, plot=IS_MATPLOTLIB,
769771
show=False, log=log)
770772

771-
772773
def test_f06_trim_freedlm(self):
773774
"""tests read_f06_trim"""
774775
bdf_filename = AERO_PATH / 'freedlm' / 'freedlm.bdf'

pyNastran/f06/utils.py

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""
22
defines:
33
- cmd_line_plot_flutter()
4+
- cmd_line_plot_trim()
5+
- cmd_line_plot_optimization()
46
57
"""
68
from __future__ import annotations
@@ -31,19 +33,9 @@
3133
def cmd_line_plot_trim(argv=None, plot: bool=True, show: bool=True,
3234
log: Optional[SimpleLogger]=None):
3335
"""the interface to ``f06 plot_144`` on the command line"""
34-
from pyNastran.f06.parse_flutter import plot_flutter_f06, float_types
3536
if argv is None: # pragma: no cover
3637
argv = sys.argv
3738

38-
# is_gui = '--gui' in argv
39-
# if is_gui:
40-
# argv.remove('--gui')
41-
# from pyNastran.f06.dev.flutter.gui_flutter import main as gui_flutter
42-
#
43-
# if len(argv) == 2 and is_gui:
44-
# gui_flutter()
45-
# return
46-
4739
msg = (
4840
USAGE_144 +
4941
' f06 plot_144 -h | --help\n'
@@ -78,18 +70,17 @@ def cmd_line_plot_trim(argv=None, plot: bool=True, show: bool=True,
7870
f06_filename = data['F06_FILENAME']
7971
aerobox_caero_filename = data['--caero']
8072
bdf_filename = data['--bdf']
73+
dirname = os.path.dirname(f06_filename)
74+
base = os.path.splitext(f06_filename)[0]
8175

8276
from pyNastran.utils import print_bad_path
83-
# print(aerobox_caero_filename)
84-
# print(bdf_filename)
85-
if bdf_filename is None:
86-
base = os.path.splitext(f06_filename)[0]
87-
bdf_filename = base + '.bdf'
88-
assert os.path.exists(bdf_filename), print_bad_path(bdf_filename)
89-
9077
if aerobox_caero_filename is None:
78+
if bdf_filename is None:
79+
bdf_filename = base + '.bdf'
80+
assert os.path.exists(bdf_filename), print_bad_path(bdf_filename)
81+
9182
from pyNastran.bdf.mesh_utils.export_caero_mesh import export_caero_mesh
92-
aerobox_caero_filename = 'caero.bdf'
83+
aerobox_caero_filename = os.path.join(dirname, 'caero.bdf')
9384
export_caero_mesh(
9485
bdf_filename,
9586
caero_bdf_filename=aerobox_caero_filename,
@@ -98,7 +89,6 @@ def cmd_line_plot_trim(argv=None, plot: bool=True, show: bool=True,
9889
write_panel_xyz=False)
9990

10091
assert os.path.exists(aerobox_caero_filename), print_bad_path(aerobox_caero_filename)
101-
dirname = os.path.dirname(f06_filename)
10292
loads_filename = os.path.join(dirname, 'loads.inc')
10393
base = os.path.splitext(f06_filename)[0]
10494
if f06_filename.lower().endswith(('.bdf', '.op2')):
@@ -273,7 +263,7 @@ def cmd_line_plot_flutter(argv=None, plot: bool=True, show: bool=True,
273263
else:
274264
in_units = data['--in_units']
275265
in_units = in_units.lower()
276-
assert in_units in {'si', 'si_mm', 'english_in', 'english_ft', 'english_kt'}, 'in_units=%r' % in_units
266+
assert in_units in {'si', 'si_mm', 'english_in', 'english_ft', 'english_kt'}, f'in_units={in_units!r}'
277267

278268
# The default used to be SI, but it's really weird when I'm working in
279269
# English units and my output is in SI

0 commit comments

Comments
 (0)