Skip to content

Commit

Permalink
STY: Update PEP8 formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
zssherman committed Sep 24, 2024
1 parent 38a44c8 commit 6d658a6
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 20 deletions.
8 changes: 4 additions & 4 deletions pyart/io/output_to_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def write_grid_geotiff(
sld=False,
use_doublequotes=True,
transparent_bg=True,
opacity=1.0
opacity=1.0,
):
"""
Write a Py-ART Grid object to a GeoTIFF file.
Expand Down Expand Up @@ -169,8 +169,9 @@ def write_grid_geotiff(
)
else:
# Assign data RGB levels based on value relative to vmax/vmin
rarr, garr, barr, aarr = _get_rgb_values(data, vmin, vmax, color_levels, cmap,
transparent_bg, opacity)
rarr, garr, barr, aarr = _get_rgb_values(
data, vmin, vmax, color_levels, cmap, transparent_bg, opacity
)
dst_ds = out_driver.Create(
ofile, data.shape[1], data.shape[0], 4, gdal.GDT_Byte
)
Expand Down Expand Up @@ -283,7 +284,6 @@ def _get_rgb_values(data, vmin, vmax, color_levels, cmap, transpbg, op):
else:
aarr.append(0)


rarr = np.reshape(rarr, data.shape)
garr = np.reshape(garr, data.shape)
barr = np.reshape(barr, data.shape)
Expand Down
41 changes: 25 additions & 16 deletions tests/io/test_output_to_geotiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ def test__get_rgb_values_nan():
assert np.isnan(garr[5])



def test_raise_missingoptionaldepedency():
backup = bool(pyart.io.output_to_geotiff.IMPORT_FLAG)
pyart.io.output_to_geotiff.IMPORT_FLAG = False
Expand Down Expand Up @@ -55,6 +54,7 @@ def make_tiny_grid():
grid.fields = {"reflectivity": rdic}
return grid


def make_tiny_grid_with_mask():
"""Make a tiny grid."""
grid_shape = (2, 10, 8)
Expand All @@ -70,6 +70,7 @@ def make_tiny_grid_with_mask():
grid.fields = {"reflectivity": rdic}
return grid


@pytest.mark.skipif(
not pyart.io.output_to_geotiff.IMPORT_FLAG, reason="GDAL is not installed."
)
Expand Down Expand Up @@ -150,6 +151,7 @@ def test_write_grid_geotiff_missing_field():
grid = make_tiny_grid()
pytest.raises(KeyError, pyart.io.write_grid_geotiff, grid, "test.foo", "foobar")


@pytest.mark.skipif(
not pyart.io.output_to_geotiff.IMPORT_FLAG, reason="GDAL is not installed."
)
Expand All @@ -160,21 +162,24 @@ def test_write_grid_geotiff_transparent_background():
with pyart.testing.InTemporaryDirectory() as tmpdir:
tmp = Path(tmpdir)
outname = tmp / "transparent_bg.tif"
pyart.io.write_grid_geotiff(grid, str(outname), "reflectivity",
rgb=True,
cmap='pyart_HomeyerRainbow',
vmin=0,
vmax=40,
transparent_bg=True,
opacity=1)
pyart.io.write_grid_geotiff(
grid,
str(outname),
"reflectivity",
rgb=True,
cmap="pyart_HomeyerRainbow",
vmin=0,
vmax=40,
transparent_bg=True,
opacity=1,
)
imgname = outname.rename(tmp / "transparent_bg.tiff")
img = Image.open(imgname)
img.show()
except PermissionError:
pass



@pytest.mark.skipif(
not pyart.io.output_to_geotiff.IMPORT_FLAG, reason="GDAL is not installed."
)
Expand All @@ -184,13 +189,17 @@ def test_write_grid_geotiff_opacity():
with pyart.testing.InTemporaryDirectory() as tmpdir:
tmp = Path(tmpdir)
outname = tmp / "opacity.tif"
pyart.io.write_grid_geotiff(grid, str(outname), 'reflectivity',
rgb=True,
cmap='pyart_HomeyerRainbow',
vmin=0,
vmax=40,
transparent_bg=False,
opacity=0.25)
pyart.io.write_grid_geotiff(
grid,
str(outname),
"reflectivity",
rgb=True,
cmap="pyart_HomeyerRainbow",
vmin=0,
vmax=40,
transparent_bg=False,
opacity=0.25,
)
imgname = outname.rename(tmp / "opacity.tiff")
img = Image.open(imgname)
img.show()
Expand Down

0 comments on commit 6d658a6

Please sign in to comment.