glue-viz / glue-astronomy

Plugin to add astronomy-specific functionality to glue
https://glue-astronomy.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
11 stars 12 forks source link

Added spectral-cube factory and add ability to load CASA .image directories #5

Closed astrofrog closed 4 years ago

astrofrog commented 4 years ago

This moves the spectral-cube loader from the core glue package to here, and adds the ability to load CASA .image directories directly into glue.

https://github.com/glue-viz/glue/pull/2077 is also needed for this to all work properly

codecov[bot] commented 4 years ago

Codecov Report

Merging #5 into master will decrease coverage by 1.06%. The diff coverage is 89.23%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #5      +/-   ##
==========================================
- Coverage   98.61%   97.54%   -1.07%     
==========================================
  Files          10       13       +3     
  Lines         506      571      +65     
==========================================
+ Hits          499      557      +58     
- Misses          7       14       +7
Impacted Files Coverage Δ
...onomy/io/spectral_cube/tests/test_spectral_cube.py 100% <100%> (ø)
glue_astronomy/io/spectral_cube/__init__.py 50% <50%> (ø)
glue_astronomy/io/spectral_cube/spectral_cube.py 82.35% <82.35%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 10d9a32...11621ea. Read the comment docs.

keflavich commented 4 years ago

I'm running into additional errors:

s$ /orange/adamginsburg/miniconda3/envs/casa6_py36/bin/glue
^LDownloading https://hpiers.obspm.fr/iers/bul/bulc/Leap_Second.dat
|==============================================================================================================================| 1.3k/1.3k (100.00%)         0s
Traceback (most recent call last):
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 41, in data_wizard
    result = gdd.load_data()
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 129, in load_data
    d = load_data(path, factory=fac.function)
AttributeError: 'NoneType' object has no attribute 'function'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/orange/adamginsburg/repos/glue/glue/utils/misc.py", line 55, in result
    return func(*args, **kwargs)
  File "/orange/adamginsburg/repos/glue/glue/app/qt/application.py", line 249, in _choose_load_data
    data = data_importer()
  File "/orange/adamginsburg/repos/glue/glue/io/qt/directory_importer/directory_importer.py", line 7, in directory_importer
    return data_wizard(mode='directories')
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 44, in data_wizard
    decision = report_error(e, gdd.factory(), gdd._curfile)
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 29, in report_error
    "File load method: %s" % factory.label])
AttributeError: 'NoneType' object has no attribute 'label'
keflavich commented 4 years ago

Followup with glue -v on a debug branch:

$ /orange/adamginsburg/miniconda3/envs/casa6_py36/bin/glue -v
INFO:glue:Input arguments: ['/orange/adamginsburg/miniconda3/envs/casa6_py36/bin/glue', '-v']
INFO:glue:Loading external plugins using setuptools==41.0.1
INFO:glue:Loading plugin vispy_scatter failed (Exception: cannot import name 'six')
INFO:glue:Loading plugin vispy_volume failed (Exception: cannot import name 'six')
INFO:glue:Loading plugin coordinate_helpers succeeded
INFO:glue:Loading plugin data_exporters succeeded
INFO:glue:Loading plugin dendro_factory failed (Exception: No module named 'astrodendro')
INFO:glue:Loading plugin dendro_viewer succeeded
INFO:glue:Loading plugin directory_importer succeeded
INFO:glue:Loading plugin export_d3po succeeded
INFO:glue:Loading plugin export_python succeeded
INFO:glue:Loading plugin fits_format succeeded
INFO:glue:Loading plugin histogram_viewer succeeded
INFO:glue:Loading plugin image_viewer succeeded
INFO:glue:Loading plugin profile_viewer succeeded
INFO:glue:Loading plugin pv_slicer succeeded
INFO:glue:Loading plugin scatter_viewer succeeded
INFO:glue:Loading plugin table_viewer succeeded
INFO:glue:Loading plugin wcs_autolinking succeeded
INFO:glue:Loading plugin glue_astronomy succeeded
INFO:glue:Loading plugin spectral_cube succeeded
INFO:glue:Loading settings from /home/adamginsburg/.glue/settings.cfg
INFO:glue:Setting AUTOLINK already initialized - skipping
INFO:glue:Setting BACKGROUND_COLOR already initialized - skipping
INFO:glue:Setting DATA_ALPHA already initialized - skipping
INFO:glue:Setting DATA_COLOR already initialized - skipping
INFO:glue:Setting FONT_SIZE already initialized - skipping
INFO:glue:Setting FOREGROUND_COLOR already initialized - skipping
INFO:glue:Setting SHOW_INFO_PROFILE_OPEN already initialized - skipping
INFO:glue:Setting SHOW_LARGE_DATA_WARNING already initialized - skipping
INFO:glue:Setting SHOW_WARN_PROFILE_DUPLICATE already initialized - skipping
INFO:glue:Setting SUBSET_COLORS already initialized - skipping
INFO:glue.core.hub:Subscribing DataCollection (0 data sets)
         to ComponentsChangedMessage
