首先你得安裝
netCDF4
這個(gè)庫(kù) (pip install)
簡(jiǎn)單讀取 如下
可以看到
dimensions
(sizes)
:
longitude
(480),
latitude
(241),
time
(480)
variables
(dimensions)
: float32
longitude
(longitude), float32
latitude
(latitude), int32
time
(time), int16
z
(time,latitude,longitude)
這是一個(gè)三維數(shù)據(jù)集,空間兩維(
z
高度層為1,
500hPa
)、時(shí)間一維
數(shù)據(jù)提取
注意
:變量是
z
,
shape= (480,241,480)
時(shí)間40年x12月,空間0.75°x0.75°
用
np.array
把數(shù)據(jù)轉(zhuǎn)化成數(shù)組(矩陣)類型
import
numpy
as
np
import
netCDF4
as
nc
d
=
nc
.
Dataset
(
'weishi79_18.nc'
)
time
=
np
.
array
(
d
.
variables
[
'time'
]
)
d_lon
=
np
.
array
(
d
.
variables
[
'longitude'
]
)
d_lat
=
np
.
array
(
d
.
variables
[
'latitude'
]
)
ws
=
np
.
array
(
d
.
variables
[
'z'
]
)
只做冬季,挑選所有12,1,2月
現(xiàn)有時(shí)間序列:197901-201812
a
=
[
]
for
t in
range
(
1
,
481
)
:
if
t
%
12
==
1
or t
%
12
==
2
or t
%
12
==
0
:
a
.
extend
(
[
t
-
1
]
)
ws_t
=
ws
[
a
,
:
,
:
]
ws_winter
=
np
.
zeros
(
(
39
,
241
,
480
)
)
for
m in
range
(
0
,
39
)
:
ws_winter
[
m
,
:
,
:
]
=
(
ws_t
[
m
*
3
+
2
,
:
,
:
]
+
ws_t
[
m
*
3
+
3
,
:
,
:
]
+
ws_t
[
m
*
3
+
4
,
:
,
:
]
)
/
3
80年-18年冬季平均就得到了
求距平值
ws_mean
=
np
.
zeros
(
(
241
,
480
)
)
ws_mean
=
np
.
mean
(
ws_winter
,
axis
=
0
)
ws_st
=
np
.
zeros
(
(
39
,
241
,
480
)
)
for
m in
range
(
0
,
39
)
:
ws_st
[
m
,
:
,
:
]
=
ws_winter
[
m
,
:
,
:
]
-
ws_mean
[
:
,
:
]
更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號(hào)聯(lián)系: 360901061
您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對(duì)您有幫助,請(qǐng)用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長(zhǎng)非常感激您!手機(jī)微信長(zhǎng)按不能支付解決辦法:請(qǐng)將微信支付二維碼保存到相冊(cè),切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對(duì)您有幫助就好】元
