Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
weihuang-jedi committed Jul 29, 2022
1 parent b6aef1c commit 4c56b7d
Show file tree
Hide file tree
Showing 5 changed files with 317 additions and 3 deletions.
4 changes: 3 additions & 1 deletion genplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,12 @@ def plot(self, pvar, addmark=0, marker='x', size=3, color='green'):

msg = ('plot variable min: %s, max: %s' % (np.min(pvar), np.max(pvar)))
print(msg)
print('pvar.shape = ', pvar.shape)
print('pvar.size = ', pvar.size)

(self.x, self.y) = self.basemap(self.lon1d, self.lat1d)
#(self.x, self.y) = np.meshgrid(lon1d, lat1d)
v1d = np.reshape(pvar, (len(pvar), ))
v1d = np.reshape(pvar, (pvar.size, ))

contfill = self.basemap.contourf(self.x, self.y, v1d, tri=True,
levels=self.clevs, extend=self.extend,
Expand Down
36 changes: 36 additions & 0 deletions genps
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

set -x

case_dir=/work2/noaa/gsienkf/weihuang/jedi/case_study

output=1

var_list=(sfc_ps sfcship_ps sondes_ps)

#gridfile=regrid/lonlat_sfc-letkf-nbc.nc
gridfile=regrid/lonlat_sfc-letkf.nc
if [ ! -f ${gridfile} ]
then
cd regrid
rm -f fv3latlon.nc
#interp.sh ${case_dir}/sfc-letkf/analysis.2/increment/
interp.sh ${case_dir}/sfc-letkf/analysis/increment/
cd ..
mv regrid/fv3latlon.nc ${gridfile}
fi

for j in ${!var_list[@]}
do
obsfile=${case_dir}/sfc-letkf/gsiobs/${var_list[$j]}_obs_2020011006_0000.nc4
if [ -f ${obsfile} ]
then
python new-obs-jedi.py \
--output=${output} \
--casename=sfc-letkf_${var_list[$j]} \
--varname=T \
--gridfile=${gridfile} \
--obsfile=${obsfile}
fi
done

72 changes: 72 additions & 0 deletions showcolors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
from matplotlib.patches import Rectangle
import matplotlib.pyplot as plt
import matplotlib.colors as mcolors


def plot_colortable(colors, title, sort_colors=True, emptycols=0):

cell_width = 212
cell_height = 22
swatch_width = 48
margin = 12
topmargin = 40

# Sort colors by hue, saturation, value and name.
if sort_colors is True:
by_hsv = sorted((tuple(mcolors.rgb_to_hsv(mcolors.to_rgb(color))),
name)
for name, color in colors.items())
names = [name for hsv, name in by_hsv]
else:
names = list(colors)

n = len(names)
ncols = 4 - emptycols
nrows = n // ncols + int(n % ncols > 0)

width = cell_width * 4 + 2 * margin
height = cell_height * nrows + margin + topmargin
dpi = 72

fig, ax = plt.subplots(figsize=(width / dpi, height / dpi), dpi=dpi)
fig.subplots_adjust(margin/width, margin/height,
(width-margin)/width, (height-topmargin)/height)
ax.set_xlim(0, cell_width * 4)
ax.set_ylim(cell_height * (nrows-0.5), -cell_height/2.)
ax.yaxis.set_visible(False)
ax.xaxis.set_visible(False)
ax.set_axis_off()
ax.set_title(title, fontsize=24, loc="left", pad=10)

for i, name in enumerate(names):
row = i % nrows
col = i // nrows
y = row * cell_height

swatch_start_x = cell_width * col
text_pos_x = cell_width * col + swatch_width + 7

ax.text(text_pos_x, y, name, fontsize=14,
horizontalalignment='left',
verticalalignment='center')

ax.add_patch(
Rectangle(xy=(swatch_start_x, y-9), width=swatch_width,
height=18, facecolor=colors[name], edgecolor='0.7')
)

return fig

plot_colortable(mcolors.BASE_COLORS, "Base Colors",
sort_colors=False, emptycols=1)
plot_colortable(mcolors.TABLEAU_COLORS, "Tableau Palette",
sort_colors=False, emptycols=2)

plot_colortable(mcolors.CSS4_COLORS, "CSS Colors")

# Optionally plot the XKCD colors (Caution: will produce large figure)
# xkcd_fig = plot_colortable(mcolors.XKCD_COLORS, "XKCD Colors")
# xkcd_fig.savefig("XKCD_Colors.png")

plt.show()

203 changes: 203 additions & 0 deletions use-eva/obscoef.yaml.template.GSIHofXBc
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
diagnostics:

# Data read
# ---------
- data:
type: IodaObsSpace
datasets:
- name: experiment
filenames:
- OBSFILE
groups:
- name: ObsValue
variables: &variables [VARNAME]
- name: hofx_y_mean_xb0
- name: PreQC
- name: GsiHofXBc
- name: GsiEffectiveQC
- name: MetaData

transforms:

# Generate omb for GSI
- transform: arithmetic
new name: experiment::ObsValueMinushofx_y_mean_xb0::${variable}
equals: experiment::ObsValue::${variable}-experiment::hofx_y_mean_xb0::${variable}
for:
variable: *variables

# Generate omb for JEDI
- transform: arithmetic
new name: experiment::ObsValueMinusHofx::${variable}
equals: experiment::ObsValue::${variable}-experiment::GsiHofXBc::${variable}
for:
variable: *variables

# Generate hofx that passed QC for JEDI
- transform: accept where
new name: experiment::hofxPassedQc::${variable}
starting field: experiment::GsiHofXBc::${variable}
where:
- experiment::GsiEffectiveQC::${variable} == 0
for:
variable: *variables

# Generate GSI hofx that passed JEDI QC
- transform: accept where
new name: experiment::hofx_y_mean_xb0PassedQc::${variable}
starting field: experiment::hofx_y_mean_xb0::${variable}
where:
- experiment::GsiEffectiveQC::${variable} == 0
for:
variable: *variables

# Generate omb that passed QC for JEDI
- transform: accept where
new name: experiment::ObsValueMinushofxPassedQc::${variable}
starting field: experiment::ObsValueMinusHofx::${variable}
where:
- experiment::GsiEffectiveQC::${variable} == 0
for:
variable: *variables

# Generate omb that passed QC for GSI
- transform: accept where
new name: experiment::ObsValueMinushofx_y_mean_xb0PassedQc::${variable}
starting field: experiment::ObsValueMinushofx_y_mean_xb0::${variable}
where:
- experiment::GsiEffectiveQC::${variable} == 0
for:
variable: *variables

graphics:

# JEDI h(x) vs Observations
# -------------------------
- batch figure:
variables: *variables
figure:
layout: [1,1]
title: 'Observations vs. JEDI h(x) | CASENAME | ${variable_title}'
output name: PLOTDIR/${variable}/jedi_hofx_vs_obs_${variable}.png
plots:
- add_xlabel: 'Observation Value'
add_ylabel: 'JEDI h(x)'
add_grid:
add_legend:
loc: 'upper left'
layers:
- type: Scatter
x:
variable: experiment::ObsValue::${variable}
y:
variable: experiment::GsiHofXBc::${variable}
markersize: 5
color: 'black'
label: 'JEDI h(x) versus obs (all obs)'
- type: Scatter
x:
variable: experiment::ObsValue::${variable}
y:
variable: experiment::hofxPassedQc::${variable}
markersize: 5
color: 'red'
label: 'JEDI h(x) versus obs (passed QC in JEDI)'

# GSI h(x) vs Observations
# -------------------------
- batch figure:
variables: *variables
figure:
layout: [1,1]
title: 'Observations vs. GSI h(x) | CASENAME | ${variable_title}'
output name: PLOTDIR/${variable}/gsi_hofx_vs_obs_${variable}.png
plots:
- add_xlabel: 'Observation Value'
add_ylabel: 'GSI h(x)'
add_grid:
add_legend:
loc: 'upper left'
layers:
- type: Scatter
x:
variable: experiment::ObsValue::${variable}
y:
variable: experiment::hofx_y_mean_xb0::${variable}
markersize: 5
color: 'black'
label: 'GSI h(x) versus obs (all obs)'
- type: Scatter
x:
variable: experiment::ObsValue::${variable}
y:
variable: experiment::hofx_y_mean_xb0PassedQc::${variable}
markersize: 5
color: 'red'
label: 'GSI h(x) versus obs (passed QC in JEDI)'

# JEDI h(x) vs GSI h(x)
# ---------------------

- batch figure:
variables: *variables
figure:
layout: [1,1]
title: 'JEDI h(x) vs. GSI h(x) | CASENAME | ${variable_title}'
output name: PLOTDIR/${variable}/gsi_hofx_vs_jedi_hofx_${variable}.png
bbox_inches: 'tight'
plots:
- add_xlabel: 'GSI h(x)'
add_ylabel: 'JEDI h(x)'
add_grid:
add_legend:
loc: 'upper left'
layers:
- type: Scatter
x:
variable: experiment::hofx_y_mean_xb0::${variable}
y:
variable: experiment::GsiHofXBc::${variable}
markersize: 5
color: 'black'
label: 'JEDI h(x) versus GSI h(x)'
- type: Scatter
x:
variable: experiment::hofx_y_mean_xb0PassedQc::${variable}
y:
variable: experiment::hofxPassedQc::${variable}
markersize: 5
color: 'red'
label: 'JEDI h(x) versus GSI h(x) (passed QC in JEDI)'

# JEDI omb vs GSI omb
# ---------------------

- batch figure:
variables: *variables
figure:
layout: [1,1]
title: 'JEDI omb vs. GSI omb| CASENAME | ${variable_title}'
output name: PLOTDIR/${variable}/gsi_omb_vs_jedi_omb_${variable}.png
plots:
- add_xlabel: 'GSI observation minus h(x)'
add_ylabel: 'JEDI observation minus h(x)'
add_grid:
add_legend:
loc: 'upper left'
layers:
- type: Scatter
x:
variable: experiment::ObsValueMinushofx_y_mean_xb0::${variable}
y:
variable: experiment::ObsValueMinusHofx::${variable}
markersize: 5
color: 'black'
label: 'GSI omb vs JEDI omb (all obs)'
- type: Scatter
x:
variable: experiment::ObsValueMinushofx_y_mean_xb0PassedQc::${variable}
y:
variable: experiment::ObsValueMinushofxPassedQc::${variable}
markersize: 5
color: 'red'
label: 'GSI omb vs JEDI omb (passed QC in JEDI)'
5 changes: 3 additions & 2 deletions use-eva/ps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

casedir=/work2/noaa/gsienkf/weihuang/jedi/case_study

#caselist=(sfc-letkf sfc-letkf sfc-letkf)
caselist=(surf surf surf surf)
caselist=(sfc-letkf sfc-letkf sfc-letkf)
#caselist=(surf surf surf surf)
var_list=(sfc_ps sfcship_ps sondes_ps)
namelist=(surface_pressure surface_pressure surface_pressure)

Expand All @@ -14,6 +14,7 @@
do
echo "element $i is ${var_list[$i]}"
obsfile=${casedir}/${caselist[$i]}/obsout/${var_list[$i]}_obs_2020011006_0000.nc4
#obsfile=${casedir}/${caselist[$i]}/obsout.2/${var_list[$i]}_obs_2020011006_0000.nc4
varname=${namelist[$i]}
plotdir=${caselist[$i]}_${var_list[$i]}

Expand Down

0 comments on commit 4c56b7d

Please sign in to comment.