-from compass.testcase import TestCase
-from compass.landice.tests.calving_dt_convergence.run_model import RunModel
+import matplotlib.cm
+import matplotlib.pyplot as plt
+import netCDF4
# from compass.validate import compare_variables # not currently used
import numpy
-import netCDF4
-import matplotlib.pyplot as plt
-import matplotlib.cm
+
+from compass.landice.tests.calving_dt_convergence.run_model import RunModel
+from compass.testcase import TestCase
@@ -146,7 +147,7 @@
Source code for compass.landice.tests.calving_dt_convergence.dt_convergence_
test_group : compass.landice.tests.calving_dt_convergence.CalvingDtConvergence
The test group that this test case belongs to
- """
+ """ # noqa: E501
self.name = f'calving_dt_convergence_test_{mesh}_{calving}_{velo}'
subdir = f'{mesh}.{calving}.{velo}'
super().__init__(test_group=test_group, name=self.name, subdir=subdir)
@@ -198,7 +199,8 @@ Source code for compass.landice.tests.calving_dt_convergence.dt_convergence_
ax[3].set_ylabel('# warnings', color='c')
ax2 = ax[3].twinx()
ax2.set_ylabel('fraction with warnings', color='g')
- colors = matplotlib.cm.jet(numpy.linspace(0, 1, len(self.fractions)))
+ jet = matplotlib.colormaps['jet']
+ colors = jet(numpy.linspace(0, 1, len(self.fractions)))
nWarn = numpy.zeros([len(self.fractions)])
nTimesteps = numpy.zeros([len(self.fractions)])
@@ -212,7 +214,7 @@ Source code for compass.landice.tests.calving_dt_convergence.dt_convergence_
ax[0].plot(yr[1:], calv[1:], '-', label=f'{frac:.2f}',
color=colors[i])
- ax[1].plot(yr[1:], (calv[1:]*deltat[1:]).cumsum(), '-',
+ ax[1].plot(yr[1:], (calv[1:] * deltat[1:]).cumsum(), '-',
color=colors[i])
ratio = f.variables['dtCalvingCFLratio'][:]
@@ -228,7 +230,7 @@ Source code for compass.landice.tests.calving_dt_convergence.dt_convergence_
nWarn[i] = logcontents.count("WARNING: Failed to ablate")
nTimesteps[i] = logcontents.count("Starting timestep number")
ax[3].plot(frac, nWarn[i], 'co')
- ax2.plot(frac, nWarn[i]/nTimesteps[i], 'gx')
+ ax2.plot(frac, nWarn[i] / nTimesteps[i], 'gx')
f.close()
i += 1
diff --git a/latest/_modules/compass/landice/tests/eismint2/standard_experiments/visualize.html b/latest/_modules/compass/landice/tests/eismint2/standard_experiments/visualize.html
index 51a9c14c89..2284e0382b 100644
--- a/latest/_modules/compass/landice/tests/eismint2/standard_experiments/visualize.html
+++ b/latest/_modules/compass/landice/tests/eismint2/standard_experiments/visualize.html
@@ -114,8 +114,9 @@
Source code for compass.landice.tests.eismint2.standard_experiments.visualize
import datetime
-import netCDF4
+
import matplotlib.pyplot as plt
+import netCDF4
import numpy as np
from scipy.interpolate import griddata
@@ -138,7 +139,7 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
----------
test_case : compass.landice.tests.eismint2.standard_experiments.StandardExperiments
The test case this step belongs to
- """
+ """ # noqa: E501
super().__init__(test_case=test_case, name='visualize')
@@ -196,8 +197,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
# open supplied MPAS output file and get variables needed
filein = netCDF4.Dataset(filename, 'r')
- xCell = filein.variables['xCell'][:]/1000.0
- yCell = filein.variables['yCell'][:]/1000.0
+ xCell = filein.variables['xCell'][:] / 1000.0
+ yCell = filein.variables['yCell'][:] / 1000.0
xtime = filein.variables['xtime'][:]
nCells = len(filein.dimensions['nCells'])
nVertLevels = len(filein.dimensions['nVertLevels'])
@@ -229,16 +230,17 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
# make an educated guess about how big the markers should be.
if nCells**0.5 < 100.0:
- markersize = max(int(round(3600.0/(nCells**0.5))), 1)
+ markersize = max(int(round(3600.0 / (nCells**0.5))), 1)
# use hexes if the points are big enough, otherwise just dots
markershape = 'h'
else:
- markersize = max(int(round(1800.0/(nCells**0.5))), 1)
+ markersize = max(int(round(1800.0 / (nCells**0.5))), 1)
markershape = '.'
logger.info('Using a markersize of {}'.format(markersize))
fig = plt.figure(1, facecolor='w')
- fig.suptitle('Payne et al. Fig. 1, 3, 6, 9, or 11', fontsize=10, fontweight='bold')
+ fig.suptitle('Payne et al. Fig. 1, 3, 6, 9, or 11', fontsize=10,
+ fontweight='bold')
iceIndices = np.where(thickness[timelev, :] > 10.0)[0]
plt.scatter(xCell[iceIndices], yCell[iceIndices], markersize,
@@ -264,7 +266,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
plt.savefig('EISMINT2-{}-basaltemp.png'.format(experiment), dpi=150)
# ================
- # STEADY STATE MAPS - panels b and c are switched and with incorrect units in the paper
+ # STEADY STATE MAPS - panels b and c are switched and with incorrect
+ # units in the paper
# ================
fig = plt.figure(2, facecolor='w', figsize=(12, 6), dpi=72)
fig.suptitle('Payne et al. Fig. 2 or 4', fontsize=10, fontweight='bold')
@@ -278,7 +281,7 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
edgecolors='none')
# add contours of ice thickness over the top
- contour_intervals = np.linspace(0.0, 5000.0, int(5000.0/250.0)+1)
+ contour_intervals = np.linspace(0.0, 5000.0, int(5000.0 / 250.0) + 1)
_contour_mpas(thickness[timelev, :], nCells, xCell, yCell,
contour_levs=contour_intervals)
@@ -293,8 +296,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
flux = np.zeros((nCells,))
for k in range(nVertLevels):
- speedLevel = (uReconstructX[timelev, :, k:k+2].mean(axis=1)**2 +
- uReconstructY[timelev, :, k:k+2].mean(axis=1)**2)**0.5
+ speedLevel = (uReconstructX[timelev, :, k:k + 2].mean(axis=1)**2 +
+ uReconstructY[timelev, :, k:k + 2].mean(axis=1)**2)**0.5
flux += speedLevel * thickness[timelev, :] * layerThicknessFractions[k]
plt.scatter(xCell[iceIndices], yCell[iceIndices], markersize,
@@ -302,8 +305,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
edgecolors='none')
# add contours over the top
- contour_intervals = np.linspace(0.0, 20.0, 11)
- _contour_mpas(flux * 3600.0*24.0*365.0 / 10000.0, nCells, xCell, yCell,
+ contour_intervals = np.linspace(0.0, 20.0, 11)
+ _contour_mpas(flux * 3600.0 * 24.0 * 365.0 / 10000.0, nCells, xCell, yCell,
contour_levs=contour_intervals)
ax.set_aspect('equal')
plt.title('Final flux (m$^2$ a$^{-1}$ / 10000)')
@@ -325,7 +328,7 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
if flwa[timelev, :, :].max() > 0.0:
# NOT SURE WHICH LEVEL FLWA SHOULD COME FROM - so taking column average
_contour_mpas(
- flwa[timelev, :, :].mean(axis=1) * 3600.0*24.0*365.0 / 1.0e-17,
+ flwa[timelev, :, :].mean(axis=1) * 3600.0 * 24.0 * 365.0 / 1.0e-17,
nCells, xCell, yCell)
ax.set_aspect('equal')
# Note: the paper's figure claims units of 10$^{-25}$ Pa$^{-3}$ a$^{-1}$
@@ -341,7 +344,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
# DIVIDE EVOLUTION TIME SERIES
# ================
fig = plt.figure(3, facecolor='w')
- fig.suptitle('Payne et al. Fig. 5, 7, or 8', fontsize=10, fontweight='bold')
+ fig.suptitle('Payne et al. Fig. 5, 7, or 8', fontsize=10,
+ fontweight='bold')
# get indices for given time
if experiment == 'b':
@@ -358,14 +362,15 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
# panel a - thickness
fig.add_subplot(211)
timeInd = np.nonzero(years <= endTime)[0][0:]
- plt.plot(years[timeInd]/1000.0, thickness[timeInd, divideIndex], 'k.-')
+ plt.plot(years[timeInd] / 1000.0, thickness[timeInd, divideIndex], 'k.-')
plt.ylabel('Thickness (m)')
# panel b - basal temperature
fig.add_subplot(212)
# skip the first index cause basalTemperature isn't calculated then
timeInd = np.nonzero(years <= endTime)[0][1:]
- plt.plot(years[timeInd]/1000.0, basalTemperature[timeInd, divideIndex], 'k.-')
+ plt.plot(years[timeInd] / 1000.0, basalTemperature[timeInd, divideIndex],
+ 'k.-')
plt.ylabel('Basal temperature (K)')
plt.xlabel('Time (kyr)')
@@ -422,8 +427,8 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
'min/mean/max of community', fontsize=10, fontweight='bold')
fig.add_subplot(151)
- volume = ((thickness[timelev, iceIndices] * areaCell[iceIndices]).sum()
- / 1000.0**3 / 10.0**6)
+ volume = ((thickness[timelev, iceIndices] * areaCell[iceIndices]).sum() /
+ 1000.0**3 / 10.0**6)
# benchmark results
plt.plot(np.zeros((3,)), bench['volume'], 'k*')
if bench['stattype'] == 'relative':
@@ -600,7 +605,7 @@ Source code for compass.landice.tests.eismint2.standard_experiments.visualiz
if len(contour_levs) == 1:
im = plt.contour(xi, yi, zi)
else:
- im = plt.contour(xi, yi, zi, contour_levs, cmap=plt.cm.jet)
+ im = plt.contour(xi, yi, zi, contour_levs, cmap=plt.get_cmap('jet'))
# to see the raw data on top
# plt.scatter(xCell, yCell, c=temperature[timelev,:,-1], s=100,
diff --git a/latest/_modules/compass/ocean/tests/global_convergence/cosine_bell/analysis.html b/latest/_modules/compass/ocean/tests/global_convergence/cosine_bell/analysis.html
index 33d2e1a1ae..21cca7c4dd 100644
--- a/latest/_modules/compass/ocean/tests/global_convergence/cosine_bell/analysis.html
+++ b/latest/_modules/compass/ocean/tests/global_convergence/cosine_bell/analysis.html
@@ -256,21 +256,20 @@ Source code for compass.ocean.tests.global_convergence.cosine_bell.analysis<
# find time since the beginning of run
ds = xr.open_dataset(f'{mesh_name}_output.nc')
for j in range(len(ds.xtime)):
- tt = str(ds.xtime[j].values)
- tt.rfind('_')
- DY = float(tt[10:12]) - 1
- if DY == pd:
+ time_string = str(np.strings.decode(ds.xtime[j].values))
+ day = float(time_string[8:10]) - 1
+ if day == pd:
sliceTime = j
break
- HR = float(tt[13:15])
- MN = float(tt[16:18])
- t = 86400.0 * DY + HR * 3600. + MN
+ hour = float(time_string[11:13])
+ min = float(time_string[14:16])
+ t = 86400.0 * day + hour * 3600. + min
# find new location of blob center
# center is based on equatorial velocity
- R = init.sphere_radius
- distTrav = 2.0 * 3.14159265 * R / (86400.0 * pd) * t
+ r = init.sphere_radius
+ distTrav = 2.0 * np.pi * r / (86400.0 * pd) * t
# distance in radians is
- distRad = distTrav / R
+ distRad = distTrav / r
newLon = lonCent + distRad
if newLon > 2.0 * np.pi:
newLon -= 2.0 * np.pi
@@ -279,12 +278,12 @@ Source code for compass.ocean.tests.global_convergence.cosine_bell.analysis<
tracer = np.zeros_like(init.tracer1[0, :, 0].values)
latC = init.latCell.values
lonC = init.lonCell.values
- temp = R * np.arccos(np.sin(latCent) * np.sin(latC) +
- np.cos(latCent) * np.cos(latC) * np.cos(
- lonC - newLon))
+ temp = r * np.arccos(np.sin(latCent) * np.sin(latC) +
+ (np.cos(latCent) * np.cos(latC) *
+ np.cos(lonC - newLon)))
mask = temp < radius
tracer[mask] = psi0 / 2.0 * (
- 1.0 + np.cos(3.1415926 * temp[mask] / radius))
+ 1.0 + np.cos(np.pi * temp[mask] / radius))
# oad forward mode data
tracerF = ds.tracer1[sliceTime, :, 0].values
@@ -292,7 +291,7 @@ Source code for compass.ocean.tests.global_convergence.cosine_bell.analysis<
init.close()
ds.close()
- return rmseValue, init.dims['nCells']
+ return rmseValue, init.sizes['nCells']