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

Add ClimaExplorer #42

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 5 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
79 changes: 79 additions & 0 deletions ClimaExplorer/ClimaExplorer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
module ClimaExplorer

import ClimaAnalysis

import Bonito:
Observable,
App,
Slider,
Dropdown,
DOM,
Asset,
TextField,
Card,
Grid,
Label,
Styles,
Centered,
Button,
on
import WGLMakie
import GeoMakie

include("layouts.jl")

function _logo_img()

# TODO: The logo does not resize correctly
imstyle = Styles(
"display" => :block,
"position" => :relative,
"width" => "180px",
"max-width" => :none, # needs to be set so it's not overwritten by others
)
img = DOM.a(
href = "https://www.github.com/CliMA/ClimaAnalysis.jl",
DOM.img(;
src = Asset(joinpath("assets", "logo-full.svg")),
style = imstyle,
),
)
return img
end



"""
BonitoApp(path)

Return a `Bonito` `App` for data at `path`.
"""
function BonitoApp(path)
app = App(; title = "ClimaExplorer") do

# Text field to change the path
#
# TODO: width = 98% is pretty random. We should find a truly responsive with.
path_obs = TextField(path, style = Styles("width" => "98%"))

# Most of the logic is implemented in the layout.jl file. Every time path_obs
# change, the body of the web page is redrawn. This allows us to handle invalid
# states too.
body_layout = map(layout, path_obs)

img = _logo_img()
input_field = Centered(
Grid(
"Insert the path of your output data and press ENTER",
path_obs,
),
)

grid = Grid(Card(input_field), Card(img); columns = "90% 10%")

return Grid(grid, body_layout)
end
return app
end

end
14 changes: 14 additions & 0 deletions ClimaExplorer/Project.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name = "ClimaExplorer"
authors = ["Gabriele Bozzola <[email protected]>"]
version = "0.0.1"

[deps]
Bonito = "824d6782-a2ef-11e9-3a09-e5662e0c26f8"
ClimaAnalysis = "29b5916a-a76c-4e73-9657-3c8fd22e65e6"
GeoMakie = "db073c08-6b98-4ee5-b6a4-5efafb3259c6"
WGLMakie = "276b4fcb-3e11-5398-bf8b-a0c2d153d008"

[compat]
Bonito = "3"
ClimaAnalysis = "0.5.5"
GeoMakie = "0.6.5, 0.7"
10 changes: 10 additions & 0 deletions ClimaExplorer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<h1 align="center">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="assets/logo-small-white.svg" width="100px">
<source media="(prefers-color-scheme: light)" srcset="assets/logo-small.svg" width="100px">
<img alt="Shows the logo of ClimaExplorer, a compass styled with Julia's colors" src="assets/logo-small.svg">
</picture> <br>
ClimaExplorer
</h1>

`ClimaExplorer` is a tool to explore simulation outputs interactively. Please, refer to the ClimaAnalysis [documentation](https://clima.github.io/ClimaAnalysis.jl/) for more information.
12 changes: 12 additions & 0 deletions ClimaExplorer/assets/interactive.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.container {
display: flex;
}
.column {
padding: 10px;
}
.left {
flex: 0 1 20%; /* Flex-grow: 0, Flex-shrink: 1, Flex-basis: 20% */
}
.right {
flex: 1;
}
79 changes: 79 additions & 0 deletions ClimaExplorer/assets/logo-full.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions ClimaExplorer/assets/logo-small-white.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions ClimaExplorer/assets/logo-small.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions ClimaExplorer/explorer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
include(joinpath(@__DIR__, "ClimaExplorer.jl"))

import Bonito: route!, wait, Server

path = length(ARGS) >= 1 ? ARGS[1] : "."

# Create server
IPa = "127.0.0.1"
port = 8080
server = Server(IPa, port; proxy_url = "http://localhost:9384")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:
This is valid only for the remote cluster method.
If run locally, you only need server = Server(IPa, port)
OR server = Server(IPa, port; proxy_url = "http://localhost:8080")

otherwise it will return a broken pipe error

Copy link
Member Author

@Sbozzolo Sbozzolo Aug 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When run explorer.jl on my computer like this, it works

EDIT, or maybe no...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it just loses interactivity (but initial figure shows)


app = ClimaExplorer.BonitoApp(path)
route!(server, "/" => app)
println(server)
wait(server)
Loading
Loading