# Import the MIRI ramp data model utilities. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['dark_reference_flags', 'MiriDarkReferenceModel'] # The new JWST dark reference flags. Note that these flags are a subset # of the JWST master flags table. The names and descriptions are the same # but the bit values can be different. dark_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'UNRELIABLE_DARK', 'Dark variance large')] dark_reference_flags = insert_value_column(dark_reference_setup) # # Global helper function # def linear_regression(x, y): """ Linear regression function. Fit an intercept and a slope to a set of x,y coordinates """ #print("Fitting", y, "\nagainst", x) matrix = np.vstack([x, np.ones_like(x)]).T slope, intercept = np.linalg.lstsq(matrix, y)[0]
# Import the MIRI measured data model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = [ 'MiriPointSpreadFunctionModel', 'MiriImagingPointSpreadFunctionModel', 'MiriLrsPointSpreadFunctionModel', 'MiriMrsPointSpreadFunctionModel' ] psf_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'UNRELIABLE_SLOPE', 'Data of low quality'), # Was CDP_LOW_QUAL (2, 'CDP_UNRELIABLE_ERROR', 'Data without reliable error estimate')] psf_reference_flags = insert_value_column(psf_reference_setup) class MiriPointSpreadFunctionModel(MiriMeasuredModel): """ A data model for MIRI generic point spread function data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the data parameter, the shape is derived from the
# Import the MIRI measured data model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['linearity_reference_flags', 'MiriLinearityModel'] # The new JWST linearity reference flags linearity_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'NONLINEAR', 'Pixel highly non-linear'), (2, 'NO_LIN_CORR', 'Linearity correction not available'), (3, 'OTHER_BAD_PIXEL', 'Bad solution'), # Was CDP_BAD_SOLUTION (4, 'DROPOUT', 'Data derived from incomplete input')] # Was CDP_PARTIAL_DATA linearity_reference_flags = insert_value_column(linearity_reference_setup) class MiriLinearityModel(MiriMeasuredModel): """ A data model for MIRI linearity correction data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the coeffs parameter, the shape is derived from the
from miri.datamodels.operations import HasMask # List all classes and global functions here. __all__ = ['mask_reference_flags', 'MiriBadPixelMaskModel'] # The new JWST mask reference flags. Note that these flags are a subset # of the JWST master flags table. The names and descriptions are the same # but the bit values can be different. mask_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'DEAD', 'Dead pixel'), (2, 'HOT', 'Hot pixel'), (3, 'UNRELIABLE_SLOPE', 'Slope variance large (=noisy pixel)'), # Was NOISY. (4, 'RC', 'RC pixel'), (9, 'NON_SCIENCE', 'Pixel not on science portion of detector')] mask_reference_flags = insert_value_column( mask_reference_setup ) class MiriBadPixelMaskModel(MiriDataModel, HasMask): """ A data model for a MIRI bad pixel mask, based on the STScI base model, DataModel. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is
import numpy as np # Import the MIRI measured model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['MiriResetModel'] # The new JWST reset reference flags reset_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'UNRELIABLE_RESET', 'Sensitive to reset anomaly')] reset_reference_flags = insert_value_column( reset_reference_setup ) class MiriResetModel(MiriMeasuredModel): """ A data model for MIRI reset correction data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the mask parameter, the shape is derived from the
import numpy as np # Import the MIRI image model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['MiriLastFrameModel'] lastframe_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'NO_LASTFRAME_CORR', 'No last frame correction')] # (2, 'CDP_LOW_QUAL', 'Data of low quality')] lastframe_reference_flags = insert_value_column(lastframe_reference_setup) class MiriLastFrameModel(MiriMeasuredModel): """ A data model for MIRI last frame correction data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the mask parameter, the shape is derived from the
ylabel = 'SRF' title = self.get_data_title('flux_table') # Plot each ramp as an XY plot overlaid on the same axis. mplt.plot_xy(wavlist, srflist, xlabel=xlabel, ylabel=ylabel, title=title) mplt.show_plot() mplt.close() # The new JWST SRF reference flags mrssrf_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'NON_SCIENCE', 'Pixel not on science portion of detector'), (2, 'CDP_LOW_QUAL', 'Data of low quality')] # (3, 'CDP_DO_NOT_USE_ERR', 'Data without reliable error estimate')] mrssrf_reference_flags = insert_value_column( mrssrf_reference_setup ) class MiriMrsFluxconversionModel(MiriMeasuredModel): """ A data model for MIRI MRS mode flux conversion data, based on MiriMeasuredModel. See MIRI-TN-00003-KUL and MIRI-TN-00004-KUL for a description of the MRS spectrophotometric calibration. :Parameters: The same as MiriMeasuredModel (data, err, dq) plus pixsiz: numpy array (optional)
if hastable: print("Ramp data has data table") else: print("Ramp data has no data table") mask = np.array([[0, 1, 0], [1, 0, 1], [0, 1, 0]]) maskdef = [(0, 'good', 'Good data'), (1, 'dead', 'Dead Pixel'), (2, 'hot', 'Hot Pixel'), (3, 'noisy', 'Noisy pixel'), (4, 'globsat', 'Above global saturation'), (5, 'pixsat', 'Above pixel saturation'), (6, 'cosmic', 'Cosmic ray detected'), (7, 'anomaly', 'Noise anomaly or cosmic ray'), (8, 'spike', 'Noise spike detected'), (9, 'nolin', 'No linearity correction possible'), (10, 'outlin', 'Outside linearity correction range')] maskdef_4 = insert_value_column(maskdef) print("\nMask with field values derived from list of tuples:") testmask = NewMaskModel(dq=mask, dq_def=maskdef_4) # print(testmask1) print("Mask data structure title is:\n" + testmask.get_title(underline=True)) hasdata = testmask.has_dataarray('data') if hasdata: print("Mask data has data array with title \'" + \ testmask.get_data_title('data') + \ "\', ndim=" + str(testmask.ndim) + \ ", size=" + str(testmask.size) + \ " and shape=" + str(testmask.shape))
import numpy as np #import numpy.ma as ma # Import the MIRI measured data model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['MiriTelescopeEmissionModel'] telem_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'UNRELIABLE_SLOPE', 'Slope variance large')] telem_reference_flags = insert_value_column(telem_reference_setup) class MiriTelescopeEmissionModel(MiriMeasuredModel): """ A data model for MIRI telescope emission data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the data parameter, the shape is derived from the
import numpy as np #import numpy.ma as ma # Import the MIRI image model. from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_measured_model import MiriMeasuredModel # List all classes and global functions here. __all__ = ['saturation_reference_flags', 'MiriPixelSaturationModel'] # The new JWST saturation reference flags saturation_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'NO_SAT_CHECK', 'Saturation check not available')] saturation_reference_flags = insert_value_column(saturation_reference_setup) class MiriPixelSaturationModel(MiriMeasuredModel): """ A data model for MIRI pixel saturation data. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the mask parameter, the shape is derived from the
# Import the MIRI base data model and utilities. # from miri.datamodels.plotting import DataModelPlotVisitor from miri.datamodels.ancestry import get_my_model_type from miri.datamodels.dqflags import insert_value_column from miri.datamodels.miri_badpixel_model import MiriBadPixelMaskModel from miri.datamodels.miri_model_base import MiriDataModel from miri.datamodels.operations import HasData # List all classes and global functions here. __all__ = ['MiriMrsStraylightModel'] straylight_reference_setup = \ [(0, 'DO_NOT_USE', 'Bad pixel. Do not use.'), (1, 'NON_SCIENCE', 'Pixel not on science portion of detector')] straylight_reference_flags = insert_value_column(straylight_reference_setup) class MiriMrsStraylightModel(MiriDataModel, HasData): """ A data model for a MIRI MRS straylight mask. :Parameters: init: shape tuple, file path, file object, pyfits.HDUList, numpy array An optional initializer for the data model, which can have one of the following forms: * None: A default data model with no shape. (If a data array is provided in the mask parameter, the shape is derived from the