viscid.calculator.separator module

viscid.calculator.separator.trace_separator(grid, b_slcstr='x=-25j:15j, y=-30j:30j, z=-15j:15j', r=1.0, plot=False, trace_opts=None, cache=True, cache_dir=None)[source]

Trace a separator line from most dawnward null

Still in testing Uses the bisection algorithm.

Parameters:
  • grid (Grid) – A grid that has a “b” field
  • b_slcstr (str) – Some valid slice for B field
  • r (float) – spatial step of separator line
  • plot (bool) – make debugging plots
  • trace_opts (dict) – passed to streamline function
  • cache (bool, str) – Save to and load from cache, if “force”, then don’t load from cache if it exists, but do save a cache at the end
  • cache_dir (str) – Directory for cache, if None, same directory as that file to which the grid belongs
Raises:

IOError – Description

Returns:

(separator_lines, nulls)

  • separator_lines (list): list of M 3xN ndarrays that represent M separator lines with N points
  • nulls (ndarray): 3xN array of N null points

Return type:

tuple

viscid.calculator.separator.topology_bitor_clusters(fld, min_depth=1, max_depth=10, multiple=True, plot=False, sep_val=15, mask_limit=15, periodic='00', pt_bnds=())[source]

Find separator as intersection of all global topologies

Neighbors are bitwise ORed until at least one value matches sep_val which is presumably (Close | Open N | Open S | SW). This happens between min_depth and max_depth times, where the resolution of each iteration is reduced by a factor of two, ie, worst case 2**(max_depth).

Parameters:
  • fld (Field) – Topology (bitmask) as a field
  • min_depth (int) – Iterate at least this many times
  • max_depth (int) – Iterate at most this many times
  • multiple (bool) – passed to viscid.cluster()
  • sep_val (int) – Value of bitmask that indicates a separator
  • plot (bool) – Make a 2D plot of Fld and the sep candidates
  • mask_limit (int) – if > 0, then bitmask fld with mask_limit, i.e., fld = fld & mask_limit (bitwise and)
  • periodic (sequence) – indicate whether that direction is periodic, and if so, whether the coordinate arrays are overlapped or not. Values can be True, False, or ‘+’. ‘+’ indicates that x[0] and x[-1] are not colocated, so assume they’re dx apart where dx = x[-1] - x[-2].
  • pt_bnd (sequence) – Boundaries that come to a point, i.e., all values along that boundary are neighbors such as the poles of a sphere. Specified like “0-” for lower boundary of dimension 0 or “1+” for the upper boundary of dimension 1.
Returns:

2xN for N clusters of separator points in the same coordinates as fld

Return type:

ndarray

viscid.calculator.separator.get_sep_pts_bitor(fld, seed, trace_opts=None, make_3d=True, **kwargs)[source]

bitor topologies to find separator points in uv map from seed

Parameters:
  • fld (VectorField) – Magnetic Field
  • seed (viscid.seed.SeedGen) – Any Seed generator with a 2d local representation
  • trace_opts (dict) – kwargs for calc_streamlines
  • make_3d (bool) – convert result from uv to 3d space
  • **kwargs – passed to topology_bitor_clusters()
Returns:

3xN ndarray of N separator points in uv space or 3d space depending on the make_3d kwarg

viscid.calculator.separator.get_sep_pts_bisect(fld, seed, trace_opts=None, min_depth=3, max_depth=7, plot=False, perimeter_check=<function perimeter_check_bitwise_or>, make_3d=True)[source]

bisect uv map of seed to find separator points

Parameters:
  • fld (VectorField) – Magnetic Field
  • seed (viscid.seed.SeedGen) – Any Seed generator with a 2d local representation
  • trace_opts (dict) – kwargs for calc_streamlines
  • min_depth (int) – Min allowable bisection depth
  • max_depth (int) – Max bisection depth
  • plot (bool) – Useful for debugging the algorithm
  • perimeter_check (func) – Some func that returns a bool with the same signature as perimeter_check_bitwise_or()
  • make_3d (bool) – convert result from uv to 3d space
Returns:

3xN ndarray of N separator points in uv space or 3d space depending on the make_3d kwarg