Skip to content

classes

This file contains the shadow lookup and temperature lookup classes that are used by the roughness thermal model.

RoughnessThermalModel

Initialize a roughness thermophysical model object.

Source code in roughness/classes.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
class RoughnessThermalModel:
    """Initialize a roughness thermophysical model object."""

    def __init__(self, shadow_lookup=FLOOKUP, temperature_lookup=TLOOKUP):
        if shadow_lookup == FLOOKUP and not Path(shadow_lookup).exists():
            raise FileNotFoundError(
                "Default shadow lookup table not found. Please run \
                `roughness -d` in the terminal to download it."
            )
        self.shadow_lookup = shadow_lookup
        self.temperature_lookup = temperature_lookup
        self.temperature_ds = xr.open_dataset(temperature_lookup)
        if not {"theta", "az"}.issubset(self.temperature_ds.dims):
            raise ValueError(
                f"Temperature lookup {self.temperature_lookup} \
                               must have dimensions az, theta"
            )

    def __repr__(self):
        return (f"RoughnessThermalModel(shadow_lookup='{self.shadow_lookup}'" +
                f", temperature_lookup='{self.temperature_lookup}')")

    def emission(
        self, sun_theta, sun_az, sc_theta, sc_az, wls, rms, tparams, **kwargs
    ):
        """
        Return rough surface emission at the given viewing geometry.

        Parameters:
            sun_theta,sun_az,sc_theta,sc_az (num): Viewing angles [degrees]
                (incidence, solar_azimuth, emergence, emergence_azimuth)
            wls (arr): Wavelengths [microns]
            rms (arr, optional): RMS roughness [degrees]. Default is 15.
            rerad (bool, optional): If True, include re-radiation from adjacent
                facets. Default is True.
            tparams (dict, optional): Dictionary of temp erature lookup parameters.
                Default is None.
            **kwargs

        Returns:
            (xr.DataArray): Rough emission spectrum.

        """
        if tparams.keys() != self.required_tparams:
            raise ValueError(f"Tparams must contain {self.required_tparams}")
        args = ((sun_theta, sun_az, sc_theta, sc_az), wls, rms, tparams)
        return re.rough_emission_lookup(*args, **kwargs)

    @cached_property
    def required_tparams(self):
        """Check which tparams are required by the TemperatureLookup."""
        return set(self.temperature_ds.dims) - {"theta", "az"}

required_tparams cached property

Check which tparams are required by the TemperatureLookup.

emission(sun_theta, sun_az, sc_theta, sc_az, wls, rms, tparams, **kwargs)

Return rough surface emission at the given viewing geometry.

Parameters:

Name Type Description Default
sun_theta,sun_az,sc_theta,sc_az num

Viewing angles [degrees] (incidence, solar_azimuth, emergence, emergence_azimuth)

required
wls arr

Wavelengths [microns]

required
rms arr

RMS roughness [degrees]. Default is 15.

required
rerad bool

If True, include re-radiation from adjacent facets. Default is True.

required
tparams dict

Dictionary of temp erature lookup parameters. Default is None.

required

Returns:

Type Description
DataArray

Rough emission spectrum.

Source code in roughness/classes.py
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
def emission(
    self, sun_theta, sun_az, sc_theta, sc_az, wls, rms, tparams, **kwargs
):
    """
    Return rough surface emission at the given viewing geometry.

    Parameters:
        sun_theta,sun_az,sc_theta,sc_az (num): Viewing angles [degrees]
            (incidence, solar_azimuth, emergence, emergence_azimuth)
        wls (arr): Wavelengths [microns]
        rms (arr, optional): RMS roughness [degrees]. Default is 15.
        rerad (bool, optional): If True, include re-radiation from adjacent
            facets. Default is True.
        tparams (dict, optional): Dictionary of temp erature lookup parameters.
            Default is None.
        **kwargs

    Returns:
        (xr.DataArray): Rough emission spectrum.

    """
    if tparams.keys() != self.required_tparams:
        raise ValueError(f"Tparams must contain {self.required_tparams}")
    args = ((sun_theta, sun_az, sc_theta, sc_az), wls, rms, tparams)
    return re.rough_emission_lookup(*args, **kwargs)