def __init__(self, init=None, rscd_table=None, detector=None, **kwargs):
        """
        
        Initialises the MiriResetSwitchChargeDecayModel class.
        
        Parameters: See class doc string.

        """
        super(MiriResetSwitchChargeDecayModel, self).__init__(init=init,
                                                              **kwargs)

        # Data type is RSCD.
        self.meta.reftype = 'RSCD'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Define the detector identifier, if specified. (N.B. The detector
        # ID is compulsory, so it must be specified either here, in the
        # source file or later after creation of this data object.)
        # The warning is commented out because it causes unnecessary
        # output during tests or when creating an empty data product and
        # filling it in later.
        if detector is not None:
            self.meta.instrument.detector = detector

        if rscd_table is not None:
            try:
                self.rscd_table = rscd_table
            except (ValueError, TypeError) as e:
                strg = "rscd_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
    def __init__(self, init=None, fringefreq_table=None, **kwargs):
        """
        
        Initialises the MiriMrsFringeFrequenciesModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsFringeFrequenciesModel, self).__init__(init=init, **kwargs)

        # Data type is fringe frequencies.
        self.meta.reftype = 'FRINGEFREQ'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type        

        # This is a reference data model.
        self._reference_model()
        
        if fringefreq_table is not None:
            try:
                self.fringefreq_table = fringefreq_table
            except (ValueError, TypeError) as e:
                strg = "fringefreq_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
         
        # Copy the table column units from the schema, if defined.
        fringefreq_units = self.set_table_units('fringefreq_table')
Example #3
0
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 dq_def=None,
                 detector=None,
                 **kwargs):
        """
        
        Initialises the MiriMrsStraylightModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsStraylightModel, self).__init__(init=init, **kwargs)

        # Data type is Straylight mask.
        self.meta.reftype = 'STRAYMASK'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # Set the instrument detector, if provided (backwards compatibility).
        if detector is not None:
            self.meta.instrument.detector = detector

        # This is a reference data model.
        self._reference_model()

        # The data array is provided either in the data parameter or
        # the dq parameter (backwards compatibility).
        if data is not None:
            HasData.__init__(self, data)
        else:
            HasData.__init__(self, dq)
    def __init__(self, init=None, apercorr_table=None, **kwargs):
        """
        
        Initialises the MiriMrsApertureCorrectionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsApertureCorrectionModel, self).__init__(init=init,
                                                             **kwargs)

        # Data type is aperture correction.
        self.meta.reftype = 'APERCORR'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        if apercorr_table is not None:
            try:
                self.apercorr_table = apercorr_table
            except (ValueError, TypeError) as e:
                strg = "apercorr_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Copy the table column units from the schema, if defined.
        apercorr_units = self.set_table_units('apercorr_table')
Example #5
0
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 err=None,
                 dq_def=None,
                 **kwargs):
        """
        
        Initialises the MiriLastFrameModel class.
        
        Parameters: See class doc string.

        """
        super(MiriLastFrameModel, self).__init__(init=init,
                                                 data=data,
                                                 dq=dq,
                                                 err=err,
                                                 dq_def=dq_def,
                                                 **kwargs)

        # Data type is last frame.
        self.meta.reftype = 'LASTFRAME'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()
Example #6
0
    def __init__(self,
                 init=None,
                 data=None,
                 pixar_sr=None,
                 pixar_a2=None,
                 **kwargs):
        """
        
        Initialises the MiriPixelAreaModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPixelAreaModel, self).__init__(init=init, **kwargs)

        # Data type is AREA.
        self.meta.reftype = 'AREA'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
        # This is a reference data model.
        self._reference_model()

        # If provided, define the pixel area metadata.
        if pixar_sr is not None:
            self.meta.photometry.pixelarea_steradians = pixar_sr
            # Should both keywords be written?
#             self.meta.photometry.arcsecsq = pixar_s2 * ARCSEC2_PER_STERADIAN
        if pixar_a2 is not None:
            self.meta.photometry.pixelarea_arcsecsq = pixar_a2
            # Should both keywords be written?
#             self.meta.photometry.pixelarea_steradians = \
#                 pixar_s2 / ARCSEC2_PER_STERADIAN

