Skip to content

Commit

Permalink
Fix small errors in the arctic_ocean diagnostic (#1722)
Browse files Browse the repository at this point in the history
* fix 2 errors in the arctic_ocean diagnostic

* fix cm import

* fix provenance error for the latest esmvalcore master
  • Loading branch information
koldunovn committed Jul 20, 2020
1 parent e9ab24b commit bcfed57
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions esmvaltool/diag_scripts/arctic_ocean/plotting.py
Expand Up @@ -223,7 +223,7 @@ def hofm_plot(cfg, plot_params):
plt.tight_layout()
# generate the path to the output file
plot_params['basedir'] = cfg['plot_dir']
plot_params['ori_file'] = [ifilename]
plot_params['ori_file'] = ifilename
plot_params['areacello'] = None
plot_params['mmodel'] = None

Expand Down Expand Up @@ -336,7 +336,7 @@ def tsplot_plot(cfg, plot_params):
data_type='tsplot')
plt.savefig(pltoutname, dpi=100)
plot_params['basedir'] = cfg['plot_dir']
plot_params['ori_file'] = [ifilename_t]
plot_params['ori_file'] = ifilename_t
plot_params['areacello'] = None
plot_params['mmodel'] = None

Expand Down Expand Up @@ -451,7 +451,7 @@ def plot_profile(cfg, plot_params):
plt.gca().invert_yaxis()

plot_params['basedir'] = cfg['plot_dir']
plot_params['ori_file'] = [ifilename]
plot_params['ori_file'] = ifilename
plot_params['areacello'] = None
plot_params['mmodel'] = None

Expand Down Expand Up @@ -590,7 +590,7 @@ def plot2d_original_grid(cfg, plot_params):
data_type=plot_type)

plot_params['basedir'] = cfg['plot_dir']
plot_params['ori_file'] = [ifilename]
plot_params['ori_file'] = ifilename
plot_params['areacello'] = None
plot_params['mmodel'] = None
plot_params['region'] = "Global"
Expand Down Expand Up @@ -753,7 +753,7 @@ def plot2d_bias(cfg, plot_params):
str(int(target_depth))))

plot_params['basedir'] = cfg['plot_dir']
plot_params['ori_file'] = [ifilename]
plot_params['ori_file'] = ifilename
plot_params['areacello'] = None
plot_params['mmodel'] = None
plot_params['region'] = "Global"
Expand Down
20 changes: 13 additions & 7 deletions esmvaltool/diag_scripts/arctic_ocean/utils.py
Expand Up @@ -7,13 +7,14 @@
import os
import shutil

import cmocean.cm as cmo
import matplotlib as mpl
import matplotlib.cm as cm
import numpy as np
import pyproj
import seawater as sw
from cdo import Cdo
from cmocean import cm as cmo
from matplotlib import cm
from matplotlib import pylab as plt

from esmvaltool.diag_scripts.shared import ProvenanceLogger

Expand Down Expand Up @@ -202,8 +203,8 @@ def dens_back(smin, smax, tmin, tmax):
xdim = round((smax - smin) / 0.1 + 1, 0)
ydim = round((tmax - tmin) + 1, 0)

ti_size = np.linspace(tmin, tmax, ydim * 10)
si_size = np.linspace(smin, smax, xdim * 10)
ti_size = np.linspace(tmin, tmax, int(ydim * 10))
si_size = np.linspace(smin, smax, int(xdim * 10))

si2d, ti2d = np.meshgrid(si_size, ti_size)

Expand All @@ -223,8 +224,8 @@ def get_cmap(cmap_name):

if cmap_name in cmo.cmapnames:
colormap = cmo.cmap_d[cmap_name]
elif cmap_name in cm.datad:
colormap = cm.get_cmap(cmap_name)
elif cmap_name in plt.colormaps():
colormap = plt.get_cmap(cmap_name)
elif cmap_name == "custom_salinity1":
colormap = shiftedcolormap(cm.get_cmap("cubehelix3"),
start=0,
Expand Down Expand Up @@ -311,13 +312,18 @@ def get_provenance_record(attributes, data_type, file_type):
else:
caption = "None"

if isinstance(attributes['ori_file'], str):
ancestor_files = [attributes['ori_file'], attributes['areacello']]
else:
ancestor_files = ["No_ancestor_file"]

record = {
'caption': caption,
'region': attributes['region'],
'authors': ['koldunov_nikolay'],
'references': [
'contact_authors',
],
'ancestors': [attributes['ori_file'], attributes['areacello']]
'ancestors': ancestor_files
}
return record

0 comments on commit bcfed57

Please sign in to comment.