@@ -40,6 +40,27 @@ module plotting
4040 return @sprintf (" %d" ,v)
4141 end
4242
43+ # Get y-axis limits
44+ function _get_ylims (atmos:: atmosphere.Atmos_t ):: Tuple
45+ return (1e-5 * atmos. pl[1 ]/ 1.5 , 1e-5 * max (atmos. p_oboa, atmos. p_boa)* 1.5 )
46+ end
47+
48+ # Gey y-axis ticks for log10 axis scale
49+ function _get_yticks (atmos:: atmosphere.Atmos_t ):: Array
50+ ylims = _get_ylims (atmos)
51+ return 10.0 .^ round .(Int,range ( log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
52+ end
53+
54+ # Reusable plotting snippets
55+ macro _plt_pboa ()
56+ return esc (:(hline! (plt, [atmos. p_boa/ 1e5 ], color= " black" , label= L " p_s" , ls= :solid )))
57+ end
58+ macro _plt_poboa ()
59+ return esc (:(hline! (plt, [atmos. p_oboa/ 1e5 ], color= " black" , label= L " p_s^o" , ls= :dot )))
60+ end
61+
62+
63+
4364 """
4465 Plot the temperature-pressure profile.
4566 """
@@ -48,13 +69,14 @@ module plotting
4869 incl_magma:: Bool = false ,
4970 title:: String = " " )
5071
51- ylims = (1e-5 * atmos. pl[1 ]/ 1.5 , 1e-5 * atmos. pl[end ]* 1.5 )
52- yticks = 10.0 .^ round .(Int,range (log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
53-
5472 # Create plot
55- plt = plot (ylims= ylims , yticks= yticks , legend= :outertopright ,
73+ plt = plot (ylims= _get_ylims (atmos) , yticks= _get_yticks (atmos) , legend= :outertopright ,
5674 size= (size_x,size_y); plt_default... )
5775
76+ # Plot current surface pressure and original
77+ @_plt_pboa
78+ @_plt_poboa
79+
5880 # Plot phase boundary
5981 if atmos. condense_any
6082 sat_t:: Array{Float64,1} = zeros (Float64, atmos. nlev_c)
@@ -80,15 +102,15 @@ module plotting
80102
81103 # Plot tmp_magma
82104 if incl_magma
83- scatter! (plt, [atmos. tmp_magma], [atmos. pl[ end ] * 1e-5 ],
105+ scatter! (plt, [atmos. tmp_magma], [atmos. p_boa / 1e5 ],
84106 color= " cornflowerblue" , label= L " T_m" )
85107 end
86108
87109 # Plot tmp_surf
88- scatter! (plt, [atmos. tmp_surf], [atmos. pl[ end ] * 1e-5 ], color= " brown3" , label= L " T_s" )
110+ scatter! (plt, [atmos. tmp_surf], [atmos. p_boa / 1e5 ], color= " brown3" , label= L " T_s" )
89111
90112 # Plot profile
91- plot! (plt, atmos. tmpl, atmos. pl* 1e-5 , lc= " black" , lw= 2 , label= L " T(p)" )
113+ plot! (plt, atmos. tmpl, atmos. pl/ 1e5 , lc= " black" , lw= 2 , label= L " T(p)" )
92114
93115 # Decorate
94116 xlabel! (plt, " Temperature [K]" )
@@ -112,13 +134,15 @@ module plotting
112134 size_x:: Int = 500 , size_y:: Int = 400 ,
113135 title:: String = " " )
114136
115- ylims = (1e-5 * atmos. pl[1 ]/ 1.5 , 1e-5 * atmos. pl[end ]* 1.5 )
116- yticks = 10.0 .^ round .(Int,range ( log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
117-
118137 # Create plot
119- plt = plot (ylims= ylims, yticks= yticks, legend= :outertopright ,
138+ plt = plot (ylims= _get_ylims (atmos), yticks= _get_yticks (atmos),
139+ legend= :outertopright ,
120140 size= (size_x,size_y); plt_default... )
121141
142+ # Plot current surface pressure and original
143+ @_plt_pboa
144+ @_plt_poboa
145+
122146 # Plot surface
123147 scatter! (plt, [atmos. rp* 1e-3 ], [atmos. pl[end ]* 1e-5 ], color= " brown3" , label= L " P_s" )
124148
@@ -151,12 +175,9 @@ module plotting
151175 xlims = (- 1 , 101 )
152176 xticks = collect (range (start= 0.0 , stop= 100.0 , step= 10.0 ))
153177
154- ylims = (1e-5 * atmos. pl[1 ]/ 1.5 , 1e-5 * atmos. pl[end ]* 1.5 )
155- yticks = 10.0 .^ round .(Int,range ( log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
156-
157178 # Create plot
158179 plt = plot ( xlims= xlims, xticks= xticks,
159- ylims= ylims , yticks= yticks ,
180+ ylims= _get_ylims (atmos) , yticks= _get_yticks (atmos) ,
160181 legend= :outertopright , size= (size_x,size_y); plt_default... )
161182
162183 # Temperature profile for reference
@@ -195,13 +216,17 @@ module plotting
195216 la = 0.7
196217
197218 arr_P = atmos. p .* 1.0e-5 # Convert Pa to bar
198- ylims = (arr_P[1 ]/ 1.5 , arr_P[end ]* 1.5 )
199- yticks = 10.0 .^ round .(Int,range ( log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
200219
201220 # Create plot
202- plt = plot (ylims= ylims, yticks= yticks, legend= :outertopright ,
221+ plt = plot (ylims= _get_ylims (atmos), yticks= _get_yticks (atmos),
222+ legend= :outertopright ,
203223 size= (size_x,size_y); plt_default... )
204224
225+
226+ # Plot current surface pressure and original
227+ @_plt_pboa
228+ @_plt_poboa
229+
205230 # Plot log10 VMRs for each gas
206231 gas_xsurf:: Array = zeros (Float64, atmos. gas_num)
207232 gas:: String = " "
@@ -287,19 +312,23 @@ module plotting
287312 )
288313
289314 arr_P = atmos. pl .* 1.0e-5 # Convert Pa to bar
290- ylims = (arr_P[1 ]/ 1.5 , arr_P[end ]* 1.5 )
291- yticks = 10.0 .^ round .(Int,range ( log10 (ylims[1 ]), stop= log10 (ylims[2 ]), step= 1 ))
292315
293316 max_fl = log10 (max (100.0 , maximum (abs .(atmos. flux_tot)), maximum (atmos. flux_u), maximum (atmos. flux_d)))
294317 xticks_pos = unique (ceil .(Int, range ( start= 1 , stop= max_fl+ 1 , step= 1 )))
295318 xticks = unique (vcat (- 1.0 .* reverse (xticks_pos), 0.0 , xticks_pos))
296319 xlims = (- xticks_pos[end ], xticks_pos[end ])
297320 xticklabels = _intstr .(round .(Int, abs .(xticks)))
298321
299- plt = plot (legend= :outertopright , ylims= ylims, yticks= yticks,
322+ plt = plot (legend= :outertopright ,
323+ ylims= _get_ylims (atmos), yticks= _get_yticks (atmos),
300324 xticks= (xticks, xticklabels), xlims= xlims,
301325 size= (size_x,size_y); plt_default... )
302326
327+ # Plot current surface pressure and original
328+ @_plt_pboa
329+ @_plt_poboa
330+
331+
303332 col_r:: String = " #c0c0c0"
304333 col_n:: String = " #000000"
305334 col_c:: String = " #6495ed"
0 commit comments