# Update the data array if it has been specifically provided.
        HasData.__init__(self, data)
Example #7
0
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 err=None,
                 dq_def=None,
                 integration=None,
                 fitted_after=None,
                 averaged=False,
                 **kwargs):
        """
        
        Initialises the MiriDarkReferenceModel class.
        
        Parameters: See class doc string.

        """
        super(MiriDarkReferenceModel, self).__init__(init=init,
                                                     data=data,
                                                     dq=dq,
                                                     err=err,
                                                     dq_def=dq_def,
                                                     **kwargs)

        # Data type is dark.
        self.meta.reftype = 'DARK'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
        self.averaged = averaged

        # This is a reference data model.
        self._reference_model()

        # Define the exposure type (if not already contained in the data model)
        if not self.meta.exposure.type:
            self.set_exposure_type(datatype='DARK')

        if integration is not None:
            self.meta.integration_number = integration
        if fitted_after is not None:
            self.meta.fitted_after_frame = fitted_after

        # The main data array should be 2-D, 3-D or 4-D.
        # TODO: Can this check be included in the schema?
        if data is not None:
            if not hasattr(data, 'ndim'):
                data = np.asarray(data)
            if data.ndim < 2 or data.ndim > 4:
                strg = "The main data array in a dark reference object must be "
                strg += "2-D, 3-D or 4-D. %d-D data provided" % data.ndim
                raise ValueError(strg)
        elif self.data is not None and len(self.data) > 0 and \
             hasattr(self.data, 'ndim'):
            if self.data.ndim < 2 or self.data.ndim > 4:
                strg = "The main data array in a dark reference object must be "
                strg += "2-D, 3-D or 4-D. %d-D data provided" % self.data.ndim
                raise ValueError(strg)
Example #8
0
    def __init__(self,
                 init=None,
                 pce_table=None,
                 component=None,
                 detector=None,
                 **kwargs):
        """
        
        Initialises the MiriPceModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPceModel, self).__init__(init=init, **kwargs)

        # Data type is PCE.
        self.meta.reftype = 'PCE'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Define the component name, if given
        if component is not None:
            self.meta.etc.component = component
        # If the component name is not defined, define it from the other metadata.
        if self.meta.etc.component is None:
            if self.meta.instrument.filter is not None:
                self.meta.etc.component = self.meta.instrument.filter
            elif self.meta.instrument.channel is not None and \
                 self.meta.instrument.band is not None:
                self.meta.etc.component = "CHANNEL" + \
                    str(self.meta.instrument.channel) + \
                    str(self.meta.instrument.band)

        # Define the detector identifier, if specified.
        if detector is not None:
            self.meta.instrument.detector = detector

        if pce_table is not None:
            try:
                #pce_table = np.recarray(phot_table)
                self.pce_table = pce_table
            except (ValueError, TypeError) as e:
                strg = "pce_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Copy the table column units from the schema, if defined.
        pce_units = self.set_table_units('pce_table')

        # Cached arrays
        self._wavelength = None
        self._efficiency = None
        self._interpefficiency = None
Example #9
0
    def __init__(self,
                 init=None,
                 phot_table=None,
                 pixar_sr=None,
                 pixar_a2=None,
                 **kwargs):
        """
        
        Initialises the MiriPhotometricModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPhotometricModel, self).__init__(init=init, **kwargs)

        # Data type is photometric flux conversion.
        self.meta.reftype = 'PHOTOM'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        if phot_table is not None:
            try:
                #phot_table = np.recarray(phot_table)
                self.phot_table = phot_table
            except (ValueError, TypeError) as e:
                strg = "phot_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Copy the table column units from the schema, if defined.
        phot_table_units = self.set_table_units('phot_table')

        # If provided, define the pixel area metadata.
        if pixar_sr is not None:
            self.meta.photometry.pixelarea_steradians = pixar_sr
            # Should both keywords be written?
#             self.meta.photometry.arcsecsq = pixar_s2 * ARCSEC2_PER_STERADIAN
        if pixar_a2 is not None:
            self.meta.photometry.pixelarea_arcsecsq = pixar_a2
            # Should both keywords be written?


