sup3r.utilities.utilities

Miscellaneous utilities for computing features, preparing training data, timing functions, etc

Functions

bvf_squared(T_top, T_bottom, P_top, ...)

Squared Brunt Vaisala Frequency

correct_path(path)

If running on windows we need to replace backslashes with double backslashes so paths can be parsed correctly with safe_open_json

daily_temporal_coarsening(data[, temporal_axis])

Temporal coarsening for daily average climate change data.

daily_time_sampler(data, shape, time_index)

Finds a random temporal slice from data starting at midnight

estimate_max_workers(max_workers, ...)

Estimate max number of workers based on available memory

expand_paths(fps)

Expand path(s)

forward_average(array_in)

Average neighboring values in an array.

generate_random_string(length)

Generate random string with given length.

get_chunk_slices(arr_size, chunk_size[, ...])

Get array slices of corresponding chunk size

get_input_handler_class(file_paths, ...)

Get the DataHandler class.

get_raster_shape(raster_index)

Method to get shape of raster_index

get_source_type(file_paths)

Get data source type

get_time_dim_name(filepath)

Get the name of the time dimension in the given file.

get_wrf_date_range(files)

Get wrf date range for cleaner log output.

gradient_richardson_number(T_top, T_bottom, ...)

Formula for the gradient richardson number - related to the bouyant production or consumption of turbulence divided by the shear production of turbulence.

ignore_case_path_fetch(fp)

Get file path which matches fp while ignoring case

inverse_mo_length(U_star, flux_surf)

Inverse Monin - Obukhov Length

invert_pot_temp(PT, P)

Potential temperature of fluid at pressure P and temperature T

invert_uv(u, v, lat_lon)

Transform u and v back to windspeed and winddirection

lat_lon_coarsening(lat_lon[, s_enhance])

Coarsen lat_lon according to s_enhance resolution

nn_fill_array(array)

Fill any NaN values in an np.ndarray from the nearest non-nan values.

np_to_pd_times(times)

Convert np.bytes_ times to DatetimeIndex

nsrdb_reduce_daily_data(data, shape[, csr_ind])

Takes a 5D array and reduces the axis=3 temporal dim to daylight hours.

nsrdb_sub_daily_sampler(data, shape, time_index)

Finds a random sample during daylight hours of a day.

pd_date_range(*args, **kwargs)

A simple wrapper on the pd.date_range() method that handles the closed vs.

potential_temperature(T, P)

Potential temperature of fluid at pressure P and temperature T

potential_temperature_average(T_top, P_top, ...)

Potential temp average calculation

potential_temperature_difference(T_top, ...)

Potential temp difference calculation

rotor_area(h_bottom, h_top[, radius])

Area of circular section between two heights

rotor_equiv_ws(data, heights)

Calculate rotor equivalent wind speed.

round_array(arr[, digits])

Method to round elements in an array or list.

smooth_data(low_res, training_features, ...)

Smooth data using a gaussian filter

spatial_coarsening(data[, s_enhance, obs_axis])

Coarsen data according to s_enhance resolution

spatial_simple_enhancing(data[, s_enhance, ...])

Simple enhancing according to s_enhance resolution

st_interp(low, s_enhance, t_enhance[, ...])

Spatiotemporal bilinear interpolation for low resolution field on a regular grid.

temporal_coarsening(data[, t_enhance, method])

Coarsen data according to t_enhance resolution

temporal_simple_enhancing(data[, t_enhance, ...])

Upsample data according to t_enhance resolution

transform_rotate_wind(ws, wd, lat_lon)

Transform windspeed/direction to u and v and align u and v with grid

uniform_box_sampler(data, shape)

Extracts a sample cut from data.

uniform_time_sampler(data, shape)

Extracts a temporal slice from data.

vorticity_calc(u, v[, scale])

Returns the vorticity field.

weighted_box_sampler(data, shape, weights)

Extracts a temporal slice from data with selection weighted based on provided weights

weighted_time_sampler(data, shape, weights)

Extracts a temporal slice from data with selection weighted based on provided weights

windspeed_log_law(z, a, b, c)

Windspeed log profile.

Classes

Timer()

Timer class for timing and storing function call times.