Пример #1
0
    def __new__(cls, flux, wavelength, scale=None, unit=Angstrom,
                wavelength_unit=Angstrom, ivar=None, std=None,
                mask=None, dtype=None, copy=True, pixmask_flag=None, **kwargs):

        flux = np.array(flux)

        # If the scale is defined, creates a new composite unit with the input scale.
        if scale is not None:
            unit = CompositeUnit(unit.scale * scale, unit.bases, unit.powers)

        obj = Quantity(flux, unit=unit, dtype=dtype, copy=copy)
        obj = obj.view(cls)
        obj._set_unit(unit)

        obj.ivar = np.array(ivar) if ivar is not None else None
        obj.mask = np.array(mask) if mask is not None else None

        if std is not None:
            assert ivar is None, 'std and ivar cannot be used at the same time.'
            obj._std = np.array(std)

        assert wavelength is not None, 'invalid wavelength'

        if isinstance(wavelength, Quantity):
            obj.wavelength = wavelength
        else:
            obj.wavelength = np.array(wavelength) * wavelength_unit

        obj.pixmask_flag = pixmask_flag

        return obj
Пример #2
0
    def __new__(cls,
                value,
                unit=dimensionless_unscaled,
                scale=1,
                ivar=None,
                mask=None,
                dtype=None,
                copy=True):

        obj = Quantity(value, unit=unit, dtype=dtype, copy=copy)
        obj = obj.view(cls)
        obj._set_unit(unit)

        obj.ivar = ivar
        obj.mask = mask

        return obj
Пример #3
0
    def __new__(cls, prop, value, ivar=None, mask=None, dtype=None, copy=True):

        unit = prop.unit
        scale = prop.scale
        value = value * scale * unit

        obj = Quantity(value, unit=unit, dtype=dtype, copy=copy)
        obj = obj.view(cls)
        obj._set_unit(unit)

        obj.property = prop

        obj.ivar = (ivar /
                    (obj.property.scale**2)) if ivar is not None else None
        obj.mask = mask

        obj.name = obj.property.name
        obj.channel = obj.property.channel

        obj.description = obj.property.description

        return obj