Table of Contents

    
    
    In [12]:
    %matplotlib widget
    
    
    
    In [1]:
    %load_ext lab_black
    
    
    
    In [2]:
    import matplotlib.pyplot as plt
    
    
    
    In [3]:
    from pyuvis import QUBE, FUV_PDS
    
    
    
    In [17]:
    lbl = "/Users/klay6683/Dropbox/data/uvis/EUV2009_173_15_16.LBL"
    
    
    
    In [18]:
    qube = QUBE(lbl)
    
    
    
    In [19]:
    import xarray as xr
    
    
    
    In [20]:
    xarr = xr.DataArray(
        qube.data,
        dims=["spectral", "spatial", "samples"],
        coords={"spectral": qube.waves},
    )
    
    
    
    
    ---------------------------------------------------------------------------
    AttributeError                            Traceback (most recent call last)
    <ipython-input-20-4f5ab2dff843> in <module>
          2     qube.data,
          3     dims=["spectral", "spatial", "samples"],
    ----> 4     coords={"spectral": qube.waves},
          5 )
    
    ~/Dropbox/src/pyuvis/pyuvis/io.py in waves(self)
         58     @property
         59     def waves(self):
    ---> 60         return np.linspace(self.wave_min, self.wave_max, self.shape[0])
         61 
         62     @property
    
    AttributeError: 'QUBE' object has no attribute 'wave_min'
    
    
    In [21]:
    plt.figure()
    plt.imshow(qube.data[..., 0], aspect="auto")
    
    
    
    
    Out[21]:
    <matplotlib.image.AxesImage at 0x1269929e8>
    
    
    In [9]:
    xarr
    
    
    
    
    Out[9]:
    <xarray.DataArray (spectral: 1024, spatial: 5, samples: 1)>
    array([[[    0],
            [    0],
            ...,
            [    0],
            [    0]],
    
           [[    0],
            [    0],
            ...,
            [    0],
            [    0]],
    
           ...,
    
           [[65535],
            [65535],
            ...,
            [65535],
            [65535]],
    
           [[65535],
            [65535],
            ...,
            [65535],
            [65535]]], dtype=uint16)
    Coordinates:
      * spectral  (spectral) float64 111.5 111.6 111.7 111.7 ... 189.8 189.9 190.0
    Dimensions without coordinates: spatial, samples
    
    
    In [10]:
    import hvplot.xarray
    
    
    
    
    
    
    In [11]:
    xarr.hvplot()
    
    
    
    
    Out[11]:
    
    
    In [19]:
    from astropy import units as u
    
    
    
    In [30]:
    np.linspace(qube.wave_min.value, qube.wave_max.value, qube.shape[0])
    
    
    
    
    Out[30]:
    array([111.5       , 111.57673509, 111.65347019, ..., 189.84652981,
           189.92326491, 190.        ])
    
    
    In [29]:
    qube.shape[0]
    
    
    
    
    Out[29]:
    1024
    
    
    In [25]:
    from astropy.units import QuantityIterator
    
    
    
    
    ---------------------------------------------------------------------------
    ImportError                               Traceback (most recent call last)
    <ipython-input-25-c92b32cc2b4d> in <module>
    ----> 1 from astropy.units import QuantityIterator
    
    ImportError: cannot import name 'QuantityIterator' from 'astropy.units' (/Users/klay6683/miniconda3/envs/py37/lib/python3.7/site-packages/astropy/units/__init__.py)
    
    
    In [18]:
    xarr
    
    
    
    
    Out[18]:
    <xarray.DataArray (spectral: 1024, spatial: 5, samples: 1)>
    array([[[    0],
            [    0],
            ...,
            [    0],
            [    0]],
    
           [[    0],
            [    0],
            ...,
            [    0],
            [    0]],
    
           ...,
    
           [[65535],
            [65535],
            ...,
            [65535],
            [65535]],
    
           [[65535],
            [65535],
            ...,
            [65535],
            [65535]]], dtype=uint16)
    Dimensions without coordinates: spectral, spatial, samples
    
    
    In [14]:
    def show_slice(i):
        im = plt.imshow(qube.data[i], aspect="auto", interpolation="nearest")
        plt.colorbar(im, ax=plt.gca())
    
    
    interactive(show_slice, i=(0, qube.shape[0]))
    
    
    
    

    The preview data from the UVIS data catalog seems to be often the mean value over the bands, at least I could match the preview images quite often. Just for your data file, it does not make sense yet, but maybe because of the missing binning implementation.

    
    
    In [33]:
    plt.imshow(qube.data.mean(axis=0), aspect='auto', interpolation='nearest',
               cmap=plt.cm.rainbow)
    
    
    
    
    Out[33]:
    <matplotlib.image.AxesImage at 0x10d892eb8>
    
    
    In [34]:
    qube.line_range
    
    
    
    
    Out[34]:
    (4, 57)
    
    
    In [35]:
    qube.band_range
    
    
    
    
    Out[35]:
    (0, 1023)
    
    
    In [36]:
    qube.data1D
    
    
    
    
    Out[36]:
    array([65535, 65535, 65535, ..., 65535, 65535, 65535], dtype=uint16)
    
    
    In [37]:
    qube.data.shape
    
    
    
    
    Out[37]:
    (1024, 64, 9748)
    
    
    In [ ]:
    qube