Python 在气象上的应用
Python 在气象上的应用
![](https://upload.jianshu.io/users/upload_avatars/635081/5d2cacfa-78fc-4cc9-97cb-ee2fb14583d6.jpg?imageMogr2/auto-orient/strip|imageView2/1/w/96/h/96/format/webp)
为什么选择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')
其他:
绘图
![](https://upload-images.jianshu.io/upload_images/635081-b844655f8b31c07a.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
![](https://upload-images.jianshu.io/upload_images/635081-5556d3dc0866d46b.png?imageMogr2/auto-orient/strip|imageView2/2/w/720/format/webp)
基础绘图类
![](https://upload-images.jianshu.io/upload_images/635081-f3096a3f10808091.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
![](https://upload-images.jianshu.io/upload_images/635081-8040aed15f4ab7bc.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
![](https://upload-images.jianshu.io/upload_images/635081-59c2c3bbaacc6c10.png?imageMogr2/auto-orient/strip|imageView2/2/w/336/format/webp)
气象常用类
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 文件上传(一) 这种方法直接通过命令行执行脚本时没有问题,可以成功上传,但是 ...
随机推荐
- 常用的web api总结
1.querySelector 获取指定元素中匹配css选择器的元素. // 作用在document document.querySelector("#nav"); // 获取文档 ...
- Java实现简单RPC框架(转)
一.RPC简介 RPC,全称Remote Procedure Call, 即远程过程调用,它是一个计算机通信协议.它允许像本地服务一样调用远程服务.它可以有不同的实现方式.如RMI(远程方法调用).H ...
- pip 安装,更新模块
moudle_name:是对应的模块名:请自行更换为自己需要更新的模块名 查看所有可更新的模块: pip list --outdated 更新某一个模块: pip install --upgrade ...
- 【434】COMP9024 Exercises Revision
目录: Week01 Week02 Week03 Week04 Week05 Week06 Week07 Week08 Week09 Week10 01. Week01 数字通过 #define 来定 ...
- Django中models定义的choices字典使用get_FooName_display()在页面中显示值
问题 在django的models.py 中,我们定义了一些choices的元组,类似一些字典值,一般都是下拉框或者单多选框,例如 0对应男 1对应女等等 看下例子: class Area(model ...
- System.getProperties 获取当前的系统属性
getProperties public static Properties getProperties() 确定当前的系统属性. 首先,如果有安全管理器,则不带参数直接调用其 checkProper ...
- lombok插件/slf4j中字符串格式化
大家在编写springboot项目的过程中可能会接触到lombok这个插件,这个插件可以在编译时帮我生成很多代码. 1.@Data生成Getter和Setter代码,用于类名注释 2.@Getter ...
- realloc(void *__ptr, size_t __size)
#include <stdlib.h>realloc(void *__ptr, size_t __size):更改已经配置的内存空间,即更改由malloc()函数分配的内存空间的大小.如果 ...
- 《MySQL必知必会》学习笔记——附录B 样例表
附录B 样例表 本附录简要描述本书中所用的表及它们的用途. 编写SQL语句需要对基础数据库的设计有良好的理解.不知道什么信息存储在什么表中,表之间如何关联以及行内数据如何分解,是不可能编写出高效的SQ ...
- 对于新手用c#中的delegate(委托)和event(事件)
一.delegate到底是什么东西 delegate允许你传递一个类A的方法m给另一个类B的对象,使得类B的对象能够调用这个方法m,说白了就是可以把方法当作参数传递.delegate既可以引用静态函数 ...