@@ -226,11 +226,11 @@ def __init__(
226226 def setup_direction (self , x_direction :bool = True ):
227227 self .x_direction = x_direction
228228 self .direction = 'X' if x_direction else 'Y'
229- self .id = f'{ self .sim_type } | { self .stories } stories - { self .nsubs } subs - { self .direction } dir' if self .grid else f'{ self .sim_type } | { self .magnitude } Mw | Station { self .station } | { self .stories } stories - { self .nsubs } subs - { self .direction } dir'
229+ self .id = f'{ self .sim_type } - { self .stories } stories - { self .nsubs } subs - { self .direction } dir' if self .grid else f'{ self .sim_type } - { self .magnitude } Mw - Station { self .station } - { self .stories } stories - { self .nsubs } subs - { self .direction } dir'
230230 self .file_name = f'{ self .sim_type } _20f{ self .nsubs } _{ self .direction } ' if self .grid else f'{ self .sim_type } _{ self .magnitude } _{ self .rup_type } { self .iteration } _s{ self .station } _{ self .direction } '
231- self .drift_title = f'Drift per story Plot | { self .id } '
232- self .spectrums_title = f'Story PSa Plot | { self .id } '
233- self .base_shear_ss_title = f'Base Shear Plot | { self .id } '
231+ self .drift_title = f'Drift Plot - { self .id } '
232+ self .spectrums_title = f'Story PSa Plot - { self .id } '
233+ self .base_shear_ss_title = f'Base Shear Plot - { self .id } '
234234
235235 def plotConfig (self , title :str , x = 19.2 , y = 10.8 ):
236236 """
@@ -276,7 +276,10 @@ def to_empty(self, x, pos):
276276 return ''
277277 def to_equal (self , x , pos ):
278278 return f'{ x } '
279-
279+ def to_int (self , x , pos ):
280+ return f'{ int (x )} '
281+ def to_dot_mil (self , x , pos ):
282+ return f'{ (int (x / 1000 ))} '
280283 def plotModelDrift (self , max_corner_x : list , max_center_x : list , max_corner_y : list , max_center_y :list , xlim_inf :float = 0.0 , xlim_sup :float = 0.002 ,
281284 axes :plt .Axes | NDArray [plt .Axes ]= None , save_fig :bool = True , legend :bool = True , fig_size : tuple [float , float ]= (19.2 , 10.8 ), line_color = None
282285 )-> plt .Axes | NDArray [plt .Axes ]:
@@ -319,23 +322,26 @@ def plotModelDrift(self, max_corner_x: list, max_center_x: list, max_corner_y: l
319322 color = color_1 if self .grid and not line_color else 'red'
320323 linewidth = 0.5 if self .grid and not line_color else 0.6
321324 marker = 'v' if line_color else None
322- ax .plot (max_center_x , y , label = 'max_center_x' , marker = marker , color = color , linewidth = 0.5 , markersize = 2 )
325+ label = 'Iter.Drift' if not line_color else 'Mean Iter.Drift'
326+ ax .plot (max_center_x , y , label = label , marker = marker , color = color , linewidth = 0.5 , markersize = 2 )
323327 else :
324328 candidate = np .array (max_center_y ).max () + 0.0005 if self .station == 1 else 0
325329 ax .set_xlim (xlim_inf , candidate ) if candidate > axes [0 ,0 ].get_xlim ()[1 ] else ax .set_xlim (xlim_inf , axes [0 ,0 ].get_xlim ()[1 ])
326330 color = color_1 if self .grid and not line_color else 'blue'
327331 linewidth = 0.5 if self .grid and not line_color else 0.6
328332 marker = 'd' if line_color else None
329- ax .plot (max_center_y , y , label = 'max_center_y' , marker = marker , color = color , linewidth = linewidth , markersize = 2 )
333+ label = 'Iter.Drift' if not line_color else 'Mean Iter.Drift'
334+ ax .plot (max_center_y , y , label = label , marker = marker , color = color , linewidth = linewidth , markersize = 2 )
330335
331336 # Plot NCH433 limits
332- ax .axvline (x = 0.002 , color = 'black' , linestyle = '--' , linewidth = 0.55 , alpha = 0.9 , label = 'NCh433 Limit - 5.9.2 = 0.002' )
337+ ax .axvline (x = 0.002 , color = 'black' , linestyle = '--' , linewidth = 0.55 , alpha = 0.9 , label = 'NCh433 Limit= 0.002' )
333338
334339 # Set legend and save fig if needed
335340 if legend :
336341 handles , labels = axes [0 , 0 ].get_legend_handles_labels ()
337- fig .legend (handles , labels , loc = 'upper right' , bbox_to_anchor = (1 , 1 ), bbox_transform = fig .transFigure )
338-
342+ fig .legend ([handles [- 4 ], handles [- 2 ], handles [- 1 ]], [labels [- 4 ], labels [- 2 ], labels [- 1 ]],
343+ loc = 'upper right' , bbox_to_anchor = (1 , 1 ), bbox_transform = fig .transFigure , fontsize = 'small' )
344+
339345 if save_fig :
340346 fig .tight_layout ()
341347 self .plotSave (fig )
@@ -397,7 +403,6 @@ def plotLocalStoriesSpectrums(self,
397403 # Compute df
398404 spa_df = pd .DataFrame ({f'Story { story } { direction } ' : spa for story , spa in zip (stories_lst , spa_lst )}, index = T )
399405
400-
401406 if save_fig :
402407 self .plotSave (fig )
403408 return axes , spa_df
@@ -432,10 +437,12 @@ def plotMeanStoriesSpectrums(self,
432437 ax .set_title (f'Station { self .station } ' )
433438
434439 # Setup axis
435- formatter = FuncFormatter (self .to_empty )
436- ax .set_xlabel ('T (s)' ) if self .station in [7 ,8 ,9 ] else ax .xaxis .set_major_formatter (formatter )
440+ formatter1 = FuncFormatter (self .to_empty )
441+ formatter2 = FuncFormatter (self .to_int )
442+ ax .set_xlabel ('T (s)' ) if self .station in [7 ,8 ,9 ] else ax .xaxis .set_major_formatter (formatter1 )
437443 ax .set_ylabel (f'Acceleration in { direction .upper ()} (m/s/s)' ) if self .station in [4 ] else ax .set_ylabel ('' )
438-
444+ ax .yaxis .set_major_formatter (formatter2 )
445+
439446 # Make plot spectrum
440447 T = np .linspace (0.003 , 2 , 1000 )
441448 spa_lst = []
@@ -483,33 +490,30 @@ def plotShearBaseOverTime(self, time:np.ndarray, time_shear_fma:list[float], Qma
483490
484491 # Plot
485492 alpha = 0.1 if not mean else 1
486- ax .plot (time , time_shear_fma , label = 'Shear Base Series ' , color = 'blue' , linewidth = 0.5 , alpha = alpha )
487- ax .axhline (y = Qmax , color = 'red' , linestyle = '--' , linewidth = 0.5 , alpha = 0.9 , label = 'NCh433 Qmax - 6.3.7.1 ' )
493+ ax .plot (time , time_shear_fma , label = 'Shear Base' , color = 'blue' , linewidth = 0.5 , alpha = alpha )
494+ ax .axhline (y = Qmax , color = 'red' , linestyle = '--' , linewidth = 0.5 , alpha = 0.9 , label = 'NCh433 Qmax' )
488495 ax .axhline (y = - Qmax , color = 'red' , linestyle = '--' , linewidth = 0.5 , alpha = 0.9 , label = None )
489496
490497 # Setup axis
491498 formatter1 = FuncFormatter (self .to_empty )
492499 formatter2 = FuncFormatter (self .to_equal )
500+ formatter3 = FuncFormatter (self .to_dot_mil )
493501 ax .set_ylim (ylim_inf , ylim_sup ) if self .station == 1 and self .iteration == 1 else ax .set_ylim (axes [0 , 0 ].get_ylim ())
494502 ax .set_xlabel ('Time (s)' ) if self .station in [8 ] else ax .xaxis .set_major_formatter (formatter1 )
495- ax .set_ylabel (f'Shear in { dir_ .upper ()} direction (kN )' ) if self .station in [4 ] else ax .set_ylabel ('' )
503+ ax .set_ylabel (f'Shear in { dir_ .upper ()} direction (Mega Newtons )' ) if self .station in [4 ] else ax .set_ylabel ('' )
496504 ax .xaxis .set_major_formatter (formatter2 ) if self .station in [7 ,8 ,9 ] else ax .xaxis .set_major_formatter (formatter1 )
497- ax .yaxis .set_major_formatter (formatter2 ) if self .station in [1 ,4 ,7 ] else ax .yaxis .set_major_formatter (formatter1 )
498-
499- # Update lim negative if candidate is less than the current limit
500- #candidate_neg = np.array(time_shear_fma).min() - 1000 if self.station == 1 else 0
501- #ax.set_ylim(candidate_neg, axes[0,0].get_ylim()[1]) if candidate_neg < axes[0,0].get_ylim()[0] else ax.set_ylim(axes[0,0].get_ylim()[0], axes[0,0].get_ylim()[1])
502- #candidate_pos = np.array(time_shear_fma).max() + 1000 if self.station == 1 else 0
503- #ax.set_ylim(axes[0,0].get_ylim()[0], candidate_pos) if candidate_pos > axes[0,0].get_ylim()[1] else ax.set_ylim(axes[0,0].get_ylim()[0], axes[0,0].get_ylim()[1])
504-
505+ ax .yaxis .set_major_formatter (formatter3 ) if self .station in [1 ,4 ,7 ] else ax .yaxis .set_major_formatter (formatter1 )
506+
505507 candidate_neg = np .array (time_shear_fma ).min () - 1000 if self .station == 1 and mean else 0
506508 ax .set_ylim (candidate_neg , axes [0 ,0 ].get_ylim ()[1 ]) if candidate_neg < axes [0 ,0 ].get_ylim ()[0 ] else ax .set_ylim (axes [0 ,0 ].get_ylim ()[0 ], axes [0 ,0 ].get_ylim ()[1 ])
507509 candidate_pos = np .array (time_shear_fma ).max () + 1000 if self .station == 1 and mean else 0
508510 ax .set_ylim (axes [0 ,0 ].get_ylim ()[0 ], candidate_pos ) if candidate_pos > axes [0 ,0 ].get_ylim ()[1 ] else ax .set_ylim (axes [0 ,0 ].get_ylim ()[0 ], axes [0 ,0 ].get_ylim ()[1 ])
509511
510- handles , labels = axes [0 , 0 ].get_legend_handles_labels ()
511512 if leyend :
512- fig .legend (handles [- 5 :], labels [- 5 :], loc = 'upper right' , bbox_to_anchor = (1 , 1 ), bbox_transform = fig .transFigure )
513+ handles , labels = axes [0 , 0 ].get_legend_handles_labels ()
514+ fig .legend ([handles [- 3 ], handles [- 2 ]], [labels [- 3 ], labels [- 2 ]],
515+ loc = 'upper right' , bbox_to_anchor = (1 , 1 ), bbox_transform = fig .transFigure , fontsize = 'small' )
516+
513517 if save_fig :
514518 self .plotSave (fig )
515519 return axes
0 commit comments