Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI rework #3

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
1,345 changes: 1,345 additions & 0 deletions Manifest.toml

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa"
PlotlyJS = "f0f68f2c-4968-5e81-91da-67840de0976a"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Revise = "295af30f-e4ad-537b-8983-00126c2a3abe"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
Expand All @@ -28,11 +29,11 @@ DashBootstrapComponents = "1.4.1"
DelimitedFiles = "1"
GeophysicalModelGenerator = "0.5.4"
HTTP = "1.0"
Interpolations = "0.14"
JLD2 = "0.4"
JSON3 = "1"
Meshes = "0.30"
PlotlyJS = "0.18"
Statistics = "1.9"
UrlDownload = "1.0.1"
julia = "1.9"
Interpolations = "0.14"
Binary file modified playground/Marcel/Matlab/GMGDataPicker.mlapp
Binary file not shown.
17 changes: 6 additions & 11 deletions src/GMG_Tomo/GMG_TomoData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,18 @@ function main_layout(Datasets, max_num_users)
label="File",
id="id-dropdown-file"),

dbc_col([html_h1("Geo Data Picker", style = Dict("margin-top" => 0, "textAlign" => "center")),
html_h5("GeophysicalModelGenerator", style = Dict("margin-top" => 0, "textAlign" => "center"))]),

dbc_col(html_img(src="assets/GeophysicalModelGenerator-logos_cut.png",height="140vh",), width=2),
# dbc_col(html_img(src=joinpath(pkgdir(GeoDataPicker),"src/assets/GeophysicalModelGenerator-logos_cut.png"), height="140vh"), width=2),

#joinpath(pkgdir(GeoDataPicker),"src","GMG_Tomo/assets/logo/Logo_GMG.png")

dbc_col(html_img(src="assets/LogoPicker.png",height="100vh",)),
dbc_col(html_img(src="assets/GMG_Logo_new.png",height="100vh",), width=2),

]),
),

dbc_tabs(
[
dbc_tab(tab_id="tab-setup",label="Setup", children = [Tab_Data(Datasets)]),
dbc_tab(tab_id="tab-cross", label="Cross-sections", children = [Tab_CrossSection()]),
dbc_tab(tab_id="tab-3D", label="3D view", children = [Tab_3Dview()])
dbc_tab(tab_id="tab-setup",label="Setup", children = [tab_data(Datasets)]),
dbc_tab(tab_id="tab-map", label="Map", children = [tab_map()]),
dbc_tab(tab_id="tab-cross", label="Cross-sections", children = [tab_cross_section()]),
dbc_tab(tab_id="tab-3D", label="3D view", children = [tab_3Dview()])
],
id = "tabs", active_tab="tab-setup",

Expand Down
114 changes: 83 additions & 31 deletions src/GMG_Tomo/GMG_TomoData_Plots.jl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# functions to create the various plots shown in the GUI

"""
Creates a topo plot & line that shows the cross-section
updates the topo plot & line that shows the cross-section
"""
function plot_topo(AppData)
function plot_topo(AppData,session_id)
xdata = AppData.DataTopo.lon.val[:,1]
ydata = AppData.DataTopo.lat.val[1,:]
zdata = AppData.DataTopo.depth.val[:,:,1]'
Expand Down Expand Up @@ -44,30 +44,32 @@ function plot_topo(AppData)
colorscale = colorscale_topo,
zmin = -4,
zmax = 4,
colorbar=attr(thickness=5, title="topography [km]", titleside="right"),
colorbar=attr(thickness=20, title="topography [km]", titleside="right"),
)
],
colorbar=Dict("orientation"=>"v", "len"=>0.5, "thickness"=>10),
colorbar=Dict("orientation"=>"v", "len"=>0.5, "thickness"=>20),
layout = ( #title = "topography [km]",
yaxis=attr(
title="Latitude",
tickfont_size= 14,
tickfont_size= 16,
tickfont_color="rgb(100, 100, 100)"
),
xaxis=attr(
title="Longitude",
tickfont_size= 14,
tickfont_color="rgb(10, 10, 10)"
tickfont_size= 16,
tickfont_color="rgb(10, 10, 10)",
scaleanchor="y", scaleratio=1/1.65,
),

aspectmode="manual",
aspectratio=attr(x=0.8, y=1, z=1),
# once we save additional cross-sections, add them here
shapes = shapes,
),


scene = attr( aspectmode="manual",
aspectratio=attr(x=1, y=1, z=1)
),
#scene = attr( aspectmode="manual",
# aspectratio=attr(x=1, y=1, z=1) # change the aspect ratio so that we have an approximately orthogonal
# ),

