Repository navigation
jrob93-patch: deep_coadd save to fits #227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
0270521
719bb8e
ed92f9e
2936195
c344bc0
7fd6a57
1b8f432
57d7b21
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -74,7 +74,7 @@ | |
| "### 1.1. Import packages\n", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Line #9. # print("save file: {}".format(save_file))
i think it would be make sense to print the message after you save (e.g. save file -> saved to) so the user knows the cell has actually run and saved a file. Reply via ReviewNB
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i would also maybe remove the comments above so the code actually runs and just delete the file during cleanup.
Reply via ReviewNB |
||
| "\n", | ||
| "From the LSST Science Pipelines import the packages for the Butler, 2-dimensional sky geometry, and for image display.\n", | ||
| "Also import the `numpy` package, `matplotlib` plotting tools, and `Astropy` coordinate utilities." | ||
| "Also import the `numpy` package, `matplotlib` plotting tools, and `Astropy` coordinate utilities. Import `os` and `getpass` for setting up a temporary directory to save files." | ||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -92,7 +92,9 @@ | |
| "import astropy.units as u\n", | ||
| "import matplotlib.pyplot as plt\n", | ||
| "from matplotlib.collections import PatchCollection\n", | ||
| "import numpy as np" | ||
| "import numpy as np\n", | ||
| "import os\n", | ||
| "import getpass" | ||
| ] | ||
| }, | ||
| { | ||
|
|
@@ -1845,16 +1847,80 @@ | |
| "outputs": [], | ||
| "source": [ | ||
| "del ref, dataId, use_tract, use_patch, use_columns, objects, tx\n", | ||
| "del dataset_refs, deep_coadd" | ||
| "del dataset_refs" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "c06ebdd7-482a-43a6-aed8-4ed053c8d184", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "## 6. Save `deep_coadd` to file\n", | ||
| "`deep_coadd` is a `CellCoadd` object type and has an associated method to write the object to file, as described in the [API](https://images.lsst.io/api/lsst.images.cells.CellCoadd.html#lsst.images.cells.CellCoadd.write). It is recommended for users to save temporary files in the shared scratch directory, `/deleted-sundays/`, in sub-directories named with their RSP username." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "6f0887f4-b789-42d7-b1da-931d2e42e45b", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "username = getpass.getuser()\n", | ||
| "print('username: ', username)\n", | ||
| "\n", | ||
| "userdir = '/deleted-sundays/' + username\n", | ||
| "if not os.path.exists(userdir):\n", | ||
| " os.makedirs(userdir)\n", | ||
| " print('Created ', userdir)\n", | ||
| "else:\n", | ||
| " print('Directory already existed: ', userdir)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "aa295f27-e9df-42cc-9911-192bb3798458", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Uncomment the following cell to save `deep_coadd` as a FITS file in the scratch directory." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "255b693c-4767-4152-addf-1d98a7276783", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [ | ||
| "# save_file = \"{}/deep_coadd_{}_{}_{}_{}.fits\".format(\n", | ||
| "# userdir,\n", | ||
| "# deep_coadd.skymap,\n", | ||
| "# deep_coadd.tract,\n", | ||
| "# deep_coadd.patch.id,\n", | ||
| "# deep_coadd.band\n", | ||
| "# )\n", | ||
| "\n", | ||
| "# print(\"save file: {}\".format(save_file))\n", | ||
| "# deep_coadd.image.write(save_file)" | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "markdown", | ||
| "id": "8270ac15-73ee-4e87-ab72-f0a12b3c455f", | ||
| "metadata": {}, | ||
| "source": [ | ||
| "Clean up." | ||
| ] | ||
| }, | ||
| { | ||
| "cell_type": "code", | ||
| "execution_count": null, | ||
| "id": "7cf73981-189c-401d-bde8-e6e8fc26b31e", | ||
| "metadata": {}, | ||
| "outputs": [], | ||
| "source": [] | ||
| "source": [ | ||
| "del deep_coadd" | ||
| ] | ||
| } | ||
| ], | ||
| "metadata": { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line #1. # save_file = "{}/deep_coadd_{}_{}_{}_{}.fits".format(save_file = os.path.join(userdir, ...)is slightly saferReply via ReviewNB