# Uncomment and run this line to get a copy of the latest Klimmakoffer.jl. # run(`git clone git@github.com:klimakoffer/Klimakoffer.jl.git`) # Change into the Klimakoffer project if not already done. Adapt the path # if necessary. cd("Klimakoffer.jl") # Here we tell Julia that the current working directory (cwd) is our main project path now. push!(LOAD_PATH, pwd()) # We instantiate the project and additionally install a needed plotting library. # This may take a while. Get a cup of tea or coffee while we wait ... import Pkg Pkg.instantiate() Pkg.add("PyPlot") # You only have to this once! # Now we can use Klimkoffer and can do some nice plots along the way. using Klimakoffer using Plots pyplot(); NT = 48; mesh = Klimakoffer.Mesh() model = Klimakoffer.Model(mesh, NT) size(model.heat_capacity) # 2D matrix model.radiative_cooling_co2 model.radiative_cooling_feedback size(model.diffusion_coeff) # 2D matrix size(model.albedo) # 2D matrix # Load the input data. data = model.albedo x,y,z = Klimakoffer.apply_richardson_projection(data); title = "Surface Albedo of the Earth"; z = reverse(reverse(data),dims=1); contourf(x,y,z, clims=(0.1,0.65), levels=LinRange(0.1,0.65,500), aspect_ratio=1.0, title=title, xlabel="longitude [°]", ylabel="latitude [°]", colorbar_title="albedo", c=:bone, size=(1024,640)) size(model.solar_forcing) # 3D matrix # Read in the outline of the continents. outline = Klimakoffer.read_geography("./input/The_World_Outline.dat",128,65); xol,yol,zol = Klimakoffer.apply_richardson_projection(outline); x,y,z = Klimakoffer.apply_richardson_projection(model.solar_forcing[:,:,1]); anim = @animate for t in 1:size(model.solar_forcing,3) title = "Solar Forcing of the Earth: t = " * lpad(string(Int(floor(t*365/48))), 6, ' ') * " days"; data = model.solar_forcing[:,:,t]; z = reverse(reverse(data),dims=1); contourf(x,y,z, clims=(0,400), levels=LinRange(0,400,20), aspect_ratio=1.0, title=title, xlabel="longitude [°]", ylabel="latitude [°]", colorbar_title="scale of solar forcing", size=(1024,640)); contour!(xol,yol,zol,c=:grays); end; gif(anim, "solar_forcing.gif", fps = 7) disc = Klimakoffer.Discretization(mesh, model, NT) global_mean_temp = Klimakoffer.compute_equilibrium!(disc) temperatures = reshape(disc.annual_temperature,(128,65,NT)); # Read in the outline of the continents. outline = Klimakoffer.read_geography("./input/The_World_Outline.dat",128,65); xol,yol,zol = Klimakoffer.apply_richardson_projection(outline); x,y,z = Klimakoffer.apply_richardson_projection(temperatures[:,:,1]); cmin = -50 cmax = 50 levels = LinRange(cmin,cmax,100); anim = @animate for t in 1:size(temperatures,3) title = "Temperature Distribution of the Earth: t = " title *= lpad(string(Int(floor(t*365/48))), 5, ' ') * " days" data = temperatures[:,:,t] levels = LinRange(cmin,cmax,100) z = reverse(reverse(data),dims=1) contourf(x,y,z, clims=(cmin,cmax), levels=levels, aspect_ratio=1.0, title=title, xlabel="longitude [°]", ylabel="latitude [°]", c=:seismic, colorbar_title="temperatur [°C]", size=(1024,640)); levels = LinRange(cmin,cmax,50); contour!(x,y,z, clims=(cmin,cmax), levels=levels); contour!(xol,yol,zol,c=:grays); end; gif(anim, "temp.gif", fps = 7)