reVX.turbine_flicker.turbine_flicker.TurbineFlicker

class TurbineFlicker(excl_fpath, res_fpath, features, regulations, building_threshold=0, resolution=640, grid_cell_size=90, max_flicker_exclusion_range='10x', tm_dset='techmap_wtk', hsds=False)[source]

Bases: AbstractBaseExclusionsMerger

Class to compute turbine shadow flicker and exclude sites that will cause excessive flicker on building

Parameters:
  • excl_fpath (str) – Filepath to exclusions h5 file. File must contain “building_layer” and “tm_dset”.

  • res_fpath (str) – Filepath to wind resource .h5 file containing hourly wind direction data

  • features (str) – This input should either be the name of an exclusion layer in excl_fpath or a file path to a GeoTIFF file containing buildings data from which turbine flicker exclusions should be computed.

  • regulations (FlickerRegulations) – A FlickerRegulations object used to shadow flicker regulation values.

  • building_threshold (float, optional) – Threshold for exclusion layer values to identify pixels with buildings, values are % of pixel containing a building. Threshold is NOT inclusive. By default, 0.

  • resolution (int, optional) – SC resolution, must be input in combination with gid, by default 640

  • grid_cell_size (float, optional) – Length (m) of a side of each grid cell in excl_fpath.

  • max_flicker_exclusion_range (float | int | str, optional) – Max distance (m) that flicker exclusions will extend in any of the cardinal directions. Can also be a string like "10x" (default), which is interpreted as 10 times the turbine rotor diameter. Note that increasing this value can lead to drastically instead memory requirements. This value may be increased slightly during execution (no more then the size of one grid cell) in order to yield odd exclusion array shapes.

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

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS. By default False.

Methods

compute_all_local_exclusions([max_workers])

Compute local exclusions for all counties either.

compute_exclusions([out_layer, out_tiff, ...])

Compute exclusions for all states either in serial or parallel.

compute_generic_exclusions([max_workers])

Compute generic flicker exclusions.

compute_local_exclusions(regulation_value, ...)

Compute local flicker exclusions.

parse_features()

Get the building layer used to compute flicker exclusions.

pre_process_regulations()

Reduce regulations to correct state and features.

run(excl_fpath, features_path, out_fn, ...)

Compute exclusions and write them to a geotiff.

Attributes

DEFAULT_FEATURE_OUTFILE

STEPS_PER_HOUR

description

Description to be added to excl H5.

exclusion_merge_func

Function to merge overlapping exclusion layers.

no_exclusions_array

Array representing no exclusions.

profile

Geotiff profile.

regulations_table

Regulations table.

property description

Description to be added to excl H5.

Type:

str

property no_exclusions_array

Array representing no exclusions.

Type:

np.array

property exclusion_merge_func

Function to merge overlapping exclusion layers.

Type:

callable

pre_process_regulations()[source]

Reduce regulations to correct state and features.

parse_features()[source]

Get the building layer used to compute flicker exclusions.

static compute_local_exclusions(regulation_value, county, *args)[source]

Compute local flicker exclusions.

This method computes a flicker exclusion layer using the information about the input county.

Parameters:
  • regulation_value (float | int) – Maximum number of allowable flicker hours in county.

  • county (geopandas.GeoDataFrame) – Regulations for a single county.

  • tf (TurbineFlicker) – Instance of TurbineFlicker objects used to compute the flicker exclusions.

Returns:

  • flicker (ndarray) – Raster array of flicker exclusions

  • slices (2-tuple of slice) – X and Y slice objects defining where in the original array the exclusion data should go.

compute_generic_exclusions(max_workers=None)[source]

Compute generic flicker exclusions.

This method will compute a generic flicker exclusion layer.

Parameters:

max_workers (int, optional) – Number of workers to use for exclusions computation, if 1 run in serial, if > 1 run in parallel with that many workers, if None run in parallel on all available cores. By default None.

Returns:

flicker (ndarray) – Raster array of flicker exclusions

compute_all_local_exclusions(max_workers=None)

Compute local exclusions for all counties either.

Parameters:

max_workers (int, optional) – Number of workers to use for exclusions computation, if 1 run in serial, if > 1 run in parallel with that many workers, if None run in parallel on all available cores. By default None.

Returns:

exclusions (ndarray) – Raster array of exclusions.

compute_exclusions(out_layer=None, out_tiff=None, replace=False, max_workers=None)

Compute exclusions for all states either in serial or parallel. Existing exclusions are computed if a regulations file was supplied during class initialization, otherwise generic exclusions are computed.

Parameters:
  • out_layer (str, optional) – Name to save rasterized exclusions under in .h5 file. If None, exclusions will not be written to the .h5 file. By default None.

  • out_tiff (str, optional) – Path to save geotiff containing rasterized exclusions. If None, exclusions will not be written to a geotiff file. By default None.

  • replace (bool, optional) – Flag to replace geotiff if it already exists. By default False.

  • max_workers (int, optional) – Number of workers to use for exclusion computation, if 1 run in serial, if > 1 run in parallel with that many workers, if None, run in parallel on all available cores. By default None.

Returns:

exclusions (ndarray) – Raster array of exclusions

property profile

Geotiff profile.

Type:

dict

property regulations_table

Regulations table.

Returns:

geopandas.GeoDataFrame | None

classmethod run(excl_fpath, features_path, out_fn, regulations, max_workers=None, replace=False, out_layers=None, hsds=False, **kwargs)

Compute exclusions and write them to a geotiff. If a regulations file is given, compute local exclusions, otherwise compute generic exclusions. If both are provided, generic and local exclusions are merged such that the local exclusions override the generic ones.

Parameters:
  • excl_fpath (str) – Path to .h5 file containing exclusion layers, will also be the location of any new exclusion layers.

  • features_path (str) – Path to file or directory feature shape files. This path can contain any pattern that can be used in the glob function. For example, /path/to/features/[A]* would match with all the features in the directory /path/to/features/ that start with “A”. This input can also be a directory, but that directory must ONLY contain feature files. If your feature files are mixed with other files or directories, use something like /path/to/features/*.geojson.

  • out_fn (str) – Path to output geotiff where exclusion data should be stored.

  • regulations (~reVX.utilities.AbstractBaseRegulations subclass) – A regulations object used to extract exclusion regulation distances.

  • max_workers (int, optional) – Number of workers to use for exclusion computation, if 1 run in serial, if > 1 run in parallel with that many workers, if None, run in parallel on all available cores. By default None.

  • replace (bool, optional) – Flag to replace geotiff if it already exists. By default False.

  • out_layers (dict, optional) – Dictionary mapping feature file names (with extension) to names of layers under which exclusions should be saved in the excl_fpath .h5 file. If None or empty dictionary, no layers are saved to the h5 file. By default None.

  • hsds (bool, optional) – Boolean flag to use h5pyd to handle .h5 ‘files’ hosted on AWS behind HSDS. By default False.

  • **kwargs – Keyword args to exclusions calculator class.