hybrid_jp.analysis.shock_centering module#

class hybrid_jp.analysis.shock_centering.CenteredShock(sdfs: list[hybrid_jp.sdf_files.SDF], deck: Deck)[source]#

Bases: object

property chunk_i: int#
property downstream_start_chunk: int#
get_qty_in_frame(qty_func: Callable[[SDF], ndarray[Any, dtype[float64]]], chunk: int, t_idx: int) tuple[numpy.ndarray[Any, numpy.dtype[numpy.float64]], tuple[int, int]][source]#

Extract from an SDF using qty_func at a chosen chunk and timestep.

Example

>>> def get_nd(sdf: SDF) -> npt.NDArray[np.float64]:
...     return sdf.numberdensity
>>> qty, start_stop = cs.get_qty_in_frame(get_qty, 0, 0)
>>> def get_median_bx(sdf: SDF) -> npt.NDArray[np.float64]:
...     return np.median(sdf.mag.bx, axis=1)
>>> qty, start_stop = cs.get_qty_in_frame(get_median_bx, 0, 0)
>>> plt.plot(x=cs.grid.x[slice(*start_stop)], y=qty)
get_x_offset_for_frame(chunk: int, t_idx: int) int[source]#

The start index for a chunk at a timestep.

property missing: ndarray[Any, dtype[int64]]#
reshape_qty_to_shock_arr(qty: ndarray[Any, dtype[float64]])[source]#

Reshape qty so that shock is aligned.

Note

  • qty must have shape (grid.x.size, time.size) i.e. the first dimension is the width of the grid in x and the second is the number of timesteps.

Parameters:

qty (npt.NDArray[np.float64]) – The quantity to be reshaped.

set_chunk_i_missing() dict[str, Any][source]#
set_start_offset() ndarray[Any, dtype[int64]][source]#
set_valid_chunks()[source]#
shock_index_from_nd(threshold=0.37)[source]#
property start_offset: ndarray[Any, dtype[int64]]#
property valid_chunks: ndarray[Any, dtype[bool_]]#
exception hybrid_jp.analysis.shock_centering.InvalidChunkError(chunk_idx: int, t_idx: int)[source]#

Bases: Exception

Raised when a chunk is not valid.

exception hybrid_jp.analysis.shock_centering.NChunksNotSetError(message: str = 'n_chunks must be set before calling this method.')[source]#

Bases: Exception

Raised in a CentredShock when n_chunks is not set.

message = 'n_chunks must be set before calling this method.'#
exception hybrid_jp.analysis.shock_centering.NoTimestampError[source]#

Bases: Exception