Last active
October 24, 2022 09:18
-
-
Save Erlemar/119daef34132c6765622807bb8dcfc86 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
res_layers = list(range(1, 66)) | |
upper_shale = [1, 2, 3, 4] | |
middle_shale =[29, 30, 31, 32, 33, 34] | |
lower_shale = [62, 63, 64, 65] | |
shale_layers = upper_shale + middle_shale + lower_shale | |
sand_layers = [x for x in res_layers if x not in shale_layers] | |
# create figure | |
fig = go.Figure() | |
fig = make_subplots(rows=2, cols=3, subplot_titles=("Row_1", "Row_2", "Row_3", "Row_4", "Row_5", "Row_6")) | |
# Add heatmap trace | |
for layer in sand_layers: | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df['i'] < 68) & (df_small['i'] > 56) & (df_small['j'] < 68) & (df_small['j'] > 56)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=1, col=1) | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df_small['i'] < 32) & (df_small['i'] > 20) & (df_small['j'] < 32) & (df_small['j'] > 20)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=1, col=2) | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df_small['i'] < 32) & (df_small['i'] > 20) & (df_small['j'] < 68) & (df_small['j'] > 56)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=1, col=3) | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df['i'] < 32) & (df_small['i'] > 20) & (df_small['j'] < 105) & (df_small['j'] > 93)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=2, col=1) | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df_small['i'] < 50) & (df_small['i'] > 38) & (df_small['j'] < 105) & (df_small['j'] > 93)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=2, col=2) | |
df_small = df.loc[df['k'] == layer] | |
df_small = df_small.loc[(df_small['i'] < 68) & (df_small['i'] > 56) & (df_small['j'] < 105) & (df_small['j'] > 93)] | |
fig.add_trace((go.Heatmap(z=df_small['porosity'].values.reshape(11, 11), colorscale="jet", | |
zmin=df['porosity'].min(), zmax=df['porosity'].max())), row=2, col=3) | |
# Make 10th trace visible | |
fig.data[0].visible = True | |
# Create and add slider | |
layers = [] | |
for i in range(len(sand_layers)): | |
layer = dict( | |
method="update", | |
args=[{"visible": [False] * len(fig.data)}, | |
{"title": "Slider switched to layer: " + str(i)}], # layout attribute | |
) | |
layer["args"][0]["visible"][i * 6] = True # Toggle i'th trace to "visible" | |
layer["args"][0]["visible"][i * 6 + 1] = True # Toggle i'th trace to "visible" | |
layer["args"][0]["visible"][i * 6 + 2] = True # Toggle i'th trace to "visible" | |
layer["args"][0]["visible"][i * 6 + 3] = True # Toggle i'th trace to "visible" | |
layer["args"][0]["visible"][i * 6 + 4] = True # Toggle i'th trace to "visible" | |
layer["args"][0]["visible"][i * 6 + 5] = True # Toggle i'th trace to "visible" | |
layers.append(layer) | |
sliders = [dict( | |
active=15, | |
#currentvalue={"prefix": "Frequency: "}, | |
currentvalue={"prefix": "Layer: ", "suffix": ""}, | |
pad={"t": 70}, | |
steps=layers | |
)] | |
fig.update_layout( | |
sliders=sliders | |
) | |
fig['layout']['sliders'][0]['currentvalue']['prefix'] = 'Layer: ' | |
for i, v in enumerate(sand_layers, start = 0): | |
fig['layout']['sliders'][0]['steps'][i]['label'] = i | |
fig.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment