1212def parallel_client (cpu_params = dict (tpw = 2 ,nw = 4 ,ml = 7.5 )):
1313 """
1414 Create client kernel for parallel computing
15-
15+ ====================================================
1616 INPUT:
1717 -> cpu_params: dict containing floats with keys
1818 -> tpw: threads_per_worker
1919 -> nw: n_workers
2020 -> ml: memory_limit per worker [GB]
2121 OUTPUT:
2222 -> client: configuration of parallel computing
23+ ====================================================
2324 """
2425
2526 client = Client (threads_per_worker = cpu_params ['tpw' ],
@@ -33,19 +34,21 @@ def parallel_client(cpu_params=dict(tpw=2,nw=4,ml=7.5)):
3334#=============================================================================
3435def argdistnear (x ,y ,xi ,yi ):
3536 '''
36- This function finds the index to nearest points in (xi,yi) from (x,y).
37-
38- usage:
37+ This function finds the index to nearest points in (xi,yi) from (x,y)
38+ ======================================================================
39+
40+ USAGE:
3941 x,y = [5,1,10],[2,6,3]
4042 xi,yi = np.linspace(0,19,20),np.linspace(-5,30,20)
4143 ind = argdistnear(x,y,xi,yi)
4244
4345 INPUT:
44- --> (x,y): points [list]
45- --> (xi,yi): series to search nearest point [list]
46-
47- Iury T.Simões-Sousa
48- (IO-USP/ UMass-Dartmouth)
46+ (x,y) = points [list]
47+ (xi,yi) = series to search nearest point [list]
48+
49+ OUTPUT:
50+ ind = index of the nearest points
51+ ======================================================================
4952 '''
5053
5154 idxs = [np .argmin (np .sqrt ((xi - xx )** 2 + (yi - yy )** 2 )) for xx ,yy in zip (x ,y )]
@@ -59,36 +62,39 @@ def argdistnear(x,y,xi,yi):
5962def meaneddy (prop ,days = 60 ,ndim = 1 ,DataArray = False ,timedim = None ):
6063
6164 """
62- Apply a low-pass filter (scipy.signal.butter) to 'prop' and obtain the mean and eddy components.
63-
64- usage [1]:
65- Velocity = np.random.randn(365,17,13) # one year, 17 lat x 13 lon domain
66- Filtered, Residual = meaneddy(Velocity, days=10, ndim=3, DataArray=False,timedim=None)
65+ Apply a low-pass filter (scipy.signal.butter) to 'prop' and obtain the
66+ mean and eddy components.
67+ ==========================================================================
68+
69+ USAGE [1]:
70+ # np.array() one year, 17 lat x 13 lon domain
71+ Velocity = np.random.randn(365,17,13)
72+ Filtered, Residual = meaneddy(Velocity, days=10, ndim=3,
73+ DataArray=False,timedim=None)
6774
68- usage [2]:
69- Velocity = xr.DataArray(data=np.random.randn(365,17,13), dims=["time","lat","lon"],
70- coords=dict(time=(["time"],range(0,365)), lat=(["lat"],np.arange(-4,4.5,0.5)), lon=(["lon"],np.arange(1,7.5,0.5)))) # one year, 17 lat x 13 lon domain
71- Filtered, Residual = meaneddy(Velocity, days=10, DataArray=True,timedim=["time"])
72-
75+ USAGE [2]:
76+ # xr.DataArray() one year, 17 lat x 13 lon domain
77+ Velocity = xr.DataArray(data=np.random.randn(365,17,13),
78+ dims=["time","lat","lon"],
79+ coords=dict(time=(["time"],range(0,365)),
80+ lat=(["lat"],np.arange(-4,4.5,0.5)),
81+ lon=(["lon"],np.arange(1,7.5,0.5))))
82+ Filtered, Residual = meaneddy(Velocity, days=10,
83+ DataArray=True,timedim=["time"])
7384
7485 INPUT:
75- -> prop: 1, 2 or 3D array to filter
76- -> days: number of days to set up the filter
77- -> ndim: number of dimensions of the data [only used for DataArray=False, max:3]
78- -> DataArray: True if prop is in xr.DataArray format
79- -> dim: name of time dimension to filter (only used for DataArray=True)
86+ prop = 1, 2 or 3D array to be filtered
87+ days = number of days to set up the filter
88+ ndim = number of dimensions of the data
89+ [only used for DataArray=False, max:3]
90+ DataArray = True if prop is in xr.DataArray format
91+ dim = name of time dimension to filter
92+ [only used for DataArray=True]
8093
8194 OUTPUT:
82- -> m_prop: mean (filtered) part of the property
83- -> p_prop: prime part of the property, essentially prop - m_prop
84-
85- v1 (February 2018)
86- Cesar B. Rocha
87- Dante C. Napolitano ([email protected] ) 88-
89- v2 (December 2020)
90- Dante C. Napolitano ([email protected] ) 91- Mariana M. Lage ([email protected] ) 95+ m_prop = mean (filtered) part of the property
96+ p_prop = prime part of the property, essentially prop - m_prop
97+ ==========================================================================
9298 """
9399
94100 # creating filter
0 commit comments