Skip to content

Commit

Permalink
#3177 review. Avoid more magic numbers.
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrobodas committed Oct 13, 2023
1 parent 015eec3 commit 000206c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions esmvaltool/diag_scripts/iht_toa/single_model_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def var_name_constraint(var_name):

def call_poisson(flux_cube, latitude='latitude', longitude='longitude'):
"""Top-level function that calls the Poisson solver for source cube."""
earth_radius = 6371e3 # Earth's radius in m
if flux_cube.coord(latitude).bounds is None:
flux_cube.coord(latitude).guess_bounds()
if flux_cube.coord(longitude).bounds is None:
Expand All @@ -108,7 +109,7 @@ def call_poisson(flux_cube, latitude='latitude', longitude='longitude'):

logger.info("Calling spherical_poisson")
sphpo = SphericalPoisson(logger,
source=data * (6371e3**2.0),
source=data * (earth_radius**2.0),
tolerance=2.0e-4)
sphpo.solve()
sphpo.calc_mht()
Expand Down Expand Up @@ -293,6 +294,7 @@ def mht_symmetry_metrics(self):
Produce 12-month rolling means for all monthly time time series
of MHT.
"""
petaunit = 1.0e15
for mht_series in self.mht_rolling_mean:
time_coord = mht_series.coord('time')
ntime = time_coord.shape[0]
Expand All @@ -304,21 +306,21 @@ def mht_symmetry_metrics(self):
# Create the cubes for each metric
long_name = f"symmetry_hemisphere_of_{mht_series.long_name}"
var_name = f"s_hem_{mht_series.var_name}"
cube_h = iris.cube.Cube(hem / 1.0e15,
cube_h = iris.cube.Cube(hem / petaunit,
long_name=long_name,
var_name=var_name,
units="PW",
dim_coords_and_dims=[(time_coord, 0)])
long_name = f"symmetry_tropics_of_{mht_series.long_name}"
var_name = f"s_tro_{mht_series.var_name}"
cube_t = iris.cube.Cube(trop / 1.0e15,
cube_t = iris.cube.Cube(trop / petaunit,
long_name=long_name,
var_name=var_name,
units="PW",
dim_coords_and_dims=[(time_coord, 0)])
long_name = f"symmetry_extratropics_of_{mht_series.long_name}"
var_name = f"s_ext_{mht_series.var_name}"
cube_e = iris.cube.Cube(extratrop / 1.0e15,
cube_e = iris.cube.Cube(extratrop / petaunit,
long_name=long_name,
var_name=var_name,
units="PW",
Expand Down

0 comments on commit 000206c

Please sign in to comment.