sqlalchemy.func.log - python examples

Here are the examples of the python api sqlalchemy.func.log taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

4 Examples 7

3 View Complete Implementation : SampleModelClasses.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : sdss
def logmast(parameter):

    @hybrid_property
    def mast(self):
        par = getattr(self, parameter)
        return math.log10(par) if par > 0. else 0.

    @mast.expression
    def mast(cls):
        par = getattr(cls, parameter)
        return cast(case([(par > 0., func.log(par)),
                          (par == 0., 0.)]), Float)

    return mast

0 View Complete Implementation : DataModelClasses.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : sdss
    @nsa_logmstar.expression
    def nsa_logmstar(cls):
        return func.log(cls.nsa_mstar)

0 View Complete Implementation : DataModelClasses.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : sdss
    @nsa_logmstar_el.expression
    def nsa_logmstar_el(cls):
        return func.log(cls.nsa_mstar_el)

0 View Complete Implementation : SampleModelClasses.py
Copyright BSD 3-Clause "New" or "Revised" License
Author : sdss
def HybridMag(flux_parameter, band, index=None):
    """Returns a hybrid property describing an asinh magnitude.

    ``flux_parameter`` must be a column with a flux in nanomaggies. ``band`` is
    the band name, to determine the softening parameter. If ``flux_parameter``
    is and array, ``index`` defines the position of ``band`` within the array.

    """

    @hybrid_property
    def hybridMag(self):
        if index is not None:
            flux = getattr(self, flux_parameter)[index]
        else:
            flux = getattr(self, flux_parameter)

        flux *= 1e-9  # From nanomaggies to maggies
        bb_band = bb[band]
        asinh_mag = -2.5 / np.log(10) * (np.arcsinh(flux / (2. * bb_band)) + np.log(bb_band))
        return asinh_mag

    @hybridMag.expression
    def hybridMag(cls):
        if index is not None:
            # It needs to be index + 1 because Postgresql arrays are 1-indexed.
            flux = getattr(cls, flux_parameter)[index + 1]
        else:
            flux = getattr(cls, flux_parameter)

        flux *= 1e-9
        bb_band = bb[band]
        xx = flux / (2. * bb_band)
        asinh_mag = (-2.5 / func.log(10) *
                     (func.log(xx + func.sqrt(func.pow(xx, 2) + 1)) + func.log(bb_band)))
        return cast(asinh_mag, Float)

    return hybridMag