scotty.fun_general module
scotty.fun_general module#
Created on Fri Jun 8 10:44:34 2018
Functions for Scotty (excluding functions for finding derivatives of H).
@author: chenv Valerian Hongjie Hall-Chen valerian@hall-chen.com
Run in Python 3, does not work in Python 2
- scotty.fun_general.contract_special(arg_a, arg_b)#
Takes Either:
matrix of TxMxN and a vector of TxN or TxM For each T, contract the matrix with the vector
- Or:
two vectors of size TxN
For each T, contract the indices N Covers the case that matmul and dot don’t do very elegantly Avoids having to use a for loop to iterate over T
- scotty.fun_general.find_Booker_alpha(electron_density, B_Total, sin_theta_m_sq, launch_angular_frequency)#
- scotty.fun_general.find_Booker_beta(electron_density, B_Total, sin_theta_m_sq, launch_angular_frequency)#
- scotty.fun_general.find_Booker_gamma(electron_density, B_Total, launch_angular_frequency)#
- scotty.fun_general.find_D(K_magnitude, launch_angular_frequency, epsilon_para, epsilon_perp, epsilon_g, theta_m)#
- scotty.fun_general.find_H(q_R, q_Z, K_R, K_zeta, K_Z, launch_angular_frequency, mode_flag, interp_poloidal_flux, find_density_1D, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_H_Cardano(K_magnitude, launch_angular_frequency, epsilon_para, epsilon_perp, epsilon_g, theta_m)#
- scotty.fun_general.find_H_numba(K_magnitude, electron_density, B_Total, sin_theta_m_sq, launch_angular_frequency, mode_flag)#
- scotty.fun_general.find_K_lab(K_lab_Cartesian, q_lab_Cartesian)#
- scotty.fun_general.find_K_lab_Cartesian(K_lab, q_lab)#
- scotty.fun_general.find_Psi_3D_lab(Psi_3D_lab_Cartesian, q_R, q_zeta, K_R, K_zeta)#
Converts Psi_3D from Cartesian to cylindrical coordinates, both in the lab frame (not the beam frame)
- scotty.fun_general.find_Psi_3D_lab_Cartesian(Psi_3D_lab, q_R, q_zeta, K_R, K_zeta)#
Converts Psi_3D from cylindrical to Cartesian coordinates, both in the lab frame (not the beam frame) The shape of Psi_3D_lab must be either [3,3] or [numberOfDataPoints,3,3]
- scotty.fun_general.find_Psi_3D_plasma(Psi_vacuum_3D, dH_dKR, dH_dKzeta, dH_dKZ, dH_dR, dH_dZ, d_poloidal_flux_d_R, d_poloidal_flux_d_Z)#
- scotty.fun_general.find_Rayleigh_length(waist, wavenumber)#
- scotty.fun_general.find_ST_terms(tau_array, K_magnitude_array, k_perp_1_bs, g_magnitude_Cardano, g_magnitude_output, theta_m_output, M_w_inv_xx_output)#
- scotty.fun_general.find_area_points(xs, ys, fraction_wanted)#
ys = f(xs)
Finds the maximum in ys, and finds an area around that Used to find localisation
Assume xs sorted in ascending order
- scotty.fun_general.find_d2B_dR2_CFD(q_R, q_Z, delta_R, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d^2 B}{d R^2}, where B is the magnitude of the B field
- scotty.fun_general.find_d2B_dR2_FFD(q_R, q_Z, delta_R, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d B}{d Z}, where B is the magnitude of the B field
- scotty.fun_general.find_d2B_dR_dZ_FFD(q_R, q_Z, delta_R, delta_Z, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_d2B_dZ2_CFD(q_R, q_Z, delta_Z, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_d2B_dZ2_FFD(q_R, q_Z, delta_Z, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_d2_poloidal_flux_dR2(q_R, q_Z, delta_R, interp_poloidal_flux)#
- scotty.fun_general.find_d2_poloidal_flux_dZ2(q_R, q_Z, delta_Z, interp_poloidal_flux)#
- scotty.fun_general.find_dB_dR_CFD(q_R, q_Z, delta_R, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d B}{d Z}, where B is the magnitude of the B field
- scotty.fun_general.find_dB_dR_FFD(q_R, q_Z, delta_R, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d B}{d Z}, where B is the magnitude of the B field
- scotty.fun_general.find_dB_dZ_CFD(q_R, q_Z, delta_Z, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d B}{d Z}, where B is the magnitude of the B field
- scotty.fun_general.find_dB_dZ_FFD(q_R, q_Z, delta_Z, find_B_R, find_B_T, find_B_Z)#
Finds
ract{d B}{d Z}, where B is the magnitude of the B field
- scotty.fun_general.find_d_poloidal_flux_dR(q_R, q_Z, delta_R, interp_poloidal_flux)#
- scotty.fun_general.find_d_poloidal_flux_dZ(q_R, q_Z, delta_Z, interp_poloidal_flux)#
- scotty.fun_general.find_dbhat_dR(q_R, q_Z, delta_R, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_dbhat_dZ(q_R, q_Z, delta_Z, find_B_R, find_B_T, find_B_Z)#
- scotty.fun_general.find_distance_from_waist(width, wavenumber, curvature)#
- scotty.fun_general.find_epsilon_g(electron_density, B_Total, launch_angular_frequency)#
- scotty.fun_general.find_epsilon_para(electron_density, launch_angular_frequency)#
- scotty.fun_general.find_epsilon_perp(electron_density, B_Total, launch_angular_frequency)#
- scotty.fun_general.find_inverse_2D(matrix_2D)#
- scotty.fun_general.find_nearest(array, value)#
- scotty.fun_general.find_normalised_gyro_freq(B_Total, launch_angular_frequency)#
- scotty.fun_general.find_normalised_plasma_freq(electron_density, launch_angular_frequency)#
- scotty.fun_general.find_q_lab(q_lab_Cartesian)#
- scotty.fun_general.find_q_lab_Cartesian(q_lab)#
- scotty.fun_general.find_quick_output(ray_parameters_2D, K_zeta_initial, find_B_R, find_B_T, find_B_Z)#
Finds mismatch at cut-off location Cut-off location where K is minimised
- scotty.fun_general.find_vec_lab_Cartesian(vec_lab, q_zeta)#
- scotty.fun_general.find_waist(width, wavenumber, curvature)#
- scotty.fun_general.find_widths_and_curvatures(Psi_xx, Psi_xy, Psi_yy, K_magnitude)#
- scotty.fun_general.find_x0(xs, ys, y0)#
xs,ys are the x and y coordinates of a line on a plane Finds the value of x corresponding to a certain y0 This implementation is silly but I am impatient and want to move on to other things quickly
- scotty.fun_general.freq_GHz_to_wavenumber(freq_GHz)#
Converts frequency in GHz to wavenumber
- scotty.fun_general.genray_angles_from_mirror_angles(rot_ang_deg, tilt_ang_deg, offset_for_window_norm_to_R=3.0)#
Input args are steering mirror rotation and tilt angles in degrees (rot_ang_deg,tilt_ang_deg). rot_ang_deg,tilt_ang_deg = 0,0 imply beam propagates in negative window normal direction. optional keyword offset_for_window_norm_to_R gives toroial angle (in degrees) of window normal to major radial direction, so for rot_ang_deg,tilt_ang_deg = 0,0, beam would have toroidal angle given by offset_for_window_norm_to_R.
can get from rot_ang_deg,tilt_ang_deg buy using toroidal and poloidal “genray angles” (tor_ang, pol_ang) in IDL savefile log (/u/jhilles/DBS/dbs_logbook_2013.idl). The angles were calculated according to the logic:
tor_ang = 3.0 - rot_ang_deg pol_ang = tilt_ang_deg
- scotty.fun_general.make_unit_vector_from_cross_product(vector_a, vector_b)#
Assume np.shape(vector_a) = np.shape(vector_b) = (n,3) or np.shape(vector_a) = (n,3) , np.shape(vector_b) = (3)
- scotty.fun_general.mirrornorm_make(r, t)#
makes norm vector for mirror directly using angles in radians
- scotty.fun_general.mirrornorm_make_with_rot_tilt_operators(r, t)#
makes norm vector for mirror using rot and tilt operators given angles in radians
- scotty.fun_general.modify_beam(width, curvature, freq_GHz, z0_shift, w0_shift)#
positive z0_shift moves the waist in the direction of -infinity
- scotty.fun_general.propagate_beam(Psi_w_initial_cartesian, propagation_distance, freq_GHz)#
Uses the vacuum solution of the beam tracing equations to propagate the beam Works for arbitrary Gaussian beam in vacuum
- scotty.fun_general.propagate_circular_beam(width, curvature, propagation_distance, freq_GHz)#
w0 : Width of beam waist
- scotty.fun_general.read_floats_into_list_until(terminator, lines)#
Reads the lines of a file until the string (terminator) is read.
Currently used to read topfile.
Written by NE Bricknell
- Parameters
- Return type
numpy.ndarray[Any, numpy.dtype[numpy.float64]]
- scotty.fun_general.reflector_make(r, t)#
makes relector matrix for mirror using angles in radians
- scotty.fun_general.reflector_make_from_mirrornorm(mirrornorm)#
makes relector matrix for mirror using norm vector for mirror
- scotty.fun_general.rot_trns_make(r)#
rotates R ([1,0,0]) into T ([0,1,0]) using angle in radians
- scotty.fun_general.tilt_trns_RZ_make(t)#
tilts R ([1,0,0]) in to Z ([0,0,1]) using angle in radians
- scotty.fun_general.tilt_trns_TZ_make(t)#
tilts T ([1,0,0]) in to Z ([0,0,1]) using angle in radians
- scotty.fun_general.use_deg_args(func, *args, **kwargs)#
transform args from degrees to radians before calling