py4sci

Previous topic

Compensating Sensor - Coil Couplings

Next topic

Synthetic Diagnostics for Model-Data Comparisons

This Page

2D Mode Fitting Comparing Geometric Basis FunctionsΒΆ

"""

Example -- Comparing ModeFit Basis Functions
============================================

This script tests ModeFit fitting basis functions
using a large locking mode.

"""

import numpy as np
import magnetics
import d3dgeometry


#################################################### Motivational Geometry

fg,axg = magnetics.plt.subplots()
# DIII-D Vessel wall (LFS probes cover outer 5 segments)
d3dgeometry.vessel.plot1d(axes=axg)
# Sphere
x = np.linspace(0,2.43,100)
ys1 =list( np.sqrt(2.43**2-x**2))
ys2 =list(-np.sqrt(2.43**2-x**2))
xs = x.tolist()
axg.plot(xs+xs[::-1],ys1+ys2[::-1],label='Sphere')
# Cylinder
x = np.linspace(0.95,2.43,100)
yc1 =list(np.sqrt(0.7401**2-(x-1.69)**2))
yc2 =list(-np.sqrt(0.7401**2-(x-1.69)**2))
xc = x.tolist()
axg.plot(xc+xc[::-1],yc1+yc2[::-1],label='Cylinder')
axg.legend()

#################################################### Compare poloidal field fits

mpids = magnetics.differenced_arrays['LFS MPIDs'].deepcopy()
exclude=['MPID66M307']
mpids.set_data(154551)
mpids = mpids.remove_baseline(2900,2928,slope=False)
f,ax = magnetics.plt.subplots(3,2,figsize=(10,11))

# Cylindrical harmonics
# - ms can be positive and negative
for i,ms in enumerate([ (-8,8), (-8,0,8), (-8,0,0,8)]):
	mpids.fit.update(xlim=(2900,3000),geom='cyl',ns=[1],ms=ms,
					 exclude=exclude)
	f = mpids.fit.plot(dim=3,time=2940,axes=ax[i,0])
	ax[i,0].set_title('Cylindrical Harmonics, n=1, m={}'.format(mpids.fit.ms),
					  fontsize='small')

# Spherical harmonics
# - poloidal modes restricted to |m|>n
for i,ms in enumerate([ (-10,-1), (-10,-5,-1), (-10,-10,-5,-1)]):
	mpids.fit.update(xlim=(2900,3000),geom='sphere',ns=[1],ms=ms,
					 exclude=exclude)
	f = mpids.fit.plot(dim=3,time=2940,axes=ax[i,1])
	ax[i,1].set_title('Spherical Harmonics, n=1, m={}'.format(mpids.fit.ms),
					  fontsize='small')
	ax[i,1].set_title('Spherical Harmonics, n=1, m={}'.format(mpids.fit.ms),
					  fontsize='small')


# Compare above to local extrapolations of 1D Amp/Phase
mpidlocal = magnetics.bp_differenced_arrays_LFS
for name,magarr in mpidlocal.iteritems():
	magarr.set_data(154551)
	magarr=magarr.remove_baseline(2900,2928,slope=False)
	magarr.fit.update(xlim=(2900,3000),ns=[1],ms=[0],exclude=exclude)
	mpidlocal[name]=magarr
locfit = magnetics.LocalFit(mpidlocal)
floc = locfit.plot(1,time=2940,order=3,wavenum=False)
floc.set_size_inches(10,8)

magnetics.plt.show()

(Source code)