Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions examples/01_Visualization/09_2D-visual_soil.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
"""
Simple driver file to create a 2d plot of soil types.
The input file only contains the bare minimum information to build a 2d plot
of the soil (no platforms, moorings, cables, platform design, turbines,
site condition information, etc.)
"""

from famodel import Project
import matplotlib.pyplot as plt
import os

# define name of ontology input file
dir = os.path.dirname(os.path.realpath(__file__))
input_file = os.path.join(dir,'09_2D-visual_soil.yaml')

# initialize Project class with input file, we don't need RAFT for this so mark False
project = Project(file=input_file,raft=False)

# plot (need to turn of bathymetry plotting to see the soil)
project.plot2d(plot_soil=True, plot_bathymetry=False)

plt.show()
5 changes: 5 additions & 0 deletions examples/01_Visualization/09_2D-visual_soil.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Site condition information
site:
general: {}
seabed:
file: '../GulfOfMaine_soil_uniform_100x100.txt'
29 changes: 29 additions & 0 deletions examples/01_Visualization/10_2D-visual_soil_bathy-contours.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*-
"""
Simple driver file to create a 2d plot of soil types.
The input file only contains the bare minimum information to build a 2d plot
of the soil and bathymetry contour lines (no platforms, moorings, cables, platform design, turbines,
site condition information, etc.)
"""

from famodel import Project
import matplotlib.pyplot as plt
import os

# define name of ontology input file
dir = os.path.dirname(os.path.realpath(__file__))
input_file = os.path.join(dir,'10_2D-visual_soil_bathy-contours.yaml')

# initialize Project class with input file, we don't need RAFT for this so mark False
project = Project(file=input_file,raft=False)

# plot the soil types with the bathymetry contour lines (must turn off bathymetry colorplot)
project.plot2d(plot_soil=True, plot_bathymetry=False, plot_bathy_contours=True,
bath_levels=10) # choose # of contour lines to show

# Let's change the number of contour levels
project.plot2d(plot_soil=True, plot_bathymetry=False, plot_bathy_contours=True,
bath_levels=5) # choose # of contour lines to show


plt.show()
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Site condition information
site:
general: {}
seabed:
file: '../GulfOfMaine_soil_uniform_100x100.txt'
bathymetry:
file: '../GulfOfMaine_bathymetry_100x100.txt'
68 changes: 68 additions & 0 deletions examples/01_Visualization/11_2D-visual_all_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# -*- coding: utf-8 -*-
"""
Simple driver file to create 2D plots exploring the different settings options
for plot2d().
"""

from famodel import Project
import matplotlib.pyplot as plt
import os

# define name of ontology input file
dir = os.path.dirname(os.path.realpath(__file__))
input_file = os.path.join(dir,'11_2D-visual_all_options.yaml')

# initialize Project class with input file, we don't need RAFT for this so mark False
project = Project(file=input_file,raft=False)

# create a dictionary of plot settings. We list here all the options showing default settings - comment/change different ones to see what they do!
plot_2d_settings = {
'ax' : None, # matplotlib.pyplot axis to plot on. If None, a new figure & axis is created.
'plot_soil' : False, # bool, if True plots soil
'plot_bathymetry' : True, # bool, if True plots bathymetry. plot_soil & plot_bathymetry can not both be True, but you can plot bathy contours with soil.
'plot_boundary' : True, # bool, if True plots lease boundary
'color_lineDepth' : False, # If True, color mooring lines based on depth. Only works if plot_bathymetry=False.
'plot_bathy_contours' : False, # bool, if True plots bathymetry contour lines. Can be used with plot_soil or plot_bathymetry
'bare' : False, # bool, if True does not plot extra things like colorbars
'axis_equal' : True, # bool, if True plots x and y axes at same scale to prevent distortions
'save' : False, # bool, if True saves the figure
'figsize' : (8,8), # the dimensions of the figure to be plotted
'env_color' : [.5,0,0,.8], # platform motion envelope color (need to run project.arrayWatchCircle() to get this)
'fenv_color' : [.6,.3,.3,.6], # mooring motion envelope color (need to run project.arrayWatchCircle() to get this)
'alpha' : 0.5, # the opacity of the plot
'return_contour' : False, # bool, if True returns the bathymetry or soil filled contour (only 1 of these can be plotted at a time)
'cmap_cables' : None, # matplotlib colormap string for cable conductors sizes
'cmap_soil' : None, # matplotlib colormap string for soil types
'plot_platforms' : True, # bool, if True plots the platform locations
'plot_anchors' : True, # bool, if True plots the anchor locations
'plot_moorings' : True, # bool, if True plots the mooring lines
'plot_cables' : True, # bool, if True plots the cables
'cable_labels' : False, # bool, if True adds labels of cable names to the plot
'depth_vmin' : None, # minimum depth to plot. If None, defaults to minimum depth in the bathymetry information
'depth_vmax' : None, # maximum depth to plot. If None, defaults to maximum depths in the bathymetry information
'bath_levels' : 50, # number of bathymetry contour levels, for either contour lines or the filled contour
'plot_legend' : True, # bool, if True plots the legend
'legend_x' : 0.5, # x location of the legend
'legend_y' : -0.1, # y location of the legend
'plot_landmask': False, # bool, if True plots a gray mask over land areas
'max_line_depth': None, # max depth for line coloring if color_lineDepth is True
'only_shared' : False, # if color_lineDepth is True, only color shared lines
'linewidth_multiplier' : 2 # multiplier for line widths if color_lineDepth is True
}


project.plot2d(**plot_2d_settings) # unpack settings dictionary and plot

# Let's change some settings

plot_2d_settings['cable_labels'] = True
plot_2d_settings['plot_bathymetry'] = False
plot_2d_settings['plot_soil'] = True
plot_2d_settings['bath_levels'] = 6
plot_2d_settings['plot_bathy_contours'] = True

project.plot2d(**plot_2d_settings)



plt.show()
Loading
Loading