Skip to content

Instantly share code, notes, and snippets.

@eteq
Created August 16, 2019 20:35
Show Gist options
  • Save eteq/67c5991b9e4736312e7e9c4442025cf7 to your computer and use it in GitHub Desktop.
Save eteq/67c5991b9e4736312e7e9c4442025cf7 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"\n",
"from astropy import units as u\n",
"from astropy import cosmology\n",
"from astropy.nddata import CCDData "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "fba27f662eea4a7abfa5d4d5c2009490",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(SubsetMode(children=[ToggleButton(children=[Image(value=b'<?xml version=\"1.0\" encoding=\"UTF-8\" …"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"from glue_jupyter import jglue\n",
"\n",
"app = jglue()\n",
"app"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"from glue.config import data_translator\n",
"from glue.core import Data\n",
"\n",
"@data_translator(u.Quantity)\n",
"class QuantityHandler:\n",
" def to_data(self, obj):\n",
" data = Data()\n",
" data['array'] = obj.value\n",
" data.get_component('array').units = obj.unit\n",
" return data\n",
"\n",
" def to_object(self, data):\n",
" return u.Quantity(data['array'], unit=data.get_component('array').units)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
"datadct = {}\n",
"datadct['distance'] = x = np.sort(np.random.rand(100))*40*u.Mpc\n",
"datadct['velocity'] = cosmology.Planck15.H0*x + np.random.randn(len(x))*300*u.km/u.s\n",
"\n",
"data = app.add_data(galaxies=datadct)[0]"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "b36977114d9f4af0a660ece0ea7ca471",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(BasicJupyterToolbar(children=[ToggleButton(children=[Image(value=b'<?xml version…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<glue_jupyter.bqplot.scatter.viewer.BqplotScatterView at 0x117d95b00>"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"app.scatter2d('distance', 'velocity', data=data)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tom's example"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {},
"outputs": [],
"source": [
"from glue.config import data_translator\n",
"from glue.core import Data, Subset, DataCollection\n",
"from glue.core.coordinates import WCSCoordinates\n",
"\n",
"from astropy import units as u\n",
"from astropy.nddata import CCDData\n",
"\n",
"\n",
"@data_translator(CCDData)\n",
"class CCDDataHandler:\n",
"\n",
" def to_data(self, obj):\n",
" data = Data()\n",
" if obj.wcs is not None:\n",
" data.coords = WCSCoordinates(wcs=obj.wcs)\n",
" data['array'] = obj.data\n",
" data.get_component('array').units = str(obj.unit)\n",
" data.meta.update(obj.meta)\n",
" return data\n",
"\n",
" def to_object(self, data):\n",
" if isinstance(data, Subset):\n",
" subset = data\n",
" data = subset.data\n",
" else:\n",
" subset = None\n",
" if isinstance(data.coords, WCSCoordinates):\n",
" wcs = data.coords.wcs\n",
" else:\n",
" wcs = None\n",
" cid = data.main_components[0]\n",
" comp = data.get_component(cid)\n",
" unit = u.Unit(comp.units)\n",
" ccddata = CCDData(data[cid], wcs=wcs, unit=unit)\n",
" if subset is not None:\n",
" ccddata.mask = subset.to_mask()\n",
" return ccddata"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"CCDData([[0.52662487, 0.63250189, 0.41660619],\n",
" [0.97621998, 0.20382261, 0.26196883],\n",
" [0.01208654, 0.89727943, 0.72531226]])"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"ccddata = CCDData(np.random.random((3, 3)), unit='mJy') \n",
"app.data_collection['image'] = ccddata \n",
"app.data_collection['image'].get_object() "
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "c589518926c44bb691743a8ccd659ba4",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(BasicJupyterToolbar(children=[ToggleButton(children=[Image(value=b'<?xml version…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"<glue_jupyter.bqplot.image.viewer.BqplotImageView at 0x117e26630>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"app.imshow(data=app.data_collection['image'])"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Alternate approach "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"ename": "Exception",
"evalue": "Could not add data\nInvalid data description: [[0.52662487 0.63250189 0.41660619]\n [0.97621998 0.20382261 0.26196883]\n [0.01208654 0.89727943 0.72531226]](Traceback (most recent call last):\n File \"/Users/erik/src/glue/glue/core/application_base.py\", line 26, in wrapper\n return func(*args, **kwargs)\n File \"/Users/erik/src/glue/glue/core/application_base.py\", line 238, in add_data\n datasets.extend(parse_data(data, label))\n File \"/Users/erik/src/glue/glue/qglue.py\", line 101, in parse_data\n raise TypeError(\"Invalid data description: %s\" % data)\nTypeError: Invalid data description: [[0.52662487 0.63250189 0.41660619]\n [0.97621998 0.20382261 0.26196883]\n [0.01208654 0.89727943 0.72531226]]\n)",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m~/src/glue/glue/core/application_base.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 25\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 26\u001b[0;31m \u001b[0;32mreturn\u001b[0m \u001b[0mfunc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0margs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 27\u001b[0m \u001b[0;32mexcept\u001b[0m \u001b[0mException\u001b[0m \u001b[0;32mas\u001b[0m \u001b[0me\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/src/glue/glue/core/application_base.py\u001b[0m in \u001b[0;36madd_data\u001b[0;34m(self, *args, **kwargs)\u001b[0m\n\u001b[1;32m 237\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mlabel\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mkwargs\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mitems\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 238\u001b[0;31m \u001b[0mdatasets\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mextend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mparse_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mlabel\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 239\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/src/glue/glue/qglue.py\u001b[0m in \u001b[0;36mparse_data\u001b[0;34m(data, label)\u001b[0m\n\u001b[1;32m 100\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 101\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mTypeError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m\"Invalid data description: %s\"\u001b[0m \u001b[0;34m%\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 102\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mTypeError\u001b[0m: Invalid data description: [[0.52662487 0.63250189 0.41660619]\n [0.97621998 0.20382261 0.26196883]\n [0.01208654 0.89727943 0.72531226]]",
"\nDuring handling of the above exception, another exception occurred:\n",
"\u001b[0;31mException\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-9-1d7519ffb0b9>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mapp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd_data\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mimage2\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mccddata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/src/glue/glue/core/application_base.py\u001b[0m in \u001b[0;36mwrapper\u001b[0;34m(*args, **kwargs)\u001b[0m\n\u001b[1;32m 29\u001b[0m \u001b[0mdetail\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mtraceback\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat_exc\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 30\u001b[0m \u001b[0mself\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0margs\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 31\u001b[0;31m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mreport_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mm\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdetail\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 32\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mwrapper\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 33\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mdecorator\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/src/glue/glue/core/application_base.py\u001b[0m in \u001b[0;36mreport_error\u001b[0;34m(self, message, detail)\u001b[0m\n\u001b[1;32m 256\u001b[0m \u001b[0mLonger\u001b[0m \u001b[0mcontext\u001b[0m \u001b[0mabout\u001b[0m \u001b[0mthe\u001b[0m \u001b[0merror\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 257\u001b[0m \"\"\"\n\u001b[0;32m--> 258\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mException\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmessage\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\"(\"\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mdetail\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m\")\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 259\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 260\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mdo\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcommand\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mException\u001b[0m: Could not add data\nInvalid data description: [[0.52662487 0.63250189 0.41660619]\n [0.97621998 0.20382261 0.26196883]\n [0.01208654 0.89727943 0.72531226]](Traceback (most recent call last):\n File \"/Users/erik/src/glue/glue/core/application_base.py\", line 26, in wrapper\n return func(*args, **kwargs)\n File \"/Users/erik/src/glue/glue/core/application_base.py\", line 238, in add_data\n datasets.extend(parse_data(data, label))\n File \"/Users/erik/src/glue/glue/qglue.py\", line 101, in parse_data\n raise TypeError(\"Invalid data description: %s\" % data)\nTypeError: Invalid data description: [[0.52662487 0.63250189 0.41660619]\n [0.97621998 0.20382261 0.26196883]\n [0.01208654 0.89727943 0.72531226]]\n)"
]
}
],
"source": [
"app.add_data(image2=ccddata)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Making my own spectrum translator "
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {},
"outputs": [],
"source": [
"import specutils\n",
"from specutils import Spectrum1D\n",
"from astropy.io import fits\n",
"\n",
"f = fits.open('https://dr14.sdss.org/optical/spectrum/view/data/format=fits/spec=lite?plateid=1323&mjd=52797&fiberid=12')\n",
"specdata = f[1].data\n",
"f.close()\n",
"\n",
"lamb = 10**specdata['loglam'] * u.AA \n",
"flux = specdata['flux'] * 10**-17 * u.Unit('erg cm-2 s-1 AA-1') \n",
"spec1d = Spectrum1D(spectral_axis=lamb, flux=flux)\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {},
"outputs": [],
"source": [
"del data_translator.members[-1]"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {},
"outputs": [],
"source": [
"@data_translator(Spectrum1D)\n",
"class Spectrum1DHandler:\n",
" def to_data(self, obj):\n",
" data = Data()\n",
"# These all seemed like plausible guesses, but none of them worked\n",
"\n",
"# data.coords = obj.spectral_axis.value\n",
"\n",
"# if obj.wcs is not None:\n",
"# data.coords = WCSCoordinates(wcs=obj.wcs)\n",
" data['spectral_axis'] = obj.spectral_axis\n",
" data['flux'] = obj.data\n",
" data.get_component('flux').units = str(spec.flux.unit)\n",
" data.meta['s1d'] = obj\n",
" return data\n",
"\n",
" def to_object(self, data):\n",
" return data.meta['s1d']"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"<Spectrum1D(flux=<Quantity [2.1822614e-15, 2.1554786e-15, 2.1008060e-15, ..., 1.8833996e-15,\n",
" 1.9035242e-15, 1.7559197e-15] erg / (Angstrom cm2 s)>, spectral_axis=<Quantity [3815.04833984, 3815.92602539, 3816.8059082 , ..., 9202.37890625,\n",
" 9204.49511719, 9206.61328125] Angstrom>)>"
]
},
"execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"app.data_collection['spec'] = spec1d \n",
"app.data_collection['spec'].get_object() "
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"ok that's good, but how do I plot it?"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "81ebae5a201249d6b4aa9de413baf926",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
"VBox(children=(HBox(children=(BasicJupyterToolbar(children=[ToggleButton(children=[Image(value=b'<?xml version…"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"ename": "ValueError",
"evalue": "value spectral_axis is not in valid choices: ['Coordinate components', Pixel Axis 0 [x]]",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-38-a682deef3e32>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mapp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mprofile1d\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'spectral_axis'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mapp\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdata_collection\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;34m'spec'\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;32m~/src/glue-jupyter/glue_jupyter/app.py\u001b[0m in \u001b[0;36mprofile1d\u001b[0;34m(self, x, data, widget, show)\u001b[0m\n\u001b[1;32m 385\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mx\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 386\u001b[0m \u001b[0mx\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mid\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 387\u001b[0;31m \u001b[0mview\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mstate\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mx_att\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mx\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 388\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 389\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mview\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/src/glue/glue/external/echo/core.py\u001b[0m in \u001b[0;36m__setattr__\u001b[0;34m(self, attribute, value)\u001b[0m\n\u001b[1;32m 262\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 263\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mself\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mattribute\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 264\u001b[0;31m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mHasCallbackProperties\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__setattr__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mattribute\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 265\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mis_callback_property\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mattribute\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 266\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m_notify_global\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m**\u001b[0m\u001b[0;34m{\u001b[0m\u001b[0mattribute\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m}\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;32m~/src/glue/glue/external/echo/selection.py\u001b[0m in \u001b[0;36m__set__\u001b[0;34m(self, instance, value)\u001b[0m\n\u001b[1;32m 36\u001b[0m if ((np.isscalar(value) and not any(value == x for x in choices)) or\n\u001b[1;32m 37\u001b[0m (not np.isscalar(value) and not any(value is x for x in choices))):\n\u001b[0;32m---> 38\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mValueError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'value {0} is not in valid choices: {1}'\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mformat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mvalue\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchoices\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 39\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mSelectionCallbackProperty\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__set__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minstance\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalue\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
"\u001b[0;31mValueError\u001b[0m: value spectral_axis is not in valid choices: ['Coordinate components', Pixel Axis 0 [x]]"
]
}
],
"source": [
"app.profile1d('spectral_axis', data=app.data_collection['spec'])"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"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.7.3"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment