Skip to content

Commit

Permalink
Final clean up, use generate cube.
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Dec 8, 2020
1 parent 7482173 commit 13d3ac2
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions example_notebooks/cube_4d.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,26 @@
]
},
{
"cell_type": "raw",
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"pf = None # Not using FITS file pointer\n",
"cube4d = np.random.random((2, 5, 100, 200)).astype(np.float32)\n",
"cube4d = np.random.random((1, 10, 2048, 2048)).astype(np.float32)\n",
"\n",
"# Insert something \"interesting\"\n",
"for i in range(cube4d.shape[1]):\n",
" j = i * 10\n",
" cube4d[0, i, :j, :j] = 1.\n",
"\n",
"# Convert to NDData.\n",
"im = NDData(cube4d, wcs=WCS(naxis=4))\n",
"\n",
"# Memory footprint\n",
"print((cube4d.size * 32 * u.bit).to(u.kB))"
"print((cube4d.size * 32 * u.bit).to(u.MB))"
]
},
{
Expand All @@ -160,23 +167,19 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"cell_type": "raw",
"metadata": {},
"outputs": [],
"source": [
"from astropy.io import fits\n",
"\n",
"# This is a large cube.\n",
"filename = '/redkeep/ironthrone/ssb/stginga/test_data/NRCN815A_LIN_20160115_uncal.fits'\n",
"filename = 'my_big_cube.fits'\n",
"pf = fits.open(filename, memmap=True)\n",
"\n",
"# There is no WCS assigned for UNCAL file yet.\n",
"# This is a dummy WCS.\n",
"# Grab WCS from EXT 1.\n",
"im_wcs = WCS(pf[1].header)\n",
"\n",
"# Pass memmap-ed FITS data into NDData.\n",
"# Shape is (1, 190, 2048, 2048)\n",
"im = NDData(pf[1].data, wcs=im_wcs)\n",
"\n",
"# Memory footprint\n",
Expand Down Expand Up @@ -361,7 +364,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.3"
"version": "3.8.3"
}
},
"nbformat": 4,
Expand Down

0 comments on commit 13d3ac2

Please sign in to comment.