Skip to content

Commit

Permalink
example data update for B16
Browse files Browse the repository at this point in the history
  • Loading branch information
bmorris3 committed Dec 10, 2024
1 parent 6c946d3 commit ad3f16a
Showing 1 changed file with 89 additions and 31 deletions.
120 changes: 89 additions & 31 deletions notebooks/concepts/imviz_roman_asdf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
"cell_type": "code",
"execution_count": null,
"id": "0915bde6-e3cc-4038-aca1-c2ae852f7a69",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"import warnings\n",
Expand All @@ -49,7 +51,9 @@
"cell_type": "code",
"execution_count": null,
"id": "53fb47da-0427-4a43-9d11-39567a12cdb0",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"%matplotlib inline"
Expand All @@ -60,21 +64,30 @@
"id": "d1120d18-65a4-41ec-b831-bc3637718b90",
"metadata": {},
"source": [
"For now, we will use synthetic data for testing."
"For now, we will use synthetic data for testing. \n",
"\n",
"Before downloading the example data, which were generated with schema from `rad == 0.22.0`, check that the correct version of `rad` is installed. Otherwise it may not be possible to open these example files:"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "68443a20",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"from packaging.version import Version\n",
"from astropy.utils.data import download_file\n",
"from roman_datamodels import __version__ as rdm_version\n",
"\n",
"# # Each of these files is ~1 GB:\n",
"image_model1 = download_file('https://stsci.box.com/shared/static/be2nfy4jovdhw1cxru99kdwnfnqxxlgo.asdf', cache=True)\n",
"image_model2 = download_file('https://stsci.box.com/shared/static/ktpt4li627kq4mipi3er5yd4qw6hq7ll.asdf', cache=True)"
"assert Version(rdm_version) >= Version('0.22.0'), 'Update roman_datamodels with `pip install -U roman_datamodels`'\n",
"\n",
"\n",
"# Each of these files is ~1 GB:\n",
"image_model1 = download_file('https://stsci.box.com/shared/static/oor05ut2u5e3xq4kcd244pq5md1el13h.asdf', cache=True)\n",
"image_model2 = download_file('https://stsci.box.com/shared/static/sw1jvu70q20w6czi8pmd9351f0yqkj5o.asdf', cache=True)"
]
},
{
Expand Down Expand Up @@ -107,7 +120,9 @@
"cell_type": "code",
"execution_count": null,
"id": "229d64f3-843f-4a7f-ac98-989f2a95d4c1",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"imviz.show('sidecar:split-right', height=1000)"
Expand All @@ -125,7 +140,9 @@
"cell_type": "code",
"execution_count": null,
"id": "8427d4f9-8ea3-4d60-a8b7-3f3f63e3f3e0",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"orientation = imviz.plugins['Orientation']\n",
Expand All @@ -149,7 +166,9 @@
"cell_type": "code",
"execution_count": null,
"id": "f117ebce-c7a0-44fa-82a4-0c0876663093",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plot_options = imviz.plugins['Plot Options']\n",
Expand Down Expand Up @@ -188,7 +207,9 @@
"cell_type": "code",
"execution_count": null,
"id": "1e369edd",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"regions = imviz.get_interactive_regions()"
Expand All @@ -198,7 +219,9 @@
"cell_type": "code",
"execution_count": null,
"id": "a0385234",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"regions"
Expand All @@ -216,7 +239,9 @@
"cell_type": "code",
"execution_count": null,
"id": "71e2191b",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"wcs = imviz.app.data_collection[-1].coords\n",
Expand All @@ -227,7 +252,9 @@
"cell_type": "code",
"execution_count": null,
"id": "0a4e02ef",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"data = imviz.get_data(imviz.app.data_collection[0].label)"
Expand All @@ -237,7 +264,9 @@
"cell_type": "code",
"execution_count": null,
"id": "164a1a40",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"plt.imshow(mask.to_image(data.data.shape), origin='lower')"
Expand All @@ -255,7 +284,9 @@
"cell_type": "code",
"execution_count": null,
"id": "f2ce00c9-093c-4bc0-8cb7-b7c8fe38ec64",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"viewer = imviz.default_viewer"
Expand All @@ -265,7 +296,9 @@
"cell_type": "code",
"execution_count": null,
"id": "5e908421",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Center the image on given pixel position.\n",
Expand All @@ -276,7 +309,9 @@
"cell_type": "code",
"execution_count": null,
"id": "e68b6306",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Move the image with the given pixel offsets.\n",
Expand All @@ -295,7 +330,9 @@
"cell_type": "code",
"execution_count": null,
"id": "05bc5603-9815-433f-8b4b-2556222ce6c5",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"center = regions['Subset 1'].center"
Expand All @@ -305,19 +342,23 @@
"cell_type": "code",
"execution_count": null,
"id": "e0f3845a",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Center the image on given sky coordinates.\n",
"sky = SkyCoord(ra=79.91038, dec=29.95529, unit=('deg', 'deg'))\n",
"sky = SkyCoord(ra=269.89, dec=66.04, unit=('deg', 'deg'))\n",
"viewer.center_on(sky)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "20f51452-1858-47f9-a421-2997f54f8433",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Move the image with the given sky offsets.\n",
Expand All @@ -343,7 +384,9 @@
"cell_type": "code",
"execution_count": null,
"id": "1bad9bdf-b959-4b74-9a77-07212095c2ce",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Get the current zoom level.\n",
Expand All @@ -354,7 +397,9 @@
"cell_type": "code",
"execution_count": null,
"id": "7a834bcf-7d5a-492b-bc54-740e1500a2f4",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Set the zoom level directly.\n",
Expand All @@ -365,7 +410,9 @@
"cell_type": "code",
"execution_count": null,
"id": "32288b81-1817-4549-b2e4-5e7f55b0ee3d",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Set the relative zoom based on current zoom level.\n",
Expand All @@ -384,7 +431,9 @@
"cell_type": "code",
"execution_count": null,
"id": "270a6dd2-ce21-457f-845e-19cf5405fee7",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"# Add 20 randomly generated X,Y (0-indexed) w.r.t. reference image\n",
Expand All @@ -408,13 +457,18 @@
"cell_type": "code",
"execution_count": null,
"id": "9ecfd0f9-da9e-419b-99a8-cc6efc20568f",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"np.random.seed(42)\n",
"# Mark some sky coordinates using updated marker properties.\n",
"t_sky = Table({'coord': [sky.spherical_offsets_by(*np.random.normal(scale=0.1, size=2) * u.arcsec)\n",
" for i in range(5)]})\n",
"t_sky = Table({'coord': [\n",
" sky.spherical_offsets_by(\n",
" *np.random.normal(scale=0.1, size=2) * u.arcsec\n",
" ) for i in range(5)\n",
"]})\n",
"viewer.add_markers(t_sky, use_skycoord=True, marker_name='my_sky')\n",
"t_sky"
]
Expand All @@ -431,7 +485,9 @@
"cell_type": "code",
"execution_count": null,
"id": "776c3b75-a1a9-4141-9d6d-8aa766c58d21",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"viewer.remove_markers(marker_name='my_sky')"
Expand All @@ -449,7 +505,9 @@
"cell_type": "code",
"execution_count": null,
"id": "046641de-b173-4377-92d3-344bd4ba48f3",
"metadata": {},
"metadata": {
"tags": []
},
"outputs": [],
"source": [
"viewer.reset_markers()"
Expand Down

0 comments on commit ad3f16a

Please sign in to comment.