Cordex社区的Python工具。
py-cordex的Python项目详细描述
Cordex Python包
Cordex社区的Python工具。在
- 免费软件:麻省理工学院许可证
- 文档:https://cordex.readthedocs.io。在
特点
- 管理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
- 解析
学分
此包是用Cookiecutter和audreyr/cookiecutter-pypackage项目模板创建的。在
历史
- PyPI的第一个版本。在
- 项目
标签: