Ejemplo n.º 1
0
def test_reduced_grid_a_priori():
    tropopause_mask = TropopauseMask()
    temperature_mask = TemperatureMask(lower_limit=230.0, upper_limit=280.0)
    covariance = Diagonal(2.0, And(temperature_mask, tropopause_mask))
    covariance_new = Diagonal(2.0 * np.ones(10))

    data_provider = DataProvider()
    t = data_provider.get_temperature()
    a_priori = FixedAPriori("temperature", t, covariance)
    a_priori = ReducedVerticalGrid(a_priori, np.logspace(3, 5, 10)[::-1])
    data_provider.add(a_priori)

    t_xa = data_provider.get_temperature_xa()
    assert (t_xa.size == 10)

    covmat = data_provider.get_temperature_covariance()
    assert (covmat.shape == (10, 10))

    data_provider = DataProvider()
    a_priori = ReducedVerticalGrid(a_priori,
                                   np.logspace(3, 5, 10)[::-1],
                                   covariance=covariance_new)
    data_provider.add(a_priori)
    covmat = data_provider.get_temperature_covariance()
    assert (np.all(covmat.diagonal() == 2.0))
Ejemplo n.º 2
0
def test_data_provider_a_priori():
    temperature_mask = TemperatureMask(lower_limit=230.0, upper_limit=280.0)
    tropopause_mask = TropopauseMask()
    covariance = Diagonal(2.0, And(temperature_mask, tropopause_mask))
    data_provider = DataProvider()
    data_provider.add(DataProviderAPriori("temperature", covariance))

    t = data_provider.get_temperature()
    assert (np.all(data_provider.get_temperature_xa() == t))
Ejemplo n.º 3
0
def test_functional_a_priori():
    temperature_mask = TemperatureMask(lower_limit=230.0, upper_limit=280.0)
    tropopause_mask = TropopauseMask()
    covariance = Diagonal(2.0, And(temperature_mask, tropopause_mask))
    covariance_new = Diagonal(2.0 * np.ones(10))

    data_provider = DataProvider()
    t = data_provider.get_temperature()
    f = lambda x: x**2
    a_priori = FunctionalAPriori("temperature", "temperature", f, covariance)
    data_provider.add(a_priori)
    assert (np.all(np.isclose(t**2, data_provider.get_temperature_xa())))
Ejemplo n.º 4
0
def test_masks():
    data_provider = DataProvider()
    temperature = data_provider.get_temperature()

    temperature_mask = TemperatureMask(lower_limit=230.0, upper_limit=280.0)
    mask = temperature_mask(data_provider)
    assert (np.all(temperature[mask] >= 230))
    assert (np.all(temperature[mask] < 280))

    tropopause_mask = TropopauseMask()
    mask = tropopause_mask(data_provider)
    assert (np.all(temperature[mask]) <= 225)

    mask = And(temperature_mask, tropopause_mask)(data_provider)
    assert (np.all(temperature[mask] >= 230))
    assert (np.all(temperature[mask] < 280))
    assert (np.all(temperature[mask]) <= 225)
Ejemplo n.º 5
0
"""
Common function used for LIRAS a priori.
"""
import numpy as np
import artssat
from artssat.jacobian import Atanh
from artssat.retrieval.a_priori import (And, TropopauseMask, TemperatureMask,
                                        FreezingLevel, Dilate)

"""
Mask limiting retrieval of ice to between 280 K isotherm and the tropopause.
"""
ice_mask = Dilate(And(TropopauseMask(),
                      FreezingLevel(lower_inclusive=True, invert=False)),
                  1)
#               TemperatureMask(0.0, 273.15, lower_inclusive = True))

"""
Mask limiting retrieval of rain to between surface and 264 K isotherm.
"""
rain_mask = Dilate(FreezingLevel(lower_inclusive = False, invert = True), 1)
#TemperatureMask(273.15, 340.0, upper_inclusive = True)

def n0_a_priori(t):
    """
    Functional relation for of the a priori mean of :math:`N_0^*`
    as described in Cazenave et al. 2019.

    Args:
        t: Array containing the temperature profile.