reVX.offshore.offshore_inputs.OffshoreInputs

class OffshoreInputs(inputs_fpath, offshore_sites, tm_dset='techmap_wtk')[source]

Bases: ExclusionLayers

Class to extract offshore inputs from offshore inputs .h5 at desired offshore site gids. Mapping is based on the techmapping dataset (tm_dset). Offshore input values are taken from the array pixel closest to the center of mass of each offshore site gid.

Parameters:
  • inputs_fpath (str) – Path to offshore inputs .h5 file

  • offshore_sites (str | list | tuple | ndarray |pandas.DataFrame) –

    • Path to .csv|.json file with offshore sites meta data

    • Path to a WIND Toolkit .h5 file to extact site meta from

    • List, tuple, or vector of offshore gids

    • Pre-extracted site meta DataFrame

  • tm_dset (str, optional) – Dataset / layer name for wind toolkit techmap, by default ‘techmap_wtk’

Methods

close()

Close h5 instance

compute_assembly_dist(layer)

Extract the distance from ports to assembly area and then compute the distance from nearest assembly area to sites

extract(inputs_fpath, offshore_sites[, ...])

Extract data from desired input layers for desired offshore sites

extract_array_efficiency(layer)

Extract array efficiency

extract_input_layer(layer)

Extract input data for desired layer

get_layer_crs(layer)

Get crs for a specific exclusion layer

get_layer_description(layer)

Get description for given layer

get_layer_profile(layer)

Get profile for a specific exclusion layer

get_layer_values(layer)

Get values for given layer in Geotiff format (bands, y, x)

get_nodata_value(layer)

Get the nodata value for a given layer

get_offshore_inputs([input_layers, ...])

Extract data for the desired layers

Attributes

DEFAULT_INPUT_LAYERS

chunks

Exclusion layers chunks default chunk size

column_ids

Input layer array column ids that correspond to desired offshore sites

crs

GeoTiff projection crs

h5

Open h5py File instance.

iarr

Get an array of 1D index values for the flattened h5 excl extent.

inputs_fpath

.h5 file containing offshore input layers

lat_lons

Offshore sites coordinates (lat, lons)

latitude

Latitude coordinates array

layers

Available exclusions layers

longitude

Longitude coordinates array

meta

Offshore site meta data including mapping to input layer row and column index

pixel_area

Get pixel area in km2 from the transform profile of the excl file.

profile

GeoTiff profile for exclusions

row_ids

Input layer array row ids that correspond to desired offshore sites

shape

Exclusion shape (latitude, longitude)

property inputs_fpath

.h5 file containing offshore input layers

Returns:

str

property meta

Offshore site meta data including mapping to input layer row and column index

Returns:

pandas.DataFrame

property lat_lons

Offshore sites coordinates (lat, lons)

Returns:

ndarray

property row_ids

Input layer array row ids that correspond to desired offshore sites

Returns:

ndarray

property column_ids

Input layer array column ids that correspond to desired offshore sites

Returns:

ndarray

compute_assembly_dist(layer)[source]

Extract the distance from ports to assembly area and then compute the distance from nearest assembly area to sites

Parameters:

layer (str) – Name of assembly area table/dataset

Returns:

out (dict) – Dictionary containing the distance from ports to assembly areas (‘dist_p_to_a’) and distance from nearest assembly area to sites (‘dist_a_to_s’)

extract_array_efficiency(layer)[source]

Extract array efficiency

Parameters:

layer (str) – Name of array efficiency table/dataset

Returns:

aeff (ndarray) – Vector of array efficiency ‘aeff’ values for desired offshore sites

extract_input_layer(layer)[source]

Extract input data for desired layer

Parameters:

layer (str) – Desired input layer

Returns:

data (ndarray) – Input layer data for desired offshore sites

get_offshore_inputs(input_layers=None, downtime_tolerance=0.01)[source]

Extract data for the desired layers

Parameters:
  • input_layers (str | list | dict) – Input layer, list of input layers, to extract, or dictionary mapping the input layers to extract to the column names to save them under, by default None

  • downtime_tolerance (float) – Amount to shift weather downtime layer by so they are > 0 and/or < 1, by default 0.01

Returns:

out (pandas.DataFrame) – Updated meta data table with desired layers

classmethod extract(inputs_fpath, offshore_sites, tm_dset='techmap_wtk', input_layers=None, downtime_tolerance=0.01, out_fpath=None)[source]

Extract data from desired input layers for desired offshore sites

Parameters:
  • inputs_fpath (str) – Path to offshore inputs .h5 file

  • offshore_sites (str | list | tuple | ndarray |pandas.DataFrame) –

    • Path to .csv|.json file with offshore sites meta data

    • Path to a WIND Toolkit .h5 file to extact site meta from

    • List, tuple, or vector of offshore gids

    • Pre-extracted site meta DataFrame

  • tm_dset (str, optional) – Dataset / layer name for wind toolkit techmap, by default ‘techmap_wtk’

  • input_layers (str | list | dict) – Input layer, list of input layers, to extract, or dictionary mapping the input layers to extract to the column names to save them under, by default None

  • downtime_tolerance (float) – Amount to shift weather downtime layer by so they are > 0 and/or < 1, by default 0.01

  • out_fpath (str, optional) – Output .csv path to save offshore inputs too, by default None

Returns:

out (pandas.DataFrame) – Updated meta data table with desired layers

property chunks

Exclusion layers chunks default chunk size

Returns:

chunks (tuple | None) – Chunk size of exclusion layers

close()

Close h5 instance

property crs

GeoTiff projection crs

Returns:

str

get_layer_crs(layer)

Get crs for a specific exclusion layer

Parameters:

layer (str) – Layer to get profile for

Returns:

crs (str | None) – GeoTiff projection crs

get_layer_description(layer)

Get description for given layer

Parameters:

layer (str) – Layer to get description for

Returns:

description (str) – Description of layer

get_layer_profile(layer)

Get profile for a specific exclusion layer

Parameters:

layer (str) – Layer to get profile for

Returns:

profile (dict | None) – GeoTiff profile for single exclusion layer

get_layer_values(layer)

Get values for given layer in Geotiff format (bands, y, x)

Parameters:

layer (str) – Layer to get values for

Returns:

values (ndarray) – GeoTiff values for single exclusion layer

get_nodata_value(layer)

Get the nodata value for a given layer

Parameters:

layer (str) – Layer to get nodata value for

Returns:

nodata (int | float | None) – nodata value for layer or None if not found

property h5

Open h5py File instance.

Returns:

h5 (rex.MultiFileResource | rex.Resource)

property iarr

Get an array of 1D index values for the flattened h5 excl extent.

Returns:

iarr (np.ndarray) – Uint array with same shape as exclusion extent, representing the 1D index values if the geotiff extent was flattened (with default flatten order ‘C’)

property latitude

Latitude coordinates array

Returns:

ndarray

property layers

Available exclusions layers

Returns:

layers (list)

property longitude

Longitude coordinates array

Returns:

ndarray

property pixel_area

Get pixel area in km2 from the transform profile of the excl file.

Returns:

area (float) – Exclusion pixel area in km2. Will return None if the appropriate transform attribute is not found.

property profile

GeoTiff profile for exclusions

Returns:

profile (dict)

property shape

Exclusion shape (latitude, longitude)

Returns:

shape (tuple)