WEAP 21的ERA5/modis预处理器

mET-weap的Python项目详细描述


气象站

通过anr紫水晶项目,开发了一个python包来处理modis-ndvi和meteo era5长时间序列,以生成weap 21的输入数据。

文档

  • 阅读文档“Met_WEAP安装过程和用户指南”

快速安装MET WEAP

有关更多信息,请参阅文档“Met_Weap安装过程和用户指南”。

要求

  1. 在pypi或github上下载met_weap
  2. 在您的计算机上复制/粘贴测试文件“met_weap_test”
  3. 地球数据订阅
  4. 订阅CD(气候数据存储)
  5. OSGEO4W安装
  6. 为gdal(windows)创建环境变量
  7. 下载所需文件
  8. 安装水蟒

安装

a)从本地文件安装用户:

例如,如果setup.py的源文件为“c:\ users\vi\documents\met_weap”。 在anaconda提示符下,执行:

- cd"C:\Users\VI\Documents\mET_weap"

然后,执行:

- python setup.py sdist bdist_wheel
- cd .\dist
- pip install mET_weap-1.3.tar.gz

最后,由于gdal的安装不适用于setup.py中的install_requires,请执行:

- conda install gdal

b)从pypi安装用户

在anaconda提示符下,执行:

- pip install mET_weap
- conda install gdal

测试文件夹

恢复在pypi或github上下载的包中的“met_weap_test”文件夹。 如果直接从pypi进行安装,也可以在“sites packages”文件夹中恢复此文件夹(例如“c:\ users\vi\anaconda3\lib\site packages\met_weap”)。 首先,在桌面上复制/粘贴此测试文件夹“met_weap_test”。程序将从这个“工作”目录执行。

配置

使用userconfig.py文件进行配置。这是用户要使其项目正常工作必须填写的唯一文件。

首先,必须定义路径根和osgeo的路径:

mET_weap.path_root=os.path.join('C:'+os.sep+'HAOUZ'+os.sep+'mET_weap')# The root directory for output filesmET_weap.path_to_osgeo=os.path.join('C:'+os.sep+'OSGeo4W64'+os.sep+'bin')# the path for gdal binaries

例如,在上面的示例中,path_root='c:\ haouz\met_weap'和path_to_osgeo='c:\ osgeo4w64\bin'。路径根为输出创建目录。

配置文件的下一部分是模块的开关。在执行usermain之前,填写“true”激活模块,填写“false”停用模块。 例如,在下面的示例中,“do_get_modis”是唯一激活的模块。

# ---- Switchs to activate or deactivate the modules ----# Each Modis tile covers an area of 5°x5°, it may not be necessary to download it again to process another area.'do_get_modis':True,# download modis files# If you already downloaded ERA5 files for your area and domain, don't do it again.'do_download_ERA5_cds':False,# download weather dataset from CDS ERA5# The following toggles are processing steps,# Toggle the steps that already went ok to False'do_project_subset':False,# projection and subset of the modis files'do_classification':False,# yearly classification'do_kc_fc':False,# compute Kc/Fc'do_ET0_rain_ERA5':False,# compute daily ET0 and rainfall from ERA5'do_interp_ndvi_ERA5':False,# temporal interpolation of NDVI and KC*ET0 with ERA5 data'do_synthesis_ERA5':False,# spatio-temporal synthesis with ERA5 data

在登录到服务器cds api之后。接受许可证哥白尼产品。 然后,单击“注销”按钮附近的名称,在用户配置文件中检索api密钥。使用cdsapi密钥的格式“uid:api key”。

# ----- The CDSAPI key to download ERA5 data -----'CDSAPI':{'url':"https://cds.climate.copernicus.eu/api/v2",'key':"xxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",},

接下来,在userconfig.py文件中填写modis用户名和密码。

# ---- The MODIS login to download MODIS data ----'MODIS':{'username':"xxxxxxxx",'password':"xxxxxxxx"},

然后,必须定义空间域。在userconfig.py中填写研究区域的地理坐标。

# ----- the spatial domain to be processed -----'domain':{"uly":31.7,# Upper left Y in dd (decimal degrees)"ulx":-8.6,# Upper left X in dd'lry':30.85,# Lower right Y in dd'lrx':-7# Lower Right X in dd},

之后,定义比例。通常,用户不需要更改这些值。

'scale':{"echelle":0.25,"resolution_ERA5":0.25},

选择你的时间域。例如,从2015年9月到2016年9月。

# -----  the temporal domain to be processed -----'period':{'begin':datetime(2015,9,1),# the date of beginning as a datetime (yyyy,m,j)'end':datetime(2016,8,30)# the date of ending as a datetime (yyyy,m,j)},

定义农艺年:

# -----  definition of the agronomic year with the beginning month and ending month -----'agroyear':{'begin':9,# generally the agronomic year begins in september (9)'end':8# generally the agronomic year begins in august of the next year (8)},

下一部分允许选择用于计算kc和fc因子的函数。

