reskit.weather.IconlamSource#

Submodules#

Classes#

IconlamSource

SChen: The IconlamSource from the output of ICON-LAM model minics the ERA5soure.

Package Contents#

class reskit.weather.IconlamSource.IconlamSource(source, bounds=None, index_pad=5, **kwargs)#

Bases: reskit.weather.NCSource

SChen: The IconlamSource from the output of ICON-LAM model minics the ERA5soure.

Note:#

Various constants can have been set for this weather source which can impact later simulation workflows.

These constants include:
MAX_LON_DIFFERENCE = 0.034 # SChen this is for 0.033 ICON-LAM grid
The maximum longitude difference to accept between a grid cell’s center and the coordinates

to extract data for

MAX_LAT_DIFFERENCE = 0.034 # SChen this is for 0.033 ICON-LAM grid
The maximum latitude difference to accept between a grid cell’s center and the coordinates

to extract data for

WIND_SPEED_HEIGHT_FOR_WIND_ENERGY = 100

The suggested altitude of wind speed data to use for wind-energy simulations

WIND_SPEED_HEIGHT_FOR_SOLAR_ENERGY = 10

The suggested altitude of wind speed data to use for wind-energy simulations

LONG_RUN_AVERAGE_WINDSPEED :

<RESKit path>/weather/Era5Source/data/ERA5_wind_speed_100m_mean.tiff

A path to a raster file with the long-time average wind speed in each grid cell * Can be used in wind energy simulations * Calculated at the height specified in WIND_SPEED_HEIGHT_FOR_WIND_ENERGY * Time range includes 1980 until the end of 2019 (the time of first calculation) * The averaging is performed globally

LONG_RUN_AVERAGE_WINDDIR :

<RESKit path>/weather/Era5Source/data/ERA5_wind_direction_100m_mean.tiff

A path to a raster file with the long-time average wind direction in each grid cell * Can be used in wind energy simulations * Calculated at the height specified in WIND_SPEED_HEIGHT_FOR_WIND_ENERGY * Time range includes 1980 until the end of 2019 (the time of first calculation) * The averaging is performed globally

LONG_RUN_AVERAGE_GHI :

<RESKit path>/weather/Era5Source/data/ERA5_surface_solar_radiation_downwards_mean.tiff

A path to a raster file with the long-time average global horizontal irradiance in

each grid cell

  • Can be used in solar energy simulations

  • Calculated at the surface

  • Time range includes 1980 until the end of 2019 (the time of first calculation)

  • The averaging is performed globally

LONG_RUN_AVERAGE_DNI :

<RESKit path>/weather/Era5Source/data/ERA5_total_sky_direct_solar_radiation_at_surface_mean.tiff

A path to a raster file with the long-time average direct horizontal irradiance in

each grid cell

  • Can be used in solar energy simulations

  • Calculated at the surface and on a horizontal plane (not DNI!)

  • Time range includes 1980 until the end of 2019 (the time of first calculation)

  • The averaging is performed globally

param path:

The path to the main data file(s) to load

If multiple files are given, or if a directory of netCDF4 files is given, then it is assumed that all files ending with the extension ‘.nc’ or ‘.nc4’ should be managed by this object. * Be sure that all the netCDF4 files given share the same time and spatial dimensions!

type path:

str or list of str

param bounds:
The boundaries of the data which is needed
  • Usage of this will help with memory management

  • If None, the full dataset is loaded in memory

  • The actual extent of the loaded data depends on the source’s available data

type bounds:

Anything acceptable to geokit.Extent.load(), optional

param index_pad:
The padding to apply to the boundaries
  • Useful in case of interpolation

  • Units are in longitudinal degrees

type index_pad:

int, optional

param verbose:

If True, then status outputs are printed when searching for and reading weather data

type verbose:

bool, optional

param forward_fill:

If True, then missing data in the weather file is forward-filled * Generally, there should be no missing data at all. This option is only intended to

catch the rare scenarios where one or two timesteps are missing

type forward_fill:

bool, optional

See also

MerraSource, SarahSource, Era5Source

ELEVATED_WIND_SPEED_HEIGHT = 100#
SURFACE_WIND_SPEED_HEIGHT = 10#
MAX_LON_DIFFERENCE = 0.034#
MAX_LAT_DIFFERENCE = 0.034#
loc_to_index#

Returns the closest X and Y indexes corresponding to a given location or set of locations

Parameters:
  • loc (Anything acceptable by geokit.LocationSet) –

    The location(s) to search for * A single tuple with (lon, lat) is acceptable, or a list of such tuples * A single point geometry (as long as it has an SRS), or a list

    of geometries is okay

    • geokit,Location, or geokit.LocationSet are best!

  • outside_okay (bool, optional) – Determines if points which are outside the source’s lat/lon grid are allowed * If True, points outside this space will return as None * If False, an error is raised

