<commit_before>from itertools import chain
import logging
import datetime

from astropysics import obstools
import numpy as np

from fitskeyword import FITSKeyword

logger = logging.getLogger(__name__)


class FederSite(obstools.Site):

    """
    The Feder Observatory site.

    An astropysics site with the observatory location and name pre-set.
    """

    def __init__(self):
        """
        Location/name information are set for Feder Observatory.

        `lat` = 46.86678 degrees

        `long` = -96.453278 degrees Eaast

        `alt` = 311.8 meters

        `name` = Feder Observatory
        """
        obstools.Site.__init__(self,
                               lat=46.86678,
                               long=-96.453278,
                               alt=311.8,
                               name='Feder Observatory')

    def localSiderialTime(self, seconds_decimal=None, *arg, **kwd):
        try:
            return_type = kwd['returntype']
        except KeyError:
            return_type = 'hours'

        if return_type is None or return_type == 'hours':
            return super(FederSite, self).localSiderialTime(*arg,
                                                            **kwd)

        return_type = kwd.pop('returntype', None)
        lst = super(FederSite, self).localSiderialTime(*arg,
                                                       returntype='datetime',
                                                       **kwd)
        if seconds_decimal is not None:
            seconds = np.round(lst.second + lst.microsecond / 1e6,
                               seconds_decimal)
            sec = np.int(seconds)
            microsec = np.int(np.round((seconds - sec) * 1e6))
            lst = datetime.time(lst.hour, lst.minute, sec, microsec)
        if return_type == 'string':
            lst = lst.isoformat()
        return lst


class Instrument(object):

    """
    Telescope instrument with simple properties.
    """

    def __init__(self, name, fits_names=None,
                 rows=0, columns=0,
                 overscan_start=None,
                 overscan_axis=None):
        self.name = name
        self.fits_names = fits_names
        self.rows = rows
        self.columns = columns
        self.overscan_start = overscan_start
        self.overscan_axis = overscan_axis

    def has_overscan(self, image_dimensions):
        """
        Determine whether an image taken by this instrument has overscan

        Parameters
        ----------

        image_dimensions : list-like with two elements
            Shape of the image; can be any type as long as it has two elements.
        """
        if (image_dimensions[self.overscan_axis - 1] >
                self.overscan_start):

            return True
        else:
            return False


class ApogeeAltaU9(Instrument):
    """
    The Apogee Alta U9
    """
    def __init__(self):
        Instrument.__init__(self, "Apogee Alta U9",
                            fits_names=["Apogee Alta", "Apogee USB/Net"],
                            rows=2048, columns=3085,
                            overscan_start=3073,
                            overscan_axis=1)


class ImageSoftware(object):

    """
    Represents software that takes images at telescope.

    Properties
    ----------

    name : str

        Name of the software. Can be the same is the name in the FITS file,
        or not.

    fits_keyword : str

        Name of the FITS keyword that contains the name of the software.

    fits_name : str

        Name of the software as written in the FITS file

    major_version : int

        Major version number of the software.

    minor_version : int

        Minor version number of the software.

    bad_keywords : list of strings

        Names of any keywords that should be removed from the FITS before
        further processing.
    """

    def __init__(self, name, fits_name=None,
                 major_version=None,
                 minor_version=None,
                 bad_keywords=None,
                 fits_keyword=None,
                 purged_flag_keyword='PURGED'):
        self.name = name
        self.fits_name = fits_name
        self.major_version = major_version
        self.minor_version = minor_version
        self.bad_keywords = bad_keywords
        self.fits_keyword = fits_keyword
        self.purged_flag_keyword = purged_flag_keyword

    def created_this(self, version_string):
        """
        Indicate whether version string matches this software
        """
        return version_string == self.fits_name


class MaximDL4(ImageSoftware):

    """
    Represents MaximDL version 4, all sub-versions
    """

    def __init__(self):
        super(MaximDL4, self).__init__("MaxImDL",
                                       fits_name='MaxIm DL Version 4.10',
                                       major_version=4,
                                       minor_version=10,
                                       bad_keywords=['OBSERVER'],
                                       fits_keyword='SWCREATE')


class MaximDL5(ImageSoftware):

    """
    Represents MaximDL version 5, all sub-versions
    """

    def __init__(self):
        bad_keys = ['OBJECT', 'JD', 'JD-HELIO', 'OBJCTALT', 'OBJCTAZ',
                    'OBJCTHA', 'AIRMASS', 'OBSERVER']
        fits_name = 'MaxIm DL Version 5.21 130912 01A17'
        super(MaximDL5, self).__init__("MaxImDL",
                                       fits_name=fits_name,
                                       major_version=5,
                                       minor_version=21,
                                       bad_keywords=bad_keys,
                                       fits_keyword='SWCREATE'
                                       )


class Feder(object):

    def __init__(self):
        self.site = FederSite()<commit_msg>Add MaxIm DL 5.23 to list of software versions<commit_after>from itertools import chain
import logging
import datetime

from astropysics import obstools
import numpy as np

from fitskeyword import FITSKeyword

