爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 31902|回复: 24

[参考资料] Python语言编程艺术——面向水文学子的编程(含气象应用)

[复制链接]

新浪微博达人勋

发表于 2017-3-13 16:41:26 | 显示全部楼层 |阅读模式

登录后查看更多精彩内容~

您需要 登录 才可以下载或查看,没有帐号?立即注册 新浪微博登陆

x
本帖最后由 hillside 于 2017-3-14 12:54 编辑

       "Python语言编程艺术——面向水文学子的编程"网页由荷兰阿姆斯特丹自由大学水文与地球环境系(Department of Hydrology and Geo-Environmental Sciences)的M. J. Waterloo博士维护。
http://python.hydrology-amsterdam.nl/

       The art of Python programming(Python语言编程艺术)...
                                                            
                                   Why use a programming language to process data?
Most students do their calculations in Excel or, if you do not have alicense, the alternative open source spreadsheet programme Calc from OpenOffice.However, suppose that you have long time series of meteorological data. InExcel the maximum row lenght would then be reached very quickly so that youwould have to divide your data over different sheets. This would be veryinefficient. It is also complicated to build a computer model in a spreadsheetprogram to simulate processes, such as groundwater flow, erosion, or release ofgreenhouse gases.
In this case, professionals often revert to writing of a dedicated programthat can do the processing of data and do model calculations automatically. Themost common languages for programming are C programming language and its derivatives and Java and Fortranto name just a few. These languages are very powerful but have the disadvantagethat you have to write the program and then compile it to work with it.
Another branch of programming languages are the interpretedlanguages. Commands can then typed in and are directly evaluated by theinterpreter, without compilation. A number of commands can be saved in a textfile, which is then called a script. Interpreted languages are Matlab,Python andGNUOctave. As a Matlab license is very costly we prefer to use the opensource Python language to work with. Python is a very versatile programminglangauge that can be used to process data in a rather easy way and this webpage will give you some hints and examples on how to use Python in yourscientific carreer.
How to install Python
If you are working with MS Windows (or Ubuntu Linux) go to the Python(xy)download page at www.pythonxy.organd under the Windows XP/Vista installer/administrator account, download the fulledition. Once downloaded, double-click on the installer and choose nextor I agree a couple of times until Python(xy) is installed.
Please note that if you intend to print equations or special characters inany graphs that you want to plot with Python, you will need to install LaTeXfirst.
Python(x,y) also makes several useful tools and programs available,including the Scientific PYthon Development EnviRonment (spyder), which isdesigned for interactive computing and data visualisation and has a simple andintuitive user interface.
An alternative is the Anaconda Python distribution from ContinuumAnalytics. This is also a free Python distribution (including for commercialuse and redistribution) that contains about 300 popular Python packages.
A third alternative distribution for MS Windows, MacOS or RedHat Linuxplatforms, is the Enthought Python Distribution, which contains allthe programs and tools that you will need. However, before you can downloadthis distribution you will have to register and the trial version of thisdistribution is only of unlimited duration for educational purposes, so youcannot use this commercially.
If you use the Debianor UbuntuLinux platforms you can just install Python from a shell command line using thecommand: apt-get install python python-matplotlib.
Learning Python
A short Python tutorial - Python programming for Hydrology students manual- was written by M.J. Waterloo for the Hydrology MSc course "SoilVegetation Atmosphere Exchange". You can also download the accompanying example script file, which creates an image withPython. For one of the assignments in this manual you can download the water level data text file (wl.txt) with date, time and waterlevel logger data of the Rio Boco River near Aveiro in Portugal.
There are many online tutorials. See, for instance, the Python Tutorialsweb site at www.awaretek.com.
Python modules and scripts for Hydrologists and EarthScientists
Several useful scripts are given below. You can in most cases easily adaptthese to your needs.

        
SubjectPython scripts and function libraries
Geophysics
GPS and GIS scripts
  • Python GIS: various Python modules for working with GIS - Python GPS, MapView, LatLongUTMconversion.
  • Paul Inkenbrandt from the Utah Geological Survey has made several scripts that work with ArcGIS. The scripts include Stiff diagrams, Box and Whisker and Piper plots. His scripts scan be downloadedfrom https://github.com/inkenbrandt/Arcpy.