Returns:

  • If a single location is given (tuple) –

    • Format: (yIndex, xIndex)

    • y index can be accessed with ‘.yi’

    • x index can be accessed with ‘.xi’

  • If multiple locations are given (list) –

    • Format: [ (yIndex1, xIndex1), (yIndex2, xIndex2), …]

    • Order matches the given order of locations

Note:#

The default form of this function (which is the one used here) is not very efficient, ultimately

leading to much longer look-up than they otherwise need to be. When the weather source has grid cells on a regular lat/lon grid then a more efficient form of this function can be configured using the function generator “_loc_to_index_rect”. In these instances, this is the recommended function to use.

For example, if the weather source uses a latitude spacing of 0.5, and a longitude spacing of

0.625, then the function generator can be used like:

> source.loc_to_index = source._loc_to_index_rect(lat_step=0.5, lon_step=0.625)

sload_boundary_layer_height()#

Standard loader function for the variable ‘boundary_layer_height’ in meters from the surface

sload_elevated_wind_speed()#

Standard loader function for the variable ‘elevated_wind_speed’

Automatically reads the variables “ws<X>” from the given ERA5 source and saves it as the variable ‘elevated_wind_speed’ in the data library

Where ‘<X>’ is the height specified by Era5Source.ELEVATED_WIND_SPEED_HEIGHT

The “ws<X>” variable also needs to be precomputed from the raw variables “u<X>”

and “v<X>”

TODO: Update function to also be able to handle raw ERA5 inputs for u & v

sload_surface_wind_speed()#

Standard loader function for the variable ‘surface_wind_speed’

Automatically reads the variables “ws<X>” from the given ERA5 source and saves it as the variable ‘surface_wind_speed’ in the data library

Where ‘<X>’ is the height specified by Era5Source.SURFACE_WIND_SPEED_HEIGHT

The “ws<X>” variable also needs to be precomputed from the raw variables “u<X>”

and “v<X>”

TODO: Update function to also be able to handle raw ERA5 inputs for u & v

sload_wind_speed_at_100m()#

Standard loader function for the variable ‘wind_speed_at_100m’

Automatically reads the variables “ws100” from the given ERA5 source and saves it as the variable ‘wind_speed_at_100m’ in the data library

The “ws100” variable also needs to be precomputed from the raw variables “u100”

and “v100”

TODO: Update function to also be able to handle raw ERA5 inputs for u & v

sload_wind_speed_at_10m()#

Standard loader function for the variable ‘wind_speed_at_10m’

Automatically reads the variables “ws10” from the given ERA5 source and saves it as the variable ‘wind_speed_at_10m’ in the data library

The “ws10” variable also needs to be precomputed from the raw variables “u10”

and “v10”

TODO: Update function to also be able to handle raw ERA5 inputs for u & v

sload_elevated_wind_direction()#

Standard loader function for the variable ‘elevated_wind_direction’

Automatically reads the variables “wd<X>” from the given ERA5 source and saves it as the variable ‘elevated_wind_direction’ in the data library

Where ‘<X>’ is the height specified by Era5Source.ELEVATED_WIND_SPEED_HEIGHT

The “wd<X>” variable also needs to be precomputed from the raw variables “u<X>”

and “v<X>” and made available in the raw dataset

TODO: Update function to also be able to handle raw ERA5 inputs for u & v

sload_surface_pressure()#

Standard loader function for the variable ‘surface_pressure’

Automatically reads the variable “sp” from the given ERA5 source and saves it as the variable ‘surface_pressure’ in the data library

sload_surface_air_temperature()#

Standard loader function for the variable ‘surface_air_temperature’

Automatically reads the variable “t2m” from the given ERA5 source and saves it as the variable ‘surface_air_temperature’ in the data library

Temperature values are also converted from kelvin to degrees celsius

sload_surface_dew_temperature()#

Standard loader function for the variable ‘surface_dew_temperature’

Automatically reads the variable “d2m” from the given ERA5 source and saves it as the variable ‘surface_dew_temperature’ in the data library

Temperature values are also converted from kelvin to degrees celsius

sload_direct_horizontal_irradiance()#

Standard loader function for the variable ‘direct_horizontal_irradiance’

Automatically reads the variable “fdir” from the given ERA5 source and saves it as the variable ‘direct_horizontal_irradiance’ in the data library

sload_global_horizontal_irradiance()#

Standard loader function for the variable ‘global_horizontal_irradiance’

Automatically reads the variable “ssrd” from the given ERA5 source and saves it as the variable ‘global_horizontal_irradiance’ in the data library