Skip to content

Commit

Permalink
Add test coverage for limits_from_wcs option
Browse files Browse the repository at this point in the history
Needed to flip sample dataset WCS to have the option actually do anything
  • Loading branch information
eigenbrot committed Jan 24, 2025
1 parent 7861d36 commit d9bd0de
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
25 changes: 23 additions & 2 deletions dkist/dataset/tests/test_tiled_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,15 @@ def test_tiled_dataset_from_components(dataset):

@figure_test
@pytest.mark.parametrize("share_zscale", [True, False], ids=["share_zscale", "indpendent_zscale"])
def test_tileddataset_plot(share_zscale):
@pytest.mark.parametrize("limits_from_wcs", [True, False], ids=["wcs_lims", "raw_lims"])
def test_tileddataset_plot(share_zscale, limits_from_wcs):
from dkist.data.sample import VBI_AJQWW
ori_ds = load_dataset(VBI_AJQWW)

# Swap WCS to make the `limits_from_wcs` option meaningful
for tile in ori_ds.flat:
tile.wcs.forward_transform[0].cdelt *= -1

newtiles = []
for tile in ori_ds.flat:
newtiles.append(tile.rebin((1, 8, 8), operation=np.sum))
Expand All @@ -86,11 +92,26 @@ def test_tileddataset_plot(share_zscale):
for tile in newtiles:
tile.meta["inventory"] = ori_ds.inventory
ds = TiledDataset(np.array(newtiles).reshape(ori_ds.shape), inventory=newtiles[0].inventory)

non_square_ds = ds[:2, :]
assert non_square_ds.shape[0] != non_square_ds.shape[1] # Just in case the underlying data change for some reason

fig = plt.figure(figsize=(12, 15))
non_square_ds.plot(0, share_zscale=share_zscale, fig=fig)
non_square_ds.plot(0, share_zscale=share_zscale, limits_from_wcs=limits_from_wcs, fig=fig)

assert fig.axes[0].get_gridspec().get_geometry() == non_square_ds.shape[::-1]
for ax in fig.axes:
xlims = ax.get_xlim()
ylims = ax.get_ylim()

if limits_from_wcs:
# Because we know the WCS are flipped, so a correctly ordered WCS will be a "backwards" absolute pixel order
assert xlims[0] > xlims[1]
assert ylims[0] > ylims[1]
else:
assert xlims[0] < xlims[1]
assert ylims[0] < ylims[1]

return plt.gcf()


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"dkist.dataset.tests.test_plotting.test_2d_plot[aslice1]": "cbb84fbae51d8238803f8f0d6820c575f024fe54b1656f1b181dc4ec645e9ff9",
"dkist.dataset.tests.test_plotting.test_2d_plot[aslice2]": "132c5615832daff457dacb4cb770498f1fbb4460a5b90b5d4d01d224c70eeb28",
"dkist.dataset.tests.test_plotting.test_2d_plot2": "409b5a10ad8ccf005331261505e63ce8febdc38eb8b5a34f8863e567e3cccb9c",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[share_zscale]": "839887727c4e47d956331865cb6773f8ba92e4c20f342018fd60090ae50326a5",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[indpendent_zscale]": "309e0693d666368bcc3d1c98ebb2541a09dfcf28a2451758d79f870ac6aee3cc"
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[wcs_lims-share_zscale]": "0ba8c2f7253eb14f69d12fea1bc9ed393218efc4f355db3fcad0fc9fdbc2d27b",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[wcs_lims-indpendent_zscale]": "42f8404e2dd32602087ba9c56a18c7beaf18cdd0efad45aca250b004fe5cbbd5",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[raw_lims-share_zscale]": "26357dc1e1fbf7b2b06876f2511dc8513b43a5145d7e6afab2a44328d57cd9c7",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[raw_lims-indpendent_zscale]": "dfb2e59d4f4642faad84b2d92ea1484b11f113a52383fa8dc5ec94268a4492c8"
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
"dkist.dataset.tests.test_plotting.test_2d_plot[aslice1]": "cbb84fbae51d8238803f8f0d6820c575f024fe54b1656f1b181dc4ec645e9ff9",
"dkist.dataset.tests.test_plotting.test_2d_plot[aslice2]": "4b5be9cf1883d0ebd15ff091f52cea2822068e8238a8df7b0f594d69fba27597",
"dkist.dataset.tests.test_plotting.test_2d_plot2": "1c10e9db44b0b694a6bb1b493c4c2193278541df7c1302bb11fe3f6372682e35",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[share_zscale]": "3ff43a5f92e253c9033dbfd7b101c09739d941fb604220ce88dfe2278261df06",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[indpendent_zscale]": "c0a1e248e133c6ea86f80ec5cc30d2ded9e740efec02a4f09847310b72ff9b18"
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[wcs_lims-share_zscale]": "a7af28683a85e55b76f132abcd5fb99e85b400e3d6641724dbb3414dff25df03",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[wcs_lims-indpendent_zscale]": "f18bef9708a69e61e2c6ed4e6781432188c61eb4e583aae2876164c86794cb59",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[raw_lims-share_zscale]": "540329173485ec175b4ef4a689a125004d8e988075407bd2cfc0bafd8edaa5c8",
"dkist.dataset.tests.test_tiled_dataset.test_tileddataset_plot[raw_lims-indpendent_zscale]": "05bfe3fb2c3c7b02c52b6b75944e88c19bf351b52d5f638b1d29526cc3bf8198"
}

0 comments on commit d9bd0de

Please sign in to comment.