diff --git a/climaexplorer/libexplorer.jl b/ClimaExplorer/ClimaExplorer.jl similarity index 95% rename from climaexplorer/libexplorer.jl rename to ClimaExplorer/ClimaExplorer.jl index abbce2b9..eb40cde5 100644 --- a/climaexplorer/libexplorer.jl +++ b/ClimaExplorer/ClimaExplorer.jl @@ -1,15 +1,21 @@ +module ClimaExplorer + import ClimaAnalysis import Bonito: Observable, App, Slider, Dropdown, DOM, Server, route!, wait, Asset import CairoMakie import GeoMakie +include("layouts.jl") + function BonitoApp(path) app = App() do climastyle = Asset(joinpath(@__DIR__, "assets", "interactive.css")) + simdir = ClimaAnalysis.SimDir(path) variables = ClimaAnalysis.available_vars(simdir) |> collect vars_menu = Dropdown(variables) short_name = vars_menu.value.val + short_name = "rhoa" # TODO: Add Dropdown menus for reduction and period # reductions = ClimaAnalysis.available_reductions(simdir; short_name) |> collect @@ -63,7 +69,8 @@ function BonitoApp(path) DOM.h4("Short name"), vars_menu, DOM.h4("Reduction: ", reduction), - DOM.h4("Period: ", period), + DOM.h4("Period: ", period)), + DOM.div( DOM.h4("Time: ", time_slider.value), time_slider, DOM.h4("Altitude: ", level_slider.value), @@ -76,3 +83,5 @@ function BonitoApp(path) end return app end + +end diff --git a/climaexplorer/Project.toml b/ClimaExplorer/Project.toml similarity index 100% rename from climaexplorer/Project.toml rename to ClimaExplorer/Project.toml diff --git a/ClimaExplorer/README.md b/ClimaExplorer/README.md new file mode 100644 index 00000000..6b3fc246 --- /dev/null +++ b/ClimaExplorer/README.md @@ -0,0 +1,8 @@ +

+ + + + Shows the logo of ClimaExplorer, a compass styled with Julia's colors +
+ ClimaExplorer +

diff --git a/climaexplorer/assets/interactive.css b/ClimaExplorer/assets/interactive.css similarity index 100% rename from climaexplorer/assets/interactive.css rename to ClimaExplorer/assets/interactive.css diff --git a/ClimaExplorer/assets/logo-small-white.svg b/ClimaExplorer/assets/logo-small-white.svg new file mode 100644 index 00000000..da5888d6 --- /dev/null +++ b/ClimaExplorer/assets/logo-small-white.svg @@ -0,0 +1,69 @@ + + + + + + + + + + diff --git a/ClimaExplorer/assets/logo-small.svg b/ClimaExplorer/assets/logo-small.svg new file mode 100644 index 00000000..34f7168c --- /dev/null +++ b/ClimaExplorer/assets/logo-small.svg @@ -0,0 +1,68 @@ + + + + + + + + + + diff --git a/climaexplorer/explorer.jl b/ClimaExplorer/explorer.jl similarity index 86% rename from climaexplorer/explorer.jl rename to ClimaExplorer/explorer.jl index 47751171..244f9ba8 100644 --- a/climaexplorer/explorer.jl +++ b/ClimaExplorer/explorer.jl @@ -1,6 +1,6 @@ length(ARGS) == 1 || error("Usage: julia --project=climaexplorer explorer.jl ") -include(joinpath(@__DIR__, "libexplorer.jl")) +include(joinpath(@__DIR__, "ClimaExplorer.jl")) path = first(ARGS) @@ -15,7 +15,7 @@ server = Server( proxy_url = "http://localhost:9384" ) -app = BonitoApp(path) +app = ClimaExplorer.BonitoApp(path) route!(server, "/atmos" => app) wait(server) diff --git a/ClimaExplorer/layouts.jl b/ClimaExplorer/layouts.jl new file mode 100644 index 00000000..d97b9787 --- /dev/null +++ b/ClimaExplorer/layouts.jl @@ -0,0 +1,41 @@ +""" + spherical_shell_layout(var::ClimaAnalysis.OutputVar) + +Set up the page layout and content for the given var, assuming it is a 3D sphere. +""" +function sphere_layout(var::ClimaAnalysis.OutputVar) + time_slider = Slider(ClimaAnalysis.times(var)) + level_slider = Slider(ClimaAnalysis.altitudes(var)) + + var = map(time_slider) do time + short_name = vars_menu.value.val + # Trigger level_slidel + setindex!(level_slider, level_slider.value.val) + ClimaAnalysis.slice(get(simdir; short_name, reduction = reduction.val, period = period.val); time, z = level_slider.value.val) + end + + var = map(level_slider) do level + short_name = vars_menu.value.val + ClimaAnalysis.slice(get(simdir; short_name, reduction = reduction.val, period = period.val); time = time_slider.value.val, z = level) + end + + fig = map(var) do sliced_var + fig = CairoMakie.Figure(size=(1200, 760), fontsize=30) + ClimaAnalysis.Visualize.contour2D_on_globe!(fig, sliced_var) + # ClimaAnalysis.Visualize.plot!(fig, sliced_var) + fig + end + + return + +end + + +""" + spherical_shell_layout(var::ClimaAnalysis.OutputVar) + +Set up the page layout and content for the given var, assuming it is a (2D) spherical shell. +""" +function spherical_shell_layout(var::ClimaAnalysis.OutputVar) + time_slider = Slider(ClimaAnalysis.times(var)) +end