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 文件上传(一) 这种方法直接通过命令行执行脚本时没有问题,可以成功上传,但是 ...
随机推荐
- node依赖包格式区别
UMD:UMD 版本可以通过 <script> 标签直接用在浏览器中.jsDelivr CDN 的 https://cdn.jsdelivr.net/npm/vue 默认文件就是运行时 + ...
- python : 设计模式之外观模式(Facade Pattern)
#为啥要用外观模式举例说明 这个例子很形象,直接从人家博客上贴过来的,参考链接在下面 不知道大家有没有比较过自己泡茶和去茶馆喝茶的区别,如果是自己泡茶需要自行准备茶叶.茶具和开水,如图1(A)所示,而 ...
- Mac OS 安装 MySQL5.7
在 macOS 上安装 MySQL 5.7 安装 Homebrew $ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubuserconten ...
- 获取并打印Spring容器中所有的Bean名称
思路: 1.实现Spring的ApplicationContextAware接口,重写setApplicationContext方法,将得到的ApplicationContext对象保存到一个静态变量 ...
- shell编程系列26--大型脚本工具开发实战
shell编程系列26--大型脚本工具开发实战 大型脚本工具开发实战 拆分脚本功能,抽象函数 .function get_all_group 返回进程组列表字符串 .function get_all_ ...
- 一秒解决--------No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
在打war包时候遇到错误: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.6.0:compile (d ...
- 背诵四种清净明诲断淫(愿众生断淫得究竟解脱) (转自学佛网:http://www.xuefo.net/nr/article50/495158.html)
一.为什么要戒邪淫.断淫欲 <寿康宝鉴>:盖淫念一生,诸念皆起.邪缘未凑生妄心;勾引无计,生机械心;少有阻碍,生嗔恨心;欲情颠倒,生贪着心;羡人有之,生嫉妒心;夺人之爱,生杀害心.廉耻丧尽 ...
- idea中maven项目下载源码的方式的
当我们打开class文件的时候,右上角有个Download Sources的超链接,点击就可以下载源码了. 下载源码后,就变成java文件了.
- Amazon MWS Scratchpad
https://mws.amazonservices.com/scratchpad/index.html Use this page to test Amazon MWS API request an ...
- Docker - 在CentOS7.5中升级Docker版本
1 - 检查当前版本 [root@localhost ~]# uname -a Linux localhost.localdomain 3.10.0-957.el7.x86_64 #1 SMP Thu ...


