<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Plotting ZDF data files
To Plot ZDF data files you must first import the ZDF module
Step1:  Next you need to read the data. You should also read the metadata while you are at it.
Step2:  data is a NumPy ndarray, info is a dictionary with all the Metadata.
Step3:  You can plot the data with any of your favorite tools.
Plotting with Bokeh
Step4:  Plotting with MatplotLib
Step5:  Working with particle data
The routines also work with particle data, that can be read using the zdf_read_particles command
Step6:  Particles is a dictionary of NumPy arrays containing all the particles quantities
Step7:  Again, you can plot the data with any of your favorite tools. Here's an example using Matplotlib
<ASSISTANT_TASK:>
Python Code:
from zdf import zdf_read_grid, zdf_read_particles
Explanation: Plotting ZDF data files
To Plot ZDF data files you must first import the ZDF module
End of explanation
(data, info) = zdf_read_grid( "J3-000500.zdf" )
Explanation: Next you need to read the data. You should also read the metadata while you are at it.
End of explanation
print(type(data))
print(info)
Explanation: data is a NumPy ndarray, info is a dictionary with all the Metadata.
End of explanation
import numpy as np
from bokeh.io import push_notebook, show, output_notebook
output_notebook()
from bokeh.plotting import figure
from bokeh.models import LinearColorMapper, BasicTicker, ColorBar
from bokeh.core.enums import TextBaseline
p = figure(x_range=(info['grid']['axis'][0]['min'], info['grid']['axis'][0]['max']), 
           y_range=(info['grid']['axis'][1]['min'], info['grid']['axis'][1]['max']),
           toolbar_sticky=False)
p.title.text = info['grid']['label']
p.xaxis.axis_label = info['grid']['axis'][0]['label']
p.yaxis.axis_label = info['grid']['axis'][1]['label']
color_map = LinearColorMapper(palette="Viridis256", low = np.amin(data), high = np.amax(data))
p.image(image=[data], x = 0, y = 0, 
        dw = info['grid']['axis'][0]['max'], dh = info['grid']['axis'][1]['max'], 
        color_mapper = color_map )
color_bar = ColorBar(color_mapper = color_map, ticker = BasicTicker(),
                     location = (0,0))
p.add_layout( color_bar, 'right')
t = show(p, notebook_handle = True)
Explanation: You can plot the data with any of your favorite tools.
Plotting with Bokeh
End of explanation
import matplotlib.pyplot as plt
%matplotlib notebook
fig = plt.figure( figsize = (8,6), dpi = 80)
fig.subplots_adjust( top = 0.85 )
fig.set_facecolor("#FFFFFF") 
timeLabel = r'$\sf{t = ' + str( info['iteration']['t'] ) + \
                     ' ['+info['iteration']['tunits']+r']}$'
plotTitle = r'$\sf{' + info['grid']['label'] + r'}$' + '\n' + timeLabel
plotArea = fig.add_subplot(1,1,1)
plotArea.set_title(plotTitle, fontsize = 16)
colorMap = plotArea.imshow(data, cmap = plt.cm.jet, interpolation = 'nearest', 
                           origin = 'lower')
colorBar = fig.colorbar(colorMap)
colorBar.set_label(r'$\sf{'+info['grid']['label'] +
        ' [' + info['grid']['units'] + r']}$', fontsize = 14)
xlabel = info['grid']['axis'][0]['label'] + '[' + info['grid']['axis'][0]['units'] + ']'
ylabel = info['grid']['axis'][1]['label'] + '[' + info['grid']['axis'][1]['units'] + ']'
plt.xlabel(r'$\sf{'+xlabel+r'}$', fontsize = 14)
plt.ylabel(r'$\sf{'+ylabel+r'}$', fontsize = 14)
Explanation: Plotting with MatplotLib
End of explanation
(particles, info) = zdf_read_particles("particles-electrons-001200.zdf")
Explanation: Working with particle data
The routines also work with particle data, that can be read using the zdf_read_particles command:
End of explanation
print(type(particles))
print(type(particles['x1']))
Explanation: Particles is a dictionary of NumPy arrays containing all the particles quantities
End of explanation
import matplotlib.pyplot as plt
%matplotlib notebook
x = particles['x1']
y = particles['u1']
plt.plot(x, y, 'r.', ms=1,alpha=0.5)
t = str(info["iteration"]["t"])
tunits = str(info["iteration"]["tunits"])
title = info['particles']['name'] + '  u_1 x_1'
timeLabel = r'$\sf{t = ' + t + ' [' + tunits + r']}$'
plt.title(r'$\sf{' + title + r'}$' + '\n' + timeLabel)
xlabel = 'x_1' + '[' + info['particles']['units']['x1'] + ']'
ylabel = 'u_1' + '[' + info['particles']['units']['u1'] + ']'
plt.xlabel(r'$\sf{' + xlabel + r'}$', fontsize=14)
plt.ylabel(r'$\sf{' + ylabel + r'}$', fontsize=14)
Explanation: Again, you can plot the data with any of your favorite tools. Here's an example using Matplotlib
End of explanation
<END_TASK>