diff --git a/pyart/graph/radardisplay.py b/pyart/graph/radardisplay.py index 13a6d61213..d34233752f 100644 --- a/pyart/graph/radardisplay.py +++ b/pyart/graph/radardisplay.py @@ -85,8 +85,8 @@ def __init__(self, radar, shift=(0.0, 0.0)): # radar location in latitude and longitude if radar.latitude["data"].size == 1: - lat = float(radar.latitude["data"]) - lon = float(radar.longitude["data"]) + lat = float(radar.latitude["data"][0]) + lon = float(radar.longitude["data"][0]) else: # for moving platforms stores use the median location. # The RadarDisplay object does not give a proper diff --git a/pyart/io/_sigmetfile.pyx b/pyart/io/_sigmetfile.pyx index 35f143e2ce..3f5d507c1e 100644 --- a/pyart/io/_sigmetfile.pyx +++ b/pyart/io/_sigmetfile.pyx @@ -597,7 +597,7 @@ SIGMET_DATA_TYPES = { def convert_sigmet_data(data_type, data, nbins): """ Convert sigmet data. """ out = np.empty_like(data, dtype='float32') - mask = np.zeros_like(data, dtype=np.bool8) + mask = np.zeros_like(data, dtype='bool') data_type_name = SIGMET_DATA_TYPES[data_type] diff --git a/pyart/io/cfradial.py b/pyart/io/cfradial.py index d3c908d9ed..3d1c4f2706 100644 --- a/pyart/io/cfradial.py +++ b/pyart/io/cfradial.py @@ -3,10 +3,10 @@ """ -import datetime import getpass import platform import warnings +from datetime import datetime, timedelta, timezone import netCDF4 import numpy as np @@ -531,7 +531,7 @@ def write_cfradial( else: user = getpass.getuser() node = platform.node() - time_str = datetime.datetime.now().isoformat() + time_str = datetime.now().isoformat() t = (user, node, time_str) history = "created by {} on {} at {} using Py-ART".format(*t) @@ -551,7 +551,7 @@ def write_cfradial( only_use_cftime_datetimes=False, only_use_python_datetimes=True, ) - td = dt - datetime.datetime.utcfromtimestamp(0) + td = dt - datetime.fromtimestamp(0, tz=timezone.utc).replace(tzinfo=None) base_time = { "data": np.array([td.seconds + td.days * 24 * 3600], "int32"), "string": dt.strftime("%d-%b-%Y,%H:%M:%S GMT"), @@ -698,7 +698,7 @@ def write_cfradial( ) if start_dt.microsecond != 0: # truncate to nearest second - start_dt -= datetime.timedelta(microseconds=start_dt.microsecond) + start_dt -= timedelta(microseconds=start_dt.microsecond) end_dt = netCDF4.num2date( radar.time["data"][-1], units, @@ -707,9 +707,7 @@ def write_cfradial( ) if end_dt.microsecond != 0: # round up to next second - end_dt += datetime.timedelta(seconds=1) - datetime.timedelta( - microseconds=end_dt.microsecond - ) + end_dt += timedelta(seconds=1) - timedelta(microseconds=end_dt.microsecond) start_dic = { "data": np.array(start_dt.isoformat() + "Z", dtype="S"), "long_name": "UTC time of first ray in the file", diff --git a/pyart/io/chl.py b/pyart/io/chl.py index c65b80bd00..25670e7385 100644 --- a/pyart/io/chl.py +++ b/pyart/io/chl.py @@ -4,7 +4,7 @@ """ import struct -from datetime import datetime +from datetime import datetime, timezone import numpy as np @@ -87,7 +87,9 @@ def read_chl( tdata = np.array(chl_file.time) min_time = np.floor(tdata.min()) time["data"] = (tdata - min_time).astype("float64") - time["units"] = make_time_unit_str(datetime.utcfromtimestamp(min_time)) + time["units"] = make_time_unit_str( + datetime.fromtimestamp(min_time, tz=timezone.utc).replace(tzinfo=None) + ) # range _range = filemetadata("range") diff --git a/pyart/io/grid_io.py b/pyart/io/grid_io.py index 3f35e8c190..72850aa224 100644 --- a/pyart/io/grid_io.py +++ b/pyart/io/grid_io.py @@ -3,8 +3,8 @@ """ -import datetime import warnings +from datetime import datetime, timezone import netCDF4 import numpy as np @@ -311,7 +311,7 @@ def write_grid( if arm_time_variables: time = grid.time dt = netCDF4.num2date(time["data"][0], time["units"]) - td = dt - datetime.datetime.utcfromtimestamp(0) + td = dt - datetime.fromtimestamp(0, tz=timezone.utc).replace(tzinfo=None) td = td.seconds + td.days * 24 * 3600 base_time = { diff --git a/pyart/io/nexrad_level3.py b/pyart/io/nexrad_level3.py index 69da980b43..f55e44bf9e 100644 --- a/pyart/io/nexrad_level3.py +++ b/pyart/io/nexrad_level3.py @@ -69,7 +69,7 @@ import struct import warnings from collections import namedtuple -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone import numpy as np from mda_xdrlib.xdrlib import Unpacker @@ -371,7 +371,7 @@ def _get_data_msg_134(self): def _datetime_from_mdate_mtime(mdate, mtime): """Returns a datetime for a given message date and time.""" - epoch = datetime.utcfromtimestamp(0) + epoch = datetime.fromtimestamp(0, tz=timezone.utc).replace(tzinfo=None) return epoch + timedelta(days=mdate - 1, seconds=mtime) diff --git a/pyart/io/output_to_geotiff.py b/pyart/io/output_to_geotiff.py index 827f8a22f5..2f5262fa0e 100644 --- a/pyart/io/output_to_geotiff.py +++ b/pyart/io/output_to_geotiff.py @@ -242,7 +242,7 @@ def _get_rgb_values(data, vmin, vmax, color_levels, cmap): rarr = [] garr = [] barr = [] - cmap = plt.cm.get_cmap(cmap) + cmap = plt.get_cmap(cmap) for val in index: if not np.isnan(val): ind = int(np.round(val)) @@ -287,7 +287,7 @@ def _create_sld(cmap, vmin, vmax, filename, color_levels=None): with steps << 255 (e.g., hydrometeor ID). """ - cmap = plt.cm.get_cmap(cmap) + cmap = plt.get_cmap(cmap) if color_levels is None: color_levels = 255 name, _ = filename.split(".") diff --git a/pyart/util/columnsect.py b/pyart/util/columnsect.py index 74f50ede17..68808f7654 100755 --- a/pyart/util/columnsect.py +++ b/pyart/util/columnsect.py @@ -351,7 +351,7 @@ def get_field_location(radar, latitude, longitude): # Determine the time at the center of each ray within the column # Define the start of the radar volume as a numpy datetime object for xr - base_time = np.datetime64(datetime_from_radar(radar).isoformat()) + base_time = np.datetime64(datetime_from_radar(radar).isoformat(), "ns") # Convert Py-ART radar object time (time since volume start) to time delta # Add to base time to have sequential time within the xr Dataset # for easier future merging/work diff --git a/pyart/xradar/accessor.py b/pyart/xradar/accessor.py index 94dd1b0675..7e96d47173 100644 --- a/pyart/xradar/accessor.py +++ b/pyart/xradar/accessor.py @@ -105,15 +105,15 @@ def metadata(self): @property def ny(self): - return self.ds.dims["y"] + return self.ds.sizes["y"] @property def nx(self): - return self.ds.dims["x"] + return self.ds.sizes["x"] @property def nz(self): - return self.ds.dims["z"] + return self.ds.sizes["z"] # Attribute init/reset methods def init_point_x_y_z(self): diff --git a/tests/graph/test_radarmapdisplay.py b/tests/graph/test_radarmapdisplay.py index 21dd3987e7..9a5680b77e 100644 --- a/tests/graph/test_radarmapdisplay.py +++ b/tests/graph/test_radarmapdisplay.py @@ -46,13 +46,14 @@ def test_radarmapdisplay_cartopy_ppi(outfile=None): ) def test_radarmapdisplay_cartopy_preexisting_ax(outfile=None): import cartopy - from cartopy.io.img_tiles import Stamen + from cartopy.io.img_tiles import GoogleTiles radar = pyart.io.read_cfradial(pyart.testing.CFRADIAL_PPI_FILE) display = pyart.graph.RadarMapDisplay(radar, shift=(0.1, 0.0)) fig = plt.figure() ax = plt.axes(projection=cartopy.crs.PlateCarree()) - ax.add_image(Stamen("terrain-background"), 6) + tiler = GoogleTiles(style="terrain") + ax.add_image(tiler, 6) display.plot_ppi_map("reflectivity_horizontal", 0, ax=ax, embellish=False) if outfile: fig.savefig(outfile)