nsrdb.utilities.extract_nsrdb_data.ExtractNSRDB

class ExtractNSRDB(target, source)[source]

Bases: object

Utility class to manage NSRDB data extraction for subsets.

Parameters:
  • target (str) – Target file (with path) to dump extracted data to (.csv for simple meta data extractions or .h5 for nsrdb data extractions).

  • source (str) – Source NSRDB file (with path). Data is extracted from this file and written to the target file.

Methods

extract_closest_meta(coords)

Get NSRDB meta data for pixels closest to input coordinate set.

extract_dsets(dsets)

Extract entire datasets with meta from h5 to new h5.

extract_map(dset[, time_index, sort])

Extract a lat-lon-data csv for one timestep and all sites for mapping applications.

extract_sites([sites])

Extract data from h5 for given site indices and write to new h5.

filter_meta(values, label)

Return a meta df filtered where the label is equal to the value.

meta_to_disk()

Retrieve the NSRDB meta data and save to csv.

Attributes

IGNORE_LIST

meta

Get the NSRDB meta data as a DataFrame.

extract_map(dset, time_index=0, sort=False)[source]

Extract a lat-lon-data csv for one timestep and all sites for mapping applications.

Parameters:
  • dset (str) – Target dataset in source h5 file to extract data from.

  • time_index (int) – Time series index to extract. Data from all sites for this single time index will be extracted.

  • sort (bool) – Flag on whether to sort the data by lat/lon.

extract_dsets(dsets)[source]

Extract entire datasets with meta from h5 to new h5.

Parameters:

dsets (list | tuple) – Target datasets in source h5 file to extract data from.

extract_sites(sites=range(0, 100))[source]

Extract data from h5 for given site indices and write to new h5.

Parameters:

sites (range | list | slice) – Site indicies to extract.

extract_closest_meta(coords)[source]

Get NSRDB meta data for pixels closest to input coordinate set.

Parameters:

coords (np.ndarray) – N x 2 array of lat/lon pairs.

Returns:

subset_meta (pd.DataFrame) – A subset of the source meta data with the closest sites to the input coordinates. Has length N (length of coordinate array).

property meta

Get the NSRDB meta data as a DataFrame.

meta_to_disk()[source]

Retrieve the NSRDB meta data and save to csv.

filter_meta(values, label)[source]

Return a meta df filtered where the label is equal to the value.

Parameters:
  • values (str | int | float | list) – Search variable(s). Could be a country, state, population, etc…

  • label (str) – Meta data column label corresponding to the value.

Returns:

meta (pd.DataFrame) – Filtered meta data.