#             self.meta.photometry.pixelarea_steradians = \
#                 pixar_s2 / ARCSEC2_PER_STERADIAN

# Define the exposure type (if not already contained in the data model)
# NOTE: This will only define an exposure type when a valid detector
# is defined in the metadata.
        if not self.meta.exposure.type:
            self.set_exposure_type()
Example #10
0
    def __init__(self,
                 init=None,
                 subarray=None,
                 srf_table=None,
                 pixar_sr=None,
                 pixar_a2=None,
                 **kwargs):
        """
        
        Initialises the MiriLrsPhotometricModel class.
        
        Parameters: See class doc string.

        """
        if srf_table is not None:
            # Construct a phot_table from the given subarray and srf_table and
            # some dummy photmjsr and uncertainty arrays.
            # TODO: A slow, brute force method. There is probably a faster way,
            # but the function is not time critical for small CDPs..
            mirifilter = 'P750L'
            if subarray is None or not subarray:
                strg = "If an srf_table is parameter provided, "
                strg += "a subarray parameter must also be provided."
                raise AttributeError(strg)
            photmjsr = 1.0
            uncertainty = 0.0
            wavelength = [0.0] * MAX_NELEM
            relresponse = [0.0] * MAX_NELEM
            relresperror = [0.0] * MAX_NELEM
            ii = 0
            for (wav, srf, unc) in srf_table:
                wavelength[ii] = wav
                relresponse[ii] = srf
                relresperror[ii] = unc
                ii += 1
            nelem = len(srf_table)
            new_phot_table = [(mirifilter, subarray, photmjsr, uncertainty,
                               nelem, tuple(wavelength), tuple(relresponse),
                               tuple(relresperror))]
        else:
            new_phot_table = None

        # Pass the phot_table to the generic model.
        super(MiriLrsPhotometricModel,
              self).__init__(init=init,
                             phot_table=new_phot_table,
                             pixar_sr=pixar_sr,
                             pixar_a2=pixar_a2,
                             **kwargs)
        #self.add_comment("RELRESPONSE is absolute response so PHOTMJSR is 1.0.")
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
Example #11
0
    def __init__(self, init=None, wavelength=None, **kwargs):
        """
        
        Initialises the MiriMrsPointSpreadFunctionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsPointSpreadFunctionModel, self).__init__(init=init,
                                                              **kwargs)
        # Data type is MRS PSF.
        self.meta.reftype = 'PSF'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
    def __init__(self, init=None, flux_table=None, **kwargs):
        """
        
        Initialises the MiriImagingColourCorrectionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPowerlawColourCorrectionModel, self).__init__(init=init,
                                                flux_table=flux_table,
                                                **kwargs)
        # Data type is colour correction.
        self.meta.reftype = 'COLCORRPL'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type
    def __init__(self, init=None, flux_table=None, **kwargs):
        """
        
        Initialises the MiriLrsFluxconversionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriLrsFluxconversionModel, self).__init__(init=init,
                                                    flux_table=flux_table,
                                                    **kwargs)

        # Data type is LRS flux conversion.
        self.meta.reftype = 'PHOTOM'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type
Example #14
0
    def __init__(self, init=None, intensity=None, wavelength=None, **kwargs):
        """
        
        Initialises the MiriIlluminationModel class.
        
        Parameters: See class doc string.

        """
        super(MiriIlluminationModel, self).__init__(init=init, **kwargs)

        # Data type is illumination map.
        self.meta.filetype = 'ILLUMINATION'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        if intensity is not None:
            self.intensity = intensity
        # Replace NaNs or invalid values in the intensity array with zeros.
        if self.intensity is not None:
            self.intensity[np.isnan(self.intensity)] = 0.0

        if wavelength is not None:
            self.wavelength = wavelength
        # Replace NaNs or invalid values in the wavelength array with the maximum.
        if self.wavelength is not None:
            notnanarray = self.wavelength[~np.isnan(self.wavelength)]
            if notnanarray.size > 0:
                wavmax = notnanarray.max()
                self.wavelength[np.isnan(self.wavelength)] = wavmax

        # Only test the wavelength array against the intensity array if the arrays
        # have either been provided in arrays or have been initialised from init.
        if (init is not None) or (intensity is not None
                                  and wavelength is not None):
            if not self._check_wavelength(self.intensity, self.wavelength):
                strg = "Shape of wavelength array (%s) " % \
                    str(self.wavelength.shape)
                strg += "is incompatible with intensity array (%s)." % \
                    str(self.intensity.shape)
                raise TypeError(strg)

        # Copy the units of the these arrays, if defined.
        self.set_data_units('intensity')
        self.set_data_units('wavelength')

        self._set_illumination_shape()
Example #15
0
    def __init__(self, init=None, wavcorr_optical=None, wavcorr_xslice=None,
                 wavcorr_shift=None, **kwargs):
        """
        
        Initialises the MiriMrsWavelengthCorrectionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsWavelengthCorrectionModel, self).__init__(init=init, **kwargs)

        # Data type is wavelength correction.
        self.meta.reftype = 'WAVCORR'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()
        
        if wavcorr_optical is not None:
            try:
                self.wavcorr_optical = wavcorr_optical
            except (ValueError, TypeError) as e:
                strg = "wavcorr_optical must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if wavcorr_xslice is not None:
            try:
                self.wavcorr_xslice = wavcorr_xslice
            except (ValueError, TypeError) as e:
                strg = "wavcorr_xslice must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if wavcorr_shift is not None:
            try:
                self.wavcorr_shift = wavcorr_shift
            except (ValueError, TypeError) as e:
                strg = "wavcorr_shift must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        
        # Copy the table column units from the schema, if defined.
        wavcorr_optical_units = self.set_table_units('wavcorr_optical')
        wavcorr_xslice_units = self.set_table_units('wavcorr_xslice')
        wavcorr_shift_units = self.set_table_units('wavcorr_shift')
