예제 #1
0
def make_snow_layer(layer_thickness, microstructure_model,
                    density,
                    temperature=FREEZING_POINT,
                    ice_permittivity_model=None,
                    background_permittivity_model=PERMITTIVITY_OF_AIR,
                    liquid_water=0, salinity=0,
                    **kwargs):
    """Make a snow layer for a given microstructure_model (see also :py:func:`~smrt.inputs.make_medium.make_snowpack`
    to create many layers). The microstructural parameters depend on the microstructural model and should be given as
    additional arguments to this function. To know which parameters are required or optional, refer to the documentation
    of the specific microstructure model used.

    :param layer_thickness: thickness of snow layer in m.
    :param microstructure_model: module name of microstructure model to be used.
    :param density: density of snow layer in kg m :sup:`-3`.
    :param temperature: temperature of layer in K.
    :param ice_permittivity_model: permittivity formulation of the scatterers (default is ice_permittivity_matzler87).
    :param background_permittivity_model: permittivity formulation for the background (default is air).
    :param liquid_water: volume of liquid water with respect to ice+water volume (default=0).
    liquid_water = water_volume / (ice_volume + water_volume).
    :param salinity: salinity in kg/kg, for using PSU as unit see PSU constant in smrt module (default = 0).
    :param kwargs: other microstructure parameters are given as optional arguments (in Python words) but may be required (in SMRT words).
    See the documentation of the microstructure model.

    :returns: :py:class:`Layer` instance
"""

    # TODO: Check the validity of the density or see Layer basic_check

    if ice_permittivity_model is None:
        # must import this here instead of the top of the file because of cross-dependencies
        # default ice permittivity model, use ice_permittivity_maetzler06 for dry snow and add support for wet snow
        from ..permittivity.wetice import wetice_permittivity_bohren83
        ice_permittivity_model = wetice_permittivity_bohren83

    eps_1 = background_permittivity_model
    eps_2 = ice_permittivity_model

    if isinstance(microstructure_model, str):
        microstructure_model = get_microstructure_model(microstructure_model)

    lay = Layer(layer_thickness, microstructure_model,
                frac_volume=snow_frac_volume(density, liquid_water),
                temperature=float(temperature),
                permittivity_model=(eps_1, eps_2), **kwargs)

    lay.liquid_water = float(liquid_water)  # read-only
    lay.salinity = float(salinity)
    lay.density = float(density)  # read-only

    # they are read-only because the frac_volume needs to be recomputed if they are changed
    # the only way to change these properties is to create a new Layer
    # we might introduce auto-recomputation in the future, but it may be more confusing than useful
    lay.read_only_attributes.update(['liquid_water', 'density'])

    return lay
예제 #2
0
def make_snow_layer(layer_thickness,
                    microstructure_model,
                    density,
                    temperature=FREEZING_POINT,
                    ice_permittivity_model=None,
                    background_permittivity_model=PERMITTIVITY_OF_AIR,
                    liquid_water=0,
                    salinity=0,
                    **kwargs):
    """Make a snow layer for a given microstructure_model (see also :py:func:`~smrt.inputs.make_medium.make_snowpack` to create many layers).
    The microstructural parameters depend on the microstructural model and should be given as additional arguments to this function. To know which parameters are required or optional,
    refer to the documentation of the specific microstructure model used.

    :param layer_thickness: thickness of snow layer in m
    :param microstructure_model: module name of microstructure model to be used
    :param density: density of snow layer in kg m :sup:`-3`
    :param temperature: temperature of layer in K
    :param ice_permittivity_model: permittivity formulation (default is ice_permittivity_matzler87)
    :param liquid_water: volume of liquid water with respect to ice volume (default=0)
    :param salinity: salinity in kg/kg, for using PSU as unit see PSU constant in smrt module (default = 0)
    :param kwargs: other microstructure parameters are given as optional arguments (in Python words) but may be required (in SMRT words).
    See the documentation of the microstructure model.

    :returns: :py:class:`Layer` instance
"""

    # TODO: Check the validity of the density or see Layer basic_check

    if ice_permittivity_model is None:
        # must import this here instead of the top of the file because of cross-dependencies
        # default ice permittivity model, use ice_permittivity_maetzler06 for dry snow and add support for wet snow
        from ..permittivity.wetsnow import wetsnow_permittivity
        ice_permittivity_model = wetsnow_permittivity

    # ice in air background. Note that the emmodel might inverse the medium or use other technique for mid-range densities.
    # This is the case of DMRT_Shortrange for instance.
    frac_volume = float(density) / DENSITY_OF_ICE
    eps_1 = background_permittivity_model
    eps_2 = ice_permittivity_model

    if isinstance(microstructure_model, str):
        microstructure_model = get_microstructure_model(microstructure_model)

    lay = Layer(layer_thickness,
                microstructure_model,
                frac_volume=float(frac_volume),
                temperature=float(temperature),
                permittivity_model=(eps_1, eps_2),
                **kwargs)

    lay.liquid_water = float(liquid_water)
    lay.salinity = float(salinity)
    lay.density = float(density)  # just for information

    return lay
