RayDrapingCore

class PlasmaCalcs.tools.sci_tools.ray_draping.RayDrapingCore(*, scene, anchor, fov=None)

Bases: object

core methods for the entire ray draping problem, including mapping calculations.

This includes the setup (scene, anchor, fov), and mapping methods (for any points).
Users should prefer RayDraping instead, which additionally includes
the actual rays, some plotting methods, and some clever defaults.
scene: dict or RayDrapeScene
scene conditions for ray draping problem.
dict –> convert to RayDrapeScene.
Should have keys: R0, XEXT, YEXT, ZEXT, T.
anchor: dict or RayDrapeAnchor
anchor point for ray draping problem.
dict –> convert to RayDrapeAnchor.
May have any of these keys: Asph_theta, Asph_phi, Abox_x, Abox_y.
(Missing keys use RayDrapeAnchor defaults.)
fov: None, xr.DataArray, or RayDrapeFOV
field-of-view grid for ray draping problem.
None –> specify it later, by setting self.fov = value.
xr.DataArray –> convert to RayDrapeFOV.
Should have ‘component’ dimension associated with x, y, z coords of each point,
in sph system cartesian coords centered at r=0.

Methods

box_to_sph(wbox)

return wsph corresponding to any wbox point or points.

keep_in_box(wsph, *[, in_box])

return wsph points masked to only those inside the draped box region.

periodic_wrap(wbox)

return wbox points wrapped periodically into x and y box extents.

sph_to_box(wsph, *[, in_box, periodic])

return wbox corresponding to any wsph point or points.

_get_fov_value(value)

convert value to RayDrapeFOV (unless None) appropriate for storage in self.fov.

_repr_contents()

list of contents for self.__repr__

Attributes

Abox_x

alias to self.anchor.Abox_x

Abox_y

alias to self.anchor.Abox_y

Asph

alias to self.anchor.Asph

FOV

alias to self.fov.FOV

R0

alias to self.scene.R0

T

alias to self.scene.T

X0

alias to self.scene.X0

X1

x-coordinate of right edge of box in box system.

XEXT

alias to self.scene.XEXT

Y0

alias to self.scene.Y0

Y1

y-coordinate of top edge of box in box system.

YEXT

alias to self.scene.YEXT

ZEXT

alias to self.scene.ZEXT

fov

field-of-view grid for ray draping problem.

property Abox_x

alias to self.anchor.Abox_x

property Abox_y

alias to self.anchor.Abox_y

property Asph

alias to self.anchor.Asph

property FOV

alias to self.fov.FOV

property R0

alias to self.scene.R0

property T

alias to self.scene.T

property X0

alias to self.scene.X0

property X1

x-coordinate of right edge of box in box system. == X0 + XEXT.

property XEXT

alias to self.scene.XEXT

property Y0

alias to self.scene.Y0

property Y1

y-coordinate of top edge of box in box system. == Y0 + YEXT.

property YEXT

alias to self.scene.YEXT

property ZEXT

alias to self.scene.ZEXT

_get_fov_value(value)

convert value to RayDrapeFOV (unless None) appropriate for storage in self.fov.

_repr_contents()

list of contents for self.__repr__

anchor_cls

alias of RayDrapeAnchor

box_to_sph(wbox)

return wsph corresponding to any wbox point or points.

i.e., returns w expressed in sph system cartesian coords centered at r=0.
wbox: xarray object (e.g. DataArray)
points in box system cartesian coords,
with ‘component’ dimension associated with x, y, z coords of each point.
(Possibly useful: wbox=xr.concat([xbox, ybox, zbox], dim=’component’))
property fov

field-of-view grid for ray draping problem.

For efficiency, RayDrapeFOV is created immediately when setting self.fov (unless None).
(E.g., self.fov=arr; self.fov # == RayDrapeFOV(arr))
See help(type(self)) for more details about possible values.
fov_cls

alias of RayDrapeFOV

keep_in_box(wsph, *, in_box=True)

return wsph points masked to only those inside the draped box region.

i.e., only keep points where R0 <= |wsph| <= R0 + ZEXT.
wsph: xarray object (e.g. DataArray)
points in sph system cartesian coords centered at r=0,
with ‘component’ dimension associated with x, y, z coords of each point.
(Possibly useful: wsph=xr.concat([xsph, ysph, zsph], dim=’component’))
in_box: bool, ‘lower’, or ‘upper’
whether to check that points will fall inside the draped box region,
masking all other points using NaNs.
‘lower’ –> only check lower bound: R0 <= |wsph|.
‘upper’ –> only check upper bound: |wsph| <= R0 + ZEXT.
periodic_wrap(wbox)

return wbox points wrapped periodically into x and y box extents.

The wrapping is done using modulus operation, accounting for X0 and Y0 if nonzero:
xbox = (xbox - X0) % XEXT + X0
ybox = (ybox - Y0) % YEXT + Y0
wbox: xarray object (e.g. DataArray)
points in box system cartesian coords,
with ‘component’ dimension associated with x, y, z coords of each point.
(Possibly useful: wbox=xr.concat([xbox, ybox, zbox], dim=’component’))
scene_cls

alias of RayDrapeScene

sph_to_box(wsph, *, in_box=False, periodic=True)

return wbox corresponding to any wsph point or points.

i.e., returns w expressed in box system cartesian coords.
wsph: xarray object (e.g. DataArray)
points in sph system cartesian coords centered at r=0,
with ‘component’ dimension associated with x, y, z coords of each point.
(Possibly useful: wsph=xr.concat([xsph, ysph, zsph], dim=’component’))
in_box: bool, ‘lower’, or ‘upper’
whether to check that points will fall inside the draped box region,
masking all other points using NaNs.
‘lower’ –> only check lower bound: R0 <= |wsph|.
‘upper’ –> only check upper bound: |wsph| <= R0 + ZEXT.
(Use False for efficiency if this was already checked elsewhere!)
periodic: bool
whether to wrap points periodically into x and y box extents.
True –> like draping the box periodically around the sphere.
False –> mainly useful for debugging… are there other use cases?