Skip to content

Commit

Permalink
Fix ruff-format issues
Browse files Browse the repository at this point in the history
  • Loading branch information
tomvothecoder committed Jan 21, 2025
1 parent c2ceee3 commit 4eeedc1
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 31 deletions.
1 change: 1 addition & 0 deletions e3sm_diags/derivations/derivations.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
3. 'PRECC' and 'PRECL' are used to derive `PRECT` by passing the
data for these variables to the formula function 'prect()'.
"""

from collections import OrderedDict
from typing import Callable, Dict, Tuple, Union

Expand Down
1 change: 1 addition & 0 deletions e3sm_diags/derivations/formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
the arithmetic should be wrapped with `with xr.set_options(keep_attrs=True)`
to keep attributes on the resultant `xr.DataArray`.
"""

from typing import List

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions e3sm_diags/derivations/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This module defines general utilities for deriving variables, including unit
conversion functions, renaming variables, etc.
"""

import cf_units
import xarray as xr

Expand Down
19 changes: 15 additions & 4 deletions e3sm_diags/driver/annual_cycle_zonal_mean_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,14 @@ def _run_diags_annual_cycle(
parameter.regrid_method,
)

test_zonal_mean: xr.DataArray = spatial_avg(ds_test, var_key, axis=["X"], as_list=False) # type: ignore
test_zonal_mean: xr.DataArray = spatial_avg(
ds_test, var_key, axis=["X"], as_list=False
) # type: ignore
test_reg_zonal_mean: xr.DataArray = spatial_avg(
ds_test_reg, var_key, axis=["X"], as_list=False # type: ignore
ds_test_reg,
var_key,
axis=["X"],
as_list=False, # type: ignore
)

if (
Expand All @@ -156,13 +161,19 @@ def _run_diags_annual_cycle(
else:
ref_zonal_mean = spatial_avg(ds_ref, var_key, axis=["X"], as_list=False) # type: ignore
ref_reg_zonal_mean = spatial_avg(
ds_ref_reg, var_key, axis=["X"], as_list=False # type: ignore
ds_ref_reg,
var_key,
axis=["X"],
as_list=False, # type: ignore
)

else:
ref_zonal_mean = spatial_avg(ds_ref, var_key, axis=["X"], as_list=False) # type: ignore
ref_reg_zonal_mean = spatial_avg(
ds_ref_reg, var_key, axis=["X"], as_list=False # type: ignore
ds_ref_reg,
var_key,
axis=["X"],
as_list=False, # type: ignore
)

# Make a copy of dataset to preserve time dimension
Expand Down
8 changes: 2 additions & 6 deletions e3sm_diags/driver/diurnal_cycle_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,12 @@ def run_diag(parameter: DiurnalCycleParameter) -> DiurnalCycleParameter:
test_cmean,
test_amplitude,
test_maxtime,
) = composite_diurnal_cycle(
test_domain, var_key, season
) # type: ignore
) = composite_diurnal_cycle(test_domain, var_key, season) # type: ignore
(
ref_cmean,
ref_amplitude,
ref_maxtime,
) = composite_diurnal_cycle(
ref_domain, var_key, season
) # type: ignore
) = composite_diurnal_cycle(ref_domain, var_key, season) # type: ignore

parameter.var_region = region

Expand Down
1 change: 1 addition & 0 deletions e3sm_diags/driver/mp_partition_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Zhang and Yuying Zhang, with contribution from Yunpeng Shan, Jiwen Fan,
Xue Zheng and Susannah Burrows.
"""

from __future__ import annotations

import glob
Expand Down
1 change: 1 addition & 0 deletions e3sm_diags/driver/tropical_subseasonal_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Authors: Jim Benedict and Brian Medeiros
Modified by Jill Zhang to integrate into E3SM Diags.
"""

from __future__ import annotations

import glob
Expand Down
1 change: 1 addition & 0 deletions e3sm_diags/logger.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Logger module for setting up a custom logger."""

import logging
import logging.handlers
import os
Expand Down
12 changes: 6 additions & 6 deletions e3sm_diags/plot/tropical_subseasonal_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,14 @@ def _wave_frequency_plot( # noqa: C901
z = np.log10(z) # type: ignore

z.attrs["long_name"] = PlotDesc[var_name]["long_name_desc"]
z.attrs[
"method"
] = f"Follows {PlotDesc[var_name]['ref_fig_num']} methods of Wheeler and Kiladis (1999; https://doi.org/10.1175/1520-0469(1999)056<0374:CCEWAO>2.0.CO;2)"
z.attrs["method"] = (
f"Follows {PlotDesc[var_name]['ref_fig_num']} methods of Wheeler and Kiladis (1999; https://doi.org/10.1175/1520-0469(1999)056<0374:CCEWAO>2.0.CO;2)"
)

if "spec_raw" in var_name and subplot_num < 2:
z.attrs[
"ew_ratio_method"
] = "Sum of raw (not log10) symmetric spectral power for ZWNs +/- 1-3, periods 24-96 days"
z.attrs["ew_ratio_method"] = (
"Sum of raw (not log10) symmetric spectral power for ZWNs +/- 1-3, periods 24-96 days"
)
z.attrs["east_power"] = east_power.values
z.attrs["west_power"] = west_power.values
z.attrs["ew_ratio"] = ew_ratio.values
Expand Down
30 changes: 15 additions & 15 deletions e3sm_diags/viewer/default_viewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ def create_viewer(root_dir, parameters):
# }
# }
# }
ROW_INFO: OrderedDict[
str, Dict[str, Dict[str, Dict[str, Dict[str, str]]]]
] = collections.OrderedDict()
ROW_INFO: OrderedDict[str, Dict[str, Dict[str, Dict[str, Dict[str, str]]]]] = (
collections.OrderedDict()
)
# A similar dict, but for creating the lat-lon tables.
LAT_LON_TABLE_INFO: OrderedDict[
str, Dict[str, Dict[str, Dict[str, str]]]
] = collections.OrderedDict()
LAT_LON_TABLE_INFO: OrderedDict[str, Dict[str, Dict[str, Dict[str, str]]]] = (
collections.OrderedDict()
)

# Since we're only having one set for each
# create_viewer() call, this works.
Expand Down Expand Up @@ -158,16 +158,16 @@ def create_viewer(root_dir, parameters):
if set_name not in ROW_INFO:
ROW_INFO[set_name] = collections.OrderedDict()
if parameter.case_id not in ROW_INFO[set_name]:
ROW_INFO[set_name][
parameter.case_id
] = collections.OrderedDict()
ROW_INFO[set_name][parameter.case_id] = (
collections.OrderedDict()
)
if row_name not in ROW_INFO[set_name][parameter.case_id]:
ROW_INFO[set_name][parameter.case_id][
row_name
] = collections.OrderedDict()
ROW_INFO[set_name][parameter.case_id][row_name][
"descr"
] = _get_description(var, parameter)
ROW_INFO[set_name][parameter.case_id][row_name] = (
collections.OrderedDict()
)
ROW_INFO[set_name][parameter.case_id][row_name]["descr"] = (
_get_description(var, parameter)
)
# Each season has a image_path and metadata linked to it, thus we use a dict.
ROW_INFO[set_name][parameter.case_id][row_name][season] = {}
# Format the filename to support relative paths.
Expand Down
1 change: 1 addition & 0 deletions tests/integration/complete_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh
- Or: source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_anvil.sh
"""

import os

from e3sm_diags.parameter.annual_cycle_zonal_mean_parameter import ACzonalmeanParameter
Expand Down

0 comments on commit 4eeedc1

Please sign in to comment.