INFO:glue.core.hub:Subscribing <glue.core.link_manager.LinkManager object at 0x2b63905bb5c0> to DataRemoveComponentMessage
INFO:glue.core.hub:Subscribing <glue.core.link_manager.LinkManager object at 0x2b63905bb5c0> to DataCollectionDeleteMessage
INFO:glue:Loading external plugins using setuptools==41.0.1
INFO:glue:Loading plugin vispy_scatter failed (Exception: cannot import name 'six')
INFO:glue:Loading plugin vispy_volume failed (Exception: cannot import name 'six')
INFO:glue:Plugin coordinate_helpers already loaded
INFO:glue:Plugin data_exporters already loaded
INFO:glue:Loading plugin dendro_factory failed (Exception: No module named 'astrodendro')
INFO:glue:Plugin dendro_viewer already loaded
INFO:glue:Plugin directory_importer already loaded
INFO:glue:Plugin export_d3po already loaded
INFO:glue:Plugin export_python already loaded
INFO:glue:Plugin fits_format already loaded
INFO:glue:Plugin histogram_viewer already loaded
INFO:glue:Plugin image_viewer already loaded
INFO:glue:Plugin profile_viewer already loaded
INFO:glue:Plugin pv_slicer already loaded
INFO:glue:Plugin scatter_viewer already loaded
INFO:glue:Plugin table_viewer already loaded
INFO:glue:Plugin wcs_autolinking already loaded
INFO:glue:Plugin glue_astronomy already loaded
INFO:glue:Plugin spectral_cube already loaded
INFO:glue:Loading settings from /home/adamginsburg/.glue/settings.cfg
INFO:glue:Setting AUTOLINK already initialized - skipping
INFO:glue:Setting BACKGROUND_COLOR already initialized - skipping
INFO:glue:Setting DATA_ALPHA already initialized - skipping
INFO:glue:Setting DATA_COLOR already initialized - skipping
INFO:glue:Setting FONT_SIZE already initialized - skipping
INFO:glue:Setting FOREGROUND_COLOR already initialized - skipping
INFO:glue:Setting SHOW_INFO_PROFILE_OPEN already initialized - skipping
INFO:glue:Setting SHOW_LARGE_DATA_WARNING already initialized - skipping
INFO:glue:Setting SHOW_WARN_PROFILE_DUPLICATE already initialized - skipping
INFO:glue:Setting SUBSET_COLORS already initialized - skipping
INFO:glue.core.hub:Subscribing <glue.app.qt.edit_subset_mode_toolbar.EditSubsetModeToolBar object at 0x2b63906c4438> to EditSubsetMessage
INFO:glue.core.hub:Subscribing <glue.app.qt.edit_subset_mode_toolbar.EditSubsetModeToolBar object at 0x2b63906c4438> to SubsetMessage
INFO:glue.core.hub:Subscribing <glue.app.qt.application.GlueApplication object at 0x2b63905bd558> to DataCollectionMessage
INFO:glue.core.hub:Subscribing <glue.app.qt.application.GlueApplication object at 0x2b63905bd558> to SettingsChangeMessage
INFO:glue.core.hub:Subscribing <glue.core.qt.data_collection_model.DataCollectionModel object at 0x2b63906cea68> to DataCollectionDeleteMessage
INFO:glue.core.hub:Subscribing <glue.core.qt.data_collection_model.DataCollectionModel object at 0x2b63906cea68> to SubsetDeleteMessage
INFO:glue.core.hub:Subscribing <glue.core.qt.data_collection_model.DataCollectionModel object at 0x2b63906cea68> to DataCollectionAddMessage
INFO:glue.core.hub:Subscribing <glue.core.qt.data_collection_model.DataCollectionModel object at 0x2b63906cea68> to SubsetCreateMessage
INFO:glue.core.hub:Subscribing <glue.core.qt.data_collection_model.DataCollectionView object at 0x2b63905cd1f8> to Message
INFO:glue.core.hub:Subscribing <glue.app.qt.layer_tree_widget.LayerTreeWidget object at 0x2b63905d0c18> to EditSubsetMessage
fltr 'Directories'
k, v DataFactory(function=<function auto_data at 0x2b636e7229d8>, label='Auto', identifier=<function <lambda> at 0x2b636e7226a8>, priority=0, deprecated=False) 'Auto (*)'
k, v DataFactory(function=<function astropy_tabular_data at 0x2b636e722a60>, label='Catalog (astropy.table parser)', identifier=<function is_readable_by_astropy at 0x2b636d3d68c8>, priority=0, deprecated=False) 'Catalog (astropy.table parser) (*)'
k, v DataFactory(function=<function astropy_tabular_data_votable at 0x2b636e722b70>, label='VO table', identifier=<function has_extension.<locals>.tester at 0x2b636e722950>, priority=1, deprecated=False) 'VO table (*)'
k, v DataFactory(function=<function astropy_tabular_data_fits at 0x2b636e722c80>, label='FITS table', identifier=<function has_extension.<locals>.tester at 0x2b636e722ae8>, priority=1, deprecated=False) 'FITS table (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e722e18>, label='SExtractor Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722d08>, priority=0, deprecated=False) 'SExtractor Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e722f28>, label='CDS Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722d90>, priority=0, deprecated=False) 'CDS Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7230d0>, label='DAOphot Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722ea0>, priority=0, deprecated=False) 'DAOphot Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7231e0>, label='IPAC Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723048>, priority=0, deprecated=False) 'IPAC Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7232f0>, label='AASTeX Table', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723158>, priority=0, deprecated=False) 'AASTeX Table (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e723400>, label='LaTeX Table', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723268>, priority=0, deprecated=False) 'LaTeX Table (*)'
k, v DataFactory(function=<function pandas_read_table at 0x2b636fabf488>, label='Pandas Table', identifier=<function has_extension.<locals>.tester at 0x2b636fabf2f0>, priority=0, deprecated=False) 'Pandas Table (*)'
k, v DataFactory(function=<function panda_read_excel at 0x2b636fabf598>, label='Excel', identifier=<function has_extension.<locals>.tester at 0x2b636e723378>, priority=0, deprecated=False) 'Excel (*)'
k, v DataFactory(function=<function fits_reader at 0x2b636fabf8c8>, label='FITS file', identifier=<function is_fits at 0x2b636fabf6a8>, priority=100, deprecated=False) 'FITS file (*)'
k, v DataFactory(function=<function hdf5_reader at 0x2b636fabfe18>, label='HDF5 file', identifier=<function is_hdf5 at 0x2b636fabfd08>, priority=100, deprecated=False) 'HDF5 file (*)'
k, v DataFactory(function=<function img_data at 0x2b636face048>, label='Image', identifier=<function has_extension.<locals>.tester at 0x2b636fabfea0>, priority=0, deprecated=False) 'Image (*)'
k, v DataFactory(function=<function npy_npz_reader at 0x2b636face158>, label='Numpy save file', identifier=<function is_npy_npz at 0x2b636fabff28>, priority=100, deprecated=False) 'Numpy save file (*)'
k, v DataFactory(function=<function tabular_data at 0x2b636face268>, label='ASCII Table', identifier=<function has_extension.<locals>.tester at 0x2b636face0d0>, priority=1, deprecated=False) 'ASCII Table (*)'
k, v DataFactory(function=<function read_spectral_cube at 0x2b63905bc158>, label='Spectral Cube', identifier=<function is_spectral_cube at 0x2b63905b9ae8>, priority=0, deprecated=False) 'Spectral Cube (*)'
fltr 'Directories'
k, v DataFactory(function=<function auto_data at 0x2b636e7229d8>, label='Auto', identifier=<function <lambda> at 0x2b636e7226a8>, priority=0, deprecated=False) 'Auto (*)'
k, v DataFactory(function=<function astropy_tabular_data at 0x2b636e722a60>, label='Catalog (astropy.table parser)', identifier=<function is_readable_by_astropy at 0x2b636d3d68c8>, priority=0, deprecated=False) 'Catalog (astropy.table parser) (*)'
k, v DataFactory(function=<function astropy_tabular_data_votable at 0x2b636e722b70>, label='VO table', identifier=<function has_extension.<locals>.tester at 0x2b636e722950>, priority=1, deprecated=False) 'VO table (*)'
k, v DataFactory(function=<function astropy_tabular_data_fits at 0x2b636e722c80>, label='FITS table', identifier=<function has_extension.<locals>.tester at 0x2b636e722ae8>, priority=1, deprecated=False) 'FITS table (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e722e18>, label='SExtractor Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722d08>, priority=0, deprecated=False) 'SExtractor Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e722f28>, label='CDS Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722d90>, priority=0, deprecated=False) 'CDS Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7230d0>, label='DAOphot Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e722ea0>, priority=0, deprecated=False) 'DAOphot Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7231e0>, label='IPAC Catalog', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723048>, priority=0, deprecated=False) 'IPAC Catalog (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e7232f0>, label='AASTeX Table', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723158>, priority=0, deprecated=False) 'AASTeX Table (*)'
k, v DataFactory(function=<function formatted_table_factory.<locals>.factory at 0x2b636e723400>, label='LaTeX Table', identifier=<function formatted_table_factory.<locals>.<lambda> at 0x2b636e723268>, priority=0, deprecated=False) 'LaTeX Table (*)'
k, v DataFactory(function=<function pandas_read_table at 0x2b636fabf488>, label='Pandas Table', identifier=<function has_extension.<locals>.tester at 0x2b636fabf2f0>, priority=0, deprecated=False) 'Pandas Table (*)'
k, v DataFactory(function=<function panda_read_excel at 0x2b636fabf598>, label='Excel', identifier=<function has_extension.<locals>.tester at 0x2b636e723378>, priority=0, deprecated=False) 'Excel (*)'
k, v DataFactory(function=<function fits_reader at 0x2b636fabf8c8>, label='FITS file', identifier=<function is_fits at 0x2b636fabf6a8>, priority=100, deprecated=False) 'FITS file (*)'
k, v DataFactory(function=<function hdf5_reader at 0x2b636fabfe18>, label='HDF5 file', identifier=<function is_hdf5 at 0x2b636fabfd08>, priority=100, deprecated=False) 'HDF5 file (*)'
k, v DataFactory(function=<function img_data at 0x2b636face048>, label='Image', identifier=<function has_extension.<locals>.tester at 0x2b636fabfea0>, priority=0, deprecated=False) 'Image (*)'
k, v DataFactory(function=<function npy_npz_reader at 0x2b636face158>, label='Numpy save file', identifier=<function is_npy_npz at 0x2b636fabff28>, priority=100, deprecated=False) 'Numpy save file (*)'
k, v DataFactory(function=<function tabular_data at 0x2b636face268>, label='ASCII Table', identifier=<function has_extension.<locals>.tester at 0x2b636face0d0>, priority=1, deprecated=False) 'ASCII Table (*)'
k, v DataFactory(function=<function read_spectral_cube at 0x2b63905bc158>, label='Spectral Cube', identifier=<function is_spectral_cube at 0x2b63905b9ae8>, priority=0, deprecated=False) 'Spectral Cube (*)'
Traceback (most recent call last):
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 41, in data_wizard
    result = gdd.load_data()
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 132, in load_data
    d = load_data(path, factory=fac.function)
AttributeError: 'NoneType' object has no attribute 'function'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/orange/adamginsburg/repos/glue/glue/utils/misc.py", line 55, in result
    return func(*args, **kwargs)
  File "/orange/adamginsburg/repos/glue/glue/app/qt/application.py", line 249, in _choose_load_data
    data = data_importer()
  File "/orange/adamginsburg/repos/glue/glue/io/qt/directory_importer/directory_importer.py", line 7, in directory_importer
    return data_wizard(mode='directories')
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 44, in data_wizard
    decision = report_error(e, gdd.factory(), gdd._curfile)
  File "/orange/adamginsburg/repos/glue/glue/dialogs/data_wizard/qt/data_wizard_dialog.py", line 29, in report_error
    "File load method: %s" % factory.label])
AttributeError: 'NoneType' object has no attribute 'label'