Skip to content

CordexSource

TODO: NEEDS UPDATING!!!

Classes:

  • CordexSource

    Open a netCDF4 source which is at the EURO - CORDEX EUR - 11 domain

CordexSource

CordexSource(s, path, bounds=None, domain='EUR11')

Bases: NCSource

Open a netCDF4 source which is at the EURO - CORDEX EUR - 11 domain

Standard variables are: clt - cloud cover[] dpas - 2m dew point temperature[K] hurs - 2m relative humidity[] huss - 2m specific humidity[kg kg - 1] pr - total(convective + large scale) precipitation[kg m - 2 s - 1] prsn - snowfall flux[kg m - 2 s - 1] ps - surface pressure[Pa] rlen - roughness length[m] rsds - surface downwelling shortwave radiation[W m - 2] rsdt - top of atmosphere incident shortwave radiation[W m - 2] tas - 2m temperature[K] uas - 10m u - velocity[m s - 1] vas - 10m v - velocity[m s - 1] glat - geographical latitude[deg N] glon - geographical longitude[deg E] orog - surface orography[m] sftlf - lang area fraction[]

Methods:

Source code in reskit/weather/CordexSource.py
def __init__(s, path, bounds=None, domain="EUR11"):
    print("WARNING: CordexSource has not been updated in awhile and is almost guaranteed to fail...")

    if not bounds is None:
        if isinstance(bounds, gk.Extent):
            bounds.pad((s.MAX_LON_DIFFERENCE, s.MAX_LAT_DIFFERENCE))
        else:
            if isinstance(bounds, Bounds):
                lonMin = bounds.lonMin
                latMin = bounds.latMin
                lonMax = bounds.lonMax
                latMax = bounds.latMax
            else:
                print("Consider using a Bounds object or a gk.Extent object. They are safer!")
                lonMin, latMin, lonMax, latMax = bounds

            bounds = Bounds(
                lonMin=lonMin - s.MAX_LON_DIFFERENCE,
                latMin=latMin - s.MAX_LAT_DIFFERENCE,
                lonMax=lonMax + s.MAX_LON_DIFFERENCE,
                latMax=latMax + s.MAX_LAT_DIFFERENCE,
            )

    NCSource.__init__(
        s,
        path=path,
        bounds=bounds,
        timeName="time",
        latName="lat",
        lonName="lon",
        dependent_coordinates=True,
    )

    # set maximal differences
    if domain == "EUR11":
        s._maximal_lon_difference = 0.0625
        s._maximal_lat_difference = 0.0625
    else:
        raise ResError("Domain not understood")

loadTemperature

loadTemperature(
    s, which="air", processor=lambda x: x - 273.15
)

Temperature variable loader

Source code in reskit/weather/CordexSource.py
def loadTemperature(s, which="air", processor=lambda x: x - 273.15):
    """Temperature variable loader"""
    if which.lower() == "air":
        varName = "tas"
    elif which.lower() == "dew":
        varName = "dpas"
    else:
        raise ResMerraError("sub group '%s' not understood" % which)

    # load
    s.load(varName, name=which + "_temp", processor=processor)