# -----  Kc and Fc to NDVI relationships -----'Relation_NDVI':{'scale_factor':0.0001,# A scale factor to apply to NDVI data, typically 0.001 for MODIS'Ndvi_KcKcb':os.path.join('Tab_ndvi_kc_fc','ndvi_kckcb.xlsx'),# the XLS file for relations NDVI->Kc (Crop Coefficient)'Ndvi_Fc':os.path.join('Tab_ndvi_kc_fc','NDVI-FC.xlsx'),# the XLS file for relations NDVI->Fc (Fraction Cover)'do_senescence':True,# Optional: To compute or not the fraction cover plateau for annual crops. The computation is time consuming'do_stack':False,# Optional: To output or not annual stacks. Those stacks may be useful for data vizualisation# rel OS is the table of relations between NDVI/Kcb and NDVI/Fraction covers# the syntax is: 'class_name' : [output_value, line of xls file for Kcb, line of xls file for Fc]# None if Kc is not computed for a particular class'rel_OS':{'No_data':[0,None,None],'Advent':[2,None,None],'Arb_Veg':[3,6,5],'Arb_SN':[4,0,5],'C_Anu':[5,6,0],'Sol_Nu':[8,None,None]}},

此模块允许配置研究区域的形状文件和合成模块之间的链接。 此shapefile必须位于met_weap目录中。 对于他的项目,用户需要在[“synth”][“shapefile”中填写他的shapefile的名称。 在测试文件中,在上面的示例中,“shapefile”:“zonage\atlas_piemont_haouz.shp”。 在“shp_attrib”中,填写属性表的列名。在“C区IRR”示例中。 最后,定义“timerange”和“mode”。

# -----  Synthesis -----'Synth':{'shapefile':os.path.join('zonage'+os.sep+'Atlas_Piemont_Haouz.shp'),'shp_attrib':'c_zone_irr',# column name of the attribute table'timerange':"MONTH",# an accumulation time which is either DAY, WEEK or MONTH'mode':"SUM",# MEAN or SUM},

通常,路径不需要更改,因为目录gtopo30位于met_weap_test目录中。 “geopotential_cdsapi.nc”下载在“c:\ haouz”

# -----  The path for the DEM input file -----'DEM':{'Description':'GTOPO30','DEM_Filename':os.path.join('Gtopo30','gt30w020n40.tif'),'ERA_Filename_CDSAPI':os.path.join(''.join(os.path.split(mET_weap.path_root)[0]),'geopotential_cdsapi.nc')},

这些路径定义了utputs目录。它们都是基于根路径的。通常,用户不需要更改它们。

# ----- The paths of the output files -----'path':{'Temp_ERA5':os.path.join(''.join(mET_weap.path_root),"fishnet_era5"),# directory for temporary data'Data':os.path.join(''.join(mET_weap.path_root),"data"),# the root directory to download data'MOD13Q1':os.path.join(''.join(mET_weap.path_root),"data"+os.sep+"MOD13Q1"),# the directory for downloading MODIS MOD13Q1'ERA5':os.path.join(''.join(mET_weap.path_root),os.path.join("data","ERA5")),# the directory to download ERA5 data'Tif':os.path.join(''.join(mET_weap.path_root),"tif"),# the root directory for output data'MOD13Q1_tif':os.path.join(''.join(mET_weap.path_root),"tif"+os.sep+"MOD13Q1"),# the  directory for NDVI Subsets'ERA5_tif':os.path.join(''.join(mET_weap.path_root),"tif"+os.sep+"ERA5"),# the  directory for ERA5 processed input files'outputs_ERA5':os.path.join(''.join(mET_weap.path_root),"tif"+os.sep+"outputs_ERA5"),# The directory for results used for synthesis ERA5'synthesis_ERA5':os.path.join(''.join(mET_weap.path_root),"synthesis_ERA5")# The directory for synthesized results based on ERA5 meteorological data},

许可证

Met_Weap使用GPLv3许可证。版权所有(c)2014-2018 Michel Le Page。有关详细信息,请参见复制。

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

推荐PyPI第三方库


热门话题
java InputStream对象在声明后关闭   java未定义名为“transactionManager”的bean重命名transactionManager   java“jar”命令何时会拒绝将类添加到java中。jar文件?   java JPA标准依赖WHERE子句   安卓中从SD卡读取文本文件时出现java错误   java直接启用类似位置的权限   使用@WebMvcTest和Mockito-BDDMockito对SpringBoot-RestController进行java测试   java JSESSIONID存储在哪里?   java jtextarea鼠标事件覆盖容器鼠标事件   java DRL无法解析动态加载的类   java是从一个方法返回多个对象的最简单方法   java自定义按钮/编辑框是否不可见?   java GUI如何在保存用户输入的同时在面板或框架之间切换   swing Java自定义JSlider不会更新   GridBagLayout中的java超过1个JPanel   java从ProjectReactor中的flux中采样除第一个元素外的所有元素   Java泛型和泛型类型   Java代码生成宽指令的jvm