Example #16
0
    def __init__(self,
                 init=None,
                 psf_lut=None,
                 psftype='',
                 wavelen=None,
                 pixelsize=None,
                 **kwargs):
        """
        
        Initialises the MiriImagingPointSpreadFunctionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriImagingPointSpreadFunctionModel,
              self).__init__(init=init,
                             wavelen=wavelen,
                             pixelsize=pixelsize,
                             **kwargs)

        # Data type is imager PSF.
        if not psftype:
            if not self.meta.reftype:
                self.meta.reftype = 'PSF'
        else:
            psupper = psftype.upper()
            if 'OOF' in psupper:
                self.meta.reftype = 'PSF-OOF'
            else:
                self.meta.reftype = 'PSF'

        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        if psf_lut is not None:
            try:
                self.psf_lut = psf_lut
            except (ValueError, TypeError) as e:
                strg = "psf_lut must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Copy the table column units from the schema, if defined.
        psf_units = self.set_table_units('psf_lut')
Example #17
0
    def __init__(self,
                 init=None,
                 phot_table=None,
                 pixar_sr=None,
                 pixar_a2=None,
                 **kwargs):
        """
        
        Initialises the MiriImagingPhotometricModel class.
        
        Parameters: See class doc string.

        """
        if phot_table is not None:
            # Construct a new phot_table from the given phot_table and
            # some dummy wavelength and relreponse arrays.
            wavelength = [0.0] * MAX_NELEM
            relresponse = [0.0] * MAX_NELEM
            relresperror = [0.0] * MAX_NELEM
            new_phot_table = []
            for phot_row in phot_table:
                mirifilter = phot_row[0]
                subarray = phot_row[1]
                photmjsr = phot_row[2]
                uncertainty = phot_row[3]
                if not subarray:
                    # Convert an empty SUBARRAY string to 'GENERIC'
                    subarray = 'GENERIC'
                new_phot_table.append(
                    (mirifilter, subarray, photmjsr, uncertainty, 0,
                     wavelength, relresponse, relresperror))
        else:
            new_phot_table = None

        # Pass the phot_table to the generic model.
        super(MiriImagingPhotometricModel,
              self).__init__(init=init,
                             phot_table=new_phot_table,
                             pixar_sr=pixar_sr,
                             pixar_a2=pixar_a2,
                             **kwargs)
        #self.add_comment("WAVELENGTH and RELRESPONSE arrays are all zero for imager.")
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
Example #18
0
    def __init__(self, init=None, data=None, **kwargs):
        """
        
        Initialises the MiriIPCModel class.
        
        Parameters: See class doc string.

        """
        super(MiriIPCModel, self).__init__(init=init, **kwargs)

        # Data type is IPC.
        self.meta.reftype = 'IPC'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        if data is not None:
            self.data = data
Example #19
0
    def __init__(self, init=None, data=None, **kwargs):
        """
        
        Initialises the MiriReadnoiseModel class.
        
        Parameters: See class doc string.

        """
        super(MiriReadnoiseModel, self).__init__(init=init, **kwargs)

        # Data type is last frame.
        self.meta.reftype = 'READNOISE'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Update the data array if it has been specifically provided.
        HasData.__init__(self, data)
    def __init__(self, init=None, flux_table=None, **kwargs):
        """
        
        Initialises the MiriImagingFluxconversionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriImagingFluxconversionModel, self).__init__(init=init,
                                                flux_table=flux_table,
                                                **kwargs)
        # Log an information string just once.
        if not MiriImagingFluxconversionModel.info_logged:
            LOGGER.info(self.__class__.__name__ + ": This class is valid for pre-CDP-4 data only")
            MiriImagingFluxconversionModel.info_logged = True

        # Data type is imaging flux conversion.
        self.meta.reftype = 'PHOTOM'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type
