Skip to content
This repository has been archived by the owner on Nov 5, 2020. It is now read-only.

Commit

Permalink
Merge pull request #89 from SaraOgaz/tables_doc_addition
Browse files Browse the repository at this point in the history
some small updates, closes #87
  • Loading branch information
SaOgaz committed Apr 6, 2018
2 parents 2b5a930 + 607c7bb commit d765669
Show file tree
Hide file tree
Showing 6 changed files with 130 additions and 50 deletions.
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,10 @@ Please open a new `issue <https://github.com/spacetelescope/stak-notebooks/issue
or new `pull request <https://github.com/spacetelescope/stak-notebooks/pulls>`_
for bugs, feedback, or new features you would like to see.

If there is an issue you would like to work on, please leave a comment and
we will be happy to assist. New contributions and contributors are very welcome!
If there is an issue you would like to work on, please open an issue and
we will be happy to assist. New contributions and contributors are very welcome! For
some comprehensive guidlines to contributing on Github, Astropy has a very nice
write up here: http://docs.astropy.org/en/stable/development/workflow/development_workflow.html.
But please keep in mind not all repositories on Github will want this contribution workflow.
If you need some help applying the Astropy contribution guide to this project, we are available for
questions/guidance.
33 changes: 5 additions & 28 deletions notebooks/fitsutil.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,8 @@
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": true
},
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"# Astronomy Specific Imports\n",
Expand All @@ -305,28 +303,7 @@
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[3, 4, 7]"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list=[3,4,5,6,7,7,8]\n",
"list[:2]+list[5:6]"
]
},
{
"cell_type": "code",
"execution_count": 41,
"execution_count": 10,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -389,7 +366,7 @@
"\n",
"# Now save a new copy of the original file without that third extension\n",
"edited_hdulist = fits.HDUList([hdulist[0],hdulist[1],hdulist[2],hdulist[4],hdulist[5],hdulist[6]])\n",
"print(type(edited_hdulist))\n",
"print(type(hdulist))\n",
"print(\"\\n\\nnew FITS file with the 3rd extension taken out:\")\n",
"edited_hdulist.info()\n",
"edited_hdulist.writeto(outfile_2, overwrite=True)\n",
Expand Down Expand Up @@ -653,7 +630,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.5.4"
}
},
"nbformat": 4,
Expand Down
3 changes: 3 additions & 0 deletions notebooks/images.imfilter.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
"Below we change the matplotlib colormap to ``viridis``. This is temporarily changing the colormap setting in the matplotlib rc file.\n",
"\n",
"\n",
"**Important Note to Users:**\n",
"There are some differences in algorithms between some of the IRAF and Python Interpolations. Proceed with care if you are comparing prior IRAF results to Python results. For more details on this issue see the [filed Github issue](https://github.com/spacetelescope/stak-notebooks/issues/75).\n",
"\n",
"Contents:\n",
"\n",
"* [boxcar](#boxcar)\n",
Expand Down
3 changes: 3 additions & 0 deletions notebooks/images.imgeom.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
"\n",
"The boundary condition options for IRAF and ``scipy`` are the same: nearest, wrap, reflect, and constant.\n",
"\n",
"**Important Note to Users:**\n",
"There are some differences in algorithms between some of the IRAF and Python Interpolations. Proceed with care if you are comparing prior IRAF results to Python results. For more details on this issue see the [filed Github issue](https://github.com/spacetelescope/stak-notebooks/issues/75).\n",
"\n",
"Contents:\n",
"\n",
"* [blkavg](#blkavg)\n",
Expand Down
5 changes: 4 additions & 1 deletion notebooks/images.imutil.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1868,7 +1868,10 @@
"source": [
"**Please review the** [Notes](#notes) **section above before running any examples in this notebook**\n",
"\n",
"We will use the ``astropy.stats.sigma_clipped_stats`` function here, which has some wider capabilites then the imstatistics function. Please see the ``stats`` [package documentation](http://docs.astropy.org/en/stable/api/astropy.stats.sigma_clipped_stats.html) for details on the advanced usage. We also use some Numpy functions for additional statistics."
"We will use the ``astropy.stats.sigma_clipped_stats`` function here, which has some wider capabilites then the imstatistics function. Please see the ``stats`` [package documentation](http://docs.astropy.org/en/stable/api/astropy.stats.sigma_clipped_stats.html) for details on the advanced usage. We also use some Numpy functions for additional statistics.\n",
"\n",
"**Important Note to Users:**\n",
"There are some differences in algorithms between the IRAF and Python statistical calculations. Proceed with care if you are comparing prior IRAF results to Python results. For more details on this issue see the [filed Github issue](https://github.com/spacetelescope/stak-notebooks/issues/83)."
]
},
{
Expand Down
127 changes: 108 additions & 19 deletions notebooks/tables.ttools.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
"data": {
"text/html": [
"<i>Table length=5</i>\n",
"<table id=\"table90467202944\" class=\"table-striped table-bordered table-condensed\">\n",
"<table id=\"table90472151528\" class=\"table-striped table-bordered table-condensed\">\n",
"<thead><tr><th>sname</th><th>radius</th><th>fwhm</th></tr></thead>\n",
"<thead><tr><th>str5</th><th>int64</th><th>float64</th></tr></thead>\n",
"<tr><td>star1</td><td>10</td><td>6.5</td></tr>\n",
Expand Down Expand Up @@ -1017,7 +1017,7 @@
"source": [
"**Please review the** [Notes](#notes) **section above before running any examples in this notebook**\n",
"\n",
"Tinfo, tlcol and tprint were all used to display information about the table. Below we show the ``Astropy Table`` equivalents."
"Tinfo, tlcol and tprint were all used to display information about the table. Below we show the ``Astropy Table`` equivalents, including ``showtable`` which is callable from the terminal."
]
},
{
Expand Down Expand Up @@ -1117,6 +1117,97 @@
"ex_table['sname','fwhm'][0:3]"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\u001b[0;31msname radius fwhm\u001b[0m\r\n",
"\u001b[0;31m----- ------ ----\u001b[0m\r\n",
"star1 10 6.5\r\n",
"star2 7 5.1\r\n",
"star3 2 0.5\r\n",
"star4 1 0.75\r\n",
"star5 20 13.0\r\n"
]
}
],
"source": [
"# To print a table outside of a Python interpreter\n",
"# Astropy has added the convenience function showtable\n",
"!showtable --format ascii /eng/ssb/iraf_transition/test_data/table2.txt"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"usage: showtable [-h] [--format FORMAT] [--more] [--info] [--stats]\r\n",
" [--max-lines MAX_LINES] [--max-width MAX_WIDTH] [--hide-unit]\r\n",
" [--show-dtype] [--delimiter DELIMITER] [--hdu HDU]\r\n",
" [--path PATH] [--table-id TABLE_ID]\r\n",
" filename [filename ...]\r\n",
"\r\n",
"Print tables from ASCII, FITS, HDF5, VOTable file(s). The tables are read with\r\n",
"'astropy.table.Table.read' and are printed with 'astropy.table.Table.pprint'.\r\n",
"The default behavior is to make the table output fit onto a single screen\r\n",
"page. For a long and wide table this will mean cutting out inner rows and\r\n",
"columns. To print **all** the rows or columns use ``--max-lines=-1`` or ``max-\r\n",
"width=-1``, respectively. The complete list of supported formats can be found\r\n",
"at http://astropy.readthedocs.io/en/latest/io/unified.html#built-in-table-\r\n",
"readers-writers\r\n",
"\r\n",
"positional arguments:\r\n",
" filename path to one or more files\r\n",
"\r\n",
"optional arguments:\r\n",
" -h, --help show this help message and exit\r\n",
" --format FORMAT input table format, should be specified if it cannot\r\n",
" be automatically detected\r\n",
" --more use the pager mode from Table.more\r\n",
" --info show information about the table columns\r\n",
" --stats show statistics about the table columns\r\n",
"\r\n",
"pprint arguments:\r\n",
" --max-lines MAX_LINES\r\n",
" maximum number of lines in table output\r\n",
" (default=screen length, -1 for no limit)\r\n",
" --max-width MAX_WIDTH\r\n",
" maximum width in table output (default=screen width,\r\n",
" -1 for no limit)\r\n",
" --hide-unit hide the header row for unit (which is shown only if\r\n",
" one or more columns has a unit)\r\n",
" --show-dtype include a header row for column dtypes\r\n",
"\r\n",
"ASCII arguments:\r\n",
" --delimiter DELIMITER\r\n",
" column delimiter string\r\n",
"\r\n",
"FITS arguments:\r\n",
" --hdu HDU name of the HDU to show\r\n",
"\r\n",
"HDF5 arguments:\r\n",
" --path PATH the path from which to read the table\r\n",
"\r\n",
"VOTable arguments:\r\n",
" --table-id TABLE_ID the table to read in\r\n"
]
}
],
"source": [
"# Here is the showtable help for more details on usage\n",
"!showtable --help"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -1545,12 +1636,12 @@
"source": [
"**Please review the** [Notes](#notes) **section above before running any examples in this notebook**\n",
"\n",
"Tselect is used to create a new table from selected rows, tproject from selected columns, and tquery from a combination of selected rows and columns. We show two examples of how to generate a new table from selected columns and selected rows. You can combine these two pieces of code in either order to get a tquery like result. There is an alternate way to do selections if you have already organized your table into groups by using the [filter method](http://docs.astropy.org/en/stable/table/operations.html#filtering), but the user will still need to write a custom filtering function to provide to ``filter``."
"Tselect is used to create a new table from selected rows, tproject from selected columns, and tquery from a combination of selected rows and columns. We show two examples of how to generate a new table from selected columns and selected rows. You can combine these two pieces of code in either order to get a tquery like result. For row filtering we combine boolean masks using the [Python bitwise operators](https://docs.python.org/3.5/library/stdtypes.html#bitwise-operations-on-integer-types). There is an alternate way to do selections if you have already organized your table into groups by using the [filter method](http://docs.astropy.org/en/stable/table/operations.html#filtering), but the user will still need to write a custom filtering function to provide to ``filter``."
]
},
{
"cell_type": "code",
"execution_count": 24,
"execution_count": 35,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -1560,7 +1651,7 @@
},
{
"cell_type": "code",
"execution_count": 26,
"execution_count": 33,
"metadata": {},
"outputs": [
{
Expand All @@ -1570,23 +1661,23 @@
"sname radius fwhm\n",
"----- ------ ----\n",
"star4 1 0.75\n",
"star5 20 4.5\n"
"star5 20 13.0\n"
]
}
],
"source": [
"# For selecting rows we give the new table an initial column setup, \n",
"# copied from the original table through the dtype keyword\n",
"# For selecting rows can use bitwise operators to generate a boolean mask\n",
"table1 = Table(dtype=ex_table.dtype)\n",
"for row in ex_table:\n",
" if row['sname'] == 'star4' or row['radius'] == 20:\n",
" table1.add_row(row)\n",
"table1.pprint()"
"boolean_mask = (ex_table['sname'] == 'star4') | (ex_table['radius'] == 20)\n",
"\n",
"# \n",
"subset = ex_table[boolean_mask]\n",
"subset.pprint()"
]
},
{
"cell_type": "code",
"execution_count": 27,
"execution_count": 37,
"metadata": {},
"outputs": [
{
Expand All @@ -1599,16 +1690,14 @@
"star2 5.1\n",
"star3 0.5\n",
"star4 0.75\n",
"star5 4.5\n"
"star5 13.0\n"
]
}
],
"source": [
"# For selecting columns we start with an empty new table\n",
"table2 = Table()\n",
"for col in ex_table.itercols():\n",
" if col.name in ['sname','fwhm']:\n",
" table2[col.name] = col\n",
"# For selecting columns we can pull the required columns \n",
"# out of the original table with the column names\n",
"table2 = ex_table['sname','fwhm']\n",
"table2.pprint()"
]
},
Expand Down

0 comments on commit d765669

Please sign in to comment.