Skip to content

Commit

Permalink
Merge pull request #121 from gaelforget/v0p3p5b
Browse files Browse the repository at this point in the history
improve/fix plots for Hector
  • Loading branch information
gaelforget committed Jun 3, 2024
2 parents 4f5064e + f8df4f4 commit e2daf6f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
9 changes: 4 additions & 5 deletions examples/Hector.jl
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ begin
put!(tmp,demo.Hector_launch)
launch(tmp)

f,a,year,tas=ClimateModels.plot_examples(:Hector,MC,"tas")
#Legend(f[1, 2], a)
f,a,year,tas=ClimateModels.plot_examples(:Hector,MC)
Legend(f[1, 2], a)
f
end

Expand Down Expand Up @@ -206,7 +206,7 @@ myconf

# ╔═╡ 76763a71-a8d3-472a-bb27-577a88ff637c
begin
g,b,_,_=ClimateModels.plot_examples(:Hector,myMC,"tas")
g,b,_,_=ClimateModels.plot_examples(:Hector,myMC)
lines!(b,year,tas,label=MC.configuration,linewidth=3)
Legend(g[1, 2], b)
save(joinpath(pathof(MC),"tas_custom.png"), g)
Expand Down Expand Up @@ -237,7 +237,6 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
[compat]
CairoMakie = "~0.12.2"
ClimateModels = "~0.3.2"
IniFile = "~0.5.1"
PlutoUI = "~0.7.59"
Suppressor = "~0.2.7"
Expand All @@ -249,7 +248,7 @@ PLUTO_MANIFEST_TOML_CONTENTS = """
julia_version = "1.10.3"
manifest_format = "2.0"
project_hash = "065e5e239552af3898d8e5dc026e7669e3d2ba4a"
project_hash = "a2cd5f0cd8a182c7943775d0682e9bf54661ad0f"
[[deps.AbstractFFTs]]
deps = ["LinearAlgebra"]
Expand Down
5 changes: 5 additions & 0 deletions examples/Hector_module.jl
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,11 @@ function Hector_launch(x::Hector_config)

config=joinpath("inst","input",x.configuration)
@suppress run(`./src/hector $config`)

fi1=joinpath(pth,"hector","logs","temperature.log")
fi2=joinpath(pth,"hector","logs",x.configuration[1:end-4]*"_temperature.log")
@suppress cp(fi1,fi2,force=true)

cd(pth0)
end

Expand Down
17 changes: 10 additions & 7 deletions ext/ClimateModelsMakieExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -544,11 +544,11 @@ end
##

#function plot(x::Hector_config,varname="tas")
function plot_Hector(x,varname="tas")
function plot_Hector(x;varname="tas",filename="temperature.log",label="")
varname !=="tas" ? println("case not implemented yet") : nothing

pth=pathof(x)
log=readlines(joinpath(pth,"hector","logs","temperature.log"))
log=readlines(joinpath(pth,"hector","logs",filename))

ii=findall([occursin("tas=",i) for i in log])
nt=length(ii)
Expand All @@ -564,18 +564,21 @@ function plot_Hector(x,varname="tas")
f=Figure(size = (900, 600))
a = Axis(f[1, 1],xlabel="year",ylabel="degree C",
title="global atmospheric temperature anomaly")
lines!(year,tas,label=x.configuration,linewidth=4)
lab=(isempty(label) ? x.configuration : label)
lines!(year,tas,label=lab,linewidth=4)

f,a,year,tas
end

function plot_all_scenarios(store,list)
f,a,year,tas=plot_Hector(store[1],"tas")
txt=store[1].configuration[1:end-4]
f,a,year,tas=plot_Hector(store[1],filename=txt*"_temperature.log",label=txt)
for ii in 2:length(list)
_,_,_,tas=plot_Hector(store[ii],"tas")
lines!(a,year,tas,label=list,linewidth=4)
txt=store[ii].configuration[1:end-4]
_,_,_,tas=plot_Hector(store[ii],filename=txt*"_temperature.log",label=txt)
lines!(a,year,tas,label=txt,linewidth=4)
end
#Legend(f[1, 2], a)
Legend(f[1, 2], a)
return f
end

Expand Down

0 comments on commit e2daf6f

Please sign in to comment.