Cordex社区的Python工具。

py-cordex的Python项目详细描述


Cordex Python包

https://img.shields.io/pypi/v/py-cordex.svghttps://img.shields.io/travis/euro-cordex/py-cordex.svgDocumentation StatusUpdates

Cordex社区的Python工具。在

特点

  • 管理Cordex元数据
  • 管理Cordex域数据的工具

安装

您可以使用pip直接从github安装包:

pip install git+https://github.com/euro-cordex/py-cordex

如果您想贡献,我建议您克隆存储库并在开发模式下安装包,例如

^{pr2}$

这将安装软件包,但您仍然可以编辑它,并且您的PYTHONPATH中不需要该软件包

亮点

使用域模块安全轻松地创建Cordex域:

fromcordeximportdomainasdm# available tablesprint(dm.tables())# available domains namesprint(dm.names())# available domains namesprint(dm.names('cordex-core'))# print cordex core tableprint(dm.table('cordex-core'))# show domains with some dummy data (uses cdo topo)forshort_name,domainindm.domains().items():print(domain)domain.to_netcdf(short_name+'.nc',dummy='topo')

使用ESGF模块浏览文件系统并创建文件选择的pandas数据帧: (DKRZ示例)。在

Note that DKRZ also provides an intake-esm table (https://intake-esm.readthedocs.io/en/latest/) for browsing and searchin MIP data at DKRZ. I highly recommend to have a look at it and create tables for your own data pool. For creating a table, you could use our cordex conventions module!
importdatetimeasdtfromcordex.ESGFimportget_selection,conventionsproject_id='CMIP5'root='/pool/data/CMIP5/cmip5'filter={'institute':'MPI-M','product':'output1','variable':'tas','model':'MPI-ESM-LR','modeling_realm':'atmos','experiment':'historical','ensemble_member':'r1i1p1'}# get a selection of files (using pandas dataframes)selection=get_selection(project_id,root=root,filter=filter)print(selection)# create a finer selection and convert dates to datetime objectsselection=selection.subset(variable='pr').to_datetime()# get a timeseries of filesselection=selection.select_timerange([dt.datetime(1990,1,1),dt.datetime(2000,1,1)])print(selection)

使用ESGF模块使用属性字典创建文件名。使用CORDEX文件命名 Conversion(或创建您自己的!)公司名称:

fromcordeximportESGFasesgfroot='/my_root'# define attributesattributes={'institute_id':'GERICS','product':'output','model_id':'GERICS-REMO2015','experiment_id':'evaluation','driving_model_id':'ECMWF-ERAINT','variable':'pr','rcm_version_id':'v1','date':'v20200221','frequency':'day','CORDEX_domain':'EUR-11','suffix':'nc','ensemble':'r1i1p1'}# we use the CORDEX convention as exampleconvention=esgf.CORDEX()# print the convention patternsprint(convention.path_conv.conv_str)print(convention.filename_conv.conv_str)# only filenamefilename=convention.filename(**attributes,startdate='20010101',enddate='20010131')# only pathpath=convention.path(**attributes,startdate='20010101',enddate='20010131')# only filename with pathfile=convention.pattern(root,**attributes,startdate='20010101',enddate='20010131')

使用“约定”模块创建您自己的文件命名约定:

fromcordeximportconventionsasconv# create your own filename convention string and listfilename_conv_str='my_convention_{variable}_{model_id}_{domain_id}.nc'path_conv_list=['model_id','variable']# create conventions for filename and pathfilename_conv=conv.FileNameConvention(filename_conv_str)path_conv=conv.FilePathConvention(path_conv_list)# now define your attributes to fill the templates.root='/my_root'attributes={'model_id':'GERICS-REMO2015','variable':'pr','domain_id':'EUR-11'}# create filename and pathfilename=filename_conv.pattern(**attributes)path=path_conv.pattern(root,**attributes)# create combined file conventionfile_conv=conv.FileConvention(path_conv,filename_conv)# create full filename with pathfile=file_conv.pattern(root,**attributes)

要求

  • python3.6或更高版本
  • numpy公司
  • 熊猫
  • (沙雷)
  • 网络CDF4
  • 解析

学分

此包是用Cookiecutteraudreyr/cookiecutter-pypackage项目模板创建的。在

历史

  • PyPI的第一个版本。在

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java如何向xsi:nil元素添加另一个属性?   Java抽象泛型方法,使用具体类型实现通配符   java使用pcap4j截断pcap文件   当我放置字母a、b和c时,java中的异常预期会下降   java设置活动对话框不可取消   接口类型变量上的Java克隆   使用Java或BouncyCastle对CSR(证书签名请求)进行安全解码/读取   java调用SavingsAccount对象上的函数并打印结果   java如何在Android应用程序上显示地图上的兴趣点(POI)并与之交互?   如果在JavaFX中的ResultSet中未找到任何内容,则显示java警报   java我将springboot和@component与@scheduled一起使用,它每12小时锁定一次   ApachePOI如何使用java删除包含字符串的word表的行   java如果对象(x,y)靠近其他对象(x,y)   从未对JMSException调用java JMS CachingConnectionFactory OneException方法   javascript使用java将HTML页面转换为MS word