Example #21
0
    def __init__(self, init=None, dq=None, dq_def=None, detector=None,
                 **kwargs):
        """
        
        Initialises the MiriBadPixelMaskModel class.
        
        Parameters: See class doc string.

        """
        super(MiriBadPixelMaskModel, self).__init__(init=init, **kwargs)

        # Data type is bad pixel mask.
        self.meta.reftype = 'MASK'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Define the detector identifier, if specified.
        if detector is not None:
            self.meta.instrument.detector = detector
        
        # Update the dq array if it has been specifically provided.
        HasMask.__init__(self, dq)

        # Set the bit field definitions table, if provided.
        if dq_def is not None:
            try:
                self.dq_def = dq_def
            except (ValueError, TypeError) as e:
                strg = "dq_def must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        elif self.dq_def is None or len(self.dq_def) < 1:
            # No dq_def is provided.
            # Explicitly create a DQ_DEF table with default values.
            # TODO: Can the default be declared in the schema?
            self.dq_def = self._default_dq_def
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 err=None,
                 dq_def=None,
                 tolerance=None,
                 lowlimit=None,
                 median=None,
                 **kwargs):
        """
        
        Initialises the MiriPixelSaturationModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPixelSaturationModel, self).__init__(init=init,
                                                       data=data,
                                                       dq=dq,
                                                       err=err,
                                                       dq_def=dq_def,
                                                       **kwargs)

        # Data type is pixel saturation.
        self.meta.reftype = 'SATURATION'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Set the metadata, if provided.
        if tolerance is not None:
            self.meta.sat_tolerance = tolerance
        if lowlimit is not None:
            self.meta.sat_lower = lowlimit
        if median is not None:
            self.meta.sat_median = median
    def __init__(self, init=None, data=None, dq=None, err=None, dq_def=None,
                 pixsiz=None,
                 srf_at_reference=None, srf_error=None, srf_wavelength=None,
                 **kwargs):
        """
        
        Initialises the MiriMrsFluxconversionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsFluxconversionModel, self).__init__(init=init, data=data,
                                                         dq=dq, err=err,
                                                         dq_def=dq_def,
                                                         **kwargs)

        # Data type is MRS flux conversion.
        self.meta.reftype = 'PHOTOM'
        model_type = get_my_model_type( self.__class__.__name__ )
        if model_type is not None:
            self.meta.model_type = model_type        

        # This is a reference data model.
        self._reference_model()
        
        # Set the metadata, if provided.
        if srf_at_reference is not None:
            self.meta.srf_at_reference = srf_at_reference
        if srf_error is not None:
            self.meta.srf_error = srf_error
        if srf_wavelength is not None:
            self.meta.srf_wavelength = srf_wavelength
            
        if pixsiz is not None:
            # Work around the "list object does not have shape attribute"
            # data model problem. Why does the pixsiz attribute need to
            # be converted with np.asarray but the data and err attributes
            # do not?
            self.pixsiz = np.asarray(pixsiz)
