Add forecast tutorial #1193
Add forecast tutorial #1193
4 fail, 3 skipped, 288 pass in 3m 44s
Annotations
Check warning on line 0 in climada_petals.hazard.rf_glofas.test.test_transform_ops.TestTransformOps
github-actions / Petals / Unit Test Results (3.12)
test_flood_depth (climada_petals.hazard.rf_glofas.test.test_transform_ops.TestTransformOps) failed
climada_petals/tests_xml/tests.xml [took 10s]
Raw output
TypeError: ufunc 'interpolate' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
self = <test_transform_ops.TestTransformOps testMethod=test_flood_depth>
def test_flood_depth(self):
"""Test 'flood_depth' operation"""
# Create dummy datasets
ones = np.ones((4, 3), dtype="float")
da_flood_maps = xr.DataArray(
data=[ones, ones * 10, ones * 100],
dims=["return_period", "longitude", "latitude"],
coords=dict(
return_period=[1, 10, 100],
longitude=np.arange(4),
latitude=np.arange(3),
),
)
x = np.arange(4)
y = np.arange(3)
core_dim_1 = np.arange(3)
core_dim_2 = np.arange(2)
shape = (x.size, y.size, core_dim_1.size, core_dim_2.size)
values = np.array(
list(range(x.size * y.size * core_dim_1.size * core_dim_2.size)),
dtype="float",
)
values = values.reshape(shape) + self.rng.uniform(-0.1, 0.1, size=shape)
values.flat[0] = 101 # Above max
values.flat[1] = 0.1 # Below min
da_return_period = xr.DataArray(
data=values,
dims=["longitude", "latitude", "core_dim_1", "core_dim_2"],
coords=dict(
longitude=x, latitude=y, core_dim_1=core_dim_1, core_dim_2=core_dim_2
),
).astype(np.float32)
> da_result = flood_depth(da_return_period, da_flood_maps)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
climada_petals/hazard/rf_glofas/test/test_transform_ops.py:493:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada_petals/hazard/rf_glofas/transform_ops.py:753: in flood_depth
out = xr.apply_ufunc(
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/site-packages/xarray/computation/apply_ufunc.py:1267: in apply_ufunc
return apply_dataarray_vfunc(
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/site-packages/xarray/computation/apply_ufunc.py:310: in apply_dataarray_vfunc
result_var = func(*data_vars)
^^^^^^^^^^^^^^^^
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/site-packages/xarray/computation/apply_ufunc.py:818: in apply_variable_ufunc
result_data = func(*input_data)
^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <numba._GUFunc 'interpolate'>
args = (array([[[[100. , 1. ],
[ 1.92883193, 3.08972979],
[ 3.96236634, 4.98466539]],...100.]],
[[ 1., 10., 100.],
[ 1., 10., 100.],
[ 1., 10., 100.]]]), array([ 1, 10, 100]))
kwargs = {}
def __call__(self, *args, **kwargs):
# If compilation is disabled OR it is NOT a dynamic gufunc
# call the underlying gufunc
if self._frozen or not self.is_dynamic:
# Do not unwrap the ufunc if the argument is a wrapper that will
# potentially pickle the ufunc after it receives it in
# __array_ufunc__. The same logic in theory should be replicated
# for reduce(), outer(), etc., but they're not implemented in dask.
if args and _is_array_wrapper(args[0]):
return args[0].__array_ufunc__(
self, "__call__", *args, **kwargs
)
else:
> return self.ufunc(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
E TypeError: ufunc 'interpolate' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/site-packages/numba/np/ufunc/gufunc.py:263: TypeError
Check warning on line 0 in climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestFuncs
github-actions / Petals / Unit Test Results (3.12)
test_load_topography (climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestFuncs) failed
climada_petals/tests_xml/tests.xml [took 36s]
Raw output
RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
> subprocess.check_output(cmd, stderr=subprocess.STDOUT)
climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:119:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/home/runner/micromamba/envs/climada_env_3.12/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/home/runner/climada/data/geoclaw/src'), ...],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <Popen: returncode: 1 args: ['/home/runner/micromamba/envs/climada_env_3.12/...>
stdout = b'Obtaining clawpack from git+https://github.com/clawpack/clawpack.git@v5.9.2#egg=clawpack\n Cloning https://github.c...x94\x80> clawpack\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout (seconds) is given and the process takes too long,
a TimeoutExpired exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/home/runner/micromamba/envs/climada_env_3.12/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/home/runner/climada/data/geoclaw/src'), '--no-build-isolation', '-e', 'git+https://github.com/clawpack/clawpack.git@v5.9.2#egg=clawpack']' returned non-zero exit status 1.
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestFuncs testMethod=test_load_topography>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_load_topography(self):
"""Test _load_topography function"""
# depends on the "clawpack" Python package, so make sure to have a working setup first:
> setup_clawpack()
climada_petals/hazard/tc_surge_geoclaw/test/test_geoclaw_runner.py:99:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
LOGGER.warning(
"pip install failed with return code %d and stdout:", exc.returncode
)
print(exc.output.decode("utf-8"))
> raise RuntimeError(
"pip install failed with return code %d (see output above)."
" Make sure that a Fortran compiler (e.g. gfortran) is available on "
"your machine before using tc_surge_geoclaw!"
) from exc
E RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:125: RuntimeError
github-actions / Petals / Unit Test Results (3.12)
test_init (climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestRunner) failed
climada_petals/tests_xml/tests.xml [took 1s]
Raw output
ModuleNotFoundError: No module named 'clawpack'
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_geoclaw_runner.TestRunner testMethod=test_init>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_init(self):
"""Test object initialization"""
# track and centroids are taken from the integration test
track = xr.Dataset(
{
"radius_max_wind": ("time", [15.0, 15, 15, 15, 15, 17, 20, 20]),
"radius_oci": ("time", [202.0, 202, 202, 202, 202, 202, 202, 202]),
"max_sustained_wind": ("time", [105.0, 97, 90, 85, 80, 72, 65, 66]),
"central_pressure": (
"time",
[944.0, 950, 956, 959, 963, 968, 974, 975],
),
"time_step": ("time", np.full((8,), 3, dtype=np.float64)),
},
coords={
"time": np.arange(
"2010-02-05T09:00",
"2010-02-06T09:00",
np.timedelta64(3, "h"),
dtype="datetime64[ns]",
),
"lat": (
"time",
[-26.33, -25.54, -24.79, -24.05, -23.35, -22.7, -22.07, -21.50],
),
"lon": (
"time",
[
-147.27,
-148.0,
-148.51,
-148.95,
-149.41,
-149.85,
-150.27,
-150.56,
],
),
},
attrs={
"sid": "2010029S12177_test",
},
)
centroids = np.array(
[
[-23.8908, -149.8048],
[-23.8628, -149.7431],
[-23.7032, -149.3850],
[-23.7183, -149.2211],
[-23.5781, -149.1434],
[-23.5889, -148.8824],
[-23.2351, -149.9070],
[-23.2049, -149.7927],
]
)
time_offset = track["time"].values[3]
areas = {
"period": (track["time"].values[0], track["time"].values[-1]),
"time_mask": np.ones_like(track["time"].values, dtype=bool),
"time_mask_buffered": np.ones_like(track["time"].values, dtype=bool),
"wind_area": (-151.0, -25.0, -147.0, -22.0),
"landfall_area": (-150.0, -24.0, -148.0, -23.0),
"surge_areas": [
(-150.0, -24.3, -149.0, -23.0),
(-149.0, -24.0, -148.0, -22.6),
],
"centroid_mask": np.ones_like(centroids[:, 0], dtype=bool),
}
topo_path = _test_bathymetry_tif()
with tempfile.TemporaryDirectory() as base_dir:
base_dir = pathlib.Path(base_dir)
> runner = GeoClawRunner(
base_dir, track, time_offset, areas, centroids, topo_path
)
climada_petals/hazard/tc_surge_geoclaw/test/test_geoclaw_runner.py:219:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:205: in __init__
self.write_rundata()
climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:325: in write_rundata
if not self._read_rundata():
^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <climada_petals.hazard.tc_surge_geoclaw.geoclaw_runner.GeoClawRunner object at 0x7f84d1073f50>
def _read_rundata(self) -> bool:
"""Read rundata object from files, return whether it was succesful
Returns
-------
bool
"""
# pylint: disable=import-outside-toplevel
> import clawpack.amrclaw.data
E ModuleNotFoundError: No module named 'clawpack'
climada_petals/hazard/tc_surge_geoclaw/geoclaw_runner.py:343: ModuleNotFoundError
github-actions / Petals / Unit Test Results (3.12)
test_init (climada_petals.hazard.tc_surge_geoclaw.test.test_tc_surge_geoclaw.TestHazardInit) failed
climada_petals/tests_xml/tests.xml [took 8s]
Raw output
RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
> subprocess.check_output(cmd, stderr=subprocess.STDOUT)
climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:119:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/subprocess.py:466: in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
input = None, capture_output = False, timeout = None, check = True
popenargs = (['/home/runner/micromamba/envs/climada_env_3.12/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/home/runner/climada/data/geoclaw/src'), ...],)
kwargs = {'stderr': -2, 'stdout': -1}
process = <Popen: returncode: 1 args: ['/home/runner/micromamba/envs/climada_env_3.12/...>
stdout = b'Obtaining clawpack from git+https://github.com/clawpack/clawpack.git@v5.9.2#egg=clawpack\n Updating /home/runner/cl...x94\x80> clawpack\n\nnote: This is an issue with the package mentioned above, not pip.\nhint: See above for details.\n'
stderr = None, retcode = 1
def run(*popenargs,
input=None, capture_output=False, timeout=None, check=False, **kwargs):
"""Run command with arguments and return a CompletedProcess instance.
The returned instance will have attributes args, returncode, stdout and
stderr. By default, stdout and stderr are not captured, and those attributes
will be None. Pass stdout=PIPE and/or stderr=PIPE in order to capture them,
or pass capture_output=True to capture both.
If check is True and the exit code was non-zero, it raises a
CalledProcessError. The CalledProcessError object will have the return code
in the returncode attribute, and output & stderr attributes if those streams
were captured.
If timeout (seconds) is given and the process takes too long,
a TimeoutExpired exception will be raised.
There is an optional argument "input", allowing you to
pass bytes or a string to the subprocess's stdin. If you use this argument
you may not also use the Popen constructor's "stdin" argument, as
it will be used internally.
By default, all communication is in bytes, and therefore any "input" should
be bytes, and the stdout and stderr will be bytes. If in text mode, any
"input" should be a string, and stdout and stderr will be strings decoded
according to locale encoding, or by "encoding" if set. Text mode is
triggered by setting any of text, encoding, errors or universal_newlines.
The other arguments are the same as for the Popen constructor.
"""
if input is not None:
if kwargs.get('stdin') is not None:
raise ValueError('stdin and input arguments may not both be used.')
kwargs['stdin'] = PIPE
if capture_output:
if kwargs.get('stdout') is not None or kwargs.get('stderr') is not None:
raise ValueError('stdout and stderr arguments may not be used '
'with capture_output.')
kwargs['stdout'] = PIPE
kwargs['stderr'] = PIPE
with Popen(*popenargs, **kwargs) as process:
try:
stdout, stderr = process.communicate(input, timeout=timeout)
except TimeoutExpired as exc:
process.kill()
if _mswindows:
# Windows accumulates the output in a single blocking
# read() call run on child threads, with the timeout
# being done in a join() on those threads. communicate()
# _after_ kill() is required to collect that and add it
# to the exception.
exc.stdout, exc.stderr = process.communicate()
else:
# POSIX _communicate already populated the output so
# far into the TimeoutExpired exception.
process.wait()
raise
except: # Including KeyboardInterrupt, communicate handled that.
process.kill()
# We don't call process.wait() as .__exit__ does that for us.
raise
retcode = process.poll()
if check and retcode:
> raise CalledProcessError(retcode, process.args,
output=stdout, stderr=stderr)
E subprocess.CalledProcessError: Command '['/home/runner/micromamba/envs/climada_env_3.12/bin/python', '-m', 'pip', 'install', '--src', PosixPath('/home/runner/climada/data/geoclaw/src'), '--no-build-isolation', '-e', 'git+https://github.com/clawpack/clawpack.git@v5.9.2#egg=clawpack']' returned non-zero exit status 1.
../../../../micromamba/envs/climada_env_3.12/lib/python3.12/subprocess.py:571: CalledProcessError
The above exception was the direct cause of the following exception:
self = <climada_petals.hazard.tc_surge_geoclaw.test.test_tc_surge_geoclaw.TestHazardInit testMethod=test_init>
@unittest.skipIf(sys.platform.startswith("win"), "does not run on Windows")
def test_init(self):
"""Test TCSurgeGeoClaw basic object properties"""
# use dummy track that is too weak to actually produce surge
track = xr.Dataset(
{
"radius_max_wind": ("time", np.full((8,), 20.0)),
"radius_oci": ("time", np.full((8,), 200.0)),
"max_sustained_wind": ("time", np.full((8,), 30.0)),
"central_pressure": ("time", np.full((8,), 990.0)),
"time_step": ("time", np.full((8,), 3, dtype=np.float64)),
"basin": ("time", np.full((8,), "SPW")),
},
coords={
"time": np.arange(
"2010-02-05",
"2010-02-06",
np.timedelta64(3, "h"),
dtype="datetime64[ns]",
),
"lat": ("time", np.linspace(-26.33, -21.5, 8)),
"lon": ("time", np.linspace(-147.27, -150.56, 8)),
},
attrs={
"sid": "2010029S12177_test_dummy",
"name": "Dummy",
"orig_event_flag": True,
"category": 0,
},
)
tracks = TCTracks()
tracks.data = [track, track]
topo_path = _test_bathymetry_tif()
# first run, with automatic centroids
centroids = tracks.generate_centroids(res_deg=0.1, buffer_deg=5.5)
> haz = TCSurgeGeoClaw.from_tc_tracks(tracks, centroids, topo_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
climada_petals/hazard/tc_surge_geoclaw/test/test_tc_surge_geoclaw.py:84:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
climada_petals/hazard/tc_surge_geoclaw/tc_surge_geoclaw.py:253: in from_tc_tracks
setup_clawpack()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
version = 'v5.9.2', overwrite = False
def setup_clawpack(version: str = CLAWPACK_VERSION, overwrite: bool = False) -> None:
"""Install the specified version of clawpack if not already present
Parameters
----------
version : str, optional
A git (short or long) hash, branch name or tag.
overwrite : bool, optional
If ``True``, perform a fresh install even if an existing installation is found.
Defaults to ``False``.
"""
if sys.platform.startswith("win"):
raise RuntimeError(
"The TCSurgeGeoClaw feature only works on Mac and Linux since Windows is not"
"supported by the GeoClaw package."
)
path, git_ver = clawpack_info()
if overwrite or (
path is None or version not in git_ver and version not in git_ver[0]
):
LOGGER.info("Installing Clawpack version %s", version)
pkg = f"git+{CLAWPACK_GIT_URL}@{version}#egg=clawpack"
cmd = [
sys.executable,
"-m",
"pip",
"install",
"--src",
CLAWPACK_SRC_DIR,
"--no-build-isolation",
"-e",
pkg,
]
try:
subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as exc:
LOGGER.warning(
"pip install failed with return code %d and stdout:", exc.returncode
)
print(exc.output.decode("utf-8"))
> raise RuntimeError(
"pip install failed with return code %d (see output above)."
" Make sure that a Fortran compiler (e.g. gfortran) is available on "
"your machine before using tc_surge_geoclaw!"
) from exc
E RuntimeError: pip install failed with return code %d (see output above). Make sure that a Fortran compiler (e.g. gfortran) is available on your machine before using tc_surge_geoclaw!
climada_petals/hazard/tc_surge_geoclaw/setup_clawpack.py:125: RuntimeError