scotty package#
- scotty.beam_me_up(poloidal_launch_angle_Torbeam, toroidal_launch_angle_Torbeam, launch_freq_GHz, mode_flag, launch_beam_width, launch_beam_curvature, launch_position, vacuumLaunch_flag=True, relativistic_flag=False, find_B_method='torbeam', density_fit_parameters=None, temperature_fit_parameters=None, shot=None, equil_time=None, vacuum_propagation_flag=False, Psi_BC_flag=None, poloidal_flux_enter=1.0, poloidal_flux_zero_density=1.0, poloidal_flux_zero_temperature=1.0, auto_delta_sign=True, delta_R=-0.0001, delta_Z=0.0001, delta_K_R=0.1, delta_K_zeta=0.1, delta_K_Z=0.1, interp_order=5, len_tau=102, rtol=0.001, atol=1e-06, interp_smoothing=0, ne_data_path=PosixPath('.'), magnetic_data_path=PosixPath('.'), Te_data_path=PosixPath('.'), output_path=PosixPath('.'), input_filename_suffix='', output_filename_suffix='', figure_flag=True, detailed_analysis_flag=True, quick_run=False, plasmaLaunch_K=array([0., 0., 0.]), plasmaLaunch_Psi_3D_lab_Cartesian=array([[0., 0., 0.], [0., 0., 0.], [0., 0., 0.]]), density_fit_method=None, temperature_fit_method=None, B_T_axis=None, B_p_a=None, R_axis=None, minor_radius_a=None)#
Run the beam tracer
Overview#
- Initialise density fit parameters. One of:
spline with data from file
Stefanikova
O(3) polynomial
tanh
quadratic
See
profile_fitfor more detailsIf relativistic_flag enabled, initialise temperature fit parameters. Not yet fully implemented. One of:
spline with data from file
linear
See ‘profile_fit’ for more details
- Initialise magnetic field method. One of:
TORBEAM
OMFIT
analytical
EFIT++
UDA
curvy slab
test/test_notime
See
geometryfor more detailsInitialise beam launch parameters (vacuum/plasma). See
launchfor more details.Propagate single ray with IVP solver to find point where beam leaves plasma. See
ray_solverfor more detailsPropagate beam with IVP solver
Dump raw output
Analysis
- param poloidal_launch_angle_Torbeam:
Poloidal angle of antenna in TORBEAM convention
- type poloidal_launch_angle_Torbeam:
float
- param toroidal_launch_angle_Torbeam:
Toroidal angle of antenna in TORBEAM convention
- type toroidal_launch_angle_Torbeam:
float
- param launch_freq_GHz:
Frequency of the launched beam in GHz
- type launch_freq_GHz:
float
- param mode_flag:
Either
+/-1, used to determine which mode branch to use- type mode_flag:
int
- param launch_beam_width:
Width of the beam at launch
- type launch_beam_width:
float
- param launch_beam_curvature:
Curvatuve of the beam at launch
- type launch_beam_curvature:
float
- param launch_position:
Position of the antenna in cylindrical coordinates
- type launch_position:
FloatArray
- param vacuumLaunch_flag:
If
True, launch beam from vacuum, otherwise beam launch position is inside the plasma already- type vacuumLaunch_flag:
bool
- param vacuum_propagation_flag:
If
True, run solver from the launch position, and don’t use analytical vacuum propagation- type vacuum_propagation_flag:
bool
- param relativistic_flag:
If
True, generates a temperature profile from given data or parameters and applies relativistic corrections to electron mass.- type relativistic_flag:
bool
- param Psi_BC_flag:
If
None, do no special treatment at plasma-vacuum boundary Ifcontinuous, apply BCs for continuous ne but discontinuous gradient of ne Ifdiscontinuous, apply BCs for discontinuous ne UsingTrueorFalseis now deprecated- type Psi_BC_flag:
String
- param poloidal_flux_enter:
Normalised poloidal flux label of plasma boundary. If vacuum_propagation_flag, then this is where the solver begins. If Psi_BC_flag, then this is where the plasma-vacuum BCs are applied
- type poloidal_flux_enter:
float
- param poloidal_flux_zero_density:
At and above this normalised poloidal flux label, Scotty sets the electron density to zero
- type poloidal_flux_zero_density:
float
- param poloidal_flux_zero_temperature:
At and above this normalised poloidal flux label, Scotty sets the electron temperature to zero. This effectively negates any relativistic mass corrections.
- type poloidal_flux_zero_temperature:
float
- param plasmaLaunch_Psi_3D_lab_Cartesian:
\(\Psi\) of beam in lab Cartesian coordinates. Required if
vacuumLaunch_flagisFalse- type plasmaLaunch_Psi_3D_lab_Cartesian:
FloatArray
- param plasmaLaunch_K:
Wavevector of beam at launch. Required if
vacuumLaunch_flagisFalse- type plasmaLaunch_K:
FloatArray
- param delta_R:
Finite difference spacing to use for
R- type delta_R:
float
- param delta_Z:
Finite difference spacing to use for
Z- type delta_Z:
float
- param delta_K_R:
Finite difference spacing to use for
K_R- type delta_K_R:
float
- param delta_K_zeta:
Finite difference spacing to use for
K_zeta- type delta_K_zeta:
float
- param delta_K_Z:
Finite difference spacing to use for
K_Z- type delta_K_Z:
float
- param find_B_method:
See
create_magnetic_geometryfor more information.Common options:
"efitpp"uses magnetic field data from efitpp files directly"torbeam"uses magnetic field data from TORBEAM input files"omfit"is similar to"torbeam"but reads the data from JSON files"UDA_saved"reads EFIT data from numpy’s.npzfiles"analytical"uses a constant current density circular equilibrium
Or pass a
MagneticFieldinstance directly.- param density_fit_parameters:
A list of parameters to be passed to the
density_fit_methodconstructor. See the docs for the individual methods for the meaning of their parametersNote
These parameters should not include
poloidal_flux_zero_density- param density_fit_method:
Parameterisation of the density profile. Either a callable (see
ProfileFit), or one of the following options:"smoothing-spline": 1D smoothing spline (SmoothingSplineFit)"smoothing-spline-file": 1D smoothing spline constructed from file (SmoothingSplineFit.from_dat_file)"stefanikova": combination of modified hyperbolic \(\tan\) and a Gaussian (StefanikovaFit)"poly3"or"polynomial": \(n\)-th order polynomial (PolynomialFit)"tanh": hyperbolic \(\tan\) (TanhFit)"quadratic": constrained quadratic (QuadraticFit)
If
density_fit_methodis a string, then the correspondingDensityFitobject is constructed usingpoloidal_flux_zero_densityanddensity_fit_parameters."smoothing-spline-file"looks for a file calledne<input_filename_suffix>.datinne_data_path. It also usesinterp_orderandinterp_smoothinginstead ofdensity_fit_parameters.Deprecated since version 2.4.0: If
None(the default) is passed, the method will be guessed from the length ofdensity_fit_parameters. In this case,quadraticandtanhparameters _should_ includepoloidal_flux_zero_densityas the last value.- param temperature_fit_method:
Parameterisation of the temperature profile. Leverages the same ProfileFit class used for density. See density_fit_method for details.
- param len_tau:
Number of output
taupoints- type len_tau:
int
- param rtol:
Relative tolerance for ODE solver
- type rtol:
float
- param atol:
Absolute tolerance for ODE solver
- type atol:
float
- param quick_run:
If true, then run only the ray tracer and get an analytic estimate of the \(K\) cut-off location
- type quick_run:
bool
- param auto_delta_sign:
Boolean. Ensures that forward difference is always in negative poloidal flux gradient direction (into the plasma).
- Parameters:
poloidal_launch_angle_Torbeam (float)
toroidal_launch_angle_Torbeam (float)
launch_freq_GHz (float)
mode_flag (int)
launch_beam_width (float)
launch_beam_curvature (float)
vacuumLaunch_flag (bool)
relativistic_flag (bool)
find_B_method (str | MagneticField)
density_fit_parameters (Sequence | None)
temperature_fit_parameters (Sequence | None)
vacuum_propagation_flag (bool)
poloidal_flux_enter (float)
poloidal_flux_zero_density (float)
poloidal_flux_zero_temperature (float)
delta_R (float)
delta_Z (float)
delta_K_R (float)
delta_K_zeta (float)
delta_K_Z (float)
len_tau (int)
rtol (float)
atol (float)
quick_run (bool)
density_fit_method (str | Callable[[float | ndarray[tuple[int, ...], dtype[float64]]], float | ndarray[tuple[int, ...], dtype[float64]]] | None)
temperature_fit_method (str | Callable[[float | ndarray[tuple[int, ...], dtype[float64]]], float | ndarray[tuple[int, ...], dtype[float64]]] | None)
- Return type:
DataTree
- scotty.get_parameters_for_Scotty(diagnostic, launch_freq_GHz=None, mirror_rotation=None, mirror_tilt=None, find_B_method=None, find_ne_method=None, equil_time=None, shot=None, user=None)#
Return default settings and parameters for the given diagnostic
- Parameters:
diagnostic –
Name of the diagnostic to load parameters for. One of:
"DBS_NSTX_MAST"Doppler reflectometry (Neal Crocker, Jon Hillesheim, Tony Peebles)
Used on MAST, was on loan from NSTX
"DBS_SWIP_MAST-U"Doppler reflectometry (Peng Shi)
"DBS_UCLA_MAST-U""CPS_UCLA_MAST-U"This system can either be used in CPS or DBS mode, but not both simultaneously (not yet, anyway)
CPS version not yet implemented
"hiK_Strath_MAST-U"High-k scattering diagnostic, Strathclyde (David Speirs, Kevin Ronald)
Not yet implemented
"DBS_synthetic"Circular flux surfaces
launch_freq_GHz (float | None) – Beam launch frequency in GHz
mirror_rotation (float | None) – Angle in degrees (FIXME: clarify)
mirror_tilt (float | None) – Angle in degrees (FIXME: clarify)
find_B_method (str | None) –
Equilibrium magnetic field method. One of:
"torbeam": Loads data from ne.dat and topfile. I guess I should implement loading for inbeam.dat at some point, too"UDA": Loads EFIT data directly from uda (not yet implemented)"EFITpp": Uses MSE constrained EFIT"UDA_saved": Loads EFIT data from file. UDA data must first be saved to said file
find_ne_method (str | None) –
Density profile method. One of:
"torbeam""EFITpp""UDA_saved"
equil_time (float | None) – Time in seconds
shot (int | None) – Shot number
user (str | None) – User profile settings
- scotty.open_analysis_npz(outputs, filename)#
Read a
analysis_output.npzfile created with a previous version of Scotty, v2.4.3 or earlier, returning an xarray dataset
- scotty.open_data_input_npz(filename)#
Read a
data_input.npzfile created with a previous version of Scotty, v2.4.3 or earlier, returning an xarray dataset
- scotty.open_data_output_npz(filename)#
Read a
data_output.npzfile created with a previous version of Scotty, v2.4.3 or earlier, returning an xarray dataset
Submodules#
- scotty.FindPsiBeam4 module
- scotty.PlotAllLocalisationLog module
- scotty.PlotInput module
- scotty.PlotPsiBC2 module
- scotty.beam_me_up module
- scotty.check_ModeConversion module
- scotty.check_input module
- scotty.check_output module
- scotty.compare_plot module
- scotty.density_fit module
- scotty.derivatives module
- scotty.fun_evolution module
- scotty.fun_general module
CartesianCoordsCylindricalCoordsK_magnitude()ToroidalCoordsangular_frequency_to_wavenumber()apply_continuous_BC()apply_discontinuous_BC()cartesian_to_cylindrical()cylindrical_to_cartesian()dot()find_Booker_alpha()find_Booker_beta()find_Booker_gamma()find_D()find_H_Cardano()find_H_numba()find_K_lab()find_K_lab_Cartesian()find_K_plasma()find_Psi_3D_lab()find_Psi_3D_lab_Cartesian()find_Psi_3D_plasma_continuous()find_Psi_3D_plasma_discontinuous()find_Rayleigh_length()find_ST_terms()find_area_points()find_d2B_dR2_CFD()find_d2B_dR2_FFD()find_d2B_dR_dZ_FFD()find_d2B_dZ2_CFD()find_d2B_dZ2_FFD()find_dB_dR_CFD()find_dB_dR_FFD()find_dB_dZ_CFD()find_dB_dZ_FFD()find_dbhat_dR()find_dbhat_dZ()find_distance_from_waist()find_electron_mass()find_epsilon_g()find_epsilon_para()find_epsilon_perp()find_inverse_2D()find_mode_flag_sign()find_nearest()find_normalised_gyro_freq()find_normalised_plasma_freq()find_q_lab()find_q_lab_Cartesian()find_quick_output()find_vec_lab_Cartesian()find_waist()find_widths_and_curvatures()find_x0()freq_GHz_to_angular_frequency()freq_GHz_to_wavenumber()genray_angles_from_mirror_angles()make_array_3x3()make_unit_vector_from_cross_product()mirrornorm_make()mirrornorm_make_with_rot_tilt_operators()modify_beam()propagate_beam()propagate_circular_beam()read_floats_into_list_until()reflector_make()reflector_make_from_mirrornorm()rot_trns_make()tilt_trns_RZ_make()tilt_trns_TZ_make()toroidal_to_cartesian()use_deg_args()
- scotty.geometry module
CircularCrossSectionFieldConstantCurrentDensityFieldCurvySlabFieldEFITFieldInterpolatedFieldInterpolatedField.B_R()InterpolatedField.B_T()InterpolatedField.B_Z()InterpolatedField.d2_poloidal_flux_dR2()InterpolatedField.d2_poloidal_flux_dRdZ()InterpolatedField.d2_poloidal_flux_dZ2()InterpolatedField.d_poloidal_flux_dR()InterpolatedField.d_poloidal_flux_dZ()InterpolatedField.poloidal_flux()
MagneticFieldMagneticField.B_R()MagneticField.B_T()MagneticField.B_Z()MagneticField.R_coordMagneticField.Z_coordMagneticField.d2_poloidal_flux_dR2()MagneticField.d2_poloidal_flux_dRdZ()MagneticField.d2_poloidal_flux_dZ2()MagneticField.d_poloidal_flux_dR()MagneticField.d_poloidal_flux_dZ()MagneticField.magnitude()MagneticField.poloidalFlux_gridMagneticField.poloidal_flux()MagneticField.unit()
- scotty.hamiltonian module
- scotty.hornpy module
- scotty.init_bruv module
DEFAULT_DIAGNOSTIC_PARAMETERSDENSITY_FIT_PARAMETERSDensityFitParametersLAUNCH_BEAM_METHODSLaunchBeamParametersbeam_settings()get_parameters_for_Scotty()launch_beam_DBS_CIEMAT_JT60A_data()launch_beam_DBS_NSTX_MAST_data()launch_beam_DBS_NSTX_MAST_horn_and_lens()launch_beam_DBS_SWIP_MAST_U_estimate_fix_w0()launch_beam_DBS_SWIP_MAST_U_estimate_var_w0()launch_beam_DBS_UCLA_DIII_D_240_thin_lens()launch_beam_DBS_UCLA_MAST_U_thin_lens()ne_settings()parameters_DBS_NSTX_MAST()parameters_DBS_SWIP_MAST_U()parameters_DBS_UCLA_DIII_D_240()parameters_DBS_UCLA_MAST_U()parameters_DBS_synthetic()user_settings()
- scotty.launch module
- scotty.lensalot module
- scotty.plot3_Torbeam_benchmark module
- scotty.plot3_pretty module
- scotty.plot4 module
- scotty.postmortem2 module
- scotty.ray_solver
- scotty.torbeam module
- scotty.typing module