Example #24
0
    def __init__(self,
                 init=None,
                 finejump_table=None,
                 crthresh=None,
                 **kwargs):
        """
        
        Initialises the MiriJumpModel class.
        
        Parameters: See class doc string.

        """
        super(MiriJumpModel, self).__init__(init=init, **kwargs)

        # Data type is jump.
        self.meta.reftype = 'JUMP'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Define the crthresh identifier, if specified. N.B. this ID is
        # compulsory, so it must be specified either here, in the
        # source file or later after creation of this data object.
        if crthresh is not None:
            self.meta.finejump_table.crthresh = crthresh

        if finejump_table is not None:
            try:
                self.finejump_table = finejump_table
            except (ValueError, TypeError) as e:
                strg = "finejump_table must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Copy the table column units from the schema, if defined.
        finejump_table_units = self.set_table_units('finejump_table')
Example #25
0
    def __init__(self, init=None, psftype=None, **kwargs):
        """
        
        Initialises the MiriLrsPointSpreadFunctionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriLrsPointSpreadFunctionModel, self).__init__(init=init,
                                                              **kwargs)

        # Data type is LRS PSF.
        if not psftype:
            if not self.meta.reftype:
                self.meta.reftype = 'PSF'
        else:
            psupper = psftype.upper()
            if 'MONOCHROM' in psupper:
                self.meta.reftype = 'PSF-MONOCHROM'
            else:
                self.meta.reftype = 'PSF'

        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 err=None,
                 dq_def=None,
                 filt=None,
                 temperature=None,
                 **kwargs):
        """
        
        Initialises the MiriTelescopeEmissionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriTelescopeEmissionModel, self).__init__(init=init,
                                                         data=data,
                                                         dq=dq,
                                                         err=err,
                                                         dq_def=dq_def,
                                                         **kwargs)

        # Data type is telescope emission map.
        self.meta.reftype = 'TEL_EMISSION'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # Add filter and temperature to the metadata
        if filt is not None:
            self.meta.instrument.filter = filt
        if temperature is not None:
            self.meta.telescope_temperature = temperature
