Python常用算法

创建netCDF4文件

out_file='.nc'
file_out=netCDF4.Dataset(out_file,'w')
file_out.createDimension('lat',180)
file_out.createDimension('lon',360)
file_out.createVariable('sst', np.float('lat','lon'))
file_out.variables['spatial'][:]=data片

np.hstack用法
原文地址
https://www.cjavapy.com/article/893/

去线性趋势
signal.detrend()

np.where()筛选拓展

'''将数列打包成可以用于np.where筛选的格式'''
lat_index=np.floor((lat_list+90)*96)
lon_index=np.floor((lon_list+180)*96)
lat_index=np.int64(lat_index);lon_index=np.int64(lon_index)
index_new=tuple((lat_index,lon_index))

np.where() 筛选条件合并

'''取交集'''
index1=np.where();index2=np.where();index3=np.where()
index_cross1=index1[np.in1d(index1, index2)]
index_cross2=index_cross1[np.in1d(index_cross1, index3)]

numpy与np.where tuple的相互转换

depth=[1,2,3,4,5,6]
depth=np.array(depth)
depth_tuple=[depth]
depth_tuple=tuple(depth_tuple)  #可用于index直接筛选的数据格式
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值