爱气象,爱气象家园! 

气象家园

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博登陆

只需一步, 快速开始

搜索
查看: 6528|回复: 10

[源程序] 介绍斯德哥尔摩大学副教授Christophe Sturm的气候学工具箱

[复制链接]

新浪微博达人勋

发表于 2013-6-1 19:06:50 | 显示全部楼层 |阅读模式

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

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

x
本帖最后由 hillside 于 2013-6-1 19:23 编辑

Christophe Sturm (aka. Kristof)  Associate professor in biogeochemicalmodelling
http://people.su.se/~cstur/index.htm

Department of Geology and Geochemistry  Stockholm University  10691 Stockhom, Sweden  E-mail: Christophe.Sturm@geo.su.se Phone:(+46) 8 16 47 23   Mobile: (+46) 70 49 82012  Fax:(+46) 8 674 78 97  Skype: kauboulot      

Newly added: the SWING2GNIP-Dynscape website was launched on Oct. 28, 2008.
The SWING2 website latest update happened on Dec. 11, 2008.In February 2008, I started as associateprofessor in biogeochemical modelling at theDepartment ofGeology and Geochemistry within the Bert BolinCentre for Climate Research. My research focuses on investigatingthe feedbacks between the land surface and the atmosphere. This includes themodelling of the terrestrial water and carbon cycle, with their respectiveisotopes: H218O,HD and 18O / 13C in organic matter.
For that purpose, I primarily use components of the Earth system modellingframework developed at the Max-Planck-Institutefor Meteorology, Hamburg.REMOisoa regional circulation model with embedded stable waterisotope module, which I developed during my PhD.JSBACHa land-surface model representing the terrestrial waterand carbon cycles, developed by Christian Reick and co-workers at the MPI-M.LPJa dynamical vegetation model developed by the Lund-Potsdam-Jena consortium.  


The current toolbox containsfollowing routines:

  • Introduction
  • GrADS-Matlab interface:


    • read_grads.m: Read the GrADS control file      and retrieves the variable accordingly into the Matlab workspace. Grid      dimensions are stored in the 'header' structure. It was extended to deal      with NetCDF files (provided that the mexnc and snctools is installed).
    • write_grads.m: Writes a variable from the      Matlab workspace as a binary file, with associated GrADS control file.
  • Plotting routines:


    • plot_global.m: Plots a map of a global      variable, with indications from the 'header' structure. Coastal contours      are added from an independent file
    • plot_iregy.m: Plots a global map, with      iregular Y axis (as often happens with GCM outpout).
    • remo2geog.m: converts the rotated REMO      coordinates into geographical lon/lat coordinates. This file is called by      plot_data.m.
    • plot_data.m: similar to plot_global.m,      but for a limited area.
    • add_cont.m: Adding coastal contours to an      existing plot (including lat/lon grid). Requires the cont_land.mat file (as for the above plot_{global,data}.m).
    • remo_domains.m: plots the different      domains where REMOiso has been applied so far.


  • Miscellanous(其他):
    • stable water isotope routines: delta.m and excess.m dompute the d18O, dD and D excess from H218O,      HDO and H216O input.
    • gnip_read.m: reads the GNIP 2001 climatology into Matlab, with relatedGNIP2001monthly.csv and GNIP2001monthly.txt files
    • read_lpj.m: reads the LPJ column output      and converts it into a grid format. This routine is only compatible with      the LPJ Fortran I/O routine that I use...
    • koeppen.m: computes the Koeppen climate      classes based on monthly precipitation and temperature fields.
    • plot_koeppen.m: plots the different      Koeppen classes with an appropriate colour bar. Examples can be found below.
    • NaN utilities: extension of common Matlab routines      to variables containing NAN. Includes nancorrcoeff.m, nanmeans.m, nansums.m, nanunique.m.
    • Other useful utilities: calling Linux shell      commands from within Matlab (shell.m), computes the catchment area      from topography (catchment.m).
The entire toolbox can be downloaded as a gzipped tarred archive.

Introduction    Matlab is a great tool for climatedata analysis and plotting. Below is a collection of scripts I've developed toread, analyse and plot climate data with Matlab. The routines have been testedunder Matlab R2006b and previous version, on both Mac and Linux OS, and partlyunder Windows (although I discourage any serious climate modeller to use thelatter OS). The routines are (more or less) documented, feel free to send me anemail if some features are unclear. All routines are licensed as open source(GPL License), with no personal responsability but some hope that they can beuseful to others. Bug reports are welcome...

    To give a little background, I've been using several climatemodels and used Matlab to read, analyse and plot model output. These include
