Skip to content

Commit 75aeb3d

Browse files
committed
Address mypy issues
1 parent f354152 commit 75aeb3d

File tree

6 files changed

+18
-20
lines changed

6 files changed

+18
-20
lines changed

e3sm_diags/derivations/formulas.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def qsat(temp: xr.DataArray, surfp: xr.DataArray) -> xr.DataArray:
7575

7676
# Calculation of saturation water vapour pressure (sat_wvp) from Teten's
7777
# formula/
78-
sat_wvp: xr.DataArray = a1 * np.exp(a3 * (temp - T0) / (temp - a4)) # type: ignore
78+
sat_wvp: xr.DataArray = a1 * np.exp(a3 * (temp - T0) / (temp - a4))
7979

8080
# Calculation of saturation specific humidity at 2m qsat (equal to huss)
8181
# with units g/kg.

e3sm_diags/driver/tc_analysis_driver.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ def run_diag(parameter: TCAnalysisParameter) -> TCAnalysisParameter:
8686
ref_data = collections.OrderedDict()
8787

8888
test_data["metrics"] = generate_tc_metrics_from_te_stitch_file(test_te_file)
89-
test_data["cyclone_density"] = test_cyclones_hist # type: ignore
90-
test_data["aew_density"] = test_aew_hist # type: ignore
89+
test_data["cyclone_density"] = test_cyclones_hist
90+
test_data["aew_density"] = test_aew_hist
9191
test_num_years = int(test_end_yr) - int(test_start_yr) + 1
9292
test_data["aew_num_years"] = test_num_years # type: ignore
9393
test_data["cyclone_num_years"] = test_num_years # type: ignore
@@ -119,8 +119,8 @@ def run_diag(parameter: TCAnalysisParameter) -> TCAnalysisParameter:
119119
# Note the refactor included subset that was missed in original implementation
120120
ref_aew_hist = xr.open_dataset(ref_aew_file).sel()["density"]
121121
ref_data["metrics"] = generate_tc_metrics_from_te_stitch_file(ref_te_file)
122-
ref_data["cyclone_density"] = ref_cyclones_hist # type: ignore
123-
ref_data["aew_density"] = ref_aew_hist # type: ignore
122+
ref_data["cyclone_density"] = ref_cyclones_hist
123+
ref_data["aew_density"] = ref_aew_hist
124124
ref_num_years = int(ref_end_yr) - int(ref_start_yr) + 1
125125
ref_data["aew_num_years"] = ref_num_years # type: ignore
126126
ref_data["cyclone_num_years"] = ref_num_years # type: ignore
@@ -140,9 +140,9 @@ def run_diag(parameter: TCAnalysisParameter) -> TCAnalysisParameter:
140140
ref_aew_hist = xr.open_dataset(ref_aew_file).sel(
141141
lat=slice(0, 35), lon=slice(180, 360)
142142
)["density"]
143-
ref_data["cyclone_density"] = ref_cyclones_hist # type: ignore
143+
ref_data["cyclone_density"] = ref_cyclones_hist
144144
ref_data["cyclone_num_years"] = 40 # type: ignore
145-
ref_data["aew_density"] = ref_aew_hist # type: ignore
145+
ref_data["aew_density"] = ref_aew_hist
146146
# Question, should the num_years = 5?
147147
ref_data["aew_num_years"] = 1 # type: ignore
148148
parameter.ref_name = "Observation"

