Commit d0a8f271 authored by Anthony's avatar Anthony
Browse files

numba alternative instead of Fortran call -> I will remove the fortran part when it's fully tested

parent 50779cac
...@@ -9,6 +9,7 @@ import codecs ...@@ -9,6 +9,7 @@ import codecs
import os import os
from inspect import currentframe, getframeinfo from inspect import currentframe, getframeinfo
import sys import sys
from numba import jit
# #
import F90tools as F90T import F90tools as F90T
# #
...@@ -327,6 +328,7 @@ class PlacedLocations : ...@@ -327,6 +328,7 @@ class PlacedLocations :
""" """
g0 = self.nbpt_glo[int(j)-1,int(i)-1] # -1 Because F -> C g0 = self.nbpt_glo[int(j)-1,int(i)-1] # -1 Because F -> C
b0 = int(k) b0 = int(k)
"""
mask = diagst.diagst.upstmask( mask = diagst.diagst.upstmask(
nbpt = self.nbpt, nbpt = self.nbpt,
nbasmax = self.nbasmax, nbasmax = self.nbasmax,
...@@ -338,6 +340,14 @@ class PlacedLocations : ...@@ -338,6 +340,14 @@ class PlacedLocations :
g0 = g0, g0 = g0,
b0 = b0, b0 = b0,
) )
"""
mask = diag_upstmask(
self.routetogrid,
self.routetobasin,
self.routenbintobas,
self.basin_area,
self.area,
g0,b0)
return mask return mask
def mask(self, index): def mask(self, index):
...@@ -352,3 +362,25 @@ class PlacedLocations : ...@@ -352,3 +362,25 @@ class PlacedLocations :
jj,ii = self.conv_land2ij[g] jj,ii = self.conv_land2ij[g]
mask[jj,ii] = min(mask_raw[g],1) mask[jj,ii] = min(mask_raw[g],1)
return mask return mask
@jit(nopython=True)
def diag_upstmask(routetogrid,routetobasin,routenbintobas,basin_area,area,g0,b0):
"""
Attention à l'indexation
"""
nbpt,nbasmax = routetobasin.shape
mask = np.zeros((nbpt))
for ig in range(nbpt):
nbas = routenbintobas[ig]
for ib in range(nbas):
jg = ig
jb = ib
while (jb < nbasmax):
if ((jg == g0-1) and (jb == b0-1)):
mask[ig] += basin_area[ig,ib]/area[ig]
jb = nbasmax
else:
jt = int(routetogrid[jg,jb]-1)
jb = int(routetobasin[jg,jb]-1)
jg = jt
return mask
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment