"replacing the column entirely with the new value when possible. " "This configuration option will be deprecated and then removed in " "subsequent major releases.") conf = Conf() from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo from .groups import TableGroups, ColumnGroups from .table import (Table, QTable, TableColumns, Row, TableFormatter, NdarrayMixin, TableReplaceWarning) from .operations import join, setdiff, hstack, vstack, unique, TableMergeError from .bst import BST, FastBST, FastRBT from .sorted_array import SortedArray from .soco import SCEngine from .serialize import SerializedColumn, represent_mixins_as_columns # Finally import the formats for the read and write method but delay building # the documentation until all are loaded. (#5275) from astropy.io import registry with registry.delay_doc_updates(Table): # Import routines that connect readers/writers to astropy.table from .jsviewer import JSViewer from astropy.io.ascii import connect from astropy.io.fits import connect from astropy.io.misc import connect from astropy.io.votable import connect from astropy.io.misc.asdf import connect from astropy.io.misc.pandas import connect
# add primary hdu - critical to support compressed images later # minimum header with EXTEND will be provided if header is None primary_hdu = fits.PrimaryHDU(data=None, header=None) hdulist.insert(0, primary_hdu) # add flags hdu - 2nd extension after the image data if hdu_flags and spherex_image.flags is not None: hdr_flags = fits.Header() _add_flag_defs(spherex_image, hdr_flags) hdu = fits.ImageHDU(spherex_image.flags.data, hdr_flags, name=hdu_flags) hdulist.insert(2, hdu) hdulist.writeto(fileobj, **kwd) # Register read/write methods for SPHERExImage with registry.delay_doc_updates(SPHERExImage): registry.register_reader(data_format='fits', data_class=SPHERExImage, function=spherex_image_reader) registry.register_writer(data_format='fits', data_class=SPHERExImage, function=spherex_image_writer) registry.register_identifier(data_format='fits', data_class=SPHERExImage, identifier=fits.connect.is_fits)
'PersistenceSatModel', 'PixelAreaModel', 'NirspecSlitAreaModel', 'NirspecMosAreaModel', 'NirspecIfuAreaModel', 'FgsImgPhotomModel', 'MirImgPhotomModel', 'MirLrsPhotomModel', 'MirMrsPhotomModel', 'NrcImgPhotomModel', 'NrcWfssPhotomModel', 'NisImgPhotomModel', 'NisSossPhotomModel', 'NisWfssPhotomModel', 'NrsFsPhotomModel', 'NrsMosPhotomModel', 'PsfMaskModel', 'QuadModel', 'RampModel', 'MIRIRampModel', 'RampFitOutputModel', 'ReadnoiseModel', 'ReferenceFileModel', 'ReferenceCubeModel', 'ReferenceImageModel', 'ReferenceQuadModel', 'RegionsModel', 'ResetModel', 'ResolutionModel', 'MiriResolutionModel', 'RSCDModel', 'SaturationModel', 'SlitDataModel', 'SlitModel', 'SpecModel', 'SourceModelContainer', 'StepParsModel', 'StrayLightModel', 'SuperBiasModel', 'SpecwcsModel', 'ThroughputModel', 'TrapDensityModel', 'TrapParsModel', 'TrapsFilledModel', 'TsoPhotModel', 'WavelengthrangeModel', 'WaveCorrModel', 'WfssBkgModel' ] # Initialize the astropy.io registry, # but only the first time this module is called try: _defined_models except NameError: with registry.delay_doc_updates(DataModel): registry.register_reader('datamodel', DataModel, ndmodel.read) registry.register_writer('datamodel', DataModel, ndmodel.write) registry.register_identifier('datamodel', DataModel, ndmodel.identify) _all_models = __all__[1:] _local_dict = locals() _defined_models = {k: _local_dict[k] for k in _all_models}
Default is ``UTYPE``. .. versionadded:: 3.1 kwd : All additional keywords are passed to :py:mod:`astropy.io.fits` Raises ------- ValueError - If ``self.mask`` is set but not a `numpy.ndarray`. - If ``self.uncertainty`` is set but not a `~astropy.nddata.StdDevUncertainty`. - If ``self.uncertainty`` is set but has another unit then ``self.data``. NotImplementedError Saving flags is not supported. """ hdu = ccd_data.to_hdu(hdu_mask=hdu_mask, hdu_uncertainty=hdu_uncertainty, key_uncertainty_type=key_uncertainty_type, hdu_flags=hdu_flags) hdu.writeto(filename, **kwd) with registry.delay_doc_updates(CCDData): registry.register_reader('fits', CCDData, fits_ccddata_reader) registry.register_writer('fits', CCDData, fits_ccddata_writer) registry.register_identifier('fits', CCDData, fits.connect.is_fits)
:param kwd: Any additional keyword parameters are passed through to the FITS reader in :mod:`astropy.io.fits` :raises TypeError: If the conversion from CCDData to Measurement fails ''' _id = kwd.pop('identifier', 'unknown') _squeeze = kwd.pop('squeeze', True) z = CCDData.read(filename, hdu, unit, hdu_uncertainty, hdu_mask, key_uncertainty_type, **kwd) if _squeeze: z = squeeze(z) # @TODO if uncertainty plane not present, look for RMS keyword # @TODO header values get stuffed into WCS, others may be dropped by CCDData._generate_wcs_and_update_header try: z = Measurement(z, unit=z._unit) except Exception: raise TypeError( 'could not convert fits_measurement_reader output to Measurement') z.identifier(_id) # astropy.io.registry.read creates a FileIO object before calling the registered # reader (this method), so the filename is FileIO.name. z._filename = filename.name return z with registry.delay_doc_updates(Measurement): registry.register_reader('fits', Measurement, fits_measurement_reader)
ValueError - If ``self.mask`` is set but not a `numpy.ndarray`. - If ``self.uncertainty`` is set but not a `~astropy.nddata.StdDevUncertainty`. - If ``self.uncertainty`` is set but has another unit then ``self.data``. NotImplementedError Saving flags is not supported. """ hdu = ccd_data.to_hdu( hdu_mask=hdu_mask, hdu_uncertainty=hdu_uncertainty, key_uncertainty_type=key_uncertainty_type, hdu_flags=hdu_flags) hdu.writeto(filename, **kwd) with registry.delay_doc_updates(CCDData): registry.register_reader('fits', CCDData, fits_ccddata_reader) registry.register_writer('fits', CCDData, fits_ccddata_writer) registry.register_identifier('fits', CCDData, fits.connect.is_fits) try: CCDData.read.__doc__ = fits_ccddata_reader.__doc__ except AttributeError: CCDData.read.__func__.__doc__ = fits_ccddata_reader.__doc__ try: CCDData.write.__doc__ = fits_ccddata_writer.__doc__ except AttributeError: CCDData.write.__func__.__doc__ = fits_ccddata_writer.__doc__
"""Writer function which writes the NDCube object to FITS file Parameters ---------- ndcube_data : `ndcube.NDCube` object NDCube object filename : `str` Name of the file hdu_mask, hdu_uncertainty : str, optional If it is a string append this attribute to the HDUList as `astropy.io.fits.ImageHDU` with the string as extension name. Default is `MASK` for mask, `UNCERT` for uncertainty and `None` for flags. key_uncertainty_type : str, optional Th header key name for the class name of the uncertainty (if any) that is used to store the uncertainty type in the uncertainty type in the uncertainty hdu. """ hdu = ndcube_data.to_hdu(hdu_mask, hdu_uncertainty, key_uncertainty_type) hdu.writeto(filename, **kwargs) # Registering the writer function for writing NDCube files to fits format # TODO: Implement fits reader for NDCube with registry.delay_doc_updates(NDCube): registry.register_writer('fits', NDCube, fits_ndcube_writer) registry.register_identifier('fits', NDCube, fits.connect.is_fits)
) return data def identify_piic(origin, *args, **kwargs): data_file = Path(args[0]) rgw_file = data_file.parent / (data_file.with_suffix("").name + "_rgw.fits") check = data_file.exists() & rgw_file.exists() if check: check &= fits.connect.is_fits("read", data_file.parent, data_file.open(mode="rb")) check &= fits.connect.is_fits("read", rgw_file.parent, rgw_file.open(mode="rb")) return check with registry.delay_doc_updates(NikaMap): registry.register_reader("piic", NikaMap, piic_fits_nikamap_reader) registry.register_identifier("piic", NikaMap, identify_piic) registry.register_reader("idl", NikaMap, idl_fits_nikamap_reader) registry.register_writer("idl", NikaMap, idl_fits_nikamap_writer) registry.register_identifier("idl", NikaMap, fits.connect.is_fits) class NikaFits(MutableMapping): def __init__(self, filename=None, **kwd): self._filename = filename self._kwd = kwd self.__data = {"1mm": None, "2mm": None, "1": None, "2": None, "3": None} with fits.open(filename, **kwd) as hdus: self.primary_header = hdus[0].header
"subsequent major releases." ) conf = Conf() from .column import Column, MaskedColumn, StringTruncateWarning, ColumnInfo from .groups import TableGroups, ColumnGroups from .table import (Table, QTable, TableColumns, Row, TableFormatter, NdarrayMixin, TableReplaceWarning) from .operations import join, setdiff, hstack, vstack, unique, TableMergeError from .bst import BST, FastBST, FastRBT from .sorted_array import SortedArray from .soco import SCEngine from .serialize import SerializedColumn, represent_mixins_as_columns # Finally import the formats for the read and write method but delay building # the documentation until all are loaded. (#5275) from astropy.io import registry with registry.delay_doc_updates(Table): # Import routines that connect readers/writers to astropy.table from .jsviewer import JSViewer from astropy.io.ascii import connect from astropy.io.fits import connect from astropy.io.misc import connect from astropy.io.votable import connect from astropy.io.misc.asdf import connect from astropy.io.misc.pandas import connect