Example #27
0
    def __init__(self,
                 init=None,
                 data=None,
                 dq=None,
                 err=None,
                 dq_def=None,
                 wavelen=None,
                 pixelsize=None,
                 xfield=None,
                 yfield=None,
                 **kwargs):
        """
        
        Initialises the MiriPointSpreadFunctionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriPointSpreadFunctionModel, self).__init__(init=init,
                                                           data=data,
                                                           dq=dq,
                                                           err=err,
                                                           dq_def=dq_def,
                                                           **kwargs)

        # Data type is PSF.
        if not self.meta.reftype:
            self.meta.reftype = 'PSF'
        model_type = get_my_model_type(self.__class__.__name__)
        self.meta.model_type = model_type

        # This is a reference data model.
        self._reference_model()

        # The main data array should be 2-D or 3-D.
        # TODO: Can this check be included in the schema?
        if data is not None:
            if not hasattr(data, 'ndim'):
                data = np.asarray(data)
            if data.ndim < 2 or data.ndim > 3:
                strg = "The main data array in a PSF object must be "
                strg += "2-D or 3-D. %d-D data provided" % data.ndim
                raise TypeError(strg)
        elif init is not None and self.data is not None and len(self.data) > 0 and \
             hasattr(self.data, 'ndim'):
            if self.data.ndim < 2 or self.data.ndim > 3:
                strg = "The main data array in a PSF object must be "
                strg += "2-D or 3-D. %d-D data provided" % self.data.ndim
                raise TypeError(strg)

        # Wavelength, pixel size and (xfield,yfield) are added to the metadata if present.
        if wavelen is not None:
            self.meta.wavelength_center = wavelen
        if pixelsize is not None:
            self.meta.pixel_size = pixelsize
        if xfield is not None and yfield is not None:
            self.meta.xfield = xfield
            self.meta.yfield = xfield

        # Define the exposure type (if not already contained in the data model)
        # NOTE: This will only define an exposure type when a valid detector
        # is defined in the metadata.
        if not self.meta.exposure.type:
            self.set_exposure_type()
Example #28
0
 def _init_data_type(self):
     # Initialise the data model type
     model_type = get_my_model_type( self.__class__.__name__ )
     self.meta.model_type = model_type        
Example #29
0
 def _init_data_type(self):
     # Data type is droop.
     self.meta.reftype = 'DROOP'
     model_type = get_my_model_type( self.__class__.__name__ )
     self.meta.model_type = model_type        
Example #30
0
    def __init__(self, init=None, resolving_power=None, psf_fwhm_alpha=None,
                 psf_fwhm_beta=None, resol_data=None, mlsf_data=None,
                 phase1_data=None, phase2_data=None, phase3_data=None,
                 etalon_data=None, **kwargs):
        """
        
        Initialises the MiriMrsResolutionModel class.
        
        Parameters: See class doc string.

        """
        super(MiriMrsResolutionModel, self).__init__(init=init, **kwargs)

        # Data type is spectral resolution.
        self.meta.reftype = 'RESOL'
        model_type = get_my_model_type( self.__class__.__name__ )
        self.meta.model_type = model_type        

        # This is a reference data model.
        self._reference_model()
        
# +++ Remove RESOLVING_POWER after CDP-7
        if resolving_power is not None:
            try:
                self.resolving_power = resolving_power
            except (ValueError, TypeError) as e:
                strg = "resolving_power must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if self.resolving_power is not None and len(self.resolving_power) > 1:
            warnings.warn("Old data model detected. The RESOLVING_POWER HDU is now deprecated.")
# ---
            
        if psf_fwhm_alpha is not None:
            try:
                self.psf_fwhm_alpha = psf_fwhm_alpha
            except (ValueError, TypeError) as e:
                strg = "psf_fwhm_alpha must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if psf_fwhm_beta is not None:
            try:
                self.psf_fwhm_beta = psf_fwhm_beta
            except (ValueError, TypeError) as e:
                strg = "psf_fwhm_beta must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if resol_data is not None:
            try:
                self.resol_data = resol_data
            except (ValueError, TypeError) as e:
                strg = "resol_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if mlsf_data is not None:
            try:
                self.mlsf_data = mlsf_data
            except (ValueError, TypeError) as e:
                strg = "mlsf_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if phase1_data is not None:
            try:
                self.phase1_data = phase1_data
            except (ValueError, TypeError) as e:
                strg = "phase1_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if phase2_data is not None:
            try:
                self.phase2_data = phase2_data
            except (ValueError, TypeError) as e:
                strg = "phase2_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if phase3_data is not None:
            try:
                self.phase3_data = phase3_data
            except (ValueError, TypeError) as e:
                strg = "phase3_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)
        if etalon_data is not None:
            try:
                self.etalon_data = etalon_data
            except (ValueError, TypeError) as e:
                strg = "etalon_data must be a numpy record array or list of records."
                strg += "\n   %s" % str(e)
                raise TypeError(strg)

        # Define the exposure type (if not already contained in the data model)
        # NOTE: This will only define an exposure type when a valid detector
        # is defined in the metadata.
        if not self.meta.exposure.type:
            self.set_exposure_type()
        
        # Copy the table column units from the schema, if defined.
# +++ Remove RESOLVING_POWER after CDP-7
        resolving_power_units = self.set_table_units('resolving_power')
# ---
        psf_fwhm_alpha_units = self.set_table_units('psf_fwhm_alpha')
        psf_fwhm_beta_units = self.set_table_units('psf_fwhm_beta')
        resol_data_units = self.set_table_units('resol_data')
        mlsf_data_units = self.set_table_units('mlsf_data')
        phase1_data_units = self.set_table_units('phase1_data')
        phase2_data_units = self.set_table_units('phase2_data')
        phase3_data_units = self.set_table_units('phase3_data')
        etalon_data_units = self.set_table_units('etalon_data')