超友好!气象 Python 训练营 ③ 闯关3

超友好!气象 Python 训练营 ③ 数组进阶

Q1: 读取 FNL 再分析资料中 2021 年 1 月 1 日 0 时、2021 年 1 月 1 日 6 时、2021 年 1 月 1 日 12 时、2021 年 1 月 1 日 18 时,4 个时次的地表以上 2m 温度的二维数组。对所有温度数据取整(int),然后计算这 4 个时次中,最常出现的温度(单位:K)的值

正常做法

import xarray as xr
import numpy as np
t1 = np.array(xr.open_dataset('/home/mw/input/fnl6384/fnl/fnl_20210101_00_00.grib2',engine="pynio")['TMP_P0_L103_GLL0'].loc[2,:,:]).reshape(-1).astype(int)
t2 = np.array(xr.open_dataset('/home/mw/input/fnl6384/fnl/fnl_20210106_00_00.grib2',engine="pynio")['TMP_P0_L103_GLL0'].loc[2,:,:]).reshape(-1).astype(int)
t3 = np.array(xr.open_dataset('/home/mw/input/fnl6384/fnl/fnl_20210112_00_00.grib2',engine="pynio")['TMP_P0_L103_GLL0'].loc[2,:,:]).reshape(-1).astype(int)
t3 = np.array(xr.open_dataset('/home/mw/input/fnl6384/fnl/fnl_20210118_00_00.grib2',engine="pynio")['TMP_P0_L103_GLL0'].loc[2,:,:]).reshape(-1).astype(int)
t = np.concatenate((t1,t2,t3))
a1 = np.argmax(np.bincount(t))

不正常做法

a1 = 299
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值