Skip to content

Commit

Permalink
cmake best practices compiler flags
Browse files Browse the repository at this point in the history
py37 >= annotation
  • Loading branch information
scivision committed Oct 11, 2021
1 parent 061f860 commit e12a4d1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
7 changes: 5 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: ci

env:
CMAKE_BUILD_TYPE: Release

on:
push:
paths:
Expand Down Expand Up @@ -37,8 +40,8 @@ jobs:

- run: pytest
env:
FC: gfortran-10
CC: gcc-10
FC: gfortran-11
CC: gcc-11

windows:
needs: linux
Expand Down
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,3 @@ requires = ["setuptools", "wheel"]

[tool.black]
line-length = 100

[tool.pytest.ini_options]
addopts = "-ra -v"
3 changes: 2 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = igrf
version = 13.0.0
version = 13.0.1
author = Michael Hirsch, Ph.D.
author_email = [email protected]
description = IGRF13, IGRF12, IGRF11 models with simple object-oriented Python interface.
Expand Down Expand Up @@ -44,6 +44,7 @@ lint =
flake8-builtins
flake8-blind-except
mypy
types-python-dateutil
plot =
matplotlib

Expand Down
7 changes: 3 additions & 4 deletions src/igrf/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
10 changes: 8 additions & 2 deletions src/igrf/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 5 additions & 5 deletions src/igrf/utils.py
Original file line number Diff line number Diff line change
@@ -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:
-------
Expand All @@ -29,23 +29,23 @@ 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

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)

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.
Expand Down

0 comments on commit e12a4d1

Please sign in to comment.