{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import floatview\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "import tarfile\n",
    "import urllib\n",
    "from glue.core.data_factories import load_data"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "url = 'http://docs.glueviz.org/en/stable/_downloads/36cc731fc0ef4f549762f5fe77dce94a/w5.tgz'\n",
    "file_tmp,http_message = urllib.request.urlretrieve(url)\n",
    "tf = tarfile.open(file_tmp,'r:gz')\n",
    "tf.extract(tf.getmember('w5.fits'))\n",
    "img = load_data('w5.fits')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "gmw = floatview.GlueManagerWidget(img, modal=True, label=\"\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "choice = np.random.choice(img.size, 500)\n",
    "gmw.gluemanager.updateSelection(choice)\n",
    "gmw.gluemanager.createSubsetFromSelection(\"subset\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "a = gmw.gluemanager.newView(\"image\", [\"Pixel Axis 1 [x]\",\"Pixel Axis 0 [y]\",\"PRIMARY\"])\n",
    "a.options['color_range_min'].value = 0\n",
    "a.options['color_range_max'].value = 800\n",
    "a.options['color_scale'].value = \"Viridis\""
   ]
  }
 ],
 "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.6.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