config = (edits = (shapePosition = true,)),
)
Expand All @@ -78,13 +80,18 @@ end
"""
Creates a plot of the cross-section with all requested options
"""
# WE HERE HAVE TO UPDATE EVERYTHING WITH
# - THE NEW TOMOGRAPHIC CROSS-SECTION --> adds a new field, colormap, opacity, color z_limits
# - the switches for tomographies --> adds plot_tomographyI and plot_tomographyII
function plot_cross(AppData, profile;
zmax=nothing, zmin=nothing,
field=:dVp_paf21,
colormap="vik_reverse",
screenshot_opacity=0.5,
screenshot_display=true,
cross_section_opacity=1.0,
plot_tomography = true,
plot_tomographyII = false,
plot_surfaces = false, selected_surf_data= [],EQmag=(0.1,9),
plot_earthquakes= false, selected_EQ_data= [], section_width=50,
)
Expand All @@ -96,7 +103,6 @@ function plot_cross(AppData, profile;
Profile = ProfileData(profile); # create a GMG structure for the profile
Profile, PlotCross = ExtractProfileData(Profile, AppData, field; section_width=section_width) # project data onto the profile


colorscale = colormaps[Symbol(colormap)];

println("updating cross section")
Expand Down Expand Up @@ -132,14 +138,27 @@ function plot_cross(AppData, profile;
data_plots = []

# add tomographic cross-section
push!(data_plots, heatmap(x = PlotCross.x_cart,
y = PlotCross.z_cart,
z = collect(eachcol(PlotCross.data)),
colorscale = colorscale,
colorbar=attr(thickness=5, title=String(field), titleside="right"),
zmin=zmin, zmax=zmax,
opacity = cross_section_opacity
))
if plot_tomography
push!(data_plots, heatmap(x = PlotCross.x_cart,
y = PlotCross.z_cart,
z = collect(eachcol(PlotCross.data)),
colorscale = colorscale,
colorbar=attr(thickness=20, title=String(field), titleside="right"),
zmin=zmin, zmax=zmax,
opacity = cross_section_opacity
))
end
# add second tomographic cross-section WORK IN PROGRESS!!!
if plot_tomographyII
push!(data_plots, heatmap(x = PlotCross.x_cart,
y = PlotCross.z_cart,
z = collect(eachcol(PlotCross.data)),
colorscale = colorscale,
colorbar=attr(thickness=20, title=String(field), titleside="right"),
zmin=zmin, zmax=zmax,
opacity = cross_section_opacity
))
end

if screenshot_display==true
# Note: the name of the profile should be listed in the profuile struct
Expand Down Expand Up @@ -204,22 +223,24 @@ function plot_cross(AppData, profile;
pl = ( id = "fig_cross",
data = data_plots,
colorbar=Dict("orientation"=>"v", "len"=>0.5, "thickness"=>10,"title"=>"elevat"),
layout = ( title = "Cross-section",
xaxis=attr(
layout = ( xaxis=attr(
title=xlab,
tickfont_size= 14,
tickfont_color="rgb(100, 100, 100)"
tickfont_color="rgb(100, 100, 100)",
scaleanchor="y", scaleratio=1,
autorange=false, range=[PlotCross.x_cart[1],PlotCross.x_cart[end]],

),
yaxis=attr(
title=ylab,
tickfont_size= 14,
tickfont_color="rgb(10, 10, 10)",
autorange=true
autorange=false,
range=[minimum(PlotCross.z_cart),0],
),
shapes = shapes_data,
aspectmode="manual",
aspectratio=attr(x=1, y=1, z=1)

#aspectmode="manual",
#aspectratio=attr(x=1, y=1, z=1)
),
config = (edits = (shapePosition = true,)),
)
Expand Down Expand Up @@ -431,18 +452,49 @@ end

# This creates the topography (mapview) plot (lower left)
function create_topo_plot(AppData)

# first we have to see how large the map is to determine how we plot it
# the idea is to have an image that fills the availiable screen

#lonmin = minimum(AppData.DataTopo.lon.val[:,1]);
#lonmax = maximum(AppData.DataTopo.lon.val[:,1]);
#latmin = minimum(AppData.DataTopo.lat.val[1,:]);
#latmax = maximum(AppData.DataTopo.lat.val[1,:]);

#lon_extent = lonmax-lonmin;
#lat_extent = latmat-latmin;

# until plotting in map projection works here, we simply rescale the longitude axis with a factor that
# makes the plot look not too distorted
# if we want to fill the available visible space, we now have to determine the width and height on screen
#width_lon = lon_extent*0.8;
#height_lat = lat_extent;

#if width_lon>height_lat
# plotwidth = "80vw";
# plotheight = string(100/0.8)*"vw";
#else
plotheight = "80vh";
plotwidth = "80vw"
#end

#println("AppData")
println(keys(AppData))

html_div(
dcc_graph(
id = "mapview",
figure = [], #plot_topo(AppData),
#animate = true,
#clickData = true,
animate = false,
responsive=false,
responsive=true,
#clickData = true,
config = PlotConfig(displayModeBar=false, scrollZoom = false),
style = attr(width="35vw", height="50vh",padding_left="0vw",)
# here we plot the map so that the angles look about right
# a quick and simple way to do this is to set the aspect ratio to something smaller. Here we used a factor derived by trial and error
# the issue is that we somehow have to make this dependent on the map itself
style = attr(width=plotwidth, height=plotheight,padding_left=string(0.5*(100-(80/1.65)))*"vh")
),
style = attr(textalign="center")
)
Expand All @@ -455,9 +507,9 @@ function cross_section_plot()
id = "cross_section",
figure = [], #plot_cross(),
animate = false,
responsive=false,
responsive=true,
config = PlotConfig(displayModeBar=true, modeBarButtonsToAdd=["toimage","toImage","lasso","drawopenpath","eraseshape","drawclosedpath"],displaylogo=false),
style = attr(width="70vw", height="50vh"))
style = attr(width="80vw", height="80vh"))
end


Expand Down
2 changes: 1 addition & 1 deletion src/GMG_Tomo/Tab_3Dview.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tab 2
function Tab_3Dview()
function tab_3Dview()
dbc_col([
dcc_graph(
id = "3D-image",
Expand Down
Loading