Hi everyone,
Does anyone know how to use real 2D data (on regular lat/lon grid) as initial condition in a mesh like this one?
thanks!!
p.s: To generate that figure I used the following code:
from dolfin import *
import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import interp2d
data = np.loadtxt('test.csv')
x,y,values = data[:,0], data[:,1], data[:,2]
interpolant = interp2d(x,y, values, kind='linear')
class MyExpression1(Expression):
def __init__(self, dado,*args, **kwargs):
self.dado = dado
def eval(self, values, x):
values[:] = self.dado(*x)
if(values[:]>5):
values[:] = 5
if(values[:] < -2):
values[:] = -2
mesh = Mesh("test.xml")
expression = MyExpression1(interpolant, degree=0, domain=mesh)
V = FunctionSpace(mesh, expression.ufl_element())
expression = interpolate(expression,V)
r = plot(expression)
plt.colorbar(r)
plot(mesh)
plt.show()
with the test.csv looking like:
6.061990000000000000e+05 -8.039260000000000000e+05 3
-2.800670000000000000e+05 -1.885540000000000000e+06 2
4.814150000000000000e+05 -8.780600000000000000e+05 3
-1.055750000000000000e+06 -3.797740000000000000e+05 -1
3.794040000000000000e+05 -1.073310000000000000e+06 2
-9.699220000000000000e+05 -1.430850000000000000e+06 1
4.433700000000000000e+05 -1.006770000000000000e+06 0
But to use a real 2D data I’m not able to figure out how to regrid regular grid to unstructured mesh.