logger = logging.getLogger(__name__)


class FederSite(obstools.Site):

    """
    The Feder Observatory site.

    An astropysics site with the observatory location and name pre-set.
    """

    def __init__(self):
        """
        Location/name information are set for Feder Observatory.

        `lat` = 46.86678 degrees

        `long` = -96.453278 degrees Eaast

        `alt` = 311.8 meters

        `name` = Feder Observatory
        """
        obstools.Site.__init__(self,
                               lat=46.86678,
                               long=-96.453278,
                               alt=311.8,
                               name='Feder Observatory')

    def localSiderialTime(self, seconds_decimal=None, *arg, **kwd):
        try:
            return_type = kwd['returntype']
        except KeyError:
            return_type = 'hours'

        if return_type is None or return_type == 'hours':
            return super(FederSite, self).localSiderialTime(*arg,
                                                            **kwd)

        return_type = kwd.pop('returntype', None)
        lst = super(FederSite, self).localSiderialTime(*arg,
                                                       returntype='datetime',
                                                       **kwd)
        if seconds_decimal is not None:
            seconds = np.round(lst.second + lst.microsecond / 1e6,
                               seconds_decimal)
            sec = np.int(seconds)
            microsec = np.int(np.round((seconds - sec) * 1e6))
            lst = datetime.time(lst.hour, lst.minute, sec, microsec)
        if return_type == 'string':
            lst = lst.isoformat()
        return lst


class Instrument(object):

    """
    Telescope instrument with simple properties.
    """

    def __init__(self, name, fits_names=None,
                 rows=0, columns=0,
                 overscan_start=None,
                 overscan_axis=None):
        self.name = name
        self.fits_names = fits_names
        self.rows = rows
        self.columns = columns
        self.overscan_start = overscan_start
        self.overscan_axis = overscan_axis

    def has_overscan(self, image_dimensions):
        """
        Determine whether an image taken by this instrument has overscan

        Parameters
        ----------

        image_dimensions : list-like with two elements
            Shape of the image; can be any type as long as it has two elements.
        """
        if (image_dimensions[self.overscan_axis - 1] >
                self.overscan_start):

            return True
        else:
            return False


class ApogeeAltaU9(Instrument):
    """
    The Apogee Alta U9
    """
    def __init__(self):
        Instrument.__init__(self, "Apogee Alta U9",
                            fits_names=["Apogee Alta", "Apogee USB/Net"],
                            rows=2048, columns=3085,
                            overscan_start=3073,
                            overscan_axis=1)


class ImageSoftware(object):

    """
    Represents software that takes images at telescope.

    Properties
    ----------

    name : str

        Name of the software. Can be the same is the name in the FITS file,
        or not.

    fits_keyword : str

        Name of the FITS keyword that contains the name of the software.

    fits_name : str

        Name of the software as written in the FITS file

    major_version : int

        Major version number of the software.

    minor_version : int

        Minor version number of the software.

    bad_keywords : list of strings

        Names of any keywords that should be removed from the FITS before
        further processing.
    """

    def __init__(self, name, fits_name=None,
                 major_version=None,
                 minor_version=None,
                 bad_keywords=None,
                 fits_keyword=None,
                 purged_flag_keyword='PURGED'):
        self.name = name
        self.fits_name = fits_name
        self.major_version = major_version
        self.minor_version = minor_version
        self.bad_keywords = bad_keywords
        self.fits_keyword = fits_keyword
        self.purged_flag_keyword = purged_flag_keyword

    def created_this(self, version_string):
        """
        Indicate whether version string matches this software
        """
        return version_string in self.fits_name


class MaximDL4(ImageSoftware):

    """
    Represents MaximDL version 4, all sub-versions
    """

    def __init__(self):
        super(MaximDL4, self).__init__("MaxImDL",
                                       fits_name='MaxIm DL Version 4.10',
                                       major_version=4,
                                       minor_version=10,
                                       bad_keywords=['OBSERVER'],
                                       fits_keyword='SWCREATE')


class MaximDL5(ImageSoftware):

    """
    Represents MaximDL version 5, all sub-versions
    """

    def __init__(self):
        bad_keys = ['OBJECT', 'JD', 'JD-HELIO', 'OBJCTALT', 'OBJCTAZ',
                    'OBJCTHA', 'AIRMASS', 'OBSERVER']
        fits_name = ['MaxIm DL Version 5.21 130912 01A17',
                     'MaxIm DL Version 5.23 130912 01A17']
        super(MaximDL5, self).__init__("MaxImDL",
                                       fits_name=fits_name,
                                       major_version=5,
                                       minor_version=21,
                                       bad_keywords=bad_keys,
                                       fits_keyword='SWCREATE'
                                       )


class Feder(object):

    def __init__(self):
        self.site = FederSite()
{'fraction_non_alphanumeric': 0.07894292468760554, 'fraction_numerical': 0.016379601485984465, 'mean_word_length': 1.4832285115303983, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4135201', 'n_tokens_mistral': 3327, 'n_tokens_neox': 3029, 'n_words': 812}