Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PE_CBL
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Stefano Serafin
PE_CBL
Commits
37ca9669
Commit
37ca9669
authored
10 months ago
by
Stefano Serafin
Browse files
Options
Downloads
Patches
Plain Diff
Big rearrangment of the code; First, experiments are run; then, optionally, figures are plotted.
parent
03401fd2
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
PE_CBL.py
+285
-255
285 additions, 255 deletions
PE_CBL.py
with
285 additions
and
255 deletions
PE_CBL.py
+
285
−
255
View file @
37ca9669
...
...
@@ -98,10 +98,10 @@ if __name__ == '__main__':
# Decide what figures to plot
fig01
=
False
fig02
=
True
fig03
=
Fals
e
fig04
=
Fals
e
fig05
=
Fals
e
fig06
=
Fals
e
fig03
=
Tru
e
fig04
=
Tru
e
fig05
=
Tru
e
fig06
=
Tru
e
fig07
=
True
fig08
=
True
...
...
@@ -110,9 +110,11 @@ if __name__ == '__main__':
opt02
=
False
# assimilation of profiles at two times
# Whether or not to run experiments without parameter estimation
# Applies only to sets B&C; no-PE run is always computed for experiments A&D
noPE_runs
=
False
# Default PE experiment
############################################################################
# Experiment A (control)
# Create a copy of the default settings
cbl_settings_A
=
dict
(
default_cbl_settings
)
da_settings_A
=
dict
(
default_da_settings
)
...
...
@@ -148,131 +150,8 @@ if __name__ == '__main__':
exp_A_noPE
=
experiment
(
da_settings_A_noPE
)
pickle
.
dump
(
exp_A_noPE
,
open
(
'
exp_A_noPE.pickle
'
,
'
wb
'
))
if
fig01
:
# Create a copy of the default settings
cbl_settings
=
dict
(
default_cbl_settings
)
# Disable parameter estimation (not used here)
cbl_settings
[
'
do_parameter_estimation
'
]
=
False
# Panel a) deterministic run using default settings
cbl_det
=
CBL
(
cbl_settings
)
cbl_det
.
initialize
(
1
)
cbl_det
.
run
(
output_full_history
=
True
)
# Panel b) sensitivity to p; use a smaller domain and higher
# resolution for better-looking plots.
zmax
=
2000
p_factors
=
[
0.5
,
1.5
,
4.5
]
cbl_settings
[
'
dz
'
]
=
25
cbl_settings
[
'
ztop
'
]
=
zmax
theta_profiles
=
[]
for
pfac
in
p_factors
:
cbl_settings
[
'
pfac
'
]
=
pfac
cbl_pf
=
CBL
(
cbl_settings
)
cbl_pf
.
initialize
(
1
)
cbl_pf
.
run
()
theta_profiles
.
append
(
cbl_pf
.
x
[:
cbl_pf
.
nz
])
# Panel c) spread induced by p
# Do a free ensemble run (ensemble size set expliclity)
cbl_settings_free
=
dict
(
default_cbl_settings
)
cbl_settings_free
[
'
perturb_ensemble_state
'
]
=
False
cbl_free
=
CBL
(
cbl_settings_free
)
cbl_free
.
initialize
(
nens
)
cbl_free
.
run
(
output_full_history
=
True
)
# Make plots
ncont
=
13
fig
,
[[
ax4
,
ax2
],[
ax1
,
ax3
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
6
)
c1
=
ax1
.
pcolormesh
(
cbl_det
.
history
[
'
time
'
]
/
3600
,
cbl_det
.
zt
,
cbl_det
.
history
[
'
theta
'
],
vmin
=
290
,
vmax
=
296
)
ax1
.
set_ylim
([
0
,
zmax
])
ax1
.
set_ylabel
(
r
'
Height (m)
'
)
ax1
.
set_xlabel
(
r
'
Time (h)
'
)
ax1
.
set_xticks
(
np
.
arange
(
4
))
ax1
.
set_title
(
r
'
c) $\overline{\theta}$ (K)
'
)
p
.
colorbar
(
c1
,
orientation
=
'
horizontal
'
)
ax1
.
contour
(
cbl_det
.
history
[
'
time
'
]
/
3600
,
cbl_det
.
zt
,
cbl_det
.
history
[
'
theta
'
],
np
.
linspace
(
cbl_det
.
theta_0
,
cbl_det
.
theta_0
+
cbl_det
.
gamma
*
zmax
,
ncont
),
colors
=
'
white
'
,
linestyles
=
'
--
'
,
linewidths
=
0.75
)
ax2
=
plot_p
(
p_factors
,
theta_profiles
,
cbl_pf
.
zt
,
None
,
ax
=
ax2
)
ax2
.
set_ylabel
(
r
'
Height (m)
'
)
ax2
.
set_xlabel
(
r
'
$\overline{\theta}$ (K)
'
)
ax2
.
set_xlim
([
291
,
297
])
ax2
.
set_ylim
([
0
,
zmax
])
ax2
.
legend
(
loc
=
4
,
frameon
=
False
)
ax2
.
set_title
(
r
'
b) $\overline{\theta}$ sensitivity to $p$
'
)
ax3
,
c3
=
plot_spread
(
cbl_free
,
ax
=
ax3
)
ax3
.
set_ylabel
(
r
'
Height (m)
'
)
ax3
.
set_title
(
r
'
d) $\sigma_\theta$ (K)
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_xticks
(
np
.
arange
(
4
))
p
.
colorbar
(
c3
,
orientation
=
'
horizontal
'
)
zoverh
=
np
.
linspace
(
0
,
1
,
101
)
for
pfac
in
p_factors
:
Koverkws
=
zoverh
*
(
1
-
zoverh
)
**
pfac
ax4
.
plot
(
Koverkws
,
zoverh
,
label
=
'
$p=%4.1f$
'
%
pfac
)
ax4
.
set_title
(
r
'
a) $K_h$ sensitivity to $p$
'
)
ax4
.
set_xlabel
(
'
$K_h/(\kappa w_s h)$
'
)
ax4
.
set_ylabel
(
'
$z/h$
'
)
ax4
.
set_xlim
([
0
,
0.5
])
ax4
.
legend
(
loc
=
4
,
frameon
=
False
)
#p.setp(ax2.get_yticklabels(), visible=False)
#p.setp(ax3.get_yticklabels(), visible=False)
fig
.
savefig
(
'
fig01.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig02
:
# Make plots
fig
,
[[
ax0
,
ax1
],
[
ax2
,
ax3
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
6
)
#
[
ax0
,
ax1
,
ax2
],
c0
,
c1
,
c2
=
plot_CBL_identifiability
(
exp_A
,
da_settings_A
[
'
obs_error_sdev_assimilate
'
][
0
],
None
,
ax
=
[
ax0
,
ax1
,
ax2
])
ax0
.
set_title
(
r
'
a) Exp. A, $\rho(p\prime\prime,y_b}$)
'
)
ax0
.
set_xlabel
(
'
Time (h)
'
)
ax0
.
set_ylabel
(
'
Height (m)
'
)
ax1
.
set_title
(
r
'
b) Exp. A, $\delta y\cdot(\sigma_{p\prime\prime}/\sigma_{y^b})$
'
)
ax1
.
set_xlabel
(
'
Time (h)
'
)
ax1
.
set_ylabel
(
'
Height (m)
'
)
ax2
.
set_title
(
r
'
c) Exp. A, $\delta p\prime\prime$
'
)
ax2
.
set_xlabel
(
'
Time (h)
'
)
ax2
.
set_ylabel
(
'
Height (m)
'
)
ax3
=
plot_CBL_PE
(
exp_A
,
None
,
ax
=
ax3
)
ax3
.
set_title
(
r
'
d) Exp. A, evolution of $p$
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
p
.
colorbar
(
c0
,
orientation
=
'
horizontal
'
)
p
.
colorbar
(
c1
,
orientation
=
'
horizontal
'
)
p
.
colorbar
(
c2
,
orientation
=
'
horizontal
'
)
#
fig
.
savefig
(
'
fig02.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig03
:
exp_A
=
pickle
.
load
(
open
(
"
exp_A.pickle
"
,
"
rb
"
))
exp_A_noPE
=
pickle
.
load
(
open
(
"
exp_A_noPE.pickle
"
,
"
rb
"
))
experiments_pe
=
[
exp_A
]
experiments_nope
=
[
exp_A_noPE
]
labels
=
[
"
Exp. A
"
]
plot_diagnostics
(
experiments_pe
,
experiments_nope
,
labels
,
'
fig03.png
'
)
if
fig04
:
########################################################################
# Experiment B1
# Create a copy of the default settings
# Then re-use the available nature run and derived information
cbl_settings_B1
=
dict
(
default_cbl_settings
)
...
...
@@ -288,6 +167,9 @@ if __name__ == '__main__':
da_settings_B1
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
# Run and save to disk
try
:
exp_B1
=
pickle
.
load
(
open
(
"
exp_B1.pickle
"
,
"
rb
"
))
except
:
exp_B1
=
experiment
(
da_settings_B1
)
setattr
(
exp_B1
,
'
label
'
,
'
B1
'
)
pickle
.
dump
(
exp_B1
,
open
(
'
exp_B1.pickle
'
,
'
wb
'
))
...
...
@@ -302,10 +184,14 @@ if __name__ == '__main__':
da_settings_B1_noPE
[
'
cbl_settings
'
]
=
cbl_settings_B1_noPE
# Run and save to disk
try
:
exp_B1_noPE
=
pickle
.
load
(
open
(
"
exp_B1_noPE.pickle
"
,
"
rb
"
))
except
:
exp_B1_noPE
=
experiment
(
da_settings_B1_noPE
)
pickle
.
dump
(
exp_B1_noPE
,
open
(
'
exp_B1_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Experiment B2
# Create a copy of the default settings
# Then re-use the available nature run and derived information
cbl_settings_B2
=
dict
(
default_cbl_settings
)
...
...
@@ -321,6 +207,9 @@ if __name__ == '__main__':
da_settings_B2
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Run and save to disk
try
:
exp_B2
=
pickle
.
load
(
open
(
"
exp_B2.pickle
"
,
"
rb
"
))
except
:
exp_B2
=
experiment
(
da_settings_B2
)
setattr
(
exp_B2
,
'
label
'
,
'
B2
'
)
pickle
.
dump
(
exp_B2
,
open
(
'
exp_B2.pickle
'
,
'
wb
'
))
...
...
@@ -335,10 +224,14 @@ if __name__ == '__main__':
da_settings_B2_noPE
[
'
cbl_settings
'
]
=
cbl_settings_B2_noPE
# Run and save to disk
try
:
exp_B2_noPE
=
pickle
.
load
(
open
(
"
exp_B2_noPE.pickle
"
,
"
rb
"
))
except
:
exp_B2_noPE
=
experiment
(
da_settings_B2_noPE
)
pickle
.
dump
(
exp_B2_noPE
,
open
(
'
exp_B2_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Experiment B3
# Create a copy of the default settings
# Then re-use the available nature run and derived information
cbl_settings_B3
=
dict
(
default_cbl_settings
)
...
...
@@ -354,6 +247,9 @@ if __name__ == '__main__':
da_settings_B3
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Run and save to disk
try
:
exp_B3
=
pickle
.
load
(
open
(
"
exp_B3.pickle
"
,
"
rb
"
))
except
:
exp_B3
=
experiment
(
da_settings_B3
)
setattr
(
exp_B3
,
'
label
'
,
'
B3
'
)
pickle
.
dump
(
exp_B3
,
open
(
'
exp_B3.pickle
'
,
'
wb
'
))
...
...
@@ -368,10 +264,14 @@ if __name__ == '__main__':
da_settings_B3_noPE
[
'
cbl_settings
'
]
=
cbl_settings_B3_noPE
# Run and save to disk
try
:
exp_B3_noPE
=
pickle
.
load
(
open
(
"
exp_B3_noPE.pickle
"
,
"
rb
"
))
except
:
exp_B3_noPE
=
experiment
(
da_settings_B3_noPE
)
pickle
.
dump
(
exp_B3_noPE
,
open
(
'
exp_B3_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Experiment B4
# Create a copy of the default settings
cbl_settings_B4
=
dict
(
default_cbl_settings
)
da_settings_B4
=
dict
(
default_da_settings
)
...
...
@@ -385,6 +285,9 @@ if __name__ == '__main__':
da_settings_B4
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Run and save to disk
try
:
exp_B4
=
pickle
.
load
(
open
(
"
exp_B4.pickle
"
,
"
rb
"
))
except
:
exp_B4
=
experiment
(
da_settings_B4
)
setattr
(
exp_B4
,
'
label
'
,
'
B4
'
)
pickle
.
dump
(
exp_B4
,
open
(
'
exp_B4.pickle
'
,
'
wb
'
))
...
...
@@ -397,46 +300,14 @@ if __name__ == '__main__':
da_settings_B4_noPE
[
'
cbl_settings
'
]
=
cbl_settings_B4_noPE
# Run and save to disk
try
:
exp_B4_noPE
=
pickle
.
load
(
open
(
"
exp_B4_noPE.pickle
"
,
"
rb
"
))
except
:
exp_B4_noPE
=
experiment
(
da_settings_B4_noPE
)
pickle
.
dump
(
exp_B4_noPE
,
open
(
'
exp_B4_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Make plots
fig
,
[[
ax1
,
ax2
],
[
ax3
,
ax4
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
4
)
#
ax1
=
plot_CBL_PE
(
exp_B1
,
None
,
ax
=
ax1
)
ax1
.
set_title
(
r
'
a) Exp. B$_1$
'
)
ax1
.
set_xlabel
(
'
Time (h)
'
)
ax1
.
set_ylabel
(
r
'
$p$
'
)
#
ax2
=
plot_CBL_PE
(
exp_B2
,
None
,
ax
=
ax2
)
ax2
.
set_title
(
r
'
b) Exp. B$_2$
'
)
ax2
.
set_xlabel
(
'
Time (h)
'
)
ax2
.
set_ylabel
(
r
'
$p$
'
)
#
ax3
=
plot_CBL_PE
(
exp_B3
,
None
,
ax
=
ax3
)
ax3
.
set_title
(
r
'
c) Exp. B$_3$
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_ylabel
(
r
'
$p$
'
)
#
ax4
=
plot_CBL_PE
(
exp_B4
,
None
,
ax
=
ax4
)
ax4
.
set_title
(
r
'
d) Exp. B$_4$
'
)
ax4
.
set_xlabel
(
'
Time (h)
'
)
ax4
.
set_ylabel
(
r
'
$p$
'
)
#
ax1
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
ax2
.
sharey
(
ax1
)
ax3
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
ax4
.
sharey
(
ax3
)
#
fig
.
savefig
(
'
fig04.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig05
:
########################################################################
# Experiment C1
# Create a copy of the default settings
cbl_settings_C1
=
dict
(
default_cbl_settings
)
da_settings_C1
=
dict
(
default_da_settings
)
...
...
@@ -452,6 +323,9 @@ if __name__ == '__main__':
da_settings_C1
[
'
cbl_settings
'
]
=
cbl_settings_C1
# Run and save to disk
try
:
exp_C1
=
pickle
.
load
(
open
(
"
exp_C1.pickle
"
,
"
rb
"
))
except
:
exp_C1
=
experiment
(
da_settings_C1
)
setattr
(
exp_C1
,
'
label
'
,
'
C1
'
)
pickle
.
dump
(
exp_C1
,
open
(
'
exp_C1.pickle
'
,
'
wb
'
))
...
...
@@ -464,10 +338,14 @@ if __name__ == '__main__':
da_settings_C1_noPE
[
'
cbl_settings
'
]
=
cbl_settings_C1_noPE
# Run and save to disk
try
:
exp_C1_noPE
=
pickle
.
load
(
open
(
"
exp_C1_noPE.pickle
"
,
"
rb
"
))
except
:
exp_C1_noPE
=
experiment
(
da_settings_C1_noPE
)
pickle
.
dump
(
exp_C1_noPE
,
open
(
'
exp_C1_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Experiment C2
# Create a copy of the default settings
cbl_settings_C2
=
dict
(
default_cbl_settings
)
da_settings_C2
=
dict
(
default_da_settings
)
...
...
@@ -483,6 +361,9 @@ if __name__ == '__main__':
da_settings_C2
[
'
cbl_settings
'
]
=
cbl_settings_C2
# Run and save to disk
try
:
exp_C2
=
pickle
.
load
(
open
(
"
exp_C2.pickle
"
,
"
rb
"
))
except
:
exp_C2
=
experiment
(
da_settings_C2
)
setattr
(
exp_C2
,
'
label
'
,
'
C2
'
)
pickle
.
dump
(
exp_C2
,
open
(
'
exp_C2.pickle
'
,
'
wb
'
))
...
...
@@ -495,11 +376,209 @@ if __name__ == '__main__':
da_settings_C2_noPE
[
'
cbl_settings
'
]
=
cbl_settings_C2_noPE
# Run and save to disk
try
:
exp_C2_noPE
=
pickle
.
load
(
open
(
"
exp_C2_noPE.pickle
"
,
"
rb
"
))
except
:
exp_C2_noPE
=
experiment
(
da_settings_C2_noPE
)
pickle
.
dump
(
exp_C2_noPE
,
open
(
'
exp_C2_noPE.pickle
'
,
'
wb
'
))
########################################################################
# Experiment D
# Create a copy of the default settings
cbl_settings_D
=
dict
(
default_cbl_settings
)
da_settings_D
=
dict
(
default_da_settings
)
# Change settings as necessary
# Changes include generation of observations, so the existing nature run
# can't be reused.
cbl_settings_D
[
'
initial_perturbed_parameters
'
]
=
exp_A
.
da
.
initial_perturbed_parameters
cbl_settings_D
[
'
perturbations_theta_amplitude
'
]
=
sigma_b_init
*
10
cbl_settings_D
[
'
Hmax
'
]
=
0.15
cbl_settings_D
[
'
is_cgrad
'
]
=
False
cbl_settings_D
[
'
simulate_error_growth
'
]
=
True
cbl_settings_D
[
'
error_growth_perturbations_amplitude
'
]
=
sigma_b_init
*
5
da_settings_D
[
'
cbl_settings
'
]
=
cbl_settings_D
da_settings_D
[
'
obs_error_sdev_generate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
5
da_settings_D
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Run and save to disk
try
:
exp_D
=
pickle
.
load
(
open
(
"
exp_D.pickle
"
,
"
rb
"
))
except
:
exp_D
=
experiment
(
da_settings_D
)
setattr
(
exp_D
,
'
label
'
,
'
D
'
)
pickle
.
dump
(
exp_D
,
open
(
'
exp_D.pickle
'
,
'
wb
'
))
# Experiment matching D, but without parameter estimation
cbl_settings_D_noPE
=
dict
(
cbl_settings_D
)
da_settings_D_noPE
=
dict
(
da_settings_D
)
cbl_settings_D_noPE
[
'
do_parameter_estimation
'
]
=
False
da_settings_D_noPE
[
'
cbl_settings
'
]
=
cbl_settings_D_noPE
try
:
exp_D_noPE
=
pickle
.
load
(
open
(
"
exp_D_noPE.pickle
"
,
"
rb
"
))
except
:
exp_D_noPE
=
experiment
(
da_settings_D_noPE
)
pickle
.
dump
(
exp_A_noPE
,
open
(
'
exp_D_noPE.pickle
'
,
'
wb
'
))
########################################################################
if
fig01
:
# Create a copy of the default settings
cbl_settings
=
dict
(
default_cbl_settings
)
# Disable parameter estimation (not used here)
cbl_settings
[
'
do_parameter_estimation
'
]
=
False
# Panel a) deterministic run using default settings
cbl_det
=
CBL
(
cbl_settings
)
cbl_det
.
initialize
(
1
)
cbl_det
.
run
(
output_full_history
=
True
)
# Panel b) sensitivity to p; use a smaller domain and higher
# resolution for better-looking plots.
zmax
=
2000
p_factors
=
[
0.5
,
1.5
,
4.5
]
cbl_settings
[
'
dz
'
]
=
25
cbl_settings
[
'
ztop
'
]
=
zmax
theta_profiles
=
[]
for
pfac
in
p_factors
:
cbl_settings
[
'
pfac
'
]
=
pfac
cbl_pf
=
CBL
(
cbl_settings
)
cbl_pf
.
initialize
(
1
)
cbl_pf
.
run
()
theta_profiles
.
append
(
cbl_pf
.
x
[:
cbl_pf
.
nz
])
# Panel c) spread induced by p
# Do a free ensemble run (ensemble size set expliclity)
cbl_settings_free
=
dict
(
default_cbl_settings
)
cbl_settings_free
[
'
perturb_ensemble_state
'
]
=
False
cbl_free
=
CBL
(
cbl_settings_free
)
cbl_free
.
initialize
(
nens
)
cbl_free
.
run
(
output_full_history
=
True
)
# Make plots
ncont
=
13
fig
,
[[
ax4
,
ax2
],[
ax1
,
ax3
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
6
)
c1
=
ax1
.
pcolormesh
(
cbl_det
.
history
[
'
time
'
]
/
3600
,
cbl_det
.
zt
,
cbl_det
.
history
[
'
theta
'
],
vmin
=
290
,
vmax
=
296
)
ax1
.
set_ylim
([
0
,
zmax
])
ax1
.
set_ylabel
(
r
'
Height (m)
'
)
ax1
.
set_xlabel
(
r
'
Time (h)
'
)
ax1
.
set_xticks
(
np
.
arange
(
4
))
ax1
.
set_title
(
r
'
c) $\overline{\theta}$ (K)
'
)
p
.
colorbar
(
c1
,
orientation
=
'
horizontal
'
)
ax1
.
contour
(
cbl_det
.
history
[
'
time
'
]
/
3600
,
cbl_det
.
zt
,
cbl_det
.
history
[
'
theta
'
],
np
.
linspace
(
cbl_det
.
theta_0
,
cbl_det
.
theta_0
+
cbl_det
.
gamma
*
zmax
,
ncont
),
colors
=
'
white
'
,
linestyles
=
'
--
'
,
linewidths
=
0.75
)
ax2
=
plot_p
(
p_factors
,
theta_profiles
,
cbl_pf
.
zt
,
None
,
ax
=
ax2
)
ax2
.
set_ylabel
(
r
'
Height (m)
'
)
ax2
.
set_xlabel
(
r
'
$\overline{\theta}$ (K)
'
)
ax2
.
set_xlim
([
291
,
297
])
ax2
.
set_ylim
([
0
,
zmax
])
ax2
.
legend
(
loc
=
4
,
frameon
=
False
)
ax2
.
set_title
(
r
'
b) $\overline{\theta}$ sensitivity to $p$
'
)
ax3
,
c3
=
plot_spread
(
cbl_free
,
ax
=
ax3
)
ax3
.
set_ylabel
(
r
'
Height (m)
'
)
ax3
.
set_title
(
r
'
d) $\sigma_\theta$ (K)
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_xticks
(
np
.
arange
(
4
))
p
.
colorbar
(
c3
,
orientation
=
'
horizontal
'
)
zoverh
=
np
.
linspace
(
0
,
1
,
101
)
for
pfac
in
p_factors
:
Koverkws
=
zoverh
*
(
1
-
zoverh
)
**
pfac
ax4
.
plot
(
Koverkws
,
zoverh
,
label
=
'
$p=%4.1f$
'
%
pfac
)
ax4
.
set_title
(
r
'
a) $K_h$ sensitivity to $p$
'
)
ax4
.
set_xlabel
(
'
$K_h/(\kappa w_s h)$
'
)
ax4
.
set_ylabel
(
'
$z/h$
'
)
ax4
.
set_xlim
([
0
,
0.5
])
ax4
.
legend
(
loc
=
4
,
frameon
=
False
)
#p.setp(ax2.get_yticklabels(), visible=False)
#p.setp(ax3.get_yticklabels(), visible=False)
fig
.
savefig
(
'
fig01.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig02
:
fig
,
[[
ax0
,
ax1
],
[
ax2
,
ax3
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
6
)
#
[
ax0
,
ax1
,
ax2
],
c0
,
c1
,
c2
=
plot_CBL_identifiability
(
exp_A
,
da_settings_A
[
'
obs_error_sdev_assimilate
'
][
0
],
None
,
ax
=
[
ax0
,
ax1
,
ax2
])
ax0
.
set_title
(
r
'
a) Exp. A, $\rho(p\prime\prime,y_b}$)
'
)
ax0
.
set_xlabel
(
'
Time (h)
'
)
ax0
.
set_ylabel
(
'
Height (m)
'
)
ax1
.
set_title
(
r
'
b) Exp. A, $\delta y\cdot(\sigma_{p\prime\prime}/\sigma_{y^b})$
'
)
ax1
.
set_xlabel
(
'
Time (h)
'
)
ax1
.
set_ylabel
(
'
Height (m)
'
)
ax2
.
set_title
(
r
'
c) Exp. A, $\delta p\prime\prime$
'
)
ax2
.
set_xlabel
(
'
Time (h)
'
)
ax2
.
set_ylabel
(
'
Height (m)
'
)
ax3
=
plot_CBL_PE
(
exp_A
,
None
,
ax
=
ax3
)
ax3
.
set_title
(
r
'
d) Exp. A, evolution of $p$
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
p
.
colorbar
(
c0
,
orientation
=
'
horizontal
'
)
p
.
colorbar
(
c1
,
orientation
=
'
horizontal
'
)
p
.
colorbar
(
c2
,
orientation
=
'
horizontal
'
)
#
fig
.
savefig
(
'
fig02.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig03
:
exp_A
=
pickle
.
load
(
open
(
"
exp_A.pickle
"
,
"
rb
"
))
exp_A_noPE
=
pickle
.
load
(
open
(
"
exp_A_noPE.pickle
"
,
"
rb
"
))
experiments_pe
=
[
exp_A
]
experiments_nope
=
[
exp_A_noPE
]
labels
=
[
"
Exp. A
"
]
plot_diagnostics
(
experiments_pe
,
experiments_nope
,
labels
,
'
fig03.png
'
)
if
fig04
:
fig
,
[[
ax1
,
ax2
],
[
ax3
,
ax4
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
4
)
#
ax1
=
plot_CBL_PE
(
exp_B1
,
None
,
ax
=
ax1
)
ax1
.
set_title
(
r
'
a) Exp. B$_1$
'
)
ax1
.
set_xlabel
(
'
Time (h)
'
)
ax1
.
set_ylabel
(
r
'
$p$
'
)
#
ax2
=
plot_CBL_PE
(
exp_B2
,
None
,
ax
=
ax2
)
ax2
.
set_title
(
r
'
b) Exp. B$_2$
'
)
ax2
.
set_xlabel
(
'
Time (h)
'
)
ax2
.
set_ylabel
(
r
'
$p$
'
)
#
ax3
=
plot_CBL_PE
(
exp_B3
,
None
,
ax
=
ax3
)
ax3
.
set_title
(
r
'
c) Exp. B$_3$
'
)
ax3
.
set_xlabel
(
'
Time (h)
'
)
ax3
.
set_ylabel
(
r
'
$p$
'
)
#
ax4
=
plot_CBL_PE
(
exp_B4
,
None
,
ax
=
ax4
)
ax4
.
set_title
(
r
'
d) Exp. B$_4$
'
)
ax4
.
set_xlabel
(
'
Time (h)
'
)
ax4
.
set_ylabel
(
r
'
$p$
'
)
#
ax1
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
ax2
.
sharey
(
ax1
)
ax3
.
set_yticks
([
0
,
1
,
2
,
3
,
4
,
5
])
ax4
.
sharey
(
ax3
)
#
fig
.
savefig
(
'
fig04.png
'
,
format
=
'
png
'
,
dpi
=
300
)
p
.
close
(
fig
)
if
fig05
:
fig
,
[
ax1
,
ax2
]
=
p
.
subplots
(
1
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
2
)
#
...
...
@@ -550,29 +629,6 @@ if __name__ == '__main__':
if
fig07
:
# Create a copy of the default settings
cbl_settings_D
=
dict
(
default_cbl_settings
)
da_settings_D
=
dict
(
default_da_settings
)
# Change settings as necessary
# Changes include generation of observations, so the existing nature run
# can't be reused.
cbl_settings_D
[
'
initial_perturbed_parameters
'
]
=
exp_A
.
da
.
initial_perturbed_parameters
cbl_settings_D
[
'
perturbations_theta_amplitude
'
]
=
sigma_b_init
*
10
cbl_settings_D
[
'
Hmax
'
]
=
0.15
cbl_settings_D
[
'
is_cgrad
'
]
=
False
cbl_settings_D
[
'
simulate_error_growth
'
]
=
True
cbl_settings_D
[
'
error_growth_perturbations_amplitude
'
]
=
sigma_b_init
*
10
da_settings_D
[
'
cbl_settings
'
]
=
cbl_settings_D
da_settings_D
[
'
obs_error_sdev_generate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
5
da_settings_D
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Run and save to disk
exp_D
=
experiment
(
da_settings_D
)
setattr
(
exp_D
,
'
label
'
,
'
D
'
)
pickle
.
dump
(
exp_D
,
open
(
'
exp_D.pickle
'
,
'
wb
'
))
# Make plots
fig
,
[[
ax0
,
ax1
],[
ax2
,
ax3
]]
=
p
.
subplots
(
2
,
2
,
constrained_layout
=
True
)
fig
.
set_size_inches
(
6
,
6
)
#
...
...
@@ -600,41 +656,15 @@ if __name__ == '__main__':
if
fig08
:
# Create a copy of the default settings
cbl_settings_D
=
dict
(
default_cbl_settings
)
da_settings_D
=
dict
(
default_da_settings
)
# Change settings as necessary
# Changes include generation of observations, so the existing nature run
# can't be reused.
cbl_settings_D
[
'
initial_perturbed_parameters
'
]
=
exp_A
.
da
.
initial_perturbed_parameters
cbl_settings_D
[
'
perturbations_theta_amplitude
'
]
=
sigma_b_init
*
10
cbl_settings_D
[
'
Hmax
'
]
=
0.15
cbl_settings_D
[
'
is_cgrad
'
]
=
False
cbl_settings_D
[
'
simulate_error_growth
'
]
=
True
cbl_settings_D
[
'
error_growth_perturbations_amplitude
'
]
=
sigma_b_init
*
10
da_settings_D
[
'
cbl_settings
'
]
=
cbl_settings_D
da_settings_D
[
'
obs_error_sdev_generate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
da_settings_D
[
'
obs_error_sdev_assimilate
'
]
=
np
.
ones
(
nobs
)
*
sigma_o_as
*
10
# Experiment matching D, but without parameter estimation
cbl_settings_D_noPE
=
dict
(
cbl_settings_D
)
da_settings_D_noPE
=
dict
(
da_settings_D
)
cbl_settings_D_noPE
[
'
do_parameter_estimation
'
]
=
False
da_settings_D_noPE
[
'
cbl_settings
'
]
=
cbl_settings_D_noPE
exp_D
=
pickle
.
load
(
open
(
"
exp_D.pickle
"
,
"
rb
"
))
try
:
exp_D_noPE
=
pickle
.
load
(
open
(
"
exp_D_noPE.pickle
"
,
"
rb
"
))
except
:
exp_D_noPE
=
experiment
(
da_settings_D_noPE
)
pickle
.
dump
(
exp_A_noPE
,
open
(
'
exp_D_noPE.pickle
'
,
'
wb
'
))
experiments_pe
=
[
exp_A
]
experiments_nope
=
[
exp_A_noPE
]
labels
=
[
"
Exp. A
"
]
plot_diagnostics
(
experiments_pe
,
experiments_nope
,
labels
,
'
fig08a.png
'
)
experiments_pe
=
[
exp_D
]
experiments_nope
=
[
exp_D_noPE
]
labels
=
[
"
Exp. D
"
]
plot_diagnostics
(
experiments_pe
,
experiments_nope
,
labels
,
'
fig08.png
'
)
plot_diagnostics
(
experiments_pe
,
experiments_nope
,
labels
,
'
fig08d.png
'
)
if
opt01
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment