Skip to content

Commit 323fc9b

Browse files
authored
fix issues in storm.py (#42)
1 parent 20d46e8 commit 323fc9b

File tree

1 file changed

+2
-19
lines changed

1 file changed

+2
-19
lines changed

src/python/geoclaw/surge/storm.py

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@
3636
"""
3737

3838
import sys
39-
# import os
4039
import argparse
4140
import datetime
4241
import warnings
4342
from pathlib import Path
4443

4544
import numpy as np
4645
import pandas as pd
46+
import xarray as xr
4747

4848
import clawpack.geoclaw.units as units
4949
import clawpack.clawutil.data as clawdata
@@ -600,13 +600,6 @@ def read_ibtracs(self, path, sid=None, storm_name=None, year=None, start_date=No
600600
value error is risen.
601601
"""
602602

603-
# imports that you don't need for other read functions
604-
try:
605-
import xarray as xr
606-
except ImportError as e:
607-
print("IBTrACS currently requires xarray to work.")
608-
raise e
609-
610603
# only allow one method for specifying storms
611604
if (sid is not None) and ((storm_name is not None) or (year is not None)):
612605
raise ValueError(
@@ -771,10 +764,7 @@ def read_ibtracs_processed(self, path, sid, start_date=None):
771764
value error is risen.
772765
"""
773766

774-
import xarray as xr
775-
776-
engine, backend_kwargs = _set_engine_kwargs(path)
777-
with xr.open_dataset(path, engine=engine, backend_kwargs=backend_kwargs) as ds:
767+
with xr.open_dataset(path) as ds:
778768
# match on sid
779769
ds = ds.sel(storm=ds.sid == sid).load().squeeze()
780770

@@ -2019,12 +2009,6 @@ def fill_rad_w_other_source(t, storm_targ, storm_fill, var, interp_kwargs={}):
20192009
... max_wind_radius_fill = fill_mwr)
20202010
"""
20212011

2022-
try:
2023-
import xarray as xr
2024-
except ImportError as e:
2025-
print("fill_rad_w_other_source currently requires xarray to work.")
2026-
raise e
2027-
20282012
fill_da = xr.DataArray(getattr(storm_fill, var),
20292013
coords={'t': getattr(storm_fill, 't')},
20302014
dims=('t',))
@@ -2220,7 +2204,6 @@ def write_data_derived(self, filename):
22202204
:param filename: The name of the output NetCDF file (without the extension).
22212205
:return: None
22222206
"""
2223-
import xarray as xr
22242207

22252208
windx = numpy.array(self.u)
22262209
windy = numpy.array(self.v)

0 commit comments

Comments
 (0)