Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v4.4.0'
rev: 'v6.0.0'
hooks:
- id: check-added-large-files
- id: check-ast
Expand All @@ -25,21 +25,21 @@ repos:
entry: found Copier update rejection files; review them and remove them
language: fail
files: "\\.rej$"
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.263'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.15.20'
hooks:
- id: ruff
args: [ --fix, --exit-non-zero-on-fix ]
- repo: https://github.com/psf/black
rev: '23.3.0'
- repo: https://github.com/psf/black-pre-commit-mirror
rev: '26.5.1'
hooks:
- id: black
# additional to the above, apply black to doctests in source code
- repo: https://github.com/keewis/blackdoc
rev: v0.3.8
rev: v0.4.6
hooks:
- id: blackdoc
- repo: https://github.com/python-poetry/poetry
rev: '1.4.2'
rev: '2.4.1'
hooks:
- id: poetry-check
7 changes: 4 additions & 3 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
For the full list of built-in configuration values, see the documentation:
https://www.sphinx-doc.org/en/master/usage/configuration.html
"""

from functools import wraps

from sphinxcontrib_autodocgen import AutoDocGen
Expand Down Expand Up @@ -84,9 +85,9 @@
"modules": [spaemis],
"generated_source_dir": "docs/source/api",
# choose a different title for specific modules, e.g. the toplevel one
"module_title_decider": lambda modulename: "API Reference"
if modulename == "spaemis"
else modulename,
"module_title_decider": lambda modulename: (
"API Reference" if modulename == "spaemis" else modulename
),
}
]

Expand Down
1 change: 1 addition & 0 deletions scripts/downsample_input4MIPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
These downsampled values are used for testing because they are small and fast
to run
"""

import os
from glob import glob

Expand Down
1 change: 1 addition & 0 deletions scripts/downsample_inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

This results in fewer grid cells and therefore faster execution
"""

import os

import click
Expand Down
2 changes: 1 addition & 1 deletion scripts/extract_sedacs.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Extract the SEDACS population proxy
"""

import os

import rioxarray # noqa
Expand All @@ -16,7 +17,6 @@ def extract_sedac():

The SEDACS file should be downloaded manually from https://sedac.ciesin.columbia.edu/
"""
#
da = xr.open_dataset(
os.path.join(
RAW_DATA_DIR,
Expand Down
1 change: 1 addition & 0 deletions scripts/test-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Thanks https://stackoverflow.com/a/25562415/10473080
"""

import importlib
import pkgutil

Expand Down
1 change: 1 addition & 0 deletions src/spaemis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Produce a coherent set of emissions for regional air quality modelling
"""

import importlib.metadata

__version__ = importlib.metadata.version("spaemis")
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/commands/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
CLI commands
"""

from .base import cli
from .generate_command import run_generate_command # noqa
from .gse_emis_command import run_gse_command # noqa
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/commands/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Common CLI functionality
"""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/commands/generate_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
generate CLI command
"""

import io
import logging
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/commands/gse_emis_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
GSE emis CLI command
"""

import logging
import os

Expand Down
1 change: 1 addition & 0 deletions src/spaemis/commands/point_source_command.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
point-sources CLI command
"""

import logging

import click
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ def get_path(
target directory
rel_path
Path within ``output_dir``

Returns
-------
Path of the output file
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/constants.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Constants
"""

import os

OUTPUT_VERSION = "v20230421_1"
Expand Down
2 changes: 2 additions & 0 deletions src/spaemis/input_data.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Searching and loading of a local input4MIPs data archive
"""

from __future__ import annotations

import logging
Expand Down Expand Up @@ -109,6 +110,7 @@ def load(self, variable_id: str, source_id: str) -> xr.Dataset:
Variable identifier
source_id
Source identifier

Returns
-------
All of the available data for the given variable and source identifiers
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/inventory.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Loading emissions inventories
"""

from __future__ import annotations

import functools
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/main.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
CLI
"""

try:
import dotenv

Expand Down
1 change: 1 addition & 0 deletions src/spaemis/project.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
Project a set of emissions into the future according to a set of scaling methods
"""

import itertools
import logging
from collections.abc import Iterable
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/scaling/constant.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Apply a constant scale factor to the base inventory
"""

from typing import Any

import xarray as xr
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/scaling/point_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Split a timeseries of emissions across a number of points

"""

import logging
import os
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/scaling/proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

The proxy must cover the area of interest of the emissions timeseries
"""

import logging
import os
from typing import Any
Expand Down
1 change: 1 addition & 0 deletions src/spaemis/scaling/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

The proxy must cover the area of interest of the emissions timeseries
"""

import logging
from typing import Any

Expand Down
1 change: 1 addition & 0 deletions src/spaemis/unit_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

Adds H2 related units if they haven't been previously registered
"""

from __future__ import annotations

import pint
Expand Down
6 changes: 4 additions & 2 deletions src/spaemis/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
General utility functions
"""

import os
from collections.abc import Generator
from contextlib import contextmanager
Expand Down Expand Up @@ -62,7 +63,7 @@ def area_grid(lat: ArrayLike, lon: ArrayLike) -> xr.DataArray:
return xda


def earth_radius(lat: NDArray[np.float_]) -> NDArray[np.float_]:
def earth_radius(lat: NDArray[np.float64]) -> NDArray[np.float64]:
"""
Calculate radius of Earth assuming oblate spheroid

Expand Down Expand Up @@ -92,7 +93,7 @@ def earth_radius(lat: NDArray[np.float_]) -> NDArray[np.float_]:

# radius equation
# see equation 3-107 in WGS84
r: NDArray[np.float_] = (a * (1 - e2) ** 0.5) / (
r: NDArray[np.float64] = (a * (1 - e2) ** 0.5) / (
1 - (e2 * np.cos(lat_gc) ** 2)
) ** 0.5

Expand Down Expand Up @@ -206,6 +207,7 @@ def covers(dataarray: xr.DataArray, dim: str, value: float) -> bool:
Check if a dimension of a DataArray can be interpolated for a given value

If this check fails an extrapolation will be required

Parameters
----------
dataarray
Expand Down
Loading