NetCDF file operations
  • txt2netcdf: various Python functions for importing text into NetCDF data files (creating files, adding variables, listing structure, etc.), developed by Ko van Huissteden.
Meteorology
  • meteolib: Python library containing meteorological functions for calculation of atmospheric vapour pressures, air density, latent heat of vapourisation, heat capacity at constant pressure, psychrometric constant, day length, extraterrestrial radiation input, potential temperature and wind vector. The documentation for this module is presented at here (meteolib module functions web site). Functions  to convert event-based data records to equidistant time-spaced records (event2time) and to convert date values to day-of-year values (date2doy) are now in a separate meteo_util module. Documentation is presented here (meteo_util module functions web site). Module documentation is also available as a PDF document. Author: M.J. Waterloo.
Hydrology
  • evaplib: Python library containing functions for calculation of evaporation rates. Functions include Penman open water evaporation, Makkink reference evaporation, Priestley Taylor evaporation Penman Monteith (1965) evaporation and FAO's Penman Monteith ET0 reference evaporation for short, well-watered grass. In addition there is a function to calculate the sensible heat flux from temperature fluctuation measurements. View documentation of evaplib module functions. Module documentation is also available as a PDF document. Author: M.J. Waterloo.
  • Groundwater flow modelling manual for Python written by Vincent post
Hydrochemistry
Workshop meteorological data processing
  • Meteodataprocessing assignment manual: Meteorological data processingmanual for the script and data listed below. It also contains asection on how to report on these datausing LaTeX.
  • meteoscript_yourname_2014.py:This script file is used for processing of meteorological datacollected during the hydrological field courses in Twente andPortugal. Author: M.J. Waterloo. The script reads the ASCII data,calculates state variables and actual evaporation (temperaturevariance energy balance method) and potential evaporation. It alsoplots time series of several weather variables. The script containsquestions that should be answered by the student to better understandwhat the script does. It makes use ofthe meteoliband evaplib modules presentedabove. Create an ecohydrology/pyscript directory and download and savethe script and modules in this directory.
  • slowtable.dat: File containingmeteorological data collected in Portugal during the hydrologicalfield course in Aveiro, 2014. This is the output file of the CampbellScientific CR1000 data logger. Create an ecohydrology/data directoryand download and save the data file in this directory./li>
Statistical Resources for Hydrologists
  • RResources for Hydrologists: This weblog lists a lot of programsfor statistics in hydrologyusing R, which is a computerlanguage for statistical computing and graphics. Statistical functionsof R can be accessed in Python, for instancethrough Rpy
Python hydrological modelling tools
  • Vincent Post and others have developed a Python package to create, run and process MODFLOW, SEAWAT, MT3D and other MODFLOW based groundwater models. The software and documentation can be found at the FloPy3 web site and can be downloade from Github.
  • Catchment and plant growth modelling frameworks (CMF, PMF), and statistical parameter optimisation tools (SPOTPY) programs were developed for Python at the Justus-Liebig-University in Giessen, Germany. The software and manuals are available for download at the website of Landscape, Water and Biogeochemical Cycles, together with the papers on which the programs are based.
  • Sat Kumar Tomer from the Department of Civil Engineering - Indian Institute of Science has written an excellent Python in Hydrology handbook and also made several hydrology and earth sciences scripts available from his Ambhas project that can be downloaded from https://pypi.python.org/pypi/ambhas.
  • Jaap Schellekens from Deltares in Delft, The Netherlands, has his WFLOW distributed hydrological modelling platform - part of the Openstreams project - available at http://schj.home.xs4all.nl/html/.

