def discretize_integrate_2D(model, x_range, y_range):
 from scipy.integrate import dblquad
 x = np.arange((x_range[0] - 0.5), (x_range[1] + 0.5))
 y = np.arange((y_range[0] - 0.5), (y_range[1] + 0.5))
 values = np.empty(((y.size - 1), (x.size - 1)))
 for i in range((x.size - 1)):
  for j in range((y.size - 1)):
   values[(j, i)] = dblquad(model, x[i], x[(i + 1)], (lambda x: y[j]), (lambda x: y[(j + 1)]))[0]
 return values

def discretize_integrate_2D ( model , x_range , y_range ) : from scipy . integrate import dblquad x = np . arange ( ( x_range [ 0 ] - 0.5 ) , ( x_range [ 1 ] + 0.5 ) ) y = np . arange ( ( y_range [ 0 ] - 0.5 ) , ( y_range [ 1 ] + 0.5 ) ) values = np . empty ( ( ( y . size - 1 ) , ( x . size - 1 ) ) ) for i in range ( ( x . size - 1 ) ) : for j in range ( ( y . size - 1 ) ) : values [ ( j , i ) ] = dblquad ( model , x [ i ] , x [ ( i + 1 ) ] , ( lambda x : y [ j ] ) , ( lambda x : y [ ( j + 1 ) ] ) ) [ 0 ] return values
discretize model by integrating the model over the pixel .