示例#1
0
    def wavelength(self, wavelength):
        setattr(self, "_wavelength", wavelength)

        if not isinstance(wavelength, Quantity):
            valerr = ValueError(
                'Wavelength range must be a sequence with exactly two values',
                'expressing a frequency or wavelength range')

            try:
                # assume meters
                wavelength = wavelength * Unit("meter")
            except ValueError:
                raise valerr

            try:
                if len(wavelength) != 2:
                    raise valerr
            except TypeError:
                raise valerr

        # transform to meters
        wavelength = wavelength.to(Unit("m"),
                                   equivalencies=spectral_equivalencies())
        # frequency is counter-proportional to wavelength, so we just sort it
        # to have the right order again
        wavelength.sort()

        self["WAVELENGTH"] = "{start}/{end}".format(start=wavelength.value[0],
                                                    end=wavelength.value[1])
示例#2
0
    def band(self, band):
        setattr(self, "_band", band)

        if not isinstance(band, Quantity):
            valerr = ValueError(
                'Band must be a sequence with exactly two values',
                'expressing a frequency or wavelength range')

            try:
                # assume meters
                band = band * Unit("meter")
            except ValueError:
                raise valerr

            try:
                if len(band) != 2:
                    raise valerr
            except TypeError:
                raise valerr

        # transform to meters
        band = band.to(Unit("m"), equivalencies=spectral_equivalencies())
        # frequency is counter-proportional to wavelength, so we just sort
        # it to have the right order again
        band.sort()

        self["BAND"] = "{start}/{end}".format(
            start=band.value[0], end=band.value[1])
示例#3
0
文件: ssa.py 项目: pyvirtobs/pyvo
    def band(self, band):
        setattr(self, "_band", band)

        if not isinstance(band, Quantity):
            valerr = ValueError(
                'Band must be a sequence with exactly two values',
                'expressing a frequency or wavelength range')

            try:
                # assume meters
                band = band * Unit("meter")
            except ValueError:
                raise valerr

            try:
                if len(band) != 2:
                    raise valerr
            except TypeError:
                raise valerr

        # transform to meters
        band = band.to(Unit("m"), equivalencies=spectral_equivalencies())
        # frequency is counter-proportional to wavelength, so we just sort
        # it to have the right order again
        band.sort()

        self["BAND"] = "{start}/{end}".format(
            start=band.value[0], end=band.value[1])