예제 #1
0
def processCalibration(parentNode, tree):
    if (parentNode.isOn()):
        #If there exists a node with the dc offset removed, use that; otherwise, use the raw signal.
        try:
            dataNode = parentNode.getNode('dc_removed')
        except:
            dataNode = parentNode.getNode('raw')

        #Grab data and convert to native data type
        #		print(dataNode)
        y, t = myTools.getYX(dataNode)

        print("Got data from " + str(dataNode.getPath()))

        #Calibrate
        #Grab frequency-domain calibration
        H, fc = myTools.getYX(parentNode.getNode('cal_vs_freq'))

        #Compute calibrated output
        ycal = calibrateFourierDomain(y, t, H, fc)

        #Put calibrated data into tree.
        expr = Data.compile("BUILD_SIGNAL($VALUE, $1, $2)", ycal,
                            t)  #Build a TDI expression for storing signal
        parentNode.getNode('calibrated').putData(expr)

        print("Put data in " + str(parentNode.getNode('calibrated').getPath()))

        #Point node to calibrated data.
        parentNode.putData(
            Data.compile(str(parentNode.getNode('calibrated').getPath())))
        print("Pointed parent node to calibrated node.")

    else:
        print(parentNode.getPath() + ' is off - skipping.')
예제 #2
0
		y=numpy.array([0.0]) #Initialize array.
		scaleFac=1.0
		for myNode in nodeSubList :
			print(myNode)
			sigNode=sigTree.getNode(myNode)
		        #See if node is on; if it is off, skip and go to next.
			if( not(sigNode.isOn()) ) :
				print("Node, "+str(sigNode.getPath())+" is off; skipping and continuing")
				skipNode=True
				break
			else :
				skipNode=False

                        #Get signal of node.
			if(len(nodeSubList)==1) :
				y,t=getYX(sigNode)
			elif(len(nodeSubList)==2) :
				yTemp,t=getYX(sigNode)#"Output" signal
				y=y+scaleFac*yTemp
				scaleFac=scaleFac*1j
			else :
				yTemp,t=getYX(sigNode)#"Output" signal
				y=y+pow(yTemp,2)

		if(skipNode) :
			continue

		if(len(nodeSubList)>2) : y = sqrt(y)

		if(max(abs(y))==0.E0) : #If signal is dead - skip the node and move to next.
			print("Signal from "+sigNode.getPath()+"is zeroed out - skipping and moving on.")
sList = myTools.parseList(sys.argv[1])

#List of nodes in remaining command line arguments

stringArgs = sys.argv[2:]

#Loop through shots in list
for s in sList:
    print("Shot {0:d}".format(s))

    #Open magnetics tree to get Shoelace antenna signal.
    magTree = Tree('magnetics', s)

    #Get frequency points to extract range of frequencies.
    if (s < 1110000000):  #For Active MHD shots
        ftae, tftae = myTools.getYX(
            magTree.getNode('\MAGNETICS::TOP.ACTIVE_MHD.DPCS:FTAE_CALC'))
        deltaf = magTree.getNode('\MAGNETICS::TOP.ACTIVE_MHD.DPCS:DELTAF'
                                 ).getData().evaluate().data()
        tftae = numpy.linspace(tftae[0], tftae[-1], len(ftae))
        ftae = ftae[numpy.logical_and(tftae > 0.5, tftae < 1.5)]
        fpts = [min(ftae) - deltaf, max(ftae) + deltaf]
    else:
        fpts = magTree.getNode('shoelace.freq_program.freq_wave_hz').getData(
        ).evaluate().data()  #For Shoelace antenna work
    freqPad = 5.E3  #Extend frequency range by this amount - padding.
    fRange = numpy.array([min(fpts) - freqPad, max(fpts) + freqPad])

    #Get amplifier on and off times
    try:
        t1 = magTree.getNode('shoelace.rf_gate.on').getData().evaluate().data()
        t2 = magTree.getNode(
예제 #4
0
#Time before and after a plunge in which data is considered for radial decay. [s]
DeltaT=0.05

for s in sList :
	print("...Processing radial decay rate for Shot {0:d}".format(s))
	magTree=Tree('magnetics',s,'edit') #Edit to add nodes for fit parameters.
	edgeTree=Tree('edge',s)
	analysisTree=Tree('analysis',s)

	#Grab all nodes with plunging probe data
	allTransNodes=magTree.getNode('shoelace.trans_fun').getNodeWild('*')
	allProbeNodes=[allTransNodes[ii] for ii in myTools.find([re.search(".*BDOT.*",str(x.getPath()))!=None for x in allTransNodes])]

	try :
		rho, tRho = myTools.getYX(edgeTree.getNode('PROBES.ASP.MAG:RHO'))
		#There was a problem with some of the timebases - the number of data points was more than the number of timebase points
		tRho=linspace(tRho[0],tRho[-1],len(rho))

	except :
		print("Could not get radial position data for scanning probes for Shot {0:d}- skipping".format(s))
		continue

	#Get plunge times from Edge tree.
	tPlunge=[ myNode.getData().evaluate().data() for myNode in edgeTree.getNode('probes.asp').getNodeWild('time*')]

	for n in allProbeNodes :
		#Get Hilbert transform data for each probe.
		H,tH=myTools.getYX(n)

		#Fit a first-order polynomial for each plunge time
예제 #5
0
s1=1080000000
s2=1090000000
sList=getShotRange(s1,s2)

t1=0.5
t2=1.5

rgapCutoff=1.2 #Maximum rgap average
nl04Cutoff=1.2E20 #Minimum nl04 density (proxy for H-mode) level 

for s in sList :
	try :
		#Fetch RGAP data
		t=Tree('analysis',s)
		n=t.getNode('\ANALYSIS::EFIT_AEQDSK:Oright')
		rgap,trgap=getYX(n)

		t=Tree('electrons',s);
		nl04,tnl04 = getYX(t.getNode('tci.results:nl_04'));

		if( mean(rgap[logical_and(trgap>=t1,trgap<=t2)])<rgapCutoff and max( nl04[logical_and(tnl04>=t1,tnl04<=t2)] )>nl04Cutoff ) :
			#If shot might show an EDA on magnetics, record it in log
			myLogFile=open('/home/golfit/python/versionControlled/trunk/qcm/ShotsWithHmodeAndSmallGap.txt','a')
			myLogFile.write('{0:d}\n'.format(s))
			myLogFile.close()
	except :
		print('Could not process Shot {0:d}'.format(s))
	

print('Done with shot range, {0:d}-{1:d}'.format(s1,s2))
예제 #6
0
from MDSplus import *
from myTools import getYX

#Make a signal which changes freqency.  Calculate center frequency with calcCenterFreq.  Verify that it recovers frequency.

fs = 1E5  #Sampling frequency.
f0 = 1E3
f1 = 2E3
t = linspace(0, 1, fs)
f = ones(len(t)) * f0
f[t > 0.5] = f1

#y=cos(2*pi*f*t)+(random.rand(len(t))-0.5)*0.2
s = 1120712029
tree = Tree('pcilocal', s)
y, ty = getYX(tree.getNode('results.pci_07'))
fs = 1.0 / (ty[1] - ty[0])

[fp, tp] = getFPeak(y, fs, [50.E3, 200.E3], 1024)

print(fp)
print(tp)

print(size(fp, 0))
print(size(tp, 0))

print("Min Freq. = {0:f} [Hz]".format(min(fp)))

plt.plot(tp, fp)
plt.show()
#execfile('TestCalcCenterFreq.py')