Skip to content

Commit ad276de

Browse files
authored
Merge pull request #21 from mtezzele/str_plot
Str plot
2 parents 2a62364 + ed1681c commit ad276de

File tree

9 files changed

+70
-64
lines changed

9 files changed

+70
-64
lines changed

bladex/blade.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -461,18 +461,18 @@ def __str__(self):
461461
for debugging.
462462
"""
463463
string = ''
464-
string += 'Blade number of sections = {}\n'.format(self.n_sections)
465-
string += '\nBlade radii sections = {}\n'.format(self.radii)
466-
string += '\nChord lengths of the blade sectional profiles'\
467-
' = {}\n'.format(self.chord_lengths)
468-
string += '\nRadial distribution of the blade pitch (in unit lengths)'\
469-
' = {}\n'.format(self.pitch)
470-
string += '\nRadial distribution of the blade rake (in unit length)'\
471-
' = {}\n'.format(self.rake)
472-
string += '\nRadial distribution of the blade skew angles'\
473-
' (in degrees) = {}\n'.format(self.skew_angles)
474-
string += '\nComputed pitch angles (in radians) for the blade'\
475-
' sections = {}\n'.format(self.pitch_angles)
476-
string += '\nComputed induced rake from skew (in unit length),'\
477-
' for the blade sections = {}\n'.format(self.induced_rake)
464+
string += 'Blade number of sections = {}'.format(self.n_sections)
465+
string += '\nBlade radii sections = {}'.format(self.radii)
466+
string += '\nChord lengths of the sectional profiles'\
467+
' = {}'.format(self.chord_lengths)
468+
string += '\nRadial distribution of the pitch (in unit lengths)'\
469+
' = {}'.format(self.pitch)
470+
string += '\nRadial distribution of the rake (in unit length)'\
471+
' = {}'.format(self.rake)
472+
string += '\nRadial distribution of the skew angles'\
473+
' (in degrees) = {}'.format(self.skew_angles)
474+
string += '\nPitch angles (in radians) for the'\
475+
' sections = {}'.format(self.pitch_angles)
476+
string += '\nInduced rake from skew (in unit length)'\
477+
' for the sections = {}'.format(self.induced_rake)
478478
return string

bladex/params.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,15 +276,15 @@ def __str__(self):
276276
for debugging.
277277
"""
278278
string = ''
279-
string += '\nradii = {}\n'.format(self.radii)
279+
string += 'radii = {}'.format(self.radii)
280280
params = ['chord', 'pitch', 'rake', 'skew', 'camber']
281281
for param in params:
282-
string += '\n' + param + ' = {}\n'.format(self.parameters[param])
283-
string += '\n\n' + param + ' degree = {}\n'.format(
282+
string += '\n\n' + param + ' = {}'.format(self.parameters[param])
283+
string += '\n' + param + ' degree = {}'.format(
284284
self.degree[param])
285-
string += '\n\n' + param + ' npoints = {}\n'.format(
285+
string += '\n' + param + ' npoints = {}'.format(
286286
self.npoints[param])
287-
string += param + ' nbasis = {}\n'.format(self.nbasis[param])
288-
string += param + ' control points deformations =\n'
289-
string += '{}\n'.format(self.deformations[param])
287+
string += '\n' + param + ' nbasis = {}'.format(self.nbasis[param])
288+
string += '\n' + param + ' control points deformations = '
289+
string += '{}'.format(self.deformations[param])
290290
return string

bladex/profilebase.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -408,22 +408,19 @@ def rotate(self, rad_angle=None, deg_angle=None):
408408
:math:`R(\\theta)` is defined by:
409409
410410
.. math::
411-
\\left(\\begin{matrix} cos (\\theta) & - sin (\\theta) \\
412-
411+
\\left(\\begin{matrix} cos (\\theta) & - sin (\\theta) \\\\
413412
sin (\\theta) & cos (\\theta) \\end{matrix}\\right)
414413
415414
Given the coordinates of point :math:`P` such that
416415
417416
.. math::
418-
(P) = \\left(\\begin{matrix} x \\
419-
417+
P = \\left(\\begin{matrix} x \\\\
420418
y \\end{matrix}\\right),
421419
422420
Then, the rotated coordinates will be:
423421
424422
.. math::
425-
P^{'} = \\left(\\begin{matrix} x^{'} \\
426-
423+
P^{'} = \\left(\\begin{matrix} x^{'} \\\\
427424
y^{'} \\end{matrix}\\right)
428425
= R (\\theta) \\cdot P
429426
@@ -488,9 +485,6 @@ def reflect(self):
488485
"""
489486
Reflect the airfoil coordinates about the origin, i.e. a mirror
490487
transformation is performed about both the X-axis and the Y-axis.
491-
492-
We note that if the foil is cenetered by its reference point at the
493-
origin, then the reflection is just a simple flip.
494488
"""
495489
self.xup_coordinates *= -1
496490
self.xdown_coordinates *= -1
@@ -546,26 +540,27 @@ def plot(self,
546540
raise ValueError('One or all the coordinates have None value.')
547541

548542
if profile:
549-
plt.plot(self.xup_coordinates, self.yup_coordinates)
550-
plt.plot(self.xdown_coordinates, self.ydown_coordinates)
543+
plt.plot(self.xup_coordinates, self.yup_coordinates, label='Upper profile')
544+
plt.plot(self.xdown_coordinates, self.ydown_coordinates, label='Lower profile')
551545

552546
if chord_line:
553547
if self.chord_line is None:
554548
raise ValueError(
555549
'Chord line is None. You must compute it first')
556-
plt.plot(self.chord_line[0], self.chord_line[1])
550+
plt.plot(self.chord_line[0], self.chord_line[1], label='Chord line')
557551

558552
if camber_line:
559553
if self.camber_line is None:
560554
raise ValueError(
561555
'Camber line is None. You must compute it first')
562-
plt.plot(self.camber_line[0], self.camber_line[1])
556+
plt.plot(self.camber_line[0], self.camber_line[1], label='Camber line')
563557

564558
if ref_point:
565-
plt.scatter(self.reference_point[0], self.reference_point[1])
559+
plt.scatter(self.reference_point[0], self.reference_point[1], s=15, label='Reference point')
566560

567561
plt.grid(linestyle='dotted')
568562
plt.axis('equal')
563+
plt.legend()
569564

570565
if outfile:
571566
if not isinstance(outfile, str):

docs/source/_summaries/bladex.profilebase.ProfileBase.flip.rst

Lines changed: 0 additions & 6 deletions
This file was deleted.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
bladex.profilebase.ProfileBase.reflect
2+
======================================
3+
4+
.. currentmodule:: bladex.profilebase
5+
6+
.. automethod:: ProfileBase.reflect

docs/source/profilebase.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ ProfileBase
1414
ProfileBase.compute_camber_line
1515
ProfileBase.compute_chord_line
1616
ProfileBase.deform_camber_line
17-
ProfileBase.flip
1817
ProfileBase.interpolate_coordinates
1918
ProfileBase.max_camber
2019
ProfileBase.max_thickness
2120
ProfileBase.plot
2221
ProfileBase.reference_point
22+
ProfileBase.reflect
2323
ProfileBase.rotate
2424
ProfileBase.scale
2525
ProfileBase.translate

tests/test_blade.py

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -375,19 +375,18 @@ def test_export_ppg(self):
375375
def test_blade_str_method(self):
376376
blade = create_sample_blade_NACA()
377377
string = ''
378-
string += 'Blade number of sections = {}\n'.format(blade.n_sections)
379-
string += '\nBlade radii sections = {}\n'.format(blade.radii)
380-
string += '\nChord lengths of the blade sectional profiles'\
381-
' = {}\n'.format(blade.chord_lengths)
382-
string += '\nRadial distribution of the blade pitch (in unit lengths)'\
383-
' = {}\n'.format(blade.pitch)
384-
string += '\nRadial distribution of the blade rake (in unit length)'\
385-
' = {}\n'.format(blade.rake)
386-
string += '\nRadial distribution of the blade skew angles'\
387-
' (in degrees) = {}\n'.format(blade.skew_angles)
388-
string += '\nComputed pitch angles (in radians) for the blade'\
389-
' sections = {}\n'.format(blade.pitch_angles)
390-
string += '\nComputed induced rake from skew (in unit length),'\
391-
' for the blade sections = {}\n'.format(blade.induced_rake)
392-
378+
string += 'Blade number of sections = {}'.format(blade.n_sections)
379+
string += '\nBlade radii sections = {}'.format(blade.radii)
380+
string += '\nChord lengths of the sectional profiles'\
381+
' = {}'.format(blade.chord_lengths)
382+
string += '\nRadial distribution of the pitch (in unit lengths)'\
383+
' = {}'.format(blade.pitch)
384+
string += '\nRadial distribution of the rake (in unit length)'\
385+
' = {}'.format(blade.rake)
386+
string += '\nRadial distribution of the skew angles'\
387+
' (in degrees) = {}'.format(blade.skew_angles)
388+
string += '\nPitch angles (in radians) for the'\
389+
' sections = {}'.format(blade.pitch_angles)
390+
string += '\nInduced rake from skew (in unit length)'\
391+
' for the sections = {}'.format(blade.induced_rake)
393392
assert blade.__str__() == string

tests/test_params.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -505,14 +505,14 @@ def test_str_method(self):
505505
prm = param.ParamFile()
506506
prm.read_parameters('tests/test_datasets/temp_parameters.prm')
507507
string = ''
508-
string += '\nradii = {}\n'.format(prm.radii)
508+
string += 'radii = {}'.format(prm.radii)
509509
params = ['chord', 'pitch', 'rake', 'skew', 'camber']
510510
for par in params:
511-
string += '\n' + par + ' = {}\n'.format(prm.parameters[par])
512-
string += '\n\n' + par + ' degree = {}\n'.format(prm.degree[par])
513-
string += '\n\n' + par + ' npoints = {}\n'.format(prm.npoints[par])
514-
string += par + ' nbasis = {}\n'.format(prm.nbasis[par])
515-
string += par + ' control points deformations =\n'
516-
string += '{}\n'.format(prm.deformations[par])
511+
string += '\n\n' + par + ' = {}'.format(prm.parameters[par])
512+
string += '\n' + par + ' degree = {}'.format(prm.degree[par])
513+
string += '\n' + par + ' npoints = {}'.format(prm.npoints[par])
514+
string += '\n' + par + ' nbasis = {}'.format(prm.nbasis[par])
515+
string += '\n' + par + ' control points deformations = '
516+
string += '{}'.format(prm.deformations[par])
517517
assert prm.__str__() == string
518518
self.addCleanup(os.remove, 'tests/test_datasets/temp_parameters.prm')

tests/test_profilebase.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,18 @@ def test_plot_ref_point(self):
529529
outfile=None)
530530
plt.close()
531531

532+
def test_plot_all(self):
533+
profile = create_sample_profile()
534+
profile.compute_camber_line()
535+
profile.compute_chord_line()
536+
profile.plot(
537+
profile=True,
538+
chord_line=True,
539+
camber_line=True,
540+
ref_point=True,
541+
outfile=None)
542+
plt.close()
543+
532544
def test_plot_save(self):
533545
profile = create_sample_profile()
534546
profile.plot(outfile='tests/test_datasets/test_plot.png')

0 commit comments

Comments
 (0)