<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 A simple function with dependence on only one independent variable might be written to a file like this
Step1:  or like this
Step2:  Note the use of np.linspace to give you uniform grid spacing for your data points.
Making two dimensional data is a bit more involved.  In the case below we create a set of $(x,y)$ pairs and then use np.meshgrid to facilitate vectorizing the calculation of the value stored in z3.  For this function we use the discrete values of X and Y to compute the quantity
Step3:  The benefit in using the np.savetxt function is that you can use the inverse np.loadtxt easily.  Here we load the test data file back into a variable testZ and pass that array to an image.
<ASSISTANT_TASK:>
Python Code:
x1 = np.linspace(0, 10, 9)
y1 = x1**2
np.savetxt('test_data_001.txt', (x1,y1))
Explanation: A simple function with dependence on only one independent variable might be written to a file like this:
End of explanation
x2 = np.linspace(0, 1, 100)
y2 = np.exp(x)
np.savetxt('test_data_002.txt', (x2,y2))
Explanation: or like this:
End of explanation
x3 = np.linspace(0, 10, 100)
y3 = np.linspace(0, 10, 100)
X, Y = np.meshgrid(x3, y3)
z3 = np.sin(X)**2*np.cos(Y)**2
np.savetxt('test_data_003.txt', (z3))
Explanation: Note the use of np.linspace to give you uniform grid spacing for your data points.
Making two dimensional data is a bit more involved.  In the case below we create a set of $(x,y)$ pairs and then use np.meshgrid to facilitate vectorizing the calculation of the value stored in z3.  For this function we use the discrete values of X and Y to compute the quantity:
$$\sin(X) \cos(Y)^2$$
We store this in z3 and write to a file.
End of explanation
%matplotlib notebook
import matplotlib.pyplot as plt
from matplotlib import cm
testZ = np.loadtxt('test_data_003.txt')
# Make plot with vertical (default) colorbar
fig, ax = plt.subplots()
cax = ax.imshow(testZ, interpolation='nearest', cmap=cm.coolwarm)
ax.set_title('Scalar Field')
plt.show()
Explanation: The benefit in using the np.savetxt function is that you can use the inverse np.loadtxt easily.  Here we load the test data file back into a variable testZ and pass that array to an image.
End of explanation
<END_TASK>