當使一個2 d網格在python兩個1 d陣列,我通常使用numpy.meshgrid如下面:轉換2- d陣列1-d對應的陣列在Python
x = np.arange(10)
y = np.arange(9)
xy = np.meshgrid(x,y)
然而,我的問題是關於這個過程的逆向。我有3個二維數組。每個陣列都表示經度和相應的高度。沒有任何方法可以將這些2-d網格轉換爲python中相互對應的1-d數組? 樣品陣列顯示如下圖所示:
x=
[[-104.09417725 -104.08866882 -104.0831604 ..., -103.8795166 -103.87399292
-103.86849976]
[-104.09458923 -104.08908081 -104.08358765 ..., -103.87991333
-103.87438965 -103.86889648]
[-104.09500122 -104.08950806 -104.08401489 ..., -103.88031006
-103.87481689 -103.86932373]
...,
[-104.11058044 -104.10507202 -104.09954834 ..., -103.89535522
-103.88983154 -103.88430786]
[-104.11100769 -104.10548401 -104.09997559 ..., -103.89575195
-103.89022827 -103.88470459]
[-104.11141968 -104.10591125 -104.10038757 ..., -103.89614868 -103.890625
-103.88513184]]
y=
[[ 40.81712341 40.81744385 40.81776428 ..., 40.82929611 40.82960129
40.82990646]
[ 40.82128525 40.8216095 40.82191849 ..., 40.83345795 40.83376694
40.83407593]
[ 40.8254509 40.82577515 40.82608795 ..., 40.83763123 40.83792877
40.83824539]
...,
[ 40.97956848 40.9798851 40.98020172 ..., 40.99177551 40.99207687
40.99238968]
[ 40.98373413 40.98405457 40.98437119 ..., 40.99593735 40.99624252
40.99655533]
[ 40.98789597 40.9882164 40.98854065 ..., 41.00011063 41.00041199
41.00072479]]
z=
[[ 1605.58544922 1615.62341309 1624.33911133 ..., 1479.11254883
1478.328125 1476.13378906]
[ 1618.58520508 1632.38305664 1645.36132812 ..., 1485.84899902
1483.43847656 1481.36865234]
[ 1640.63037109 1656.0925293 1667.14697266 ..., 1492.79797363
1488.65686035 1487.40478516]
...,
[ 1599.78015137 1602.82250977 1610.40197754 ..., 1595.12097168
1594.40551758 1597.87902832]
[ 1597.80883789 1601.17883301 1607.41320801 ..., 1595.7421875
1594.26452637 1597.90893555]
[ 1596.03857422 1600.5690918 1606.30712891 ..., 1598.56982422
1594.90454102 1594.07763672]]
任何幫助或想法將非常感激。
預期陣列是: 如
x =
[-104.09417725 -104.08866882 -104.0831604 ..., -103.8795166 -103.87399292
-103.86849976]
y =
[ 40.82128525 40.8216095 40.82191849 ..., 40.83345795 40.83376694
40.83407593]
z =
[ 1618.58520508 1632.38305664 1645.36132812 ..., 1485.84899902
1483.43847656 1481.36865234]
您需要向我們展示瞭如何排列的樣子。 –
列出樣本輸入數據的預期輸出? – Divakar
@AnandSKumar我添加了示例數組,謝謝 – Isaac