pinnicle.utils
pinnicle.utils.backends_specified module
- pinnicle.utils.backends_specified.jacobian(output_var, input_var, i, j, val=0)
Compute jacobian using deepxde
- pinnicle.utils.backends_specified.jacobian_jax(output_var, input_var, i, j, val=0)[source]
Compute jacobian using deepxde This is a hack for now to take the first entry from the tuple returned by jax
- pinnicle.utils.backends_specified.jacobian_tf(output_var, input_var, i, j, val=0)[source]
Compute jacobian using deepxde
- pinnicle.utils.backends_specified.matmul(A, B)
- pinnicle.utils.backends_specified.slice_column(variable, i)
slice the column i:i+1 of variable, tensorflow version
- pinnicle.utils.backends_specified.slice_column_jax(variable, i)[source]
slice the column i:i+1 of variable, jax version currently jax output returns tuple (variable, function)
pinnicle.utils.data_misfit module
- pinnicle.utils.data_misfit.get(identifier)[source]
Retrieves a loss function.
- Parameters:
identifier – A loss identifier. String name of a loss function, or a loss function.
- Returns:
A loss function.
- pinnicle.utils.data_misfit.mean_squared_log_error_jax(y_true, y_pred)[source]
use jax/numpy function to compute mean squared log error
- pinnicle.utils.data_misfit.mean_squared_log_error_pytorch(y_true, y_pred)[source]
use jax/numpy function to compute mean squared log error
- pinnicle.utils.data_misfit.mean_squared_log_error_tf(y_true, y_pred)[source]
use tensorflow function to compute mean squared log error
- pinnicle.utils.data_misfit.surface_log_vel_misfit_jax(v_true, v_pred)[source]
Compute SurfaceLogVelMisfit: This function is for jax
pinnicle.utils.helper module
- members:
- undoc-members:
- show-inheritance:
pinnicle.utils.history module
pinnicle.utils.plotting module
- pinnicle.utils.plotting.diffplot(pinn, feature, feat_title=None, mdata='ISSM', sim='mae', figsize=(15, 4), cmap='jet', scale=1, clim=None, cbar_bins=10, elements=None)[source]
- pinnicle.utils.plotting.plot_data(X, Y, im_data, axs=None, vranges={}, **kwargs)[source]
plot all the data in im_data
- Parameters:
X (np.array) – x-coordinates of the 2D plot
Y (np.array) – y-coordinates of the 2D plot
im_data (dict) – Dict of data for the 2D plot, each element has the same size as X and Y
axs (array of AxesSubplot) – axes to plot each data, if not given, then generate a subplot according to the size of data_names
vranges (dict) – range of the data
- Returns:
axes of the subplots
- Return type:
axs (array of AxesSubplot)
- pinnicle.utils.plotting.plot_dict_data(X_dict, data_dict, axs=None, vranges={}, resolution=200, **kwargs)[source]
plot the data in data_dict, with coordinates in X_dict
- Parameters:
X_dict (dict) – Dict of the coordinates, with keys ‘x’, ‘y’
data_dict (dict) – Dict of data
axs (array of AxesSubplot) – axes to plot each data, if not given, then generate a subplot according to the size of data_names
vranges (dict) – range of the data
resolution (int) – number of pixels in horizontal and vertical direction
- Returns:
x-coordinates of the 2D plot Y (np.array): y-coordinates of the 2D plot im_data (dict): Dict of data for the 2D plot, each element has the same size as X and Y axs (array of AxesSubplot): axes of the subplots
- Return type:
X (np.array)
- pinnicle.utils.plotting.plot_nn(pinn, data_names=None, X_mask=None, axs=None, vranges={}, resolution=200, **kwargs)[source]
plot the prediction of the nerual network in pinn, according to the data_names
- Parameters:
pinn (class PINN) – The PINN model
data_names (list) – List of data names
X_mask (np.array) – xy-coordinates of the ice mask
axs (array of AxesSubplot) – axes to plot each data, if not given, then generate a subplot according to the size of data_names
vranges (dict) – range of the data
resolution (int) – number of pixels in horizontal and vertical direction
- Returns:
x-coordinates of the 2D plot Y (np.array): y-coordinates of the 2D plot im_data (dict): Dict of data for the 2D plot, each element has the same size as X and Y axs (array of AxesSubplot): axes of the subplots
- Return type:
X (np.array)
- pinnicle.utils.plotting.plot_solutions(pinn, path='', filename='2Dsolution.png', X_ref=None, sol_ref=None, cols=None, resolution=200, absvariable=[], default_time=None, **kwargs)[source]
plot model predictions
- Parameters:
path (Path, str) – Path to save the figures
filename (str) – name to save the figures, if set to None, then the figure will not be saved
X_ref (dict) – Coordinates of the reference solutions, if None, then just plot the predicted solutions
u_ref (dict) – Reference solutions, if None, then just plot the predicted solutions
cols (int) – Number of columns of subplot
resolution (int) – Number of grid points per row/column for plotting
absvariable (list) – Names of variables in the predictions that will need to take abs() before comparison
- pinnicle.utils.plotting.plot_tracks(pinn, feature, filepath=None, x_name_map='x', y_name_map='y', feat_name_map=None, gdata=None, mdata='ISSM', elements=None, scale=1, cmap='jet', figsize=(10, 8), clim=None, cbar_bins=10)[source]
plotting (sparse) ground truth data on top of prediction
- pinnicle.utils.plotting.resplot(pinn, mdata='ISSM', figsize=None, cmap='RdBu', cbar_bins=10, cbar_limits=[-5000.0, 5000.0], elements=None)[source]
plotting the pde residuals