e3sm_diags/driver/utils/dataset_xr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -918,7 +918,7 @@ def _get_dataset_with_derivation_func(
918918
func_args = [ds[var].copy() for var in src_var_keys]
919919

920920
if func in FUNC_NEEDS_TARGET_VAR:
921-
func_args = [target_var_key] + func_args # type: ignore # pragma: nocover
921+
func_args = [target_var_key] + func_args # pragma: nocover
922922

923923
# If the target variable key contains a wildcard, there are can be
924924
# N number of function arguments. For the cases, we need to pass the

e3sm_diags/driver/utils/zwf_functions.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ def resolveWavesHayashi(varfft: xr.DataArray, nDayWin: int, spd: int) -> xr.Data
336336
varspacetime = np.full(nshape, np.nan, dtype=type(varfft))
337337
# first two are the negative wavenumbers (westward), second two are the positive wavenumbers (eastward)
338338
logging.debug(
339-
f"[Hayashi] Assign values into array. Notable numbers: mlon//2={mlon//2}, N//2={N//2}"
339+
f"[Hayashi] Assign values into array. Notable numbers: mlon//2={mlon // 2}, N//2={N // 2}"
340340
)
341341
varspacetime[..., 0 : mlon // 2, 0 : N // 2] = varfft[
342342
..., mlon // 2 : 0 : -1, N // 2 :
@@ -354,8 +354,8 @@ def resolveWavesHayashi(varfft: xr.DataArray, nDayWin: int, spd: int) -> xr.Data
354354
# Create the real power spectrum pee = sqrt(real^2+imag^2)^2
355355
logging.debug("calculate power")
356356
pee = (
357-
np.abs(varspacetime)
358-
) ** 2 # JJB: abs(a+bi) = sqrt(a**2 + b**2), which is what is done in NCL's resolveWavesHayashi
357+
(np.abs(varspacetime)) ** 2
358+
) # JJB: abs(a+bi) = sqrt(a**2 + b**2), which is what is done in NCL's resolveWavesHayashi
359359
logging.debug("put into DataArray")
360360
# add meta data for use upon return
361361
wave = np.arange(-mlon // 2, (mlon // 2) + 1, 1, dtype=int)
@@ -374,9 +374,9 @@ def resolveWavesHayashi(varfft: xr.DataArray, nDayWin: int, spd: int) -> xr.Data
374374
if (c != "wavenumber") and (c != "frequency"):
375375
ocoords[c] = varfft[c]
376376
elif c == "wavenumber":
377-
ocoords["wavenumber"] = wave # type: ignore
377+
ocoords["wavenumber"] = wave
378378
elif c == "frequency":
379-
ocoords["frequency"] = freq # type: ignore
379+
ocoords["frequency"] = freq
380380
pee = xr.DataArray(pee, dims=odims, coords=ocoords)
381381
return pee
382382

@@ -616,9 +616,7 @@ def spacetime_power(
616616
return z_final
617617

618618

619-
def genDispersionCurves(
620-
nWaveType=6, nPlanetaryWave=50, rlat=0, Ahe=[50, 25, 12]
621-
): # noqa: C901
619+
def genDispersionCurves(nWaveType=6, nPlanetaryWave=50, rlat=0, Ahe=[50, 25, 12]): # noqa: C901
622620
"""
623621
Function to derive the shallow water dispersion curves. Closely follows NCL version.
624622

e3sm_diags/plot/taylor_diagram.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ def __init__(self, refstd, fig=None, rect=111, label="_"):
4949
tf2 = GF.DictFormatter(dict(gl2_ticks))
5050

5151
# Standard deviation axis extent
52-
self.smin = min(gl2_num) # type: ignore
52+
self.smin = min(gl2_num)
5353
# self.smax = 1.5*self.refstd
54-
self.smax = max(gl2_num) # type: ignore
54+
self.smax = max(gl2_num)
5555

5656
ghelper = FA.GridHelperCurveLinear(
5757
tr,

e3sm_diags/plot/tropical_subseasonal_plot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,10 @@ def _wave_frequency_plot( # noqa: C901
339339
print("west_power: %12.5f" % west_power)
340340
print("ew_ratio: %12.5f\n" % ew_ratio)
341341

342-
z = np.log10(z) # type: ignore
342+
z = np.log10(z)
343343

344344
if "spec_background" in var_name and subplot_num < 2:
345-
z = np.log10(z) # type: ignore
345+
z = np.log10(z)
346346

347347
z.attrs["long_name"] = PlotDesc[var_name]["long_name_desc"]
348348
z.attrs["method"] = (

0 commit comments

Comments
 (0)