dendrograms / astrodendro

Generate a dendrogram from a dataset
https://dendrograms.readthedocs.io/
Other
37 stars 38 forks source link

Viewer does not handle degenerate coordinates properly #117

Open jpinedaf opened 10 years ago

jpinedaf commented 10 years ago

Hi,

I run dendrograms on an integrated intensity map from JVLA successfully, which has two degenerate coordinates in the header (Stokes=1, and Frequency=1). The size of the array is:

In [14]: array.shape
Out[14]: (1, 1, 1024, 972)

However, the dendrogram viewer does not know how to handle this image:

In [9]: v = d2.viewer()
ERROR: ValueError: Only 2- and 3-dimensional arrays are supported at this time [astrodendro.viewer]
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-9-3d0d5ce782bb> in <module>()
----> 1 v = d2.viewer()

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astrodendro-0.1.0-py2.7.egg/astrodendro/dendrogram.pyc in viewer(self)
    454         """
    455         from .viewer import BasicDendrogramViewer
--> 456         return BasicDendrogramViewer(self)
    457 
    458 

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/astrodendro-0.1.0-py2.7.egg/astrodendro/viewer.pyc in __init__(self, dendrogram)
     10 
     11         if dendrogram.data.ndim not in [2, 3]:
---> 12             raise ValueError("Only 2- and 3-dimensional arrays are supported at this time")
     13 
     14         self.array = dendrogram.data

ValueError: Only 2- and 3-dimensional arrays are supported at this time

I had to go back into CASA and export the data without the degenerate axes, however, since the 2 extra dimensions in the array have length=1 I think that this should be accepted .

Cheers, Jaime

keflavich commented 10 years ago

A quick solution is to pass data.squeeze() into astrodendro; that drops the degenerate dimensions.

(but I think this is an argument for getting spectral-cube integrated into astrodendro)

jpinedaf commented 10 years ago

That helps! Thanks for the quick advice :)