calculate_budget¶
calculate_budget(particle_array, data_slice, rhs_list, prefetch_vector_kwarg={}, lhs_name='lhs', dir_of_time=-1)Calculate Lagrangian budget.
Parameters
particle_array (xr.Dataset) -- A dataset generated by seaduck that contains the location and velocity info.
data_slice (xr.Dataset) -- The ocean model (including budget terms) at a time step.
rhs_list (list) -- List of strings for the variable names on the RHS
prefetch_vector_kwarg (dict) -- Keyword arguments for reading wall concentration
lhs_name (String) -- The name of variable that stands for eulerian tendency
dir_of_time (number) -- -1 for backward, and 1 for forward.
Returns
contr_dic (dict of np.ndarray) -- The contribution of each RHS term, has same length as number of entries.
trc_conc (np.ndarray) -- Tracer concentration at each point.
first, last (np.ndarray) -- Which indices mark the start and end of the time step for each particle.
check_particle_data_compat¶
check_particle_data_compat(xrpt, xrslc, tp, use_tracer_name=None, wall_names=('sx', 'sy', 'sz'), conv_name='divus', debug=False, allclose_kwarg={})Check if you could use Lagrangian budget functionality.
Parameters
xrpt (xr.Dataset) -- A dataset generated by seaduck that contains the location and velocity info.
xrslc (xr.Dataset) -- The ocean model (including budget terms) at a time step.
tp (sd.Topology) -- The topology object for the model
use_tracer_name (string) -- if specified, use cx,cy,cz as wall name
wall_names (tuple of string) -- Name of variables if use_tracer_name is not defined.
conv_name (string) -- The variable from xrslc to be compared against.
debug (bool) -- Whether to return additional debug information.
allclose_kwarg -- Keyword arguments for np.allclose.
Returns
OK_or_not (bool) -- Is it OK to preceed?
extra (None or tuple) -- Extra information to help with debugging.
contr_p_relaxed¶
contr_p_relaxed(deltas, tres, step_dic, termlist, p=1, error_prefix='')crude_convergence¶
crude_convergence(u_list)deepcopy_inds¶
deepcopy_inds(temp)dump_to_zarr¶
dump_to_zarr(neo, oce, filename, region_names=False, region_polys=None, preserve_checks=False)fast_cumsum¶
fast_cumsum(shapes)find_ind_frac_tres¶
find_ind_frac_tres(neo, oce, region_names=False, region_polys=None, by_type=True)first_last_neither¶
first_last_neither(shapes, return_neither=True)flatten¶
flatten(lstoflst, shapes=None)ind_tend_uv¶
ind_tend_uv(ind, tp)Return the index of the velocity node.
The node is not of the same index as the center point. iw determines where to return iw
lhs_contribution¶
lhs_contribution(t, scalar_dic, last, lhs_name='lhs')particle2xarray¶
particle2xarray(p)prefetch_scalar¶
prefetch_scalar(ds_slc, scalar_names)prefetch_vector¶
prefetch_vector(ds_slc, xname='sxprime', yname='syprime', zname='szprime', same_size=True)pseudo_motion¶
pseudo_motion(pt)pt_ulist¶
pt_ulist(pt)read_from_ds¶
read_from_ds(particle_ds, oce)read_prefetched_scalar¶
read_prefetched_scalar(ind, scalar_names, prefetch)read_wall_list¶
read_wall_list(neo, tp, prefetch=None, scalar=True)redo_index¶
redo_index(pt)residence_time¶
residence_time(pt)store_lists¶
store_lists(pt, name, region_names=False, region_polys=None, **kwarg)tres_fraction¶
tres_fraction(temp, first, last, fraction_first, fraction_last)tres_update¶
tres_update(tres0, temp, first, last, fraction_first, fraction_last)wall_index¶
wall_index(inds, iwall, tp)which_wall¶
which_wall(pt)