Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
magnusuMET committed Jan 6, 2025
1 parent e5d5dfe commit 25c32f8
Showing 1 changed file with 9 additions and 21 deletions.
30 changes: 9 additions & 21 deletions pyaerocom/io/cams2_83/reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,7 @@ def fix_coord(ds: xr.Dataset) -> xr.Dataset:
ds.longitude.attrs.update(
long_name="longitude", standard_name="longitude", units="degrees_east"
)
ds.latitude.attrs.update(
long_name="latitude", standard_name="latitude", units="degrees_north"
)
ds.latitude.attrs.update(long_name="latitude", standard_name="latitude", units="degrees_north")
return ds


Expand Down Expand Up @@ -190,9 +188,7 @@ def read_dataset(paths: list[Path], *, day: int) -> xr.Dataset:
def preprocess(ds: xr.Dataset) -> xr.Dataset:
return ds.pipe(forecast_day, day=day).pipe(fix_missing_vars)

ds = xr.open_mfdataset(
paths, preprocess=preprocess, parallel=False, chunks={"time": 24}
)
ds = xr.open_mfdataset(paths, preprocess=preprocess, parallel=False, chunks={"time": 24})
return ds.pipe(fix_coord).pipe(fix_names)


Expand Down Expand Up @@ -318,9 +314,7 @@ def run_type(self, val):
if val is None:
raise AttributeError("run_type cannot be set as None")
elif not isinstance(val, RunType):
raise AttributeError(
f"run_type cannot be set as {type(val)}, but must be a RunType"
)
raise AttributeError(f"run_type cannot be set as {type(val)}, but must be a RunType")

self._run_type = val

Expand All @@ -329,12 +323,8 @@ def filepaths(self) -> list[Path]:
"""
Path to data file
"""
if (
self.data_dir is None and self._filepaths is None
): # type:ignore[unreachable]
raise AttributeError(
"data_dir or filepaths needs to be set before accessing"
)
if self.data_dir is None and self._filepaths is None: # type:ignore[unreachable]
raise AttributeError("data_dir or filepaths needs to be set before accessing")
if self._filepaths is None:
paths = list(
model_paths(
Expand Down Expand Up @@ -422,9 +412,7 @@ def has_var(var_name):
"""
return var_name in AEROCOM_NAMES.values()

def read_var(
self, var_name: str, ts_type: str | None = None, **kwargs
) -> GriddedData:
def read_var(self, var_name: str, ts_type: str | None = None, **kwargs) -> GriddedData:
"""Load data for given variable.
Parameters
Expand Down Expand Up @@ -468,9 +456,9 @@ def read_var(
reader = ReadCAMS2_83(data_dir=data_dir, data_id=data_id)
reader.daterange = ("2021-12-01", "2021-12-04")
print(
np.unique(
reader.daterange.values.astype("datetime64[Y]").astype("int") + 1970
).astype("str")
np.unique(reader.daterange.values.astype("datetime64[Y]").astype("int") + 1970).astype(
"str"
)
)
print(reader.filepaths)
# dates = ("2021-12-01", "2021-12-04")
Expand Down

0 comments on commit 25c32f8

Please sign in to comment.