附1:《Python在水文学中的应用》英文书下载网址(附件已提供。为节约金币,群友可去网址自行下载):见回复帖。
附2:《Python在水文学中的应用》作者开发的Python程序:ambhas 0.4.0(https://pypi.python.org/pypi/ambhas

ambhas-0.4.0(Agro-hydrological Monitoring).rar

4.32 MB, 下载次数: 70, 下载积分: 金钱 -5

Python In Hydrology(2011).pdf

3.68 MB, 下载次数: 82, 下载积分: 金钱 -5

Python的大气科学与海洋科学应用入门(英文).pdf

12.56 MB, 下载次数: 555, 下载积分: 金钱 -5

密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-3-13 17:23:30 | 显示全部楼层
赞!我还没有顾上粘贴呢。这本书在“阿阿飞飞”园友2013年的帖子中就有介绍:http://bbs.06climate.com/forum.php?mod=viewthread&tid=16509
下面转我在一个QQ群的发言:
我个人而言,作为比较热心水文公益者,我一直乐于在网络上交流与分享经验。可惜收效甚微。下面转我在“气候水文统计程序软件群”的发言:
比起QQ这种封闭的交流空间,我更喜欢气象家园那样的开放空间。可惜没有类似的比较单纯的网站,当然,我发现也缺乏类似的需求(我对CJD3D这样的杂烩性网站缺乏兴趣)。我在气象家园的帖子,简单地回应的似乎还挺多(尽管因时间关系,我不怎么看)。我在科学网的“水文气候学群组”(字面上也有180人)的专业性资讯介绍基本没有回应。
查看气象家园的Python版块,在我发帖参与推介Python时还比较冷清,近几年由于驻扎在cnblogs的气象博士Vamei及气象家园的版主ztftom的狂热爱好,气象家园的Python版块已经形成气候了。
与气象气候的软件爱好者风起云涌相比,网络上的水文水资源学子则安静得多。就是一个水文工具集网站,也是收费卖几个网主自己开发的旧程序而已。
尽管感觉在“气象家园”介绍Python的水文应用有些勉强,但网上确实找不到合适的地方介绍这些内容,只能将就一下了(为了跟气象搭边,加了一个补充“含气象应用”:《Python语言编程艺术——面向水文学子的编程(含气象应用)》http://bbs.06climate.com/forum.p ... mp;extra=#pid759354)。我希望在网络上见到水文学的专门交流网站或空间的想法可能过于超前或不切实际。我目前可能使用的空间是科学网的“水文气候学群组”与“新浪网”我的个人博客“
水文气候研究资讯的博客”(http://blog.sina.com.cn/u/1816815873 ),不过,“水文气候学群组”基本不能粘贴超链接,“新浪网”链接非常耗时。我有时会想到海岛卖鞋的故事,国内水文界也许不需要这种鞋子,而我还想建这么一个市场。现在看来,这个市场确实没有市场。
密码修改失败请联系微信:mofangbao
回复 支持 2 反对 0

使用道具 举报

新浪微博达人勋

发表于 2017-3-13 16:59:51 | 显示全部楼层
密码修改失败请联系微信:mofangbao

新浪微博达人勋

 楼主| 发表于 2017-3-13 17:27:24 | 显示全部楼层
andrewsoong 发表于 2017-3-13 16:59
http://greenteapress.com/pythonhydro/pythonhydro.html

由于没有翻墙,我无法下载(自动回复:请不要使用迅雷等下载工具,点我查看下载帮助)网页中该书的”The LaTeX source code“文本(The LaTeX source code is available in a Subversion repository)。如有热心园友下载并作为附件就好了。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-13 18:09:20 | 显示全部楼层
hillside 发表于 2017-3-13 17:27
由于没有翻墙,我无法下载(自动回复:请不要使用迅雷等下载工具,点我查看下载帮助)网页中该书的”The  ...

这个是排版书籍使用的源代码,一般也不需要用到。作者把资源放在google code内,现在应该不开放下载了
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-14 15:38:25 | 显示全部楼层
支持支持
{:eb502:}{:eb502:}
密码修改失败请联系微信:mofangbao
回复

使用道具 举报

新浪微博达人勋

发表于 2017-3-16 16:36:00 | 显示全部楼层
多谢楼主和大神们分享
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-17 10:35:17 | 显示全部楼层
多谢楼主和大神们分享
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2017-3-17 10:43:17 | 显示全部楼层
感谢楼主的分享,也庆幸我们有气象家园这个相互交流,相互学习的空间。
密码修改失败请联系微信:mofangbao

新浪微博达人勋

0
早起挑战累计收入
发表于 2017-3-19 08:29:00 | 显示全部楼层
楼主来这里已经好几年啦,非常感谢您分享的各种优秀内容
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

Copyright ©2011-2014 bbs.06climate.com All Rights Reserved.  Powered by Discuz! (京ICP-10201084)

本站信息均由会员发表,不代表气象家园立场,禁止在本站发表与国家法律相抵触言论

快速回复 返回顶部 返回列表