예제 #3
0
def make_ice_layer(ice_type,
                   layer_thickness,
                   temperature,
                   salinity,
                   microstructure_model,
                   brine_inclusion_shape='spheres',
                   brine_volume_fraction=None,
                   porosity=0,
                   density=None,
                   brine_permittivity_model=None,
                   ice_permittivity_model=None,
                   saline_ice_permittivity_model=None,
                   **kwargs):
    """Make an ice layer for a given microstructure_model (see also :py:func:`~smrt.inputs.make_medium.make_ice_column` to create many layers).
    The microstructural parameters depend on the microstructural model and should be given as additional arguments to this function. To know which parameters are required or optional,
    refer to the documentation of the specific microstructure model used.

    :param ice_type: Assumed ice type 
    :param layer_thickness: thickness of ice layer in m
    :param temperature: temperature of layer in K
    :param salinity: (firstyear and multiyear) salinity in kg/kg (see PSU constant in smrt module)
    :param brine_inclusion_shape: (firstyear and multiyear) assumption for shape of brine inclusions (so far, "spheres" and "random_needles" (i.e. elongated ellipsoidal inclusions), and "mix_spheres_needles" are implemented)
    :param brine_volume_fraction: (firstyear and multiyear) brine / liquid water fraction in sea ice, optional parameter, if not given brine volume fraction is calculated from temperature and salinity in ~.smrt.permittivity.brine_volume_fraction
    :param density: (multiyear) density of ice layer in kg m :sup:`-3`. If not given, density is calculated from temperature, salinity and ice porosity. 
    :param porosity: (mutliyear and fresh) air porosity of ice layer (0..1). Default is 0.
    :param ice_permittivity_model: (all) pure ice permittivity formulation (default is ice_permittivity_matzler06)
    :param brine_permittivity_model: (firstyear and multiyear) brine permittivity formulation (default is brine_permittivity_stogryn85)
    :param saline_ice_permittivity_model: (multiyear) model to mix ice and brine. The default uses polder van staten and ice_permittivity_model and brine_permittivity_model. It is highly recommanded
    to use the default.
    :param kwargs: other microstructure parameters are given as optional arguments (in Python words) but may be required (in SMRT words).
    See the documentation of the microstructure model.

    :returns: :py:class:`Layer` instance
"""

    # common setup
    if ice_type in ['firstyear', 'multiyear']:
        if brine_volume_fraction is None:
            brine_volume_fraction = brine_volume(temperature, salinity)

        if brine_permittivity_model is None:
            brine_permittivity_model = brine_permittivity_stogryn85  # default brine permittivity model

    if density is None:
        density = bulk_ice_density(temperature, salinity, porosity)
    elif porosity == 0:
        porosity = np.clip(
            1. - density / bulk_ice_density(temperature, salinity, porosity=0),
            0., 1.)
    else:
        raise SMRTError("Setting density and porosity is invalid")

    # specific setup
    if ice_type == "firstyear":
        # scatterers permittivity
        eps_2 = brine_permittivity_model

        # background permittivity
        if ice_permittivity_model is None:
            # 'must import this here instead of the top of the file because of cross-dependencies' is what it says above, so I did the same...
            eps_1 = ice_permittivity_maetzler06
        else:
            eps_1 = ice_permittivity_model

        # fractional volume of brine
        frac_volume = brine_volume_fraction

        # shape of brine
        inclusion_shape = brine_inclusion_shape

        if saline_ice_permittivity_model is not None:
            raise SMRTError(
                "Setting saline_ice_permittivity_model is invalid for firstyear seaice"
            )

    elif ice_type == "multiyear":
        # scatterers permittivity
        eps_2 = PERMITTIVITY_OF_AIR

        # background permittivity
        if saline_ice_permittivity_model is None:
            eps_1 = saline_ice_permittivity_pvs_mixing
        else:
            eps_1 = saline_ice_permittivity_model

        # fractional volume of air
        frac_volume = porosity

        # shape of air bubbles
        inclusion_shape = 'spheres'

    elif ice_type == "fresh":
        # scatterers permittivity
        eps_2 = PERMITTIVITY_OF_AIR

        # background permittivity
        if ice_permittivity_model is None:
            # 'must import this here instead of the top of the file because of cross-dependencies' is what it says above, so I did the same...
            eps_1 = ice_permittivity_maetzler06
        else:
            eps_1 = ice_permittivity_model

        # fractional volume of air
        frac_volume = porosity

        # shape of bubbles
        inclusion_shape = 'spheres'

        if saline_ice_permittivity_model is not None or brine_permittivity_model is not None \
                or brine_volume_fraction is not None or salinity > 0:
            raise SMRTError(
                "Setting any saline or brine parameter is invalid for fresh ice"
            )

    else:
        raise SMRTError(
            "Unknown ice_type. Must be firstyear, multiyear, or fresh")

    if isinstance(microstructure_model, str):
        microstructure_model = get_microstructure_model(microstructure_model)

    lay = Layer(float(layer_thickness),
                microstructure_model,
                frac_volume=float(frac_volume),
                temperature=float(temperature),
                permittivity_model=(eps_1, eps_2),
                inclusion_shape=inclusion_shape,
                salinity=float(salinity),
                **kwargs)

    if brine_volume_fraction is not None:
        lay.brine_volume_fraction = float(brine_volume_fraction)
        lay.brine_inclusion_shape = brine_inclusion_shape
    lay.density = float(density)  # just for information
    lay.porosity = float(porosity)  # just for information
    lay.inclusion_shape = inclusion_shape  # shape of inclusions (air or brine depending on ice_type)
    lay.ice_type = ice_type  # just for information

    return lay