<commit_before>astrocube
======
Python Classes for Loading and Viewing Radio Astronomy Data Cubes

By <NAME>

Copyright (c) 2011 <NAME>. Released under a BSD License.


About
-----

This package provides a simple interface for loading radio astronomy data cubes 
from a FITS file. It was written primarily as an exercise for me to learn more
about working with data cubes. Thus it is **alpha quality** and not tested
thoroughly enough to be relied upon for other work.

Developed for use with Python 2.7

Features
--------

+ Uses [PyFITS](http://www.stsci.edu/resources/software_hardware/pyfits) to 
  load cube data from FITS files in a standardized way.
+ Uses [PyWCS](http://stsdas.stsci.edu/astrolib/pywcs/) to determine the
  sky coordinates of any data element in the cube in a very easy-to-use way
+ Includes a simple algorithm for determining the standard deviation of 
  noise in the cube as a function of position. 
+ Has a `CubeViewDialog` class that can be used from ipython or other
  applications to display a data cube, browse through its contents, and 
  select points from within the cube (uses matplotlib and pygtk)
+ Installs a script called `astrocubeview.py`, which provides a simple
  ipython-like interface for quickly viewing a data cube and executing
  arbitrary commands using the data in the cube (uses matplotlib and pygtk)

Installation
-----
To install, simply run the following command:
```shell
pip install --user git+git://github.com/bradenmacdonald/astrocube.git#egg=astrocube 
```
(Requires that you have [pip](http://www.pip-installer.org) and 
[distribute](http://pypi.python.org/pypi/distribute) installed.)

To install it system-wide, remove the `--user` argument. To install an 
editable version, add `-e` as an argument just after `--user`. 

Usage
-----
Using ipython and pylab to view the spatial noise deviation in a cube:
```python
# Enter these commands into ipython with pylab enabled:
import astrocube
cube = astrocube.DataCube("L1448.13co.fits") # Substitute with your own file
imshow(cube.noise_dev_xy) # n.b. by default the matplotlib y axis is upside-down
```

Visualizing and interacting with a cube using a simple GUI:
```python
import astrocube
import astrocube.cubeview
import numpy as np
cube = astrocube.DataCube("L1448.13co.fits")  # Substitute with your own file
dialog = astrocube.cubeview.CubeViewDialog(cube)
print("Select a point in the data cube, then close the dialog.")
dialog.run()
v = dialog.view # Shorten this for convenience
print("You selected the point ({x},{y},{z})".format(x=v.x,y=v.y,z=v.z))
print("The sky coordinates of that point are: {0}".format(", ".join(cube.point_coords_str(v.x,v.y,v.z))))
print("Now let's look at the most intense value in the data cube.")
(v.x, v.y, v.z) = np.unravel_index(np.nanargmax(cube.data), cube.data.shape)<commit_msg>Fix formatting of README.<commit_after>astrocube
======
Python Classes for Loading and Viewing Radio Astronomy Data Cubes

By <NAME>

Copyright (c) 2011 <NAME>. Released under a BSD License.


About
-----

This package provides a simple interface for loading radio astronomy data cubes 
from a FITS file. It was written primarily as an exercise for me to learn more
about working with data cubes. Thus it is **alpha quality** and not tested
thoroughly enough to be relied upon for other work.

Developed for use with Python 2.7

Features
--------

+ Uses [PyFITS](http://www.stsci.edu/resources/software_hardware/pyfits) to 
  load cube data from FITS files in a standardized way.
+ Uses [PyWCS](http://stsdas.stsci.edu/astrolib/pywcs/) to determine the
  sky coordinates of any data element in the cube in a very easy-to-use way
+ Includes a simple algorithm for determining the standard deviation of 
  noise in the cube as a function of position. 
+ Has a `CubeViewDialog` class that can be used from ipython or other
  applications to display a data cube, browse through its contents, and 
  select points from within the cube (uses matplotlib and pygtk)
+ Installs a script called `astrocubeview.py`, which provides a simple
  ipython-like interface for quickly viewing a data cube and executing
  arbitrary commands using the data in the cube (uses matplotlib and pygtk)

Installation
-----
To install, simply run the following command:
```shell
pip install --user git+git://github.com/bradenmacdonald/astrocube.git#egg=astrocube 
```
(Requires that you have [pip](http://www.pip-installer.org) and 
[distribute](http://pypi.python.org/pypi/distribute) installed.)

To install it system-wide, remove the `--user` argument. To install an 
editable version, add `-e` as an argument just after `--user`. 

Usage
-----
Using ipython and pylab to view the spatial noise deviation in a cube:

```python
# Enter these commands into ipython with pylab enabled:
import astrocube
cube = astrocube.DataCube("L1448.13co.fits") # Substitute with your own file
imshow(cube.noise_dev_xy) # n.b. by default the matplotlib y axis is upside-down
```

Visualizing and interacting with a cube using a simple GUI:

```python
import astrocube
import astrocube.cubeview
import numpy as np
cube = astrocube.DataCube("L1448.13co.fits")  # Substitute with your own file
dialog = astrocube.cubeview.CubeViewDialog(cube)
print("Select a point in the data cube, then close the dialog.")
dialog.run()
v = dialog.view # Shorten this for convenience
print("You selected the point ({x},{y},{z})".format(x=v.x,y=v.y,z=v.z))
print("The sky coordinates of that point are: {0}".format(", ".join(cube.point_coords_str(v.x,v.y,v.z))))
print("Now let's look at the most intense value in the data cube.")
(v.x, v.y, v.z) = np.unravel_index(np.nanargmax(cube.data), cube.data.shape)
{'fraction_non_alphanumeric': 0.09985910531877422, 'fraction_numerical': 0.006692497358224727, 'mean_word_length': 4.37275307473983, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5637562', 'n_tokens_mistral': 1866, 'n_tokens_neox': 1723, 'n_words': 714}