@@ -1964,7 +1964,7 @@ def plot2d(self, ax=None, plot_seabed=True,plot_bathymetry=True, plot_boundary=T
19641964 plot_anchors = kwargs .get ('plot_anchors' ,True )
19651965 plot_moorings = kwargs .get ('plot_moorings' ,True )
19661966 plot_cables = kwargs .get ('plot_cables' ,True )
1967-
1967+ cable_labels = kwargs . get ( 'cable_labels' , False )
19681968
19691969
19701970 # if axes not passed in, make a new figure
@@ -2073,10 +2073,28 @@ def plot2d(self, ax=None, plot_seabed=True,plot_bathymetry=True, plot_boundary=T
20732073 ax .plot ([sub .rA [0 ],sub .rB [0 ]],
20742074 [sub .rA [1 ], sub .rB [1 ]],':' ,color = Ccable , lw = 1.2 ,
20752075 label = 'Buried Cable ' + str (cableSize )+ ' mm$^{2}$' )
2076+
2077+ # if cable_labels:
2078+ # x = np.mean([sub.rA[0],sub.rB[0]])
2079+ # y = np.mean([sub.rA[1],sub.rB[1]])
2080+ # if '_' in cable.id:
2081+ # label = cable.id.split('_')[-1]
2082+ # else:
2083+ # label = cable.id
2084+ # ax.text(x,y, label)
20762085 elif isinstance (sub ,DynamicCable ):
20772086 ax .plot ([sub .rA [0 ],sub .rB [0 ]],
20782087 [sub .rA [1 ], sub .rB [1 ]],'--' ,color = Ccable , lw = 1.2 ,
20792088 label = 'Cable ' + str (cableSize )+ ' mm$^{2}$' )
2089+
2090+ if cable_labels :
2091+ x = np .mean ([sub .rA [0 ],sub .rB [0 ]])
2092+ y = np .mean ([sub .rA [1 ],sub .rB [1 ]])
2093+ if '_' in cable .id :
2094+ label = cable .id .split ('_' )[- 1 ]
2095+ else :
2096+ label = cable .id
2097+ ax .text (x ,y , label )
20802098
20812099 # ax.plot([cable.subcomponents[0].rA[0], cable.subcomponents[-1].rB[0]],
20822100 # [cable.subcomponents[0].rA[1], cable.subcomponents[0].rB[1]], 'r--', lw=0.5)
@@ -3935,13 +3953,15 @@ def unload(self,file='project.yaml'):
39353953
39363954 # build out site info
39373955 site = {}
3938- sps = deepcopy (self .soilProps )
3939- for ks ,sp in sps .items ():
3940- for k ,s in sp .items ():
3941- if not isinstance (s ,list ) and not 'array' in type (s ).__name__ :
3942- sp [k ] = [s ]
3943- sps [ks ] = sp
3944- if hasattr (self ,'soilProps' ) and self .soilProps :
3956+
3957+ if hasattr (self ,'soilProps' ):
3958+ sps = deepcopy (self .soilProps )
3959+ for ks ,sp in sps .items ():
3960+ for k ,s in sp .items ():
3961+ if not isinstance (s ,list ) and not 'array' in type (s ).__name__ :
3962+ sp [k ] = [s ]
3963+ sps [ks ] = sp
3964+
39453965 if len (self .soil_x )> 1 :
39463966 site ['seabed' ] = {'x' :[float (x ) for x in self .soil_x ],'y' :[float (x ) for x in self .soil_y ],'type_array' :self .soil_names .tolist (),
39473967 'soil_types' : sps }# [[[float(v[0])] for v in x.values()] for x in self.soilProps.values()]}
0 commit comments