Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion astrodendro/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
from .dendrogram import Dendrogram
from .analysis import ppv_catalog, pp_catalog
from .plot import DendrogramPlotter
from .viewer import BasicDendrogramViewer
from .viewer import BasicDendrogramViewer
from .datasets import load_perseus
14 changes: 14 additions & 0 deletions astrodendro/datasets/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import os

from astropy.io import fits

path = os.path.dirname(__file__)

def load_perseus():
""" Load the Primary HDU for the Perseus extinction map
used throughout the documentation.

For more details about the data, see http://hdl.handle.net/10904/10080
"""
pth = os.path.join(path, 'PerA_Extn2MASS_F_Gal.fits')
return fits.open(pth)[0]
5 changes: 5 additions & 0 deletions astrodendro/test/test_datasets.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from astrodendro import load_perseus

def test_load_perseus():
p = load_perseus()
assert p.data.shape == (313, 217)
9 changes: 4 additions & 5 deletions docs/catalog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@ where ``structure`` is a :class:`~astrodendro.structure.Structure` instance
from a dendrogram. The resulting object then has methods to compute various
statistics. Using the example data from :doc:`using`::

>>> from astrodendro import Dendrogram
>>> from astropy.io import fits
>>> image = fits.getdata('PerA_Extn2MASS_F_Gal.fits')
>>> from astrodendro import Dendrogram, load_perseus
>>> image = load_perseus().data
>>> d = Dendrogram.compute(image, min_value=2.0, min_delta=1., min_npix=10)

we can get statistics for the first structure in the trunk, which is a leaf::
Expand Down Expand Up @@ -200,13 +199,13 @@ approximating the structures on top of the structures themselves:

from astropy.io import fits

from astrodendro import Dendrogram
from astrodendro import Dendrogram, load_perseus
from astrodendro.analysis import PPStatistic

import matplotlib.pyplot as plt
from matplotlib.patches import Ellipse

hdu = fits.open('PerA_Extn2MASS_F_Gal.fits')[0]
hdu = load_perseus()

d = Dendrogram.compute(hdu.data, min_value=2.0, min_delta=1., min_npix=10)
p = d.plotter()
Expand Down
10 changes: 4 additions & 6 deletions docs/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,9 @@ main branches:
:include-source:

import matplotlib.pyplot as plt
from astropy.io import fits
from astrodendro import Dendrogram
from astrodendro import Dendrogram, load_perseus

image = fits.getdata('PerA_Extn2MASS_F_Gal.fits')
image = load_perseus().data
d = Dendrogram.compute(image, min_value=2.0, min_delta=1., min_npix=10)
p = d.plotter()

Expand Down Expand Up @@ -98,10 +97,9 @@ shown.
:include-source:

import matplotlib.pyplot as plt
from astropy.io import fits
from astrodendro import Dendrogram
from astrodendro import Dendrogram, load_perseus

image = fits.getdata('PerA_Extn2MASS_F_Gal.fits')
image = load_perseus().data
d = Dendrogram.compute(image, min_value=2.0, min_delta=1., min_npix=10)
p = d.plotter()

Expand Down
6 changes: 3 additions & 3 deletions docs/using.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@ These options are illustrated graphically in :doc:`algorithm`.
As an example, we can use a publicly available extinction map of the Perseus
star-formation region from the The COordinated Molecular Probe Line Extinction
Thermal Emission (COMPLETE) Survey of Star Forming Regions
(:download:`PerA_Extn2MASS_F_Gal.fits`, originally obtained from
(originally obtained from
`<http://hdl.handle.net/10904/10080>`_). The units of the map are magnitudes of
extinction, and we want to make a dendrogram of all structures above a minimum
value of 2 magnitudes, and we only consider leaves with at least 10 pixels and
which have a peak to base different larger than one magnitude of extinction::

>>> from astrodendro import Dendrogram
>>> from astrodendro import Dendrogram, load_perseus
>>> from astropy.io import fits
>>> image = fits.getdata('PerA_Extn2MASS_F_Gal.fits')
>>> image = load_perseus().data
>>> d = Dendrogram.compute(image, min_value=2.0, min_delta=1., min_npix=10)

By default, the computation will be silent, but for large dendrograms, it can
Expand Down
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ def run(self):
description='Python package for computation of astronomical dendrograms',
author='Thomas Robitaille, Chris Beaumont, Braden MacDonald, and Erik Rosolowsky',
author_email='braden@bradenmacdonald.com',
packages=['astrodendro', 'astrodendro.io', 'astrodendro.test'],
package_data={'astrodendro.test':['*.npz', 'benchmark_data/*fits']},
packages=['astrodendro', 'astrodendro.io', 'astrodendro.test',
'astrodendro.datasets'],
package_data={'astrodendro.test':['*.npz', 'benchmark_data/*fits'],
'astrodendro.datasets': ['*fits']},
provides=['astrodendro'],
requires=['numpy'],
cmdclass={'build_py': build_py, 'test': DendroTest},
Expand Down