PlasmaCalcs.addons.instability_tools.instability_theory_tools.xarray_where_grows
- PlasmaCalcs.addons.instability_tools.instability_theory_tools.xarray_where_grows(growth, target=None, *, drop=UNSET)
- return target where growth > 0. Roughly: target.where(xarray_grows(growth)).(or, growth.where(xarray_grows(growth)) if target is None).
- growth: DataArray or Dataset
- xarray object containing growth info.real DataArray –> growth tells growth rates.complex DataArray –> growth tells omega; rates = omega.imag.Dataset –> growth rates = ds[‘omega’].imag
- target: None, str, DataArray, or Dataset
- xarray object of interest.result tells target.where(grows).
- drop: UNSET or bool
- whether to drop as many nan values as possible from the result.UNSET –> True if growth_kmax has ndim==1, else False.(when growth_kmax has ndim==1, it’s a list of points, easy to fully drop nans.when ndim>=2, might not be able to drop all the nans,e.g. if (x,y)=(0,0) is nan but (0,1) and (1,0) are not, cannot drop (0,0).)
Examples:dsR = xr.Dataset(…) # dataset containing omega and maybe some other valuesdsR.it.where_grows() # dataset where growth rate > 0 for any k. (i.e. dataset where dsR.it.grows())dsR.it.where_grows(drop=False) # dataset where_grows() but keep all nan regions.dsR.it.where_grows(array) # array where dsR.it.grows().# array where dsR.it.grows(), but assign array coords’ original indexes as coords.# e.g. if ‘_mask_stack’ in array coords, result will have ‘_mask_stack_index’ too.dsR.it.where_grows(array.pc.index_coords())