debug messages for plotting and saving coordinates

Commit
09fd81eac3f5861b043e00d4865fa205deba5319
Author
Marius Peter <blendoit@gmail.com>
Author date
Committer
Marius Peter <blendoit@gmail.com>
Committer date
Changed files
creator.py
index aa8001f5..a2626d05 100644..100644
@@ -92,12 +92,16 @@
92 92
93 93 file_name = '{}_{}.txt'.format(self, number)
94 94 full_path = os.path.join(save_dir_path, file_name)
95 Removed: # sys.stdout = open(full_path, 'w')
96 Removed: # self.print_coord(2)
97 Removed: with open(full_path, 'w') as sys.stdout:
98 Removed: self.print_coord(2)
99 Removed: # Following line required to reset value of sys.stdout
100 Removed: sys.stdout = sys.__stdout__
95 Added: try:
96 Added: with open(full_path, 'w') as sys.stdout:
97 Added: self.print_coord(2)
98 Added: # This line required to reset behavior of sys.stdout
99 Added: sys.stdout = sys.__stdout__
100 Added: print('Successfully wrote to file {}'.format(full_path))
101 Added: except:
102 Added: print('Unable to write {} to specified directory.\n'
103 Added: .format(file_name),
104 Added: 'Was the full path passed to the function?')
101 105 # It is cleaner to use this context guard to ensure file is closed
102 106
103 107 return None
@@ -385,7 +389,7 @@
385 389 x = (spar.x_u[_], spar.x_l[_])
386 390 y = (spar.y_u[_], spar.y_l[_])
387 391 plt.plot(x, y, '.-', color='b')
388 Removed: plt.legend()
392 Added: # plt.legend()
389 393 except:
390 394 print('Did not plot spars. Were they added?')
391 395
main.py
index 9278eeb9..b842e9e4 100644..100644
@@ -34,28 +34,29 @@
34 34
35 35 # Interate through all wings in population.
36 36 for _ in range(1, POP_SIZE + 1):
37 Added:
37 38 # Create airfoil instance
38 39 af = creator.Airfoil()
39 40 # Define NACA airfoil coordinates
40 41 af.add_naca(2412)
41 Removed: af.print_coord(2)
42 Added: # af.print_coord(2)
42 43
43 44 # Create spar instance
44 45 af.spar = creator.Spar()
45 46 # Define the spar coordinates, stored in single spar object
46 47 af.spar.add(af.coord, 0.15)
47 48 af.spar.add(af.coord, 0.55)
48 Removed: af.spar.print_coord(2)
49 Added: # af.spar.print_coord(2)
49 50
50 51 # Create stringer instance
51 52 af.stringer = creator.Stringer()
52 53 # Define the stringer coordinates from their amount
53 54 af.stringer.add(af.coord, af.spar.coord, 4, 7, 5, 6)
54 55 # Print coordinates of af.stringer to terminal
55 Removed: af.stringer.print_coord(2)
56 Added: # af.stringer.print_coord(2)
56 57
57 58 # Plot components with matplotlib
58 Removed: creator.plot(af, af.spar, af.stringer)
59 Added: # creator.plot(af, af.spar, af.stringer)
59 60
60 61 # Save component coordinates
61 62 af.save_coord(SAVE_PATH, _)