-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Glue unit conversion in Jdaviz. [ci skip] [rtd skip]
Co-authored-by: Jesse Averbukh <javerbukh@gmail.com>
- Loading branch information
Showing
11 changed files
with
219 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,163 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"id": "57c41ae5", | ||
"metadata": {}, | ||
"source": [ | ||
"This is a concept notebook to investigate Glue unit conversion behavior integrated into Jdaviz spectrum viewer." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "2b3bbfb1", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"import numpy as np\n", | ||
"from astropy import units as u\n", | ||
"from specutils import Spectrum1D\n", | ||
"\n", | ||
"from jdaviz import Specviz" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "0d253733", | ||
"metadata": {}, | ||
"source": [ | ||
"First spectrum." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "cba69bb7", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"wave1 = np.linspace(2, 5, 10) * u.um\n", | ||
"flux1 = [1, 2, 3, 4, 5, 5, 4, 3, 2, 1] * u.Jy\n", | ||
"spec1 = Spectrum1D(flux=flux1, spectral_axis=wave1)\n", | ||
"\n", | ||
"print(wave1)\n", | ||
"print(flux1)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "1e0e7dc5", | ||
"metadata": {}, | ||
"source": [ | ||
"Second spectrum in different units and with slight offsets in spectral axis." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "26bc794d", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"wave2 = (wave1 + (0.1 * u.um)).to(u.GHz, u.spectral())\n", | ||
"flux2 = flux1.to(u.mJy)\n", | ||
"spec2 = Spectrum1D(flux=flux2, spectral_axis=wave2)\n", | ||
"\n", | ||
"print(wave2)\n", | ||
"print(wave2.to(u.um, u.spectral()))\n", | ||
"print(flux2)" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "2bb4f4ea", | ||
"metadata": {}, | ||
"source": [ | ||
"Fire up Specviz." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "74692a02", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz = Specviz()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "efdba701", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz.show()" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"id": "642fbae1", | ||
"metadata": {}, | ||
"source": [ | ||
"Load the data into Specviz. Desired behavior:\n", | ||
"\n", | ||
"1. \"Jy_um\" would load with Jy in Y-axis and um in X-axis.\n", | ||
"2. \"mJy_GHz\" would load with data automatically converted to Jy and um in the plot. You would see the same shape but slightly offset in X-axis, just slightly." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "5ee09160", | ||
"metadata": { | ||
"scrolled": true | ||
}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz.load_data(spec1, data_label=\"Jy_um\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "9655292b", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"specviz.load_data(spec2, data_label=\"mJy_GHz\")" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"id": "ed8974c9", | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3 (ipykernel)", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.10.8" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 5 | ||
} |