diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7bf48a0..8f6c0c7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,8 @@ name: ci +env: + CMAKE_BUILD_TYPE: Release + on: push: paths: @@ -37,8 +40,8 @@ jobs: - run: pytest env: - FC: gfortran-10 - CC: gcc-10 + FC: gfortran-11 + CC: gcc-11 windows: needs: linux diff --git a/pyproject.toml b/pyproject.toml index a3e8a88..90ccf9c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,6 +3,3 @@ requires = ["setuptools", "wheel"] [tool.black] line-length = 100 - -[tool.pytest.ini_options] -addopts = "-ra -v" diff --git a/setup.cfg b/setup.cfg index e4f06de..1017768 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,6 +1,6 @@ [metadata] name = igrf -version = 13.0.0 +version = 13.0.1 author = Michael Hirsch, Ph.D. author_email = scivision@users.noreply.github.com description = IGRF13, IGRF12, IGRF11 models with simple object-oriented Python interface. @@ -44,6 +44,7 @@ lint = flake8-builtins flake8-blind-except mypy + types-python-dateutil plot = matplotlib diff --git a/src/igrf/CMakeLists.txt b/src/igrf/CMakeLists.txt index 5704cf3..3a2f180 100644 --- a/src/igrf/CMakeLists.txt +++ b/src/igrf/CMakeLists.txt @@ -1,8 +1,7 @@ -cmake_minimum_required(VERSION 3.12) -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Debug or Release") -endif() +cmake_minimum_required(VERSION 3.14...3.21) + project(igrf LANGUAGES Fortran) + enable_testing() add_executable(igrf13_driver fortran/igrf13_driver.f90 fortran/igrf13.f) diff --git a/src/igrf/base.py b/src/igrf/base.py index d663627..c39272a 100644 --- a/src/igrf/base.py +++ b/src/igrf/base.py @@ -90,7 +90,13 @@ def grid( def igrf( - time: datetime, glat: float, glon: float, alt_km: np.ndarray, *, isv: int = 0, itype: int = 1, + time: datetime, + glat: float, + glon: float, + alt_km: np.ndarray, + *, + isv: int = 0, + itype: int = 1, ) -> xarray.Dataset: """ @@ -139,7 +145,7 @@ def igrf( attrs={"time": time, "isv": isv, "itype": itype, "glat": glat, "glon": glon}, ) - decl, incl = mag_vector2incl_decl(mag.north, mag.east, mag.down) + decl, incl = mag_vector2incl_decl(mag.north.data, mag.east.data, mag.down.data) mag["incl"] = ("alt_km", incl) mag["decl"] = ("alt_km", decl) diff --git a/src/igrf/utils.py b/src/igrf/utils.py index f291e25..3649ca4 100644 --- a/src/igrf/utils.py +++ b/src/igrf/utils.py @@ -1,11 +1,11 @@ -import typing +from __future__ import annotations import datetime from dateutil.parser import parse import numpy as np # %% utility functions -def mag_vector2incl_decl(x: float, y: float, z: float) -> typing.Tuple[float, float]: +def mag_vector2incl_decl(x: float, y: float, z: float) -> tuple[float, float]: """ Inputs: ------- @@ -29,7 +29,7 @@ def mag_vector2incl_decl(x: float, y: float, z: float) -> typing.Tuple[float, fl return decl, incl -def latlon2colat(glat: float, glon: float) -> typing.Tuple[np.ndarray, np.ndarray]: +def latlon2colat(glat: float, glon: float) -> tuple[np.ndarray, np.ndarray]: # atleast_1d for iteration later colat = 90 - np.atleast_1d(glat) elon = (360 + np.atleast_1d(glon)) % 360 @@ -37,7 +37,7 @@ def latlon2colat(glat: float, glon: float) -> typing.Tuple[np.ndarray, np.ndarra return colat, elon -def latlonworldgrid(latstep: int = 5, lonstep: int = 5) -> typing.Tuple[np.ndarray, np.ndarray]: +def latlonworldgrid(latstep: int = 5, lonstep: int = 5) -> tuple[np.ndarray, np.ndarray]: lat = np.arange(-90.0, 90 + latstep, latstep) lon = np.arange(-180.0, 180 + lonstep, lonstep) glon, glat = np.meshgrid(lon, lat) @@ -45,7 +45,7 @@ def latlonworldgrid(latstep: int = 5, lonstep: int = 5) -> typing.Tuple[np.ndarr return glat, glon -def datetime2yeardec(time: typing.Union[str, datetime.datetime, datetime.date]) -> float: +def datetime2yeardec(time: str | datetime.datetime | datetime.date) -> float: """ Convert a datetime into a float. The integer part of the float should represent the year.