Example #1
0
    def load_data(self, data_filenames):
        """
        Load the data based on the extensions defined in the matching YAML file.  THen
        create the datacube and return it.

        :param data_filename:
        :return:
        """
        print("in load data")
        label = None
        data = None

        for data_filename in data_filenames.split(','):

            hdulist = fits.open(data_filename)
            print(hdulist)

            if not label:
                label = "{}: {}".format(self._name,
                                        splitext(basename(data_filename))[0])
                data = Data(label=label)

                # this attribute is used to indicate to the cubeviz layout that
                # this is a cubeviz-specific data component.
                data.meta[CUBEVIZ_LAYOUT] = self._name

            data_coords_set = False
            for ii, hdu in enumerate(hdulist):
                if 'NAXIS' in hdu.header and hdu.header['NAXIS'] == 3:

                    # Set the coords based on the first 3D HDU
                    if not data_coords_set:
                        data.coords = coordinates_from_header(hdu.header)
                        data_coords_set = True

                    component_name = str(ii)
                    if 'EXTNAME' in hdu.header:
                        component_name = hdu.header['EXTNAME']

                        # The data must be floating point as spectralcube is expecting floating point data
                        data.add_component(component=hdu.data.astype(np.float),
                                           label=component_name)

                        if 'BUNIT' in hdu.header:
                            c = data.get_component(component_name)
                            c.units = self.get_units(hdu.header)

            # For the purposes of exporting, we keep a reference to the original HDUList object
            data._cubeviz_hdulist = hdulist

        return data
Example #2
0
    def load_data(self, data_filenames):
        """
        Load the data based on the extensions defined in the matching YAML file.  THen
        create the datacube and return it.

        :param data_filename:
        :return:
        """

        label = None
        data = None

        ifucube = IFUCube()

        for data_filename in data_filenames.split(','):

            hdulist = ifucube.open(data_filename, fix=self._check_ifu_valid)

            # Good in this case means the file has 3D data and can be loaded by SpectralCube.read
            if self._check_ifu_valid and not ifucube.get_good():
                # Popup takes precedence and accepting continues operation and canceling closes the program
                self.popup_ui.ifucube_log.setText(ifucube.get_log_output())
                self.popup_ui.setModal(True)
                self.popup_ui.show()

                self.popup_ui.button_accept.clicked.connect(self._accept_button_click)
                self.popup_ui.button_cancel.clicked.connect(self._reject_button_click)

            if not label:
                label = "{}: {}".format(self._name, splitext(basename(data_filename))[0])
                data = Data(label=label)

                # this attribute is used to indicate to the cubeviz layout that
                # this is a cubeviz-specific data component.
                data.meta[CUBEVIZ_LAYOUT] = self._name

            data_coords_set = False
            for ii, hdu in enumerate(hdulist):
                if 'NAXIS' in hdu.header and hdu.header['NAXIS'] == 3:

                    # Set the coords based on the first 3D HDU
                    if not data_coords_set:
                        data.coords = coordinates_from_header(hdu.header)
                        data_coords_set = True

                    component_name = str(ii)
                    if 'EXTNAME' in hdu.header:
                        component_name = hdu.header['EXTNAME']

                        # The data must be floating point as spectralcube is expecting floating point data
                        data.add_component(component=hdu.data.astype(np.float), label=component_name)

                        if 'BUNIT' in hdu.header:
                            c = data.get_component(component_name)
                            c.units = self.get_units(hdu.header)
                    else:
                        # Creates a unique component name
                        component_name = str(ii)
                        data.add_component(component=hdu.data.astype(np.float), label=component_name)

            # For the purposes of exporting, we keep a reference to the original HDUList object
            data._cubeviz_hdulist = hdulist

        return data
Example #3
0
    def load_data(self, data_filenames):
        """
        Load the data based on the extensions defined in the matching YAML file.  THen
        create the datacube and return it.

        :param data_filename:
        :return:
        """

        label = None
        data = None

        ifucube = IFUCube()

        for data_filename in data_filenames.split(','):

            hdulist = ifucube.open(data_filename, fix=self._check_ifu_valid)

            # Good in this case means the file has 3D data and can be loaded by SpectralCube.read
            if self._check_ifu_valid and not ifucube.get_good():
                # Popup takes precedence and accepting continues operation and canceling closes the program
                self.popup_ui.ifucube_log.setText(ifucube.get_log_output())
                self.popup_ui.setModal(True)
                self.popup_ui.show()

                self.popup_ui.button_accept.clicked.connect(
                    self._accept_button_click)
                self.popup_ui.button_cancel.clicked.connect(
                    self._reject_button_click)

            if not label:
                label = "{}: {}".format(self._name,
                                        splitext(basename(data_filename))[0])
                data = Data(label=label)

                # this attribute is used to indicate to the cubeviz layout that
                # this is a cubeviz-specific data component.
                data.meta[CUBEVIZ_LAYOUT] = self._name

            data_coords_set = False
            for ii, hdu in enumerate(hdulist):
                if 'NAXIS' in hdu.header and hdu.header['NAXIS'] == 3:

                    # Set the coords based on the first 3D HDU
                    if not data_coords_set:
                        data.coords = coordinates_from_header(hdu.header)
                        data_coords_set = True

                    component_name = str(ii)
                    if 'EXTNAME' in hdu.header:
                        component_name = hdu.header['EXTNAME']

                        # The data must be floating point as spectralcube is expecting floating point data
                        data.add_component(component=hdu.data.astype(np.float),
                                           label=component_name)

                        if 'BUNIT' in hdu.header:
                            c = data.get_component(component_name)
                            c.units = self.get_units(hdu.header)
                    else:
                        # Creates a unique component name
                        component_name = str(ii)
                        data.add_component(component=hdu.data.astype(np.float),
                                           label=component_name)

            # For the purposes of exporting, we keep a reference to the original HDUList object
            data._cubeviz_hdulist = hdulist

        return data