Utils#
- class Utils#
Bases:
objectCollection of general-purpose utility methods used throughout Scarabaeus.
Provides static helpers for array manipulation and file I/O.
See also
scarabaeus.EpochArrayTime-tag array type accepted by several helpers.
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.
load_json(dir[, print_flag])Load and parse a JSON file from disk.
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:
- 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
Trueif all values are equal along rows. ReturnsFalseif they are not.- Return type:
- 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 (
EpochArray) – Reference epoch array to search within.target_dates (
EpochArrayorlistofEpochArray) – Target epoch(s) to locate inside epochsTDB.rtol (
float, optional) – Relative tolerance for comparing the dates. Defaults to1e-6.
- Returns:
ind – The index or indices of the target date(s), or
Noneif not found.- Return type:
- 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 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 (
tupleofint) – Target shape of the output array. The last dimension must equallen(arr); all preceding dimensions specify how many times to repeat the array along each axis.
- Returns:
tiled – The new tiled array.
- Return type: