How to use the pynpoint.core.processing.ReadingModule function in pynpoint

To help you get started, we’ve selected a few pynpoint examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PynPoint / PynPoint / pynpoint / readwrite / near.py View on Github external
import threading
import warnings
import math

import numpy as np
import shlex
import six

from astropy.io import fits

from pynpoint.core.attributes import get_attributes
from pynpoint.core.processing import ReadingModule
from pynpoint.util.module import progress


class NearInitializationModule(ReadingModule):
    """
    This module reads the input fits files from the input directory and returns 4 outputs. These
    correspond to the specific chop/nod configuration. This module is desinged for NEAR data from
    the VISIR instrument.
    The fits files are multidimensional where the first hdulist contains only the general header.
    The second hdulist contains both data and a small header, where the data is a single frame and
    the small header contains specific information about this frame. This format continues until the
    last frame, which is an average of all frames.
    """

    def __init__(self,
                 name_in="burst",
                 image_in_dir="im_in",
                 image_out_tag_1="noda_chopa",
                 image_out_tag_2="noda_chopb",
                 image_out_tag_3="nodb_chopa",
github PynPoint / PynPoint / pynpoint / readwrite / hdf5reading.py View on Github external
import os
import time
import warnings

from typing import Optional

import h5py
import numpy as np

from typeguard import typechecked

from pynpoint.core.processing import ReadingModule
from pynpoint.util.module import progress


class Hdf5ReadingModule(ReadingModule):
    """
    Reads an HDF5 file from the given *input_dir* or the default directory of the Pypeline. A tag
    dictionary has to be set in order to choose the datasets which will be imported into the
    database. Also the static and non-static attributes are read from the HDF5 file and stored
    in the database with the corresponding data set. This module should only be used for reading
    HDF5 files that are created with the Hdf5WritingModule. Reading different type of HDF5 files
    may lead to inconsistencies in the central database.
    """

    __author__ = 'Markus Bonse, Tomas Stolker'

    @typechecked
    def __init__(self,
                 name_in: str,
                 input_filename: Optional[str] = None,
                 input_dir: Optional[str] = None,
github PynPoint / PynPoint / pynpoint / readwrite / attr_reading.py View on Github external
import os
import warnings

import numpy as np

from typing import Optional

from typeguard import typechecked
from astropy.io import fits

from pynpoint.core.attributes import get_attributes
from pynpoint.core.processing import ReadingModule


class AttributeReadingModule(ReadingModule):
    """
    Module for reading a list of values from a FITS or ASCII file and appending them as a non-static
    attributes to a dataset.
    """

    __author__ = 'Tomas Stolker'

    @typechecked
    def __init__(self,
                 name_in: str,
                 data_tag: str,
                 file_name: str,
                 attribute: str,
                 input_dir: Optional[str] = None,
                 overwrite: bool = False) -> None:
        """
github PynPoint / PynPoint / pynpoint / readwrite / attr_reading.py View on Github external
elif status == -1 and self.m_overwrite:
            self.m_data_port.add_attribute('PARANG', parang, static=False)

        elif status == -1 and not self.m_overwrite:
            warnings.warn(f'The PARANG attribute is already present. Set the \'overwrite\' '
                          f'parameter to True in order to overwrite the values with '
                          f'{self.m_file_name}.')

        elif status == 0:
            warnings.warn(f'The PARANG attribute is already present and contains the same values '
                          f'as are present in {self.m_file_name}.')

        self.m_data_port.close_port()


class WavelengthReadingModule(ReadingModule):
    """
    Module for reading a list of wavelengths from a FITS or ASCII file.
    """

    __author__ = 'Tomas Stolker'

    @typechecked
    def __init__(self,
                 name_in: str,
                 data_tag: str,
                 file_name: str,
                 input_dir: Optional[str] = None,
                 overwrite: bool = False) -> None:
        """
        Parameters
        ----------
github PynPoint / PynPoint / pynpoint / readwrite / fitsreading.py View on Github external
import os
import sys
import warnings

import six
import numpy as np

from astropy.io import fits

from pynpoint.core.attributes import get_attributes
from pynpoint.core.processing import ReadingModule
from pynpoint.util.module import progress


class FitsReadingModule(ReadingModule):
    """
    Reads FITS files from the given *input_dir* or the default directory of the Pypeline. The FITS
    files need to contain either single images (2D) or cubes of images (3D). Individual images
    should have the same shape and type. The header of the FITS is scanned for the required static
    attributes (should be identical for each FITS file) and non-static attributes. Static entries
    will be saved as HDF5 attributes while non-static attributes will be saved as separate data
    sets in a subfolder of the database named *header_* + image_tag. If the FITS files in the input
    directory have changing static attributes or the shape of the input images is changing a
    warning appears. FitsReadingModule overwrites by default all existing data with the same tags
    in the central database. Note that PynPoint only supports the processing of square images so
    rectangular images should be made square with e.g. :class:`CropImagesModule` or
    :class:`RemoveLinesModule`.
    """

    def __init__(self,
                 name_in=None,
github PynPoint / PynPoint / pynpoint / readwrite / attr_reading.py View on Github external
elif status == -1 and not self.m_overwrite:
            warnings.warn(f'The attribute \'{self.m_attribute}\' is already present. Set the '
                          f'\'overwrite\' parameter to True in order to overwrite the values with '
                          f'{self.m_file_name}.')

        elif status == 0:
            warnings.warn(f'The \'{self.m_attribute}\' attribute is already present and '
                          f'contains the same values as are present in {self.m_file_name}.')

        print(' [DONE]')

        self.m_data_port.close_port()


class ParangReadingModule(ReadingModule):
    """
    Module for reading a list of parallactic angles from a FITS or ASCII file.
    """

    __author__ = 'Tomas Stolker'

    @typechecked
    def __init__(self,
                 name_in: str,
                 data_tag: str,
                 file_name: str,
                 input_dir: Optional[str] = None,
                 overwrite: bool = False) -> None:
        """
        Parameters
        ----------
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
used. This function is called in all *__init__()* functions inheriting from this class.

        Parameters
        ----------
        name_in : str
            The name of the ReadingModule.
        input_dir : str
            Directory where the input files are located.

        Returns
        -------
        NoneType
            None
        """

        super(ReadingModule, self).__init__(name_in)

        assert (os.path.isdir(str(input_dir)) or input_dir is None), 'Input directory for ' \
            'reading module does not exist - input requested: %s.' % input_dir

        self.m_input_location = input_dir
        self._m_output_ports = {}
github PynPoint / PynPoint / pynpoint / core / pypeline.py View on Github external
Parameters
        ----------
        module : ReadingModule, WritingModule, or ProcessingModule
            The pipeline module.
        tags : list(str, )
            Tags in the database.

        Returns
        -------
        bool
            Module validation.
        str
            Module name.
        """

        if isinstance(module, ReadingModule):
            tags.extend(module.get_all_output_tags())

        elif isinstance(module, WritingModule):
            for tag in module.get_all_input_tags():
                if tag not in tags:
                    return False, module.name

        elif isinstance(module, ProcessingModule):
            tags.extend(module.get_all_output_tags())
            for tag in module.get_all_input_tags():
                if tag not in tags:
                    return False, module.name

        else:
            return False, None
github PynPoint / PynPoint / pynpoint / readwrite / nearreading.py View on Github external
import warnings

from typing import Optional, Union, Tuple

import numpy as np

from astropy.io import fits
from typeguard import typechecked

from pynpoint.core.processing import ReadingModule
from pynpoint.util.attributes import set_static_attr, set_nonstatic_attr, set_extra_attr
from pynpoint.util.module import progress, memory_frames
from pynpoint.util.image import crop_image


class NearReadingModule(ReadingModule):
    """
    Pipeline module for reading VLT/VISIR data of the NEAR experiment. The FITS files and required
    header information are read from the input directory and stored in two datasets, corresponding
    to chop A and chop B. The primary HDU of the FITS files should contain the main header
    information, while the subsequent HDUs contain each a single image (alternated for chop A and
    chop B) and some additional header information for that image. The last HDU is ignored as it
    contains the average of all images.
    """

    __author__ = 'Jasper Jonker, Tomas Stolker, Anna Boehle'

    @typechecked
    def __init__(self,
                 name_in: str,
                 input_dir: Optional[str] = None,
                 chopa_out_tag: str = 'chopa',
github PynPoint / PynPoint / pynpoint / core / processing.py View on Github external
used. This function is called in all *__init__()* functions inheriting from this class.

        Parameters
        ----------
        name_in : str
            The name of the ReadingModule.
        input_dir : str
            Directory where the input files are located.

        Returns
        -------
        NoneType
            None
        """

        super(ReadingModule, self).__init__(name_in)

        assert (os.path.isdir(str(input_dir)) or input_dir is None), 'Input directory for ' \
            'reading module does not exist - input requested: %s.' % input_dir

        self.m_input_location = input_dir
        self._m_output_ports = {}