REMOiso, a regional circulation model withstable water isotope diagnostics, as well as its GCM counterpart ECHAMiso, andthe LPJ global globaldynamical vegetation model.


GrADS - Matlab interface    GrADS is a widely spread, open source software for plotting gridded datasets, astypically produced by climate models. It has developed conventions for writing and reading binary files; all the meta-information iscontained in the so-called control file (*.ctl), which lists the XY griddimensions, as well as the variables name, number of levels and time-steps.
    It is worthwile noticing that the
CDO toolbox constructs the control file for most common (grib, IEG, SV) binary formatscurrently used by MPI-Met models. The syntax is: 'cdo gradsdes<filename>'
    I introduce here an interface between GrADS and Matlab: the
read_grads.m routine reads the GrADS control file and retrieves the variable from thebinary file accordingly. As far as possible, the compenents of the GrADS Data Descriptor File (or control file) were implemented in this routine. The companion routine write_grads.m writes a variable in the Matlab workspace as a binary file, with theappropriate control file. Examples are given hereafter.Example:

[data,header]=read_grads('filename.ctl','');               % Reads only theheader
[data,header]=read_grads('filename.ctl','varname');   % Reads the headerand <varname>
[data,header]=read_grads('filename.ctl','varname','z',[z1,z2],'lon',[lon1,lon2],'lat',[lat1,lat2],'t',[t1,t2]);
[data,header]=read_grads('filename.nc','varname');    % Extension ofread_grads.m to NetCDF variables

  • data is a 4-D variable, with X/lon as the first     dimension, Y/lat as second dimension, Z/lev as third dimension and time in     fourth dimension.
  • header is a structure variable, which contains all     relevant information from the GrADS control file. In particular, the     header.XDEF and header.YDEF sub-structures contain information for     plotting the variable. header.XDEF.num is the number of X fields, and     header.XDEF.vec the X coordinates.
Details of the optional input canbe inferred from reading the Matlab script.





Plottingroutines
All routines need the coastal contours storedin
cont_land.mat (which can else be constructed from cont_land.lon-lat.ascii).
Examples:

plot_global(header,2-Dvar)                                  % Plots a 2-S XY variable, with header from the read_grads.mroutine
plot_global(header,2-Dvar,'lon',[lon1,lat1])           % Plots a 2-S XY variable only between [lon1,lon2] and [lat1,lat2]
plot_global(header,2-D var,'CA',[1 1 1;jet(63)])    % Plots the 2-D variable according to the colouraxis specified after 'CA' (cf. help caxis)
plot_global(header,2-Dvar,'CB','hor')                   % Plots the 2-D variable according to thehorizontal colour bar (cf. help colorbar)

plot_iregy(header,2-D var)                                   % Plots the 2-D variable whose header.YDEF.vec is not regularly spaced

plot_data(header,2-Dvar,'area','EU')                      % Plots the 2-Dvariable on the European rotated grid
add_cont(gca,'area','EU')                                       % Adds the coastal contours to an existing plot, withthe EU rotated coordinates

Details of the optional input can be inferredfrom reading the Matlab script.


lpj_plotand koeppen_plot routines
注:附件为作者提供打包下载的全部matlab程序。





Kristof-toolbox.20070616.tgz

321.74 KB, 下载次数: 56, 下载积分: 金钱 -5

评分

参与人数 1金钱 +8 贡献 +2 收起 理由
mofangbao + 8 + 2

查看全部评分

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

新浪微博达人勋

发表于 2013-7-31 17:26:15 | 显示全部楼层
好东西     谢谢分享
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2013-8-1 11:24:47 | 显示全部楼层
謝謝大大分享!!!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-9-23 21:13:34 | 显示全部楼层
好东西     谢谢分享
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-30 18:15:17 | 显示全部楼层
koppen ,thanks for your code
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-10-31 10:54:47 | 显示全部楼层
好东西,感谢分享!新人金钱不够,楼主可否先分享一份给我学习,非常感谢! tongb1218@163.com
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-11-1 13:36:13 | 显示全部楼层
谢谢楼主,么么哒
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-11-1 21:29:55 | 显示全部楼层
这是个好东西!
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2015-11-23 09:27:04 | 显示全部楼层
真好真好,最近真的很需要学习
密码修改失败请联系微信:mofangbao

新浪微博达人勋

发表于 2016-3-21 12:17:50 | 显示全部楼层
收藏了  可能用得到
密码修改失败请联系微信:mofangbao
您需要登录后才可以回帖 登录 | 立即注册 新浪微博登陆

本版积分规则

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

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

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