reV.nrwal.nrwal.RevNrwal

class RevNrwal(gen_fpath, site_data, sam_files, nrwal_configs, output_request, save_raw=True, meta_gid_col='gid', site_meta_cols=None)[source]

Bases: object

Framework to handle reV-NRWAL analysis.

reV NRWAL analysis runs reV data through the NRWAL compute library. Everything in this module operates on the spatiotemporal resolution of the reV generation output file (usually the wind or solar resource resolution but could also be the supply curve resolution after representative profiles is run).

Parameters:
  • gen_fpath (str) – Full filepath to HDF5 file with reV generation or rep_profiles output. Anything in the output_request input is added to and/or manipulated within this file.

    Note

    If executing reV from the command line, this input can also be "PIPELINE" to parse the output of one of the previous step and use it as input to this call. However, note that duplicate executions of reV commands prior to this one within the pipeline may invalidate this parsing, meaning the gen_fpath input will have to be specified manually.

  • site_data (str | pd.DataFrame) – Site-specific input data for NRWAL calculation.If this input is a string, it should be a path that points to a CSV file. Otherwise, this input should be a DataFrame with pre-extracted site data. Rows in this table should match the meta_gid_col in the gen_fpath meta data input sites via a gid column. A config column must also be provided that corresponds to the nrwal_configs input. Only sites with a gid in this file’s gid column will be run through NRWAL.

  • sam_files (dict | str) – A dictionary mapping SAM input configuration ID(s) to SAM configuration(s). Keys are the SAM config ID(s) which correspond to the keys in the nrwal_configs input. Values for each key are either a path to a corresponding SAM config file or a full dictionary of SAM config inputs. For example:

    sam_files = {
        "default": "/path/to/default/sam.json",
        "onshore": "/path/to/onshore/sam_config.yaml",
        "offshore": {
            "sam_key_1": "sam_value_1",
            "sam_key_2": "sam_value_2",
            ...
        },
        ...
    }
    

    This input can also be a string pointing to a single SAM config file. In this case, the config column of the CSV points input should be set to None or left out completely. See the documentation for the reV SAM class (e.g. reV.SAM.generation.WindPower, reV.SAM.generation.PvWattsv8, reV.SAM.generation.Geothermal, etc.) for documentation on the allowed and/or required SAM config file inputs.

  • nrwal_configs (dict) – A dictionary mapping SAM input configuration ID(s) to NRWAL configuration(s). Keys are the SAM config ID(s) which correspond to the keys in the sam_files input. Values for each key are either a path to a corresponding NRWAL YAML or JSON config file or a full dictionary of NRWAL config inputs. For example:

    nrwal_configs = {
        "default": "/path/to/default/nrwal.json",
        "onshore": "/path/to/onshore/nrwal_config.yaml",
        "offshore": {
            "nrwal_key_1": "nrwal_value_1",
            "nrwal_key_2": "nrwal_value_2",
            ...
        },
        ...
    }
    
  • output_request (list | tuple) – List of output dataset names to be written to the gen_fpath file. Any key from the NRWAL configs or any of the inputs (site_data or sam_files) is available to be exported as an output dataset. If you want to manipulate a dset like cf_mean from gen_fpath and include it in the output_request, you should set save_raw=True and then use cf_mean_raw in the NRWAL equations as the input. This allows you to define an equation in the NRWAL configs for a manipulated cf_mean output that can be included in the output_request list.

  • save_raw (bool, optional) – Flag to save an initial (“raw”) copy of input datasets from gen_fpath that are also part of the output_request. For example, if you request cf_mean in output_request but also manipulate the cf_mean dataset in the NRWAL equations, the original cf_mean will be archived under the cf_mean_raw dataset in gen_fpath. By default, True.

  • meta_gid_col (str, optional) – Column label in the source meta data from gen_fpath that contains the unique gid identifier. This will be joined to the site_data gid column. By default, "gid".

  • site_meta_cols (list | tuple, optional) – Column labels from site_data to be added to the meta data table in gen_fpath. If None, only the columns in DEFAULT_META_COLS will be added. Any columns requested via this input will be considered in addition to the DEFAULT_META_COLS. By default, None.

