Python 在气象上的应用
Python 在气象上的应用
为什么选择python
- 免费和开源,没有商业许可限制
anaconda
pycharm
jupyter - 庞大而稳定的社区
stackoverflow - 功能齐全的编程语言,真正面向对象
- 非常强大和灵活 (https://www.lfd.uci.edu/~gohlke/pythonlibs/)
- 喜欢可读的代码
- 出版质量图绘制
- 轻松读/写netcdf和grib数据
- 轻松使用Fortran / C / C ++
- 广泛的库支持数字和非数字工作
科学计算
1.Numpy
Numpy是python科学计算的基础包,它提供以下功能(不限于此):
(1)快速高效的多维数组对象ndarray
(2)用于对数组执行元素级计算以及直接对数组执行数学运算的函数
(3)用于读写硬盘上基于数组的数据集的工具
(4)线性代数运算、傅里叶变换,以及随机数生成
(5)用于将C、C++、Fortran代码集成到python的工具
2.pandas
pandas提供了使我们能够快速便捷地处理结构化数据的大量数据结构和函数。pandas兼具Numpy高性能的数组计算功能以及电子表格和关系型数据(如SQL)灵活的数据处理能力。它提供了复杂精细的索引功能,以便更为便捷地完成重塑、切片和切块、聚合以及选取数据子集等操作。
对于金融行业的用户,pandas提供了大量适用于金融数据的高性能时间序列功能和工具。
DataFrame是pandas的一个对象,它是一个面向列的二维表结构,且含有行标和列标。
ps.引用一段网上的话说明DataFrame的强大之处:
Excel 2007及其以后的版本的最大行数是1048576,最大列数是16384,超过这个规模的数据Excel就会弹出个框框“此文本包含多行文本,无法放置在一个工作表中”。Pandas处理上千万的数据是易如反掌的事情,同时随后我们也将看到它比SQL有更强的表达能力,可以做很多复杂的操作,要写的code也更少。 说了一大堆它的好处,要实际感触还得动手码代码。
3.Scipy
一组专门解决科学计算中各种标准问题域的包的集合。
scipy/climpy
4.statsmodels
一个Python模块,它提供对许多不同统计模型估计的类和函数,并且可以进行统计测试和统计数据的探索
5.RPy
An interface to R running embedded in a Python process
- sympy
A Python library for symbolic mathematics
7.atmqty
A Python Package for Calculating Atmospheric Quantities
8.PyWavelets
A Python wavelet transforms module
数据处理
Read/Write NetCDF file
To create a NetCDF file:
from Scientific.IO.NetCDF import NetCDFFile
import numpy as np
f = NetCDFFile('scientificio.nc', 'w')
# dimension
f.createDimension('time', 12)
# variable
time = f.createVariable('time', 'd', ('time',))
# data
time[:] = np.random.uniform(size=12)
f.close()
To read the file:
from Scientific.IO.NetCDF import NetCDFFile
import matplotlib.pyplot as plt
f = NetCDFFile('scientificio.nc')
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(f.variables['time'])
plt.show()
Read/Write NetCDF file with netcdf4-python
To create a NetCDF file:
from netCDF4 import Dataset
import numpy as np
root_grp = Dataset('test.nc', 'w', format='NETCDF4')
root_grp.description = 'Example temperature data'
# dimensions
root_grp.createDimension('time', None)
root_grp.createDimension('lat', 72)
root_grp.createDimension('lon', 144)
# variables
times = root_grp.createVariable('time', 'f8', ('time',))
latitudes = root_grp.createVariable('latitude', 'f4', ('lat',))
longitudes = root_grp.createVariable('longitude', 'f4', ('lon',))
temp = root_grp.createVariable('temp', 'f4', ('time', 'lat', 'lon',))
# data
lats = np.arange(-90, 90, 2.5)
lons = np.arange(-180, 180, 2.5)
latitudes[:] = lats
longitudes[:] = lons
for i in range(5):
temp[i,:,:] = np.random.uniform(size=(len(lats), len(lons)))
# group
# my_grp = root_grp.createGroup('my_group')
root_grp.close()
To read the file:
from netCDF4 import Dataset
import pylab as pl
root_grp = Dataset('test.nc')
temp = root_grp.variables['temp']
for i in range(len(temp)):
pl.clf()
pl.contourf(temp[i])
pl.show()
raw_input('Press enter.')
Read/Write Grib files with pygrib
To read a Grib file:
import pygrib
grbs = pygrib.open('sampledata/flux.grb')
grbs.seek(2)
grbs.tell()
grb = grbs.read(1)[0]
print grb
grb = grbs.select(name='Maximum temperature')[0]
To write a Grib file:
import pygrib
grbout = open('test.grb','wb')
grbout.write(msg)
grbout.close()
print pygrib.open('test.grb').readline()
Read/Write Matlab .mat file
To read a .mat file:
import scipy.io as sio
mat_contents = sio.loadmat('data.mat')
print mat_contents
To write a .mat file:
import numpy as np
import scipy.io as sio
vect = np.arange(10)
print vect.shape
sio.savemat('data.mat', {'vect':vect})
for hdf5
f = h5py.File('foo.hdf5','w')
其他:
绘图


基础绘图类



气象常用类
4)cis
卫星
其他绘图工具
色标 : https://matplotlib.org/cmocean/
http://colorcet.pyviz.org/
http://holoviews.org/user_guide/Colormaps.html
爬虫
机器学习
- 10 Useful Python Data Visualization Libraries for Any Discipline
- Python Data Visualization: Comparing 7 tools
- How to make beautiful data visualization in Python with matplotlib
- Dashboard API in Python
- Bokeh Applications
- pyecharts + notebook,真的不需要PPT了耶
- Pycon 2017: Python可视化库大全
- A Hands-On Introduction to Using Python in the Atmospheric and Oceanic Sciences
- An Introduction to Using Python in the Atmospheric and Oceanic Sciences
- PyAOS
- Ninth Symposium on Advances in Modeling and Analysis Using Python
Python 在气象上的应用的更多相关文章
- 让python在hadoop上跑起来
duang~好久没有更新博客啦,原因很简单,实习啦-好吧,我过来这边上班表示觉得自己简直弱爆了.第一周,配置环境:第二周,将数据可视化,包括学习了excel2013的一些高大上的技能,例如数据透视表和 ...
- 解决基于BAE python+bottle开发上的一系列问题 - artwebs - 博客频道 - CSDN.NET
解决基于BAE python+bottle开发上的一系列问题 - artwebs - 博客频道 - CSDN.NET 解决基于BAE python+bottle开发上的一系列问题 分类: python ...
- Python第一天:你必须要知道的Python擅长领域以及各种重点学习框架(包含Python在世界上的应用)
目录 Python5大擅长领域 WEB开发 网络编程 科学运算 GUI图形开发 运维自动化 Python在世界上的知名应用 国外 谷歌 CIA NASA YouTube Dropbox Instagr ...
- Python基于Python实现批量上传文件或目录到不同的Linux服务器
基于Python实现批量上传文件或目录到不同的Linux服务器 by:授客 QQ:1033553122 实现功能 1 测试环境 1 使用方法 1 1. 编辑配置文件conf/rootpath_fo ...
- Python Selenium 文件上传之Autoit
今天补充一种文件上传的方法 主要是因为工作中使用SendKeys方法不稳定,具体方法见: Python Selenium 文件上传之SendKeys 这种方法直接通过命令行执行脚本时没有问题,可以成功 ...
- Python Selenium 文件上传之SendKeys
昨天写了Web 文件下载的ui自动化,下载之后,今天就要写web 文件上传的功能了. 当然从折腾了俩小时才上传成功.下面写一下自己操作的步骤 首先网上说的有很多方法 如 input 标签的最好做了,直 ...
- python在图片上画矩形
python在图片上画矩形 image_path = '' image = cv2.imread(image_path) first_point = (100, 100) last_point = ( ...
- Python 第三方包上传至 PyPI 服务器
PyPI 服务器主要功能是?PyPI 服务器怎么搭建? PyPI 服务器可以用来管理自己开发的 Python 第三包. Pypi服务器搭建 Python 第三方包在本地打包 # 本地目录执行以下命令应 ...
- Python WebDriver 文件上传(二)
今天补充一种文件上传的方法 主要是因为工作中使用SendKeys方法不稳定,具体方法见: Python WebDriver 文件上传(一) 这种方法直接通过命令行执行脚本时没有问题,可以成功上传,但是 ...
随机推荐
- unity疯狂牧场完整项目源码 - Frenzy Farming time management game kit V1.0
You will love this game kit! Have you ever wondered what it would be like to run your own farm? Look ...
- JS实现文字向上无缝滚动轮播
效果图: 全部代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=&quo ...
- SiamRPN: High Performance Visual Tracking with Siamese Region Proposal Network
High Performance Visual Tracking with Siamese Region Proposal Network 2018-11-26 18:32:02 Paper:http ...
- 每个Web开发者都需要具备的9个软技能--ZT
本文原始链接:http://www.cnblogs.com/oooweb/p/soft-skills-every-web-developer-should-master.html 对于一份工作,你可能 ...
- 干货满满!10分钟看懂Docker和K8S(转)
2010年,几个搞IT的年轻人,在美国旧金山成立了一家名叫“dotCloud”的公司. 这家公司主要提供基于PaaS的云计算技术服务.具体来说,是和LXC有关的容器技术. LXC,就是Linux容器虚 ...
- YII2 输出 执行的 SQL 语句,直接用程序输出
$query = User::find() ->,,,]) ->select(['username']) // 输出SQL语句 $commandQuery = clone $query; ...
- Python带参数的函数装饰器
# -*- coding: utf-8 -*- # author:baoshan # 带参数的函数装饰器 def say_hello(country): def wrapper(func): def ...
- 头文件里声明和定义,Qt编译不过问题
1.现象1 Qt5.2.1,新建头文件,声明一个类,然后在此头文件中实现类的static变量和方法,但是编译不过,显示:multiple definition of `xxx'. 2.现象2 在高版本 ...
- 转 【MySQL】常用拼接语句 shell 下执行mysql 命令
[MySQL]常用拼接语句 前言:在MySQL中 CONCAT ()函数用于将多个字符串连接成一个字符串,利用此函数我们可以将原来一步无法得到的sql拼接出来,在工作中也许会方便很多,下面主要介绍下几 ...
- 转 zabbix 优化方法 以及数据库查询方法 两则
###########sample 1 https://www.cnblogs.com/hanshanxiaoheshang/p/10304672.html (不错) 如何从zabbix server ...


