-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel.py
More file actions
28 lines (25 loc) · 1000 Bytes
/
parallel.py
File metadata and controls
28 lines (25 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import numpy as np
import numpy.ma as ma
import xarray as xr
import netCDF4
from netCDF4 import Dataset
def calcmissed(procnum,qout,q2out,precipin,threshlow,startin,endin):
# if lowmem:
# print "using low memory version"
temp = np.float32(precipin.isel(time=slice(startin,endin)))
# else:
# temp = np.float64(precipnew.isel(time=slice(startin,endin)))
# if lowmem:
# print "using low memory version"
# temp = np.float32(precipnew.sel(time=str(yearin) + '-' + '{:02d}'.format(monthin)))
# else:
# temp = np.float64(precipnew.sel(time=str(yearin) + '-' + '{:02d}'.format(monthin)))
#print "number of bytes:" , temp.nbytes
temp2 = temp[np.where( temp >= threshlow)]
sum1 = np.nansum(temp) - np.nansum(temp2)
print procnum, "sum1", sum1
sum2 = np.nansum(temp)
print procnum, "sum2", sum2
del(temp,temp2)
qout.put(sum1)
q2out.put(sum2)