mirror of
https://github.com/meteoinfo/MeteoInfo.git
synced 2025-12-08 20:36:05 +00:00
add column_stack and row_stack functions
This commit is contained in:
parent
c16a807b40
commit
86850747f1
@ -1,7 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<MeteoInfo File="milconfig.xml" Type="configurefile">
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\satellite\gpm">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
<Path OpenPath="D:\Working\MIScript\Jython\mis\array">
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array\complex"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\traj"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\map"/>
|
||||
@ -16,21 +15,20 @@
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\cloudsat"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\satellite\gpm"/>
|
||||
<RecentFolder Folder="D:\Working\MIScript\Jython\mis\array"/>
|
||||
</Path>
|
||||
<File>
|
||||
<OpenedFiles>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<OpenedFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_proj.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\cloudsat\CloudSAT_Swath.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\gpm\GPM_DPRGMI_3d.py"/>
|
||||
<OpenedFile File="D:\Working\MIScript\Jython\mis\satellite\gpm\GPM_DPRGMI_cross.py"/>
|
||||
</OpenedFiles>
|
||||
<RecentFiles>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\_reload.py"/>
|
||||
<RecentFile File="D:\MyProgram\java\MeteoInfoDev\toolbox\meteoview3d\mainGUI.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\io\radar\radar_bin_proj.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\cloudsat\CloudSAT_Swath.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\gpm\GPM_DPRGMI_3d.py"/>
|
||||
<RecentFile File="D:\Working\MIScript\Jython\mis\satellite\gpm\GPM_DPRGMI_cross.py"/>
|
||||
</RecentFiles>
|
||||
</File>
|
||||
<Font>
|
||||
|
||||
Binary file not shown.
@ -1,7 +1,9 @@
|
||||
from ..core import numeric as _nx
|
||||
from ..core.numeric import asanyarray, normalize_axis_tuple
|
||||
from ..core import vstack
|
||||
|
||||
__all__ = [
|
||||
'expand_dims'
|
||||
'expand_dims','column_stack','row_stack'
|
||||
]
|
||||
|
||||
def expand_dims(a, axis):
|
||||
@ -73,4 +75,50 @@ def expand_dims(a, axis):
|
||||
shape_it = iter(a.shape)
|
||||
shape = [1 if ax in axis else next(shape_it) for ax in range(out_ndim)]
|
||||
|
||||
return a.reshape(shape)
|
||||
return a.reshape(shape)
|
||||
|
||||
|
||||
row_stack = vstack
|
||||
|
||||
|
||||
def column_stack(tup):
|
||||
"""
|
||||
Stack 1-D arrays as columns into a 2-D array.
|
||||
|
||||
Take a sequence of 1-D arrays and stack them as columns
|
||||
to make a single 2-D array. 2-D arrays are stacked as-is,
|
||||
just like with `hstack`. 1-D arrays are turned into 2-D columns
|
||||
first.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
tup : sequence of 1-D or 2-D arrays.
|
||||
Arrays to stack. All of them must have the same first dimension.
|
||||
|
||||
Returns
|
||||
-------
|
||||
stacked : 2-D array
|
||||
The array formed by stacking the given arrays.
|
||||
|
||||
See Also
|
||||
--------
|
||||
stack, hstack, vstack, concatenate
|
||||
|
||||
Examples
|
||||
--------
|
||||
>>> a = np.array((1,2,3))
|
||||
>>> b = np.array((2,3,4))
|
||||
>>> np.column_stack((a,b))
|
||||
array([[1, 2],
|
||||
[2, 3],
|
||||
[3, 4]])
|
||||
|
||||
"""
|
||||
arrays = []
|
||||
for v in tup:
|
||||
arr = asanyarray(v)
|
||||
if arr.ndim < 2:
|
||||
n = arr.shape[0]
|
||||
arr = arr.reshape(n, 1)
|
||||
arrays.append(arr)
|
||||
return _nx.concatenate(arrays, 1)
|
||||
Loading…
x
Reference in New Issue
Block a user