tools
Tools.
            SimpleJETTOOutput
    Dataclass for a simplified subset of JETTO output at a single timestamp.
Source code in tokamak_neutron_source/tools.py
                
            WarningFilter
    Filters away duplicate log messages. Source: https://stackoverflow.com/questions/31953272/60462619#60462619
Source code in tokamak_neutron_source/tools.py
                
            QuietTTSpectrumWarnings
    
              Bases: tokamak_neutron_source.tools.WarningFilter
Filter away all duplicate warnings from the energy and energy_data module.
Source code in tokamak_neutron_source/tools.py
                
              
            get_tns_root()
    Get the tokamak_neutron_source root install folder.
Returns:
| Type | Description | 
|---|---|
| str | The full path to the tokamak_neutron_source root folder, e.g.: '/home/user/code/tokamak_neutron_source' | 
Source code in tokamak_neutron_source/tools.py
              
            get_tns_path(path='', subfolder='tokamak_neutron_source')
    Get a tns path of a module subfolder. Defaults to root folder.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| path | str | The desired path from which to create a full path | '' | 
| subfolder | str | The subfolder (from the tokamak_neutron_source root) in which to create a path Defaults to the source code folder, but can be e.g. 'tests', or 'data' | 'tokamak_neutron_source' | 
Returns:
| Type | Description | 
|---|---|
| Path | The full path to the desired  | 
Source code in tokamak_neutron_source/tools.py
              
            load_eqdsk(file)
    Load an EQDSK file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| file | str | EQDSKInterface | The path to the EQDSK file. | required | 
Returns:
| Type | Description | 
|---|---|
| EQDSKInterface | The EQDSKInterface object. | 
Notes
Enforces the local convention that psi on axis is higher than psi on the boundary. This way, we do not need to ask the user what COCOS convention they are using.
The actual values of psi are irrelevant here, and may be changed to enforce this convention.
Source code in tokamak_neutron_source/tools.py
              
            load_jsp(file, frame_number=-1)
    Load a JETTO JSP binary file.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| file | str | Path | File to read | required | 
| frame_number | int | Frame number to read | -1 | 
Returns:
| Type | Description | 
|---|---|
| SimpleJETTOOutput | Simplified JETTO output | 
Raises:
| Type | Description | 
|---|---|
| ValueError | If the specified frame number is invalid. | 
Notes
For details, refer to https://users.euro-fusion.org/pages/data-cmg/wiki/JETTO_ppfjsp.html
The core values (rho = 0.0) are not provided by JETTO. Here we extrapolate them.
JETTO presently does not provide Helium-3 densities. These are taken to be 0.0.
JETTO presently does not provide D-D fusion power or reaction rates, or some files may potentially do some but only for one of the channels.
Source code in tokamak_neutron_source/tools.py
              
            load_citation()
    Load the CITATION.cff file.
Returns:
| Type | Description | 
|---|---|
| dict | The contents of the CITATION.cff file as a dictionary. | 
Source code in tokamak_neutron_source/tools.py
              
            
            check_ccw(x, z)
    Check that a set of x, z coordinates are counter-clockwise.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray | The x coordinates of the polygon | required | 
| z | ndarray | The z coordinates of the polygon | required | 
Returns:
| Type | Description | 
|---|---|
| bool | True if polygon counterclockwise | 
Source code in tokamak_neutron_source/tools.py
              
            get_area_2d(x, y)
    Calculate the area inside a closed polygon with x, y coordinate vectors.
Link Shoelace method <https://en.wikipedia.org/wiki/Shoelace_formula>_
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray | The first set of coordinates [m] | required | 
| y | ndarray | The second set of coordinates [m] | required | 
Returns:
| Type | Description | 
|---|---|
| float | The area of the polygon [m^2] | 
Source code in tokamak_neutron_source/tools.py
              
            get_centroid_2d(x, z)
    Calculate the centroid of a non-self-intersecting 2-D counter-clockwise polygon.
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| x | ndarray | x coordinates of the coordinates to calculate on | required | 
| z | ndarray | z coordinates of the coordinates to calculate on | required | 
Returns:
| Type | Description | 
|---|---|
| list[float] | The x, z coordinates of the centroid [m] | 
Source code in tokamak_neutron_source/tools.py
              
            raw_uc(value, unit_from, unit_to)
    Raw unit converter Converts a value from one unit to another
Parameters:
| Name | Type | Description | Default | 
|---|---|---|---|
| value | ValueLikeT | value to convert | required | 
| unit_from | str | Unit | unit to convert from | required | 
| unit_to | str | Unit | unit to convert to | required | 
Returns:
| Type | Description | 
|---|---|
| ValueLikeT | converted value |