Example #1
0
def test_fits_io_4d():
    # This time using the built-in glue FITS reader which returns a 4D dataset
    from glue.core.data_factories.fits import fits_reader
    data = fits_reader(
        os.path.join(os.path.dirname(__file__), '..', '..', 'io',
                     'spectral_cube', 'tests', 'data', 'cube_4d.fits'))[0]
    sc = data.get_object(cls=SpectralCube)
    assert isinstance(sc, SpectralCube)
    assert sc.shape == (2, 3, 4)
def test_fits_io_4d_fullstokes():
    # And if there are multiple Stokes axes
    from glue.core.data_factories.fits import fits_reader
    data = fits_reader(os.path.join(os.path.dirname(__file__), '..', '..',
                                    'io', 'spectral_cube', 'tests',
                                    'data', 'cube_4d_fullstokes.fits'))[0]
    sc = data.get_object(cls=SpectralCube)
    assert isinstance(sc, SpectralCube)
    assert sc.shape == (2, 3, 4)
Example #3
0
 def _parse_data_hdulist(data, label):
     from glue.core.data_factories.fits import fits_reader
     return fits_reader(data, label=label)
Example #4
0
File: fits.py Project: jzuhone/glue
 def _parse_data_hdulist(data, label):
     from glue.core.data_factories.fits import fits_reader
     return fits_reader(data, label=label)
Example #5
0
    def receive_message(self, private_key, sender_id, msg_id, mtype, params,
                        extra):

        logger.info(
            'SAMP: received message - sender_id={0} msg_id={1} mtype={2} '
            'params={3} extra={4}'.format(sender_id, msg_id, mtype, params,
                                          extra))

        if mtype.startswith('table.load'):

            if self.table_id_exists(params['table-id']):
                logger.info('SAMP: table with table-id={0} has already '
                            'been read in'.format(params['table-id']))
                return

            logger.info('SAMP: loading table with table-id={0}'.format(
                params['table-id']))

            if mtype == 'table.load.votable':
                data = astropy_tabular_data_votable(params['url'])
            elif mtype == 'table.load.fits':
                data = astropy_tabular_data_fits(params['url'])
            else:
                logger.info('SAMP: unknown format {0}'.format(
                    mtype.split('.')[-1]))
                return

            data.label = params['name']
            data.meta['samp-table-id'] = params['table-id']

            self.data_collection.append(data)

        elif mtype.startswith('image.load'):

            if self.image_id_exists(params['image-id']):
                logger.info('SAMP: image with image-id={0} has already '
                            'been read in'.format(params['image-id']))
                return

            logger.info('SAMP: loading image with image-id={0}'.format(
                params['image-id']))

            if mtype == 'image.load.fits':
                data = fits_reader(params['url'])
            else:
                logger.info('SAMP: unknown format {0}'.format(
                    mtype.split('.')[-1]))
                return

            data.label = params['name']
            data.meta['samp-image-id'] = params['image-id']

            self.data_collection.append(data)

        elif self.state.highlight_is_selection and mtype == 'table.highlight.row':

            data = self.data_from_table_id(params['table-id'])
            len(self.data_collection.subset_groups)

            subset_state = ElementSubsetState(indices=[params['row']],
                                              data=data)

            mode = EditSubsetMode()
            mode.update(self.data_collection, subset_state)

        elif mtype == 'table.select.rowList':

            data = self.data_from_table_id(params['table-id'])
            len(self.data_collection.subset_groups)

            rows = np.asarray(params['row-list'], dtype=int)

            subset_state = ElementSubsetState(indices=rows, data=data)

            mode = EditSubsetMode()
            mode.update(self.data_collection, subset_state)

        elif mtype == 'samp.hub.event.register' or mtype == 'samp.hub.event.unregister':

            self.state.on_client_change()