def run(day, shot, t0 = 25, tf = 75, sample_Freq = 5, show = True): """ Main animating function. Update paramters like day and shot, as well as start and end times To make this code work with a different set up, you will need to: - update the calibration used in pmd (process_mag_data_4x4) - create new probe locations function (vp.get_probeLocs). That's it! --KG 07/15/19 """ # day = '061219'#'062618'#'101917' # shot = 13#85 shot = day+'r'+ str(shot) #'40'# timeb,b = pmd.get_Bxy_vecRendering_format_lookup(shot) ######### fixing bounds using a function called fix_bounds ########## t_index, t = my.fix_bounds(np.array((t0, tf)), timeb) #Find what start and end index correspond to the right times t0 = t_index[0] tf = t_index[-1] b = b[:,:,t0:tf] probe_locs = vp.get_probeLocs_SSX_setup_cm(num_probes = 16) #convert things to time vs probes instead of probes vs time #and also thin the time x = b[0,:,:].T[0:-1:sample_Freq] y = b[1,:,:].T[0:-1:sample_Freq] z = b[2,:,:].T[0:-1:sample_Freq] t = timeb[t0:tf][0:-1:sample_Freq] # path = os.getcwd() + '\\' + 'Magnetic_animations\\' path = os.getcwd() + '\\data\\2019\\' +day+'\\Analyzed\\' ############################################## ######## Plotting the magnetic field vector rendering ############ Bmag = BField_mag_Animator(shot,t,probe_locs,x,y,z)#Instantiate the BField_xy_Animator Object Bmag._set_flags([8,10,12]) #some probes have questionable directions Bmag._set_dead([0])#probe has dead z- component # Bmag._set_Plot_title("\nWest Gun lagging by 1 $\\mu$s") # Bmag._set_Plot_title("\nWest Gun leading by 5 $\\mu$s") # B.gen_Arrows(30) animat = Bmag.make_animation() #Now create an animation # animation.save('test.mp4', writer="ffmpeg") Bmag.save_animation(path,animat) #Save the animation if show: plt.show()
def snapshot(day, shot, at_time, t0=25, tf=75, sample_Freq=1, show=True): shot = day + 'r' + str(shot) #'40'# timeb, b = pmd.get_Bxy_vecRendering_format_lookup(shot) ######## fixing bounds using a function called fix_bounds ########## t_index, t = my.fix_bounds(np.array((t0, tf)), timeb) # Find what start and end index correspond to the right times t0 = t_index[0] tf = t_index[-1] b = b[:, :, t0:tf] probe_locs = vp.get_probeLocs_SSX_setup_cm(num_probes=16) #convert things to time vs probes instead of probes vs time #and also thin the time x = b[0, :, :].T[0:-1:sample_Freq] y = b[1, :, :].T[0:-1:sample_Freq] z = b[2, :, :].T[0:-1:sample_Freq] t = timeb[t0:tf][0:-1:sample_Freq] # path = os.getcwd() + '\\' + 'Magnetic_animations\\' path = os.getcwd() + '\\data\\2019\\' + day + '\\Analyzed\\' ############################################## ######## Plotting the magnetic field vector rendering ############ Bmag = BField_mag_Animator(shot, t, probe_locs, x, y, z) #Instantiate the BField_xy_Animator Object Bmag._set_flags([8, 10, 12]) #some probes have questionable directions Bmag._set_dead([0]) #probe has dead z- component # Bmag._set_Plot_title("\nWest Gun lagging by 1 $\\mu$s") # Bmag._set_Plot_title("\nWest Gun leading by 5 $\\mu$s") t_index = my.tindex_center(t, at_time) Bmag.gen_Arrows(t_index) fName = os.getcwd() + '\\generated_images\\' + str(shot) + "-" + str( at_time) + "us.png" plt.savefig(fName, dpi=800, facecolor='w', edgecolor='k') if show: plt.show()
def snapshot(day, shot, t, t0 = 25, tf = 75, sample_Freq = 5): shot = day+'r'+ str(shot) #'40'# timeb,b = pmd.get_Bxy_vecRendering_format_lookup(shot) ######### fixing bounds using a function called fix_bounds ########## t_index, t = my.fix_bounds(np.array((t0, tf)), timeb) #Find what start and end index correspond to the right times t0 = t_index[0] tf = t_index[-1] b = b[:,:,t0:tf] probe_locs = vp.get_probeLocs_SSX_setup_cm(num_probes = 16) #convert things to time vs probes instead of probes vs time #and also thin the time x = b[0,:,:].T[0:-1:sample_Freq] y = b[1,:,:].T[0:-1:sample_Freq] z = b[2,:,:].T[0:-1:sample_Freq] t = timeb[t0:tf][0:-1:sample_Freq] # path = os.getcwd() + '\\' + 'Magnetic_animations\\' path = os.getcwd() + '\\data\\2019\\' +day+'\\Analyzed\\' ############################################## ######## Plotting the magnetic field vector rendering ############ Bmag = BField_mag_Animator(shot,t,probe_locs,x,y,z)#Instantiate the BField_xy_Animator Object Bmag._set_flags([8,10,12]) #some probes have questionable directions Bmag._set_dead([0])#probe has dead z- component # Bmag._set_Plot_title("\nWest Gun lagging by 1 $\\mu$s") # Bmag._set_Plot_title("\nWest Gun leading by 5 $\\mu$s") B.gen_Arrows(t) # animat = Bmag.make_animation() #Now create an animation # animation.save('test.mp4', writer="ffmpeg") # Bmag.save_animation(path,animat) #Save the animation if show: plt.show()
def main(): # day = '061219'#'062618'#'101917' # shot = 13#85 day ='050119' shot = 23 dir = 2 if day == '050119': if (shot >= 16 and shot <=20): dir = 0 elif (shot >= 21 and shot <=25): dir = 1 elif(shot >= 11 and shot <=15): dir = 2 # print(dir) else: print('Program will run as if it was in Z-dir. If this is a mistake,please check the shotnumber') shot = day+'r'+ str(shot) #'40'# timeb,b = pmd.get_Bxy_vecRendering_format(shot) # timeb=timeb-timeb[0]-2 # timeb = time ######### fixing bounds using a function called fix_bounds ########### t0 = 5 tf = 90 t_index, t = my.fix_bounds(np.array((t0, tf)), timeb) #just trying to find what start and end index correspond to the right times t0 = t_index[0] tf = t_index[-1] sample_Freq = 20 # sampling frequency b = b[:,:,t0:tf] # b # probe_locs = vp.get_probeLocs_SSX_setup(num_probes) probe_locs = vp.get_probeLocs_calib_setup(dir =2, num_probes = 16) #convert things to time x probes instead of probes x time #and also thin the time x = b[0,:,:].T[0:-1:sample_Freq] y = b[1,:,:].T[0:-1:sample_Freq] z = b[2,:,:].T[0:-1:sample_Freq] t = timeb[t0:tf][0:-1:sample_Freq] path = os.getcwd() + '\\' + 'Magnetic_animations\\' ############################################## ######## Plotting the magnetic field vector rendering ############ Bmag = BField_mag_Animator(shot,t,probe_locs,x,y,z, dir)#Instantiate the BField_xy_Animator Object Bmag._set_Plot_title("\nCalibration in Y-dir") # Bmag._set_Plot_title("\nWest Gun leading by 5 $\\mu$s") animation = Bmag.make_animation() #Now create an animation # Bmag.save_animation(path,animation) #Save the animation plt.show()
############################################## #shot = '020618r2' day = '061219'#''051917'# shot = day+'r13'#'40'# t0 = 35 tf = 150 # time,bdot,timeb,b,bmod, data = mj.process_mjmag_data(shot) time,timeb,b,bmod, data = pmd.get_Bxy_vecRendering_format(shot) timeb=timeb-timeb[0]-2 ######### fixing bounds using a function called fix_bounds ########### t_index, t = my.fix_bounds(np.array((t0, tf)), timeb) t0 = t_index[0] tf = t_index[-1] sample_Freq = 10 # sampling frequency N = 16 b = b[:,:,t0:tf] s = np.arange(N) * 1.5# - 2.86 x = b[0,0:N,:].T[0:-1:sample_Freq] y = b[1,0:N,:].T[0:-1:sample_Freq] t = timeb[t0:tf][0:-1:sample_Freq] path = 'Data\\2018\\'+day+'\\'+day+'-Analysed\\' ############### Plotting the Bx and By vector rendering ##############################