spacetelescope / specviz

An interactive astronomical 1D spectra analysis tool.
http://specviz.readthedocs.io
BSD 3-Clause "New" or "Revised" License
43 stars 31 forks source link

SpecViz updates for integration with CubeViz #671

Closed nmearl closed 5 years ago

nmearl commented 5 years ago
astrofrog commented 5 years ago

Spectral smoothing seems broken when using the specviz viewer inside glue:

Traceback (most recent call last):
  File "/Users/tom/Projects/Glue/STScI/specviz/specviz/core/plugin.py", line 282, in <lambda>
    action.triggered.connect(lambda: func(plugin, *args, **kwargs))
  File "/Users/tom/Projects/Glue/STScI/specviz/specviz/plugins/model_editor/continuum_generator.py", line 32, in on_action_triggered
    cont_mod = fit_generic_continuum(spec, exclude_regions=exc_regs)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/specutils/fitting/continuum.py", line 51, in fit_generic_continuum
    spectrum_smoothed = median_smooth(spectrum, median_window)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/specutils/manipulation/smoothing.py", line 200, in median_smooth
    rest_value=spectrum.rest_value)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/specutils/spectra/spectrum1d.py", line 76, in __init__
    wcs = WCSWrapper.from_array(spectral_axis)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/specutils/wcs/wcs_wrapper.py", line 57, in from_array
    spec_frame = cf.SpectralFrame(unit=array.unit, axes_order=(0,))
  File "/Users/tom/python/dev/lib/python3.7/site-packages/gwcs/coordinate_frames.py", line 350, in __init__
    axis_physical_types=axis_physical_types)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/gwcs/coordinate_frames.py", line 97, in __init__
    self._axis_physical_types = self._set_axis_physical_types(axis_physical_types)
  File "/Users/tom/python/dev/lib/python3.7/site-packages/gwcs/coordinate_frames.py", line 148, in _set_axis_physical_types
    validate_physical_types(ph_type)
UnboundLocalError: local variable 'ph_type' referenced before assignment

screenshot 2019-02-22 at 18 13 08

EDIT: issue report in GWCS - basically due to velocity axis: https://github.com/spacetelescope/gwcs/issues/207

astrofrog commented 5 years ago

I tried to create a 'Simple Linemap' and ended up with the following exception:

Traceback (most recent call last):
  File "/Users/tom/Projects/Glue/STScI/specviz/specviz/third_party/glue/operation_handler.py", line 191, in on_finished
    self._layout.add_overlay(data[0, :, :], component_name, display_now=False)
AttributeError: 'NoneType' object has no attribute 'add_overlay'

I'm using specviz inside glue, but not cubeviz.

nmearl commented 5 years ago

What dataset are you using?

astrofrog commented 5 years ago

@nmearl - I'm using a variant of https://astropy.stsci.edu/data/l1448/l1448_13co.fits - let me know if that specific file doesn't reproduce the errors.

astrofrog commented 5 years ago

My cube doesn't have flux units, and the dialog for changing units looks strange - I'm not sure what the different options are:

screenshot 2019-02-22 at 18 17 34

astrofrog commented 5 years ago

Another small issue: the 'Export Plot' button doesn't appear to be working. Sorry for all the separate comments, I'm just posting things as I find them.

nmearl commented 5 years ago

Glue refuses to load your data cube? Seems like glue is choking on the wcs, and there are unit mismatches.

astrofrog commented 5 years ago

Probably not related to this PR, but the zoom is quite sensitive - while trying to zoom in a lot I managed to make the plot become stuck:

screenshot 2019-02-22 at 18 20 43

I'm not able to zoom back out and I have to close and re-open the viewer.

nmearl commented 5 years ago

I'm not able to zoom back out and I have to close and re-open the viewer.

What happens when you click the "reset view" button?

astrofrog commented 5 years ago

@nmearl - no I'm not having issues loading the cube, these are all issues that occur once I have the dataset inside the specviz viewer in glue (I've tried to describe what I was doing at the start of each comment). Let me know if it'd be more useful to record a screencast.

astrofrog commented 5 years ago

What happens when you click the "reset view" button?

Yep that fixes it!

nmearl commented 5 years ago

When I load your cube, I get multiple errors and warnings:

screen shot 2019-02-22 at 1 25 02 pm screen shot 2019-02-22 at 1 24 59 pm screen shot 2019-02-22 at 1 24 57 pm

And the Glue closes without ever opening up fully.