I have a problem where I want to plot the determinant of a matrix as a function of parameters, so I have a script
def f(x, y):
DD = np.matrix([[0., 0.],[0., 0.]]) + 0.j
omega = x + 1.j * y
# set up dispersion matrix
DD[0,0] = 1 + omega
DD[1,0] = omega
DD[0,1] = omega
DD[1,1] = 1 - omega
metric = np.linalg.det(DD)
return metric
xx = np.arange(1., 2., 0.1)
yy = np.arange(1., 2., 0.1)
x, y = np.meshgrid(xx, yy)
FPlot = f(x, y)
plt.contourf(x, y, FPlot)
plt.show()
There is a type error where, since omega is a meshgrid, I can't stick it into the matrix or compute the determinant -- numpy demands scalars in matrices. What's the best way around this to get the right mesh and evaluated determinants?