Skip to content

Commit e2daf6f

Browse files
authored
Merge pull request #121 from gaelforget/v0p3p5b
improve/fix plots for Hector
2 parents 4f5064e + f8df4f4 commit e2daf6f

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

examples/Hector.jl

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,8 @@ begin
114114
put!(tmp,demo.Hector_launch)
115115
launch(tmp)
116116

117-
f,a,year,tas=ClimateModels.plot_examples(:Hector,MC,"tas")
118-
#Legend(f[1, 2], a)
117+
f,a,year,tas=ClimateModels.plot_examples(:Hector,MC)
118+
Legend(f[1, 2], a)
119119
f
120120
end
121121

@@ -206,7 +206,7 @@ myconf
206206

207207
# ╔═╡ 76763a71-a8d3-472a-bb27-577a88ff637c
208208
begin
209-
g,b,_,_=ClimateModels.plot_examples(:Hector,myMC,"tas")
209+
g,b,_,_=ClimateModels.plot_examples(:Hector,myMC)
210210
lines!(b,year,tas,label=MC.configuration,linewidth=3)
211211
Legend(g[1, 2], b)
212212
save(joinpath(pathof(MC),"tas_custom.png"), g)
@@ -237,7 +237,6 @@ Suppressor = "fd094767-a336-5f1f-9728-57cf17d0bbfb"
237237
238238
[compat]
239239
CairoMakie = "~0.12.2"
240-
ClimateModels = "~0.3.2"
241240
IniFile = "~0.5.1"
242241
PlutoUI = "~0.7.59"
243242
Suppressor = "~0.2.7"
@@ -249,7 +248,7 @@ PLUTO_MANIFEST_TOML_CONTENTS = """
249248
250249
julia_version = "1.10.3"
251250
manifest_format = "2.0"
252-
project_hash = "065e5e239552af3898d8e5dc026e7669e3d2ba4a"
251+
project_hash = "a2cd5f0cd8a182c7943775d0682e9bf54661ad0f"
253252
254253
[[deps.AbstractFFTs]]
255254
deps = ["LinearAlgebra"]

examples/Hector_module.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ function Hector_launch(x::Hector_config)
7474

7575
config=joinpath("inst","input",x.configuration)
7676
@suppress run(`./src/hector $config`)
77+
78+
fi1=joinpath(pth,"hector","logs","temperature.log")
79+
fi2=joinpath(pth,"hector","logs",x.configuration[1:end-4]*"_temperature.log")
80+
@suppress cp(fi1,fi2,force=true)
81+
7782
cd(pth0)
7883
end
7984

ext/ClimateModelsMakieExt.jl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -544,11 +544,11 @@ end
544544
##
545545

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

550550
pth=pathof(x)
551-
log=readlines(joinpath(pth,"hector","logs","temperature.log"))
551+
log=readlines(joinpath(pth,"hector","logs",filename))
552552

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

569570
f,a,year,tas
570571
end
571572

572573
function plot_all_scenarios(store,list)
573-
f,a,year,tas=plot_Hector(store[1],"tas")
574+
txt=store[1].configuration[1:end-4]
575+
f,a,year,tas=plot_Hector(store[1],filename=txt*"_temperature.log",label=txt)
574576
for ii in 2:length(list)
575-
_,_,_,tas=plot_Hector(store[ii],"tas")
576-
lines!(a,year,tas,label=list,linewidth=4)
577+
txt=store[ii].configuration[1:end-4]
578+
_,_,_,tas=plot_Hector(store[ii],filename=txt*"_temperature.log",label=txt)
579+
lines!(a,year,tas,label=txt,linewidth=4)
577580
end
578-
#Legend(f[1, 2], a)
581+
Legend(f[1, 2], a)
579582
return f
580583
end
581584

0 commit comments

Comments
 (0)