Skip to main content

稳态流模型和对 DFS 文件的 python 访问

项目描述

水文信息

这个包包含一个稳态流模型和一些从 DHI 访问 .dfs 文件的工具

用法

将 .dfs、res1d 和 res11 文件转换为 netCDF:

#Import NetCDF and DFS from hydroinform
from hydroinform import NetCDF, DFS

#Saves "omr4_jag_3DSZ.dfs3 as "omr4_jag_3DSZ.nc"
NetCDF.save_as_NetCDF('omr4_jag_3DSZ.dfs3')

#Saves "omr4_jag_3DSZ.dfs3 as "newname.nc"
NetCDF.save_as_NetCDF('omr4_jag_3DSZ.dfs3','newname.nc')

#Saves only the first item and the second and fourth time step from "omr4_jag_3DSZ.dfs3""
d= DFS.DFSBase.open_file('omr4_jag_3DSZ.dfs3')
NetCDF.save_dfs_as_NetCDF(d, [0], [1,3], 'omr4_jag_3DSZ_one_time.nc')

#Saves the discharge data from "Storaa_HD_quasiStationary_20090701.res1d" as 'Storaa_HD_quasiStationary_20090701.nc'
NetCDF.save_as_NetCDF('Storaa_HD_quasiStationary_20090701.res1d')

编写与 MikeZero 一起使用的泵提取文件:

#Import DFS from HydroInform
from hydroinform import DFS
import datetime

#The number of Items (In this case number of pumping wells)
numberofitems = 5;

#Now create the file.
_tso = DFS.DFS0.new_file(r'c:\temp\extraction.dfs0', numberofitems);

#Loop the items and set the units etc.
for itemCount in range (0, numberofitems):
    _tso.items[itemCount].value_type = DFS.DataValueType.MeanStepBackward
    _tso.items[itemCount].eum_item = DFS.EumItem.eumIPumpingRate
    _tso.items[itemCount].eum_unit = DFS.EumUnit.eumUm3PerYear
    _tso.items[itemCount].name = "Item number: " + str(itemCount)
      
#Loop the years where you have pumping data
tscount = 0;
for year in range(2010, 2016):
    #For every year append a new timestep
    _tso.append_time_step(datetime.datetime(year, 12, 31, 12))
    #Loop the items and set a value for this timestep
    for itemCount in range (0, numberofitems):
        #Sets the data. Note that timesteps count from 0 and Items count from 1
        _tso.set_data(tscount, itemCount+1, year * itemCount)
    tscount+=1
#Call dispose which will save and close the file.
_tso.dispose()

项目详情


下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

hydroinform-0.1.17.tar.gz (47.4 kB 查看哈希

已上传 source

内置分布

hydroinform-0.1.17-py3-none-any.whl (49.7 kB 查看哈希

已上传 py3