7. Utils#

class Utils#

Bases: object

Provides utility methods used throughout Scarabaeus.

Methods

check_slices_equal(arr)

Checks if all slices are equal across an array.

equal_along_rows(arr)

Check equality along rows of the given array.

find_date_indices_in_epochs(epochsTDB, ...)

Find the index or indices of target date(s) in a numpy array of epochs, accounting for floating-point precision.

make_dir(dir)

Generate a folder in the given directory.

max_of_last_slice(arr)

Finds the maximum value of the last slice of an array.

open_pickle(dir)

Return a pickle object handle from dir.

tile_array(arr, desired_shape)

Construct an array by repeating A the number of times given by reps.

static check_slices_equal(arr: ndarray)#

Checks if all slices are equal across an array.

Parameters:

arr (numpy.ndarray) – The array to examine.

Returns:

are_equal – Indicates if all slices are equal or not.

Return type:

bool

static equal_along_rows(arr: ndarray) bool#

Check equality along rows of the given array.

Parameters:

arr (numpy.ndarray) – The array to examine.

Returns:

are_equal – Returns True if all values are equal along rows. Returns False if they are not.

Return type:

bool

static find_date_indices_in_epochs(epochsTDB, target_dates, rtol=1e-06)#

Find the index or indices of target date(s) in a numpy array of epochs, accounting for floating-point precision.

Parameters:
  • epochsTDB (???) – An array or object containing time values.

  • target_dates (???) – Target date or dates.

  • rtol (float, optional) – Relative tolerance for comparing the dates. Defaults to 1e-6.

Returns:

ind – The index or indices of the target date(s), or None if not found.

Return type:

int or list of ints

static make_dir(dir: str) None#

Generate a folder in the given directory.

Parameters:

dir (str) – The directory path to a generate a folder in.

Return type:

None

static max_of_last_slice(arr: ndarray)#

Finds the maximum value of the last slice of an array.

Parameters:

arr (numpy.ndarray) – The array to examine.

Returns:

max_vals – The max value of the last slice.

Return type:

Any

static open_pickle(dir: str)#

Return a pickle object handle from dir.

Parameters:

dir (str) – Directory + name of the pickle object.

Returns:

pickle_handle – NEED DESC

Return type:

???

static tile_array(arr, desired_shape)#

Construct an array by repeating A the number of times given by reps.

Parameters:
  • arr (numpy.ndarray) – The array to examine.

  • desired_shape (???) – DESC

Returns:

tiled – The new tiled array.

Return type:

numpy.ndarray