Tools module#

OpenCL module#

To use OpenCL architecture

Convertor#

cherab.iter.tools.convertor.import_mesh(mesh_path, mesh_name, ext)#
cherab.iter.tools.convertor.save_mesh(mesh, filename, ext)#
cherab.iter.tools.convertor.relative_to_absolute_path(path)#
cherab.iter.tools.convertor.main(mesh_path, new_ext)#

Rtm#

class cherab.iter.tools.rtm.RTM#
overwrite_material(wall, tungsten_roughness=0.29, beryllium_roughness=0.26, iron_roughness=0.13)#
check_camera_attributes(camera, pixel_samples)#
calculate_zsteps(nr, nz, mask)#
create(camera, r, z, mask=None, wall=None, pixel_samples=2000, eps_rz=0.0001, integrate_step=0.0025, reflection=True)#
load(filename)#
get()#
save(filename)#
construct(emission)#

Slts#

cherab.iter.tools.slts.slts(w_reflect, wo_reflect)#

Stray light to signal

Visualization#

cherab.iter.tools.visualization.plot_fov_1D(theta, fovRad, unit='W/m$^3$')#

plotting field of view on 1D

Parameters:
  • theta (ndarray) – theta angles in units of degree

  • fovRad (ndarray) – radiances

  • unit (str) – units of radiance, by default “W/m$^3$”

Returns:

matplotlib figure object

Return type:

Figure

cherab.iter.tools.visualization.plot_fov_2D(phi, theta, fovRad)#

plotting field of view on 2D

Parameters:
  • phi (ndarray) – phi angles in units of degree

  • theta (ndarray) – theta angles in units of degree

  • fovRad (ndarray) – radiances

Returns:

matplotlib figure object

Return type:

Figure

cherab.iter.tools.visualization.create_rtm_gif(r, z, rtm, phi, theta, fov_data, view_name='')#

Create RTM gif animation

Parameters:
  • r (ndarray) – r axis data set

  • z (ndarray) – z axis data set

  • rtm (ndarray) – Ray Transfer Matrix

  • phi (ndarray) – azimuth

  • theta (ndarray) – elevation

  • fov_data (ndarray) – fov object containing Fov setting

  • view_name (str) – name of charaterizing this data, by default “”

cherab.iter.tools.visualization.plot_2D_profile(data, fig=None, xlabel='$R$[m]', ylabel='$Z$[m]', clabel='[W/m$^3$]', ax_row=1, vmin=None, xdata=array([0, 1]), ydata=array([0, 1]), plot_mode='scalar', cmap='jet', titles=None, title_params={'bbox': {'edgecolor': (0.83, 0.83, 0.83, 0.9), 'facecolor': (0.83, 0.83, 0.83, 0.9)}, 'loc': 'left', 'va': 'top', 'x': 0.05, 'y': 0.95}, grids_params={'axes_pad': 0.0, 'cbar_location': 'right', 'cbar_mode': 'single', 'cbar_pad': 0.0, 'label_mode': 'L', 'share_all': True})#

plot several 2D profile data with one color bar In particular, plot a r-z plane rofile

Parameters:
  • data (list[numpy.ndarray]) – list contains 2D numpy.ndarray data

  • fig (Optional[Figure]) – matplotlib figure object

  • xlabel (str) – x axis label, by default "$R[m]"

  • ylabel (str) – y axis label, by default "$Z[m]"

  • clabel (str) – color bar’s label, by default "[W/m$^3$]"

  • ax_row (int) – the number of rows of axes displyed in 1 figure, by default 1

  • vmin (Optional[float]) – image scaling factor for a minimal value

  • xdata (ndarray) – x axis data, by default np.array([0, 1])

  • ydata (ndarray) – y axis data, by default np.array([0, 1])

  • plot_mode (str) – plotting mode to switch scalar or logarithum scale choosing either 'scalar' or 'log', by default 'scalar'

  • cmap (str) – color map, by default "jet"

  • titles (Optional[list[str]]) – list of axes titles, by default None

  • title_paramsset_title’s parameters

  • grids_paramsImageGrid parameters

Return type:

tuple[Figure, ImageGrid]

