All Projects → CyanideCN → QXmath

CyanideCN / QXmath

Licence: MIT license
《用C语言开发的气象常用参数和物理量计算函数库》原文代码以及Python封装

Programming Languages

c
50402 projects - #5 most used programming language
python
139335 projects - #7 most used programming language
C++
36643 projects - #6 most used programming language

QXmath

《用C语言开发的气象常用参数和物理量计算函数库》原文代码以及Python封装

安装方法

python setup.py build_ext --inplace

需要C编译器和cython模块

使用方法

在此目录新建Python解释器,即可import编译好的库。

使用原始函数

>>> import pyqxmath as pq
>>> pq.showalter_index(16.6, 0.6, -15.9)
1.099999999999886

使用向量化函数

使用numpy.vectorize类进行函数的向量化,因此可以支持numpy.ndarray的直接运算。

>>> import pyqxmath as pq
>>> import numpy as np
>>> t8 = np.array([16, 17, 18])
>>> td8 = np.array([2, 1, 0])
>>> t5 = np.array([-16, -17, -18])
>>> pq.vect.showalter_index(t8, td8, t5)
array([ 0.56  , -0.48  , -1.5456])

向量化函数和原始函数的名字是相同的。

可供Python使用的函数在pyqxmath.pyx中定义,由于文献中的函数名基本由拼音缩写而来,我在包装的过程中一般都会将其重命名成英文单词的组合,以方便记忆。函数的具体用法请参见paper文件夹里面的pdf文献。

目前可用的函数

lcl_temperature, saturated_vapor_pressure, equivalent_potential_temperature, potential_temperature, total_air_energy_surface, total_air_energy, dewpoint_from_e, specific_humidity, relative_humidity, condensation_function, moist_lapse, water_vapor_flux, wind_to_uv, uv_to_wind, showalter_index, richardson_number, k_index

未来计划实现的功能

  1. 支持原C库中所有计算函数
  2. 支持numpy array的运算
  3. 完善函数的注释

备注

由于原文献扫描质量较差,可能会有(很多)排版造成的代码录入bug,如遇到计算不合理的地方,请参考paper文件夹里的pdf进行修改并重新编译, 欢迎提pull request。

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].