diff --git a/pyproject.toml b/pyproject.toml index 0f21090..cf9db89 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -51,9 +51,6 @@ exclude = ''' files = ["src", "scripts"] ignore_missing_imports = true -allow_redefinition = true -show_error_context = false -show_column_numbers = true [tool.pytest.ini_options] log_cli = true diff --git a/src/gemini3d/grid/uniform.py b/src/gemini3d/grid/uniform.py index 7d3348f..7b77741 100644 --- a/src/gemini3d/grid/uniform.py +++ b/src/gemini3d/grid/uniform.py @@ -58,14 +58,14 @@ def non_uniform1d(xmax: float, parms: list[float]): ell = parms[3] # transition length of degradation x2 = xmax - degdist - x = [dx0 / 2.0] + x = np.array([dx0 / 2.0]) # start offset from zero so we can have an even number (better for mpi) while x[-1] < xmax: dx = dx0 + dxincr * (1 / 2 + 1 / 2 * math.tanh((x[-1] - x2) / ell)) - x.append(x[-1] + dx) + x = np.append(x, x[-1] + dx) - x = np.append(-np.array(x[::-1]), x) + x = np.append(-x[::-1], x) return x @@ -78,14 +78,13 @@ def altitude_grid( if alt_max <= alt_min: raise ValueError("grid_max must be greater than grid_min") - alt = [alt_min] + alt = np.array([alt_min]) while alt[-1] < alt_max: # dalt=10+9.5*tanh((alt(i-1)-500)/150) dalt = d[0] + d[1] * math.tanh((alt[-1] - d[2]) / d[3]) - alt.append(alt[-1] + dalt) + alt = np.append(alt, alt[-1] + dalt) - alt = np.asarray(alt) if alt.size < 10: raise ValueError("grid too small") diff --git a/src/gemini3d/job.py b/src/gemini3d/job.py index 12e7e70..436bec1 100644 --- a/src/gemini3d/job.py +++ b/src/gemini3d/job.py @@ -169,22 +169,22 @@ def check_compiler(): raise EnvironmentError("Cannot find Fortran compiler e.g. Gfortran") -def check_mpiexec(mpiexec: str, gemexe: Path) -> str: +def check_mpiexec(mpiexec_name: str, gemexe: Path) -> str: """ check if specified mpiexec exists on this system. If not, error as most runs are exceedingly slow with one CPU core. """ - if not mpiexec: - mpiexec = "mpiexec" + if not mpiexec_name: + mpiexec_name = "mpiexec" mpi_root = os.environ.get("MPI_ROOT", None) if mpi_root: mpi_root += "/bin" - mpiexec = shutil.which(mpiexec, path=mpi_root) + mpiexec = shutil.which(mpiexec_name, path=mpi_root) if not mpiexec: - raise FileNotFoundError(f"Cannot find mpiexec {mpiexec}") + raise FileNotFoundError(f"Cannot find mpiexec {mpiexec_name}") ret = subprocess.run([mpiexec, "-help"], capture_output=True, text=True, timeout=5) if ret.returncode != 0: diff --git a/src/gemini3d/magcalc.py b/src/gemini3d/magcalc.py index 7069838..01b3140 100644 --- a/src/gemini3d/magcalc.py +++ b/src/gemini3d/magcalc.py @@ -93,6 +93,6 @@ def magcalc( nargs="?", default=1.5, ) - P = P.parse_args() + args = P.parse_args() - magcalc(P.direc, P.dang) + magcalc(args.direc, args.dang) diff --git a/src/gemini3d/magtools.py b/src/gemini3d/magtools.py index c73a82d..566a7a9 100644 --- a/src/gemini3d/magtools.py +++ b/src/gemini3d/magtools.py @@ -12,7 +12,7 @@ def makegrid( - direc: str, + direc: Path, dang: float = 1.5, ltheta: int = 16, lphi: int = 16, @@ -89,7 +89,7 @@ def makegrid( def makegrid_full( - direc: str, + direc: Path, ltheta: int = 16, lphi: int = 16, write_grid: bool = False, diff --git a/src/gemini3d/read.py b/src/gemini3d/read.py index 44f5a44..649a654 100644 --- a/src/gemini3d/read.py +++ b/src/gemini3d/read.py @@ -9,7 +9,6 @@ import typing as T import numpy as np -import xarray from .config import read_nml from . import find @@ -76,7 +75,7 @@ def frame( *, cfg: dict[str, T.Any] | None = None, xg: dict[str, T.Any] | None = None, -) -> xarray.Dataset: +): """ load a frame of simulation data, automatically selecting the correct functions based on simulation parameters @@ -93,6 +92,12 @@ def frame( to avoid reading config.nml xg: dict to avoid reading simgrid.*, useful to save time when reading data files in a loop + + Returns + ------- + + dat: xarray.Dataset + simulation data from this time """ # %% default variables