cherab.iter.tools.visualization.plot_2D_data(data, fig=None, xlabel='x[px]', ylabel='y[px]', clabel='[W/m$^3$]', ax_row=1, vmin=None, extent=None, plot_mode='scalar', cmap='jet', titles=None, title_params={'bbox': {'edgecolor': (0.83, 0.83, 0.83, 0.9), 'facecolor': (0.83, 0.83, 0.83, 0.9)}, 'loc': 'left', 'va': 'top', 'x': 0.05, 'y': 0.95}, grids_params={'axes_pad': 0.0, 'cbar_location': 'right', 'cbar_mode': 'single', 'cbar_pad': 0.0, 'label_mode': 'L', 'share_all': True})#

plot several 2D profile data with one color bar In particular, plot a r-z plane rofile

Parameters:
  • data (list[numpy.ndarray]) – list contains 2D numpy.ndarray data

  • fig (Optional[Figure]) – matplotlib figure object

  • xlabel (str) – x axis label, by default "x[px]"

  • ylabel (str) – y axis label, by default "y[px]"

  • clabel (str) – color bar’s label, by default "[W/m$^3$]"

  • ax_row (int) – the number of rows of axes displyed in 1 figure, by default 1

  • vmin (Optional[float]) – image scaling factor for a minimal value

  • extent (Optional[tuple]) – image extent option, by default (-0.5, numcols - 0.5, -0.5, numrows - 0.5)

  • plot_mode (str) – plotting mode to switch scalar or logarithum scale choosing either 'scalar' or 'log', by default 'scalar'

  • cmap (str) – color map, by default "jet"

  • titles (Optional[list[str]]) – list of axes titles, by default None

  • title_paramsset_title’s parameters

  • grids_paramsImageGrid parameters

Return type:

tuple[Figure, ImageGrid]

Xml#

class cherab.iter.tools.xml.XmlListConfig(aList)#

Bases: list

class cherab.iter.tools.xml.XmlDictConfig(parent_element)#

Bases: dict

Example

tree = ElementTree.parse('your_file.xml')
root = tree.getroot()
xmldict = XmlDictConfig(root)

Or, if you want to use an XML string:

root = ElementTree.XML(xml_string)
xmldict = XmlDictConfig(root)

And then use xmldict for what it is… a dict.

cast(data_dict)#
read_xml_entry(dtype, value, rtype=None)#

Read xml entry.

Parameters:
  • dtype (str) – “int”, “float”, or “str”

  • rtype (any, optional) – Return type, by default None

Returns:

Contents of entry’s ‘value’ attribute in one of Python formats.

Return type:

rtype

cherab.iter.tools.xml.str2bool(string)#

Convert “on”/”off” to True/False.

Parameters:

string (str) – “on” or “off”.

Returns:

Bool value corresponding to input.

Return type:

bool

Raises:

TypeError – If input has wrong type.

cherab.iter.tools.xml.bool2str(flag)#

Convert True/False to “on”/”off”.

Parameters:

flag (bool) – True or False.

Returns:

“on” or “off” according to input.

Return type:

str

Raises:

TypeError – If input has wrong type.

cherab.iter.tools.xml.read_xml_entry(tree_element, rtype=None)#

Read xml entry.

Parameters:
  • tree_element (xml.etree.Element) – xml tree element.

  • rtype (any, optional) – type of return

Returns:

Contents of entry’s ‘value’ attribute in one of Python formats.

Return type:

rtype

cherab.iter.tools.xml.parse_user_options(config)#

Parse user configuration.

Parameters:

config (str) – Path co configuration file.

Returns:

User options.

Return type:

dict

cherab.iter.tools.xml.parse_emission_lines(config)#

Parse list of emission lines.

Parameters:

config (str) – Path co configuration file.

Returns:

emission_lies - list of cherab.Line.

Return type:

list

Raises:

ValueError – If name of the element is not recognised.

cherab.iter.tools.xml.parse_beam_geometry(config)#

Parse beam geometry.

Parameters:

config (str) – Path to configuration file.

Returns:

  • Point3D – beam_source - beam source position.

  • Vector3D – beam_direction - beam direction vector.

cherab.iter.tools.xml.parse_diagnostic_geometry(config, name)#

Parse diagnostic geometry.

Parameters:
  • config (str) – Path co configuration file.

  • name (str) – Diagnostic’s name.

Returns:

  • Point3D – aperture_position - aperture position.

  • list – intersection_radii - list of intersection radii.

Yml#

cherab.iter.tools.yml.load_yml(config_file)#
cherab.iter.tools.yml.dump_yml(dict_data, config_file)#