|
36 | 36 | """ |
37 | 37 |
|
38 | 38 | import sys |
39 | | -# import os |
40 | 39 | import argparse |
41 | 40 | import datetime |
42 | 41 | import warnings |
43 | 42 | from pathlib import Path |
44 | 43 |
|
45 | 44 | import numpy as np |
46 | 45 | import pandas as pd |
| 46 | +import xarray as xr |
47 | 47 |
|
48 | 48 | import clawpack.geoclaw.units as units |
49 | 49 | 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 |
600 | 600 | value error is risen. |
601 | 601 | """ |
602 | 602 |
|
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 | | - |
610 | 603 | # only allow one method for specifying storms |
611 | 604 | if (sid is not None) and ((storm_name is not None) or (year is not None)): |
612 | 605 | raise ValueError( |
@@ -771,10 +764,7 @@ def read_ibtracs_processed(self, path, sid, start_date=None): |
771 | 764 | value error is risen. |
772 | 765 | """ |
773 | 766 |
|
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: |
778 | 768 | # match on sid |
779 | 769 | ds = ds.sel(storm=ds.sid == sid).load().squeeze() |
780 | 770 |
|
@@ -2019,12 +2009,6 @@ def fill_rad_w_other_source(t, storm_targ, storm_fill, var, interp_kwargs={}): |
2019 | 2009 | ... max_wind_radius_fill = fill_mwr) |
2020 | 2010 | """ |
2021 | 2011 |
|
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 | | - |
2028 | 2012 | fill_da = xr.DataArray(getattr(storm_fill, var), |
2029 | 2013 | coords={'t': getattr(storm_fill, 't')}, |
2030 | 2014 | dims=('t',)) |
@@ -2220,7 +2204,6 @@ def write_data_derived(self, filename): |
2220 | 2204 | :param filename: The name of the output NetCDF file (without the extension). |
2221 | 2205 | :return: None |
2222 | 2206 | """ |
2223 | | - import xarray as xr |
2224 | 2207 |
|
2225 | 2208 | windx = numpy.array(self.u) |
2226 | 2209 | windy = numpy.array(self.v) |
|
0 commit comments