Last active
August 29, 2015 14:06
-
-
Save taldcroft/fbf07f6da23f54541f56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| { | |
| "metadata": { | |
| "name": "", | |
| "signature": "sha256:6d9b3a8fa5ac46056d5ec289da3ecfaebb40e9d31f38730a393fb909a30a4956" | |
| }, | |
| "nbformat": 3, | |
| "nbformat_minor": 0, | |
| "worksheets": [ | |
| { | |
| "cells": [ | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "from astropy.table import *\n", | |
| "from astropy.table import table\n", | |
| "import numpy as np\n", | |
| "from astropy.units import Quantity\n", | |
| "import astropy.units as u\n", | |
| "from astropy.time import Time, TimeDelta\n", | |
| "from astropy.coordinates import SkyCoord" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 1 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "tm = Time([2000.1, 2000.2], format='jyear')\n", | |
| "tm = Time(tm, format='iso')\n", | |
| "tm" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 2, | |
| "text": [ | |
| "<Time object: scale='utc' format='iso' value=['2000-02-07 00:36:00.000' '2000-03-14 13:12:00.000']>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 2 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "sc = SkyCoord([[1,2], [3,4]], unit=(u.deg, u.deg))\n", | |
| "from copy import deepcopy\n", | |
| "sc2 = deepcopy(sc)\n", | |
| "sc2" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 3, | |
| "text": [ | |
| "<SkyCoord (ICRS): (ra, dec) in deg\n", | |
| " [(1.0, 2.0), (3.0, 4.0)]>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 3 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t = Table([[1,2], [1,2]*u.m, tm, sc], names=('a', 'b', 'c', 'sc'))\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th></tr></thead><tr><td>1</td><td>1.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td></tr><tr><td>2</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 4, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc') units=(None,'m',None,None)>\n", | |
| "array([ (1, 1.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 4 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t2 = Table(t, copy=True)\n", | |
| "t2" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4384800080\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th></tr></thead><tr><td>1</td><td>1.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td></tr><tr><td>2</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 5, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc') units=(None,'m',None,None)>\n", | |
| "array([ (1, 1.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 5 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "np.array(t[1])" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 6, | |
| "text": [ | |
| "array((2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>), \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 6 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "np.array(t)" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 7, | |
| "text": [ | |
| "array([ (1, 1.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 7 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[:1]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4384800656\"><thead><tr><th>a</th><th>b</th><th>c</th><th>icrs</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th></tr></thead><tr><td>1</td><td>1.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 8, | |
| "text": [ | |
| "<Table rows=1 names=('a','b','c','icrs') units=(None,'m',None,None)>\n", | |
| "array([ (1, 1.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('icrs', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 8 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1].data" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 9, | |
| "text": [ | |
| "(2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 9 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 10, | |
| "text": [ | |
| "<Row 1 of table\n", | |
| " values=(2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)\n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')]>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 10 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "str(t[1]['b'])" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 11, | |
| "text": [ | |
| "'2.0 m'" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 11 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "str(t[1]['c'])" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 12, | |
| "text": [ | |
| "'2000-03-14 13:12:00.000'" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 12 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t.dtype" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 13, | |
| "text": [ | |
| "dtype([('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 13 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "try:\n", | |
| " # Not implemented yet\n", | |
| " t.add_row([3, 3*u.m, 3])\n", | |
| "except Exception as err:\n", | |
| " print(err)\n" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": [ | |
| "Cannot add a row in table with column types ['Quantity', 'SkyCoord', 'Time']\n" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 14 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['b'][0] = 4 * u.km\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td></tr><tr><td>2</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 15, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc') units=(None,'m',None,None)>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 15 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "# Assignment to Time object is not allowed ()\n", | |
| "try:\n", | |
| " t['c'] = [1,2]\n", | |
| "except TypeError as err:\n", | |
| " print(err)" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": [ | |
| "'Time' object does not support item assignment\n" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 16 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a']" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 17, | |
| "text": [ | |
| "<Column name='a' unit=None format=None description=None>\n", | |
| "array([1, 2])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 17 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "q = [6, 7] * u.s\n", | |
| "q.name = 'd'\n", | |
| "t.add_column(q)\n", | |
| "t\n" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td></tr><tr><td>2</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 18, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d') units=(None,'m',None,None,'s')>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 18 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 18 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a'].mask = np.array([False, True])" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 19 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td></tr><tr><td>2</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 20, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d') units=(None,'m',None,None,'s')>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0),\n", | |
| " (2, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 20 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a'] = 1\n", | |
| "t['a']" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 21, | |
| "text": [ | |
| "<Column name='a' unit=None format=None description=None>\n", | |
| "array([1, 1])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 21 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td></tr><tr><td>1</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 22, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d') units=(None,'m',None,None,'s')>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0),\n", | |
| " (1, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 22 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "row = t[1]\n", | |
| "row.data" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 23, | |
| "text": [ | |
| "(1, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 23 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "row['a'] = 5\n", | |
| "row" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 24, | |
| "text": [ | |
| "<Row 1 of table\n", | |
| " values=(1, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)\n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O')]>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 24 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a'].mask[1] = True\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td></tr><tr><td>5</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 25, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d') units=(None,'m',None,None,'s')>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0),\n", | |
| " (5, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 25 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['e'] = t['c'] + t['d']\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th><th>e</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th><th></th></tr></thead><tr><td>1</td><td>4000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td><td>2000-02-07 00:36:06.000</td></tr><tr><td>5</td><td>2.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td><td>2000-03-14 13:12:07.000</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 26, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d','e') units=(None,'m',None,None,'s',None)>\n", | |
| "array([ (1, 4000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:06.000>),\n", | |
| " (5, 2.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:07.000>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O'), ('e', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 26 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a'] = 5\n", | |
| "t['b'] = 55*u.km\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th><th>e</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th><th></th></tr></thead><tr><td>5</td><td>55000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td><td>2000-02-07 00:36:06.000</td></tr><tr><td>5</td><td>55000.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td><td>2000-03-14 13:12:07.000</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 27, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d','e') units=(None,'m',None,None,'s',None)>\n", | |
| "array([ (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:06.000>),\n", | |
| " (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:07.000>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O'), ('e', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 27 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "try:\n", | |
| " t[1] = (100, 100*u.m, 100*u.m/u.s, 100*u.s, 100*u.m*u.m/u.s)\n", | |
| "except Exception as err:\n", | |
| " print(err)\n", | |
| "t # NOTE bug with partial assignment of row before failure" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": [ | |
| "Right side value needs 6 elements (one for each column)\n" | |
| ] | |
| }, | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th><th>e</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th><th></th></tr></thead><tr><td>5</td><td>55000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td><td>2000-02-07 00:36:06.000</td></tr><tr><td>5</td><td>55000.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td><td>2000-03-14 13:12:07.000</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 28, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d','e') units=(None,'m',None,None,'s',None)>\n", | |
| "array([ (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:06.000>),\n", | |
| " (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:07.000>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O'), ('e', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 28 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t2 = t.copy()\n", | |
| "t2['b'][0] = -100 * u.m\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4424506640\"><thead><tr><th>a</th><th>b</th><th>c</th><th>sc</th><th>d</th><th>e</th></tr></thead><thead><tr><th></th><th>m</th><th></th><th></th><th>s</th><th></th></tr></thead><tr><td>5</td><td>55000.0 m</td><td>2000-02-07 00:36:00.000</td><td><SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg></td><td>6.0 s</td><td>2000-02-07 00:36:06.000</td></tr><tr><td>5</td><td>55000.0 m</td><td>2000-03-14 13:12:00.000</td><td><SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg></td><td>7.0 s</td><td>2000-03-14 13:12:07.000</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 29, | |
| "text": [ | |
| "<Table rows=2 names=('a','b','c','sc','d','e') units=(None,'m',None,None,'s',None)>\n", | |
| "array([ (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:00.000>, <SkyCoord (ICRS): ra=1.0 deg, dec=2.0 deg>, 6.0, <Time object: scale='utc' format='iso' value=2000-02-07 00:36:06.000>),\n", | |
| " (5, 55000.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:00.000>, <SkyCoord (ICRS): ra=3.0 deg, dec=4.0 deg>, 7.0, <Time object: scale='utc' format='iso' value=2000-03-14 13:12:07.000>)], \n", | |
| " dtype=[('a', '<i8'), ('b', 'O'), ('c', 'O'), ('sc', 'O'), ('d', 'O'), ('e', 'O')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 29 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['c']" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 30, | |
| "text": [ | |
| "<Time object: scale='utc' format='iso' value=['2000-02-07 00:36:00.000' '2000-03-14 13:12:00.000']>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 30 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "try:\n", | |
| " # Hmm, this is broken\n", | |
| " t['a', 'c', 'e']\n", | |
| "except Exception as err:\n", | |
| " print(err)" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": [ | |
| "Cannot have None for column name\n" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 31 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t = Table([[1,2,3], [4,5,6]], names=('a', 'b'), masked=True)\n", | |
| "t['a'].mask = [0,1,0]\n", | |
| "t" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "html": [ | |
| "<table id=\"table4425032336\"><thead><tr><th>a</th><th>b</th></tr></thead><tr><td>1</td><td>4</td></tr><tr><td>--</td><td>5</td></tr><tr><td>3</td><td>6</td></tr></table>" | |
| ], | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 32, | |
| "text": [ | |
| "<Table rows=3 names=('a','b')>\n", | |
| "masked_array(data = [(1, 4) (--, 5) (3, 6)],\n", | |
| " mask = [(False, False) (True, False) (False, False)],\n", | |
| " fill_value = (999999, 999999),\n", | |
| " dtype = [('a', '<i8'), ('b', '<i8')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 32 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 33, | |
| "text": [ | |
| "<Row 1 of table\n", | |
| " values=(--, 5)\n", | |
| " dtype=[('a', '<i8'), ('b', '<i8')]>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 33 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "print(t[1])" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stdout", | |
| "text": [ | |
| "<Row 1 of table\n", | |
| " values=(--, 5)\n", | |
| " dtype=[('a', '<i8'), ('b', '<i8')]>\n" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 34 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t['a'][1]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 35, | |
| "text": [ | |
| "masked" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 35 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1]['a']" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 36, | |
| "text": [ | |
| "masked" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 36 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1].data" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 37, | |
| "text": [ | |
| "(--, 5)" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 37 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1].dtype" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 38, | |
| "text": [ | |
| "dtype([('a', '<i8'), ('b', '<i8')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 38 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "np.ma.array([tuple(col[1] for col in t.columns.values())], dtype=t[1].dtype)" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "output_type": "stream", | |
| "stream": "stderr", | |
| "text": [ | |
| "/Users/aldcroft/anaconda/envs/astropy/lib/python2.7/site-packages/numpy/ma/core.py:3847: UserWarning: Warning: converting a masked element to nan.\n", | |
| " warnings.warn(\"Warning: converting a masked element to nan.\")\n" | |
| ] | |
| }, | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 39, | |
| "text": [ | |
| "masked_array(data = [(0, 5)],\n", | |
| " mask = [(False, False)],\n", | |
| " fill_value = (999999, 999999),\n", | |
| " dtype = [('a', '<i8'), ('b', '<i8')])" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 39 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "[tuple(col[1] for col in t.columns.values())]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 40, | |
| "text": [ | |
| "[(masked, 5)]" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 40 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [ | |
| "t[1]" | |
| ], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [ | |
| { | |
| "metadata": {}, | |
| "output_type": "pyout", | |
| "prompt_number": 41, | |
| "text": [ | |
| "<Row 1 of table\n", | |
| " values=(--, 5)\n", | |
| " dtype=[('a', '<i8'), ('b', '<i8')]>" | |
| ] | |
| } | |
| ], | |
| "prompt_number": 41 | |
| }, | |
| { | |
| "cell_type": "code", | |
| "collapsed": false, | |
| "input": [], | |
| "language": "python", | |
| "metadata": {}, | |
| "outputs": [], | |
| "prompt_number": 41 | |
| } | |
| ], | |
| "metadata": {} | |
| } | |
| ] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment