예제 #1
0
파일: attrs.py 프로젝트: tdunn19/sunpy
    def __init__(self, start, end, near=None):
        self.start = parse_time(start)
        self.end = parse_time(end)
        self.near = None if near is None else parse_time(near)

        _Range.__init__(self, self.start, self.end, self.__class__)
        Attr.__init__(self)
예제 #2
0
파일: attrs.py 프로젝트: timmie/sunpy
    def __init__(self, start, end, near=None):
        self.start = parse_time(start)
        self.end = parse_time(end)
        self.near = None if near is None else parse_time(near)

        _Range.__init__(self, self.start, self.end, self.__class__)
        Attr.__init__(self)
예제 #3
0
    def __init__(self, start, end, near=None):
        self.start = anytim(start)
        self.end = anytim(end)
        self.near = None if near is None else anytim(near)

        _Range.__init__(self, start, end, self.__class__)
        Attr.__init__(self)
예제 #4
0
파일: attrs.py 프로젝트: calexyoung/sunpy
    def __init__(self, start, end, near=None):
        self.start = start
        self.end = end
        self.near = near

        _Range.__init__(self, start, end, self.__class__)
        Attr.__init__(self)
예제 #5
0
def query_decode(json_object):
    simple_attrs = [
        'Provider', 'Source', 'Instrument', 'Physobs', 'Pixels', 'Level',
        'Resolution', 'Detector', 'Filter', 'Sample', 'Quicklook', 'PScale'
    ]
    for key in simple_attrs:
        if key in json_object:
            Attr = getattr(vso.attrs, key)
            return Attr(json_object[key])
    for key in ['Wave', 'Time']:
        if key in json_object:
            Attr = getattr(vso.attrs, key)
            return Attr(*json_object[key])
    for key in ['Tag', 'Path', 'DownloadTime', 'FitsHeaderEntry']:
        if key in json_object:
            Attr = getattr(db_attrs, key)
            values, inverted = json_object[key][:-1], json_object[key][-1]
            if inverted:
                return ~Attr(*values)
            return Attr(*values)
    if 'Starred' in json_object:
        if json_object['Starred']:
            return ~db_attrs.Starred()
        return db_attrs.Starred()
    for key in ['AttrOr', 'AttrAnd']:
        if key in json_object:
            Attr = getattr(vso.attrs, key)
            return Attr(json_object[key])
    return json_object
예제 #6
0
파일: attrs.py 프로젝트: tdunn19/sunpy
    def __init__(self, wavemin, wavemax, waveunit='Angstrom'):
        self.min, self.max = sorted(
            to_angstrom(v, waveunit)
            for v in [float(wavemin), float(wavemax)])
        self.unit = 'Angstrom'

        Attr.__init__(self)
        _Range.__init__(self, self.min, self.max, self.__class__)
예제 #7
0
파일: attrs.py 프로젝트: timmie/sunpy
 def __init__(self, x, y, width, length, type_):
     Attr.__init__(self)
     
     self.x = x
     self.y = y
     self.width = width
     self.length = length
     self.type = type_
예제 #8
0
파일: attrs.py 프로젝트: saurvs/sunpy
    def __init__(self, x, y, width, length, atype):
        Attr.__init__(self)

        self.x = x
        self.y = y
        self.width = width
        self.length = length
        self.type = atype
예제 #9
0
파일: attrs.py 프로젝트: timmie/sunpy
 def __init__(self, wavemin, wavemax, waveunit='Angstrom'):
     self.min, self.max = sorted(
         to_angstrom(v, waveunit) for v in [wavemin, wavemax]
     )
     self.unit = 'Angstrom'
     
     Attr.__init__(self)
     _Range.__init__(self, self.min, self.max, self.__class__)
예제 #10
0
파일: attrs.py 프로젝트: tsarjak/sunpy
    def __init__(self, start, end=None, near=None):
        if end is None and not isinstance(start, _TimeRange):
            raise ValueError("Specify start and end or start has to be a TimeRange")
        if isinstance(start, _TimeRange):
            self.start = start.start
            self.end = start.end
        else:
            self.start = parse_time(start)
            self.end = parse_time(end)
        self.near = None if near is None else parse_time(near)

        _Range.__init__(self, self.start, self.end, self.__class__)
        Attr.__init__(self)
예제 #11
0
파일: attrs.py 프로젝트: saurvs/sunpy
    def __init__(self, wavemin, wavemax=None):
        """
        Specifies the wavelength or spectral energy range of the detector.

        Parameters
        ----------
        wavemin : `~astropy.units.Quantity`
            The lower bounds of the range.

        wavemax : `~astropy.units.Quantity`
            The upper bound of the range, if not specified it will default to
            the lower bound.

        Notes
        -----
        The VSO understands the 'wavelength' in one of three units, Angstroms,
        kHz or keV. Therefore any unit which is directly convertable to these
        units is valid input
        """

        if not wavemax:
            wavemax = wavemin

        if not all(isinstance(var, u.Quantity) for var in [wavemin, wavemax]):
            raise TypeError("Wave inputs must be astropy Quantities")

        if not all([wavemin.isscalar, wavemax.isscalar]):
            raise ValueError("Both wavemin and wavemax must be scalar values")

        # VSO just accept inputs as Angstroms, kHz or keV, the following
        # converts to any of these units depending on the spectral inputs
        # Note: the website asks for GHz, however it seems that using GHz
        # produces weird responses on VSO.
        supported_units = [u.AA, u.kHz, u.keV]
        for unit in supported_units:
            if wavemin.unit.is_equivalent(unit):
                break
            else:
                unit = None
        if unit is None:
            raise u.UnitsError(
                "This unit is not convertable to any of {}".format(
                    supported_units))

        self.min, self.max = sorted([wavemin.to(unit), wavemax.to(unit)])
        self.unit = unit

        Attr.__init__(self)
        _Range.__init__(self, self.min, self.max, self.__class__)
예제 #12
0
파일: attrs.py 프로젝트: tiagopereira/sunpy
    def __init__(self, start, end=None):
        if end is None and not isinstance(start, _TimeRange):
            raise ValueError("Specify start and end or start has to be a TimeRange")
        if isinstance(start, _TimeRange):
            self.start = start.start
            self.end = start.end
        else:
            self.start = start if isinstance(start, astropyTime) else astropyTime(parse_time(start))
            self.end = end if isinstance(end, astropyTime) else astropyTime(parse_time(end))

        if self.start > self.end:
            raise ValueError("End time must be after start time.")

        _Range.__init__(self, self.start, self.end, self.__class__)
        Attr.__init__(self)
예제 #13
0
    def __init__(self, wavemin, wavemax=None):
        """
        Specifies the wavelength or spectral energy range of the detector.

        Parameters
        ----------
        wavemin : `~astropy.units.Quantity`
            The lower bounds of the range.

        wavemax : `~astropy.units.Quantity`
            The upper bound of the range, if not specified it will default to
            the lower bound.

        Notes
        -----
        The VSO understands the 'wavelength' in one of three units, Angstroms,
        kHz or keV. Therefore any unit which is directly convertible to these
        units is valid input.
        """

        if not wavemax:
            wavemax = wavemin

        if not all(isinstance(var, u.Quantity) for var in [wavemin, wavemax]):
            raise TypeError("Wave inputs must be astropy Quantities")

        if not all([wavemin.isscalar, wavemax.isscalar]):
            raise ValueError("Both wavemin and wavemax must be scalar values")

        # VSO just accept inputs as Angstroms, kHz or keV, the following
        # converts to any of these units depending on the spectral inputs
        # Note: the website asks for GHz, however it seems that using GHz
        # produces weird responses on VSO.
        supported_units = [u.AA, u.kHz, u.keV]
        for unit in supported_units:
            if wavemin.unit.is_equivalent(unit):
                break
            else:
                unit = None
        if unit is None:
            raise u.UnitsError("This unit is not convertable to any of {}".format(supported_units))

        self.min, self.max = sorted([wavemin.to(unit), wavemax.to(unit)])
        self.unit = unit

        Attr.__init__(self)
        _Range.__init__(self, self.min, self.max, self.__class__)
예제 #14
0
파일: attrs.py 프로젝트: tsarjak/sunpy
    def __init__(self, wavemin, wavemax):
        if not all(isinstance(var, u.Quantity) for var in [wavemin, wavemax]):
            raise TypeError("Wave inputs must be astropy Quantities")

        # VSO just accept inputs as Angstroms, kHz or keV, the following
        # converts to any of these units depending on the spectral inputs
        # Note: the website asks for GHz, however it seems that using GHz
        # produces weird responses on VSO.
        convert = {'m': u.AA, 'Hz': u.kHz, 'eV': u.keV}
        for k in convert.keys():
            if wavemin.decompose().unit == (1 * u.Unit(k)).decompose().unit:
                unit = convert[k]
        try:
            self.min, self.max = sorted(
                value.to(unit) for value in [wavemin, wavemax]
                )
            self.unit = unit
        except NameError:
            raise ValueError("'{0}' is not a spectral supported unit".format(wavemin.unit))
        Attr.__init__(self)
        _Range.__init__(self, self.min, self.max, self.__class__)
예제 #15
0
    def __init__(self, value):
        if not (isinstance(value, u.Quantity) or isinstance(value, list)):
            raise TypeError("Wave inputs must be astropy Quantities")
        Attr.__init__(self)

        self.value = value
예제 #16
0
파일: attrs.py 프로젝트: timmie/sunpy
 def __init__(self, value):
     Attr.__init__(self)
     
     self.value = value
예제 #17
0
파일: attrs.py 프로젝트: saurvs/sunpy
    def __init__(self, value):
        Attr.__init__(self)

        self.value = value
예제 #18
0
파일: attrs.py 프로젝트: Cadair/sunpy
 def __init__(self, label, value):
     Attr.__init__(self)
     self.label = label
     self.value = value
예제 #19
0
파일: attrs.py 프로젝트: tiagopereira/sunpy
 def __init__(self, label, value):
     Attr.__init__(self)
     self.label = label
     self.value = value
예제 #20
0
파일: attrs.py 프로젝트: abigailStev/sunpy
    def __init__(self, value):
        if not (isinstance(value, u.Quantity) or isinstance(value, list)):
            raise TypeError("Wave inputs must be astropy Quantities")
        Attr.__init__(self)

        self.value = value