viscid.dipole module¶
A collection of tools for dipoles
- 
viscid.dipole.guess_dipole_moment(b, r=2.0, strength=32707.5292732387, cap_angle=40, cap_ntheta=121, cap_nphi=121, plot=False)[source]¶
- guess dipole moment from a B field 
- 
viscid.dipole.make_dipole(m=(0, 0, -32707.5292732387), strength=None, l=None, h=None, n=None, center='cell', dtype='f8', twod=False, nonuniform=False, crd_system='gse', name='b')[source]¶
- Generate a dipole field with magnetic moment m [x, y, z] 
- 
viscid.dipole.fill_dipole(B, m=(0, 0, -32707.5292732387), strength=None, mask=None)[source]¶
- set B to a dipole with magnetic moment m - Parameters: - B (Field) – Field to fill with a dipole
- m (ndarray, or datetime64-like) – Description
- strength (float) – if given, rescale the dipole moment even if it was given explicitly
- mask (Field) – boolean field as mask, B will be filled where the mask is True
 - Returns: - B - Return type: - Field 
- 
viscid.dipole.calc_dip(pts, m=(0, 0, -32707.5292732387), strength=None, crd_system='gse', dtype=None)[source]¶
- Calculate a dipole field at various points - Parameters: - pts (ndarray) – Nx3 array of points at which to calculate the dipole. Should use the same crd system as m
- m (sequence, datetime) – dipole moment
- strength (None, float) – If given, rescale m to this magnitude
- crd_system (str) – Something from which cotr can divine the coordinate system for both pts and m. This is only used if m is given as a datetime and we need to figure out the dipole moment at a given time in a given crd system
- dtype (str, np.dtype) – dtype of the result, defaults to the same datatype as pts
 - Returns: - Nx3 dipole field vectors for N points - Return type: - ndarray 
- 
viscid.dipole.set_in_region(a, b, alpha=1.0, beta=1.0, mask=None, out=None)[source]¶
- set ret = alpha * a + beta * b where mask is True 
- 
viscid.dipole.make_spherical_mask(fld, rmin=0.0, rmax=None, rsq=None)[source]¶
- make a mask that is True between rmin and rmax 
- 
viscid.dipole.xyz2lsrlp(pts, cotr=None, crd_system='gse')[source]¶
- Ceovert x, y, z -> l-shell, r, lambda, phi [sm coords] - r, theta, phi = viscid.cart2sph(pts in x, y, z)
- lambda = 90deg - theta
- r = L cos^2(lambda)
 - Parameters: - pts (ndarray) – 3xN for N (x, y, z) points
- cotr (None) – if given, use cotr to perform mapping to / from sm
- crd_system (str) – crd system of pts
 - Returns: - 4xN array of N (l-shell, r, lamda, phi) points - Return type: - ndarray 
- 
viscid.dipole.dipole_map(pts, r=1.0, cotr=None, crd_system='gse', as_spherical=False)[source]¶
- Map pts along an ideal dipole to radius r - lambda = 90deg - theta; r = L cos^2(lambda) - cos^2(lambda) = cos^2(lambda_0) * (r / r_0) - Parameters: - pts (ndarray) – 3xN for N (x, y, z) points
- r (float) – radius to map to
- cotr (None) – if given, use cotr to perform mapping to / from sm
- crd_system (str) – crd system of pts
- as_spherical (bool) – if True, then the return array is (t, theta, phi) with theta in the range [0, 180] and phi [0, 360] (in degrees)
 - Returns: - 3xN array of N (x, y, z) points all at a distance
- r_mapped from the center of the dipole 
 - Return type: - ndarray 
- 
viscid.dipole.dipole_map_value(fld, pts, r=1.0, fillna=None, cotr=None, crd_system=None, interp_kind='linear')[source]¶
- Map values assuming they’re constant along ideal dipole lines - Parameters: - fld (Field) – values to interpolate onto the mapped pts
- pts (ndarray) – 3xN for N (x, y, z) points that will be mapped
- r (float) – radius of resulting map
- cotr (None) – if given, use cotr to perform mapping in sm
- crd_system (str) – crd system of pts
- interp_kind (str) – how to interpolate fld onto source points
 - Returns: - ndarray of mapped values, one for each of the N points - Return type: - ndarray