Methods

check_outputs()

Check the nrwal outputs for nan values and raise errors if found.

run([csv_output, out_fpath])

Run NRWAL analysis.

run_nrwal()

Run analysis via the NRWAL analysis library

save_raw_dsets()

If requested by save_raw=True, archive raw datasets that exist in the gen_fpath file and are also requested in the output_request

write_meta_to_csv([out_fpath])

Combine NRWAL outputs with meta and write to output csv.

write_to_gen_fpath()

Save NRWAL outputs to input generation fpath file.

Attributes

DEFAULT_META_COLS

Columns from the site_data table to join to the output meta data

analysis_gids

Get an array of gids from the source generation meta data that are to-be analyzed by nrwal.

analysis_mask

Get a boolean array to mask the source generation meta data where True is sites that are to be analyzed by NRWAL.

gen_dsets

Get the available datasets from the gen source file

meta_out

Get the combined onshore and offshore meta data.

meta_source

Get the full meta data (onshore + offshore)

outputs

Get a dict of NRWAL outputs.

time_index

Get the source time index.

DEFAULT_META_COLS = ('config',)

Columns from the site_data table to join to the output meta data

property time_index

Get the source time index.

property gen_dsets

Get the available datasets from the gen source file

property meta_source

Get the full meta data (onshore + offshore)

property meta_out

Get the combined onshore and offshore meta data.

property analysis_mask

Get a boolean array to mask the source generation meta data where True is sites that are to be analyzed by NRWAL.

Returns:

np.ndarray

property analysis_gids

Get an array of gids from the source generation meta data that are to-be analyzed by nrwal.

Returns:

np.ndarray

property outputs

Get a dict of NRWAL outputs. Only active analysis sites will have data in the output, sites that were not found in the site_data “gid” column will not have data in these output arrays

run_nrwal()[source]

Run analysis via the NRWAL analysis library

check_outputs()[source]

Check the nrwal outputs for nan values and raise errors if found.

save_raw_dsets()[source]

If requested by save_raw=True, archive raw datasets that exist in the gen_fpath file and are also requested in the output_request

write_to_gen_fpath()[source]

Save NRWAL outputs to input generation fpath file.

Returns:

str – Path to output file.

write_meta_to_csv(out_fpath=None)[source]

Combine NRWAL outputs with meta and write to output csv.

Parameters:

out_fpath (str, optional) – Full path to output NRWAL CSV file. The file path does not need to include file ending - it will be added automatically if missing. If None, the generation HDF5 filepath will be converted to a CSV out path by replacing the “.h5” file ending with “.csv”. By default, None.

Returns:

str – Path to output file.

run(csv_output=False, out_fpath=None)[source]

Run NRWAL analysis.

Parameters:
  • csv_output (bool, optional) – Option to write H5 file meta + all requested outputs to CSV file instead of storing in the HDF5 file directly. This can be useful if the same HDF5 file is used for multiple sets of NRWAL runs. Note that all requested output datasets must be 1-dimensional in order to fir within the CSV output.

    Important

    This option is not compatible with save_raw=True. If you set csv_output=True, then the save_raw option is forced to be False. Therefore, make sure that you do not have any references to “input_dataset_name_raw” in your NRWAL config. If you need to manipulate an input dataset, save it to a different output name in the NRWAL config or manually add an “input_dataset_name_raw” dataset to your generation HDF5 file before running NRWAL.

    By default, False.

  • out_fpath (str, optional) – This option has no effect if csv_output=False. Otherwise, this should be the full path to output NRWAL CSV file. The file path does not need to include file ending - it will be added automatically if missing. If None, the generation HDF5 filepath will be converted to a CSV out path by replacing the “.h5” file ending with “.csv”. By default, None.

Returns:

str – Path to output file.