Question
I have a large number of data files that need to be processed by MIKE Zero tools exactly the same way. How do I do this the most efficient way?
Trick
One way is to create a batch file/script that can be executed from a command prompt.
The script can contain a ‘for’ loop that accounts for all files in a specific folder. Within this loop one can copy the individual files to a generic file, process the generic file as required and finally copy the result from this process to the resulting file.
For complex processes it is recommended to use a folder structure that supports the process, e.g. a main folder where the script is located and file processing takes place, and two sub-folders for the original input files and for the required result files, respectively.
Example 1
In this example we assume to have separate dfsu file results (with one time step only) in a single folder that for a specific item all need to be interpolated and exported to an ascii raster file.
The script is located in the main folder, the input dfsu files are located in a subfolder called ‘dfsu-files’ and the resulting ascii raster files will be located in another subfolder called 'asc-files'.
The process of converting a dfsu file to an ascii raster file consists of two steps (using two MIKE Zero tools) which need to be included in the script:
- Convert dfsu to dfs2: this can be done using a Data Extraction FM setup. Select one item and one time step.
- Export dfs2 file to ascii file: this can be done using a setup with the MIKE Zero toolbox tool Mike2Grd
The script would look as follows:
path =%path%;%DHI_MIKE_2025%; | (sets the path to the MIKE installation) |
After running the script the subfolder ‘asc-files’ will contain all the ascii raster files that relate to the same dfsu files in the subfolder ‘dfsu files’.
Example 2
In this example we assume to have a lot of similar dfs0 files in a folder, and the dynamic item properties for the second item need to be changed to a ‘water level’ type in all the files.
The process of changing the item properties in an existing file can be performed by a custom tool, e.g. ‘ChangeItemInfo.exe’ created by using MIKE Core SDK (for details, see KA-01170). The command to change e.g. the 2nd item in file ‘file.dfsu’ to reflect a water level is ChangeItemInfo.exe file.dfsu 2 "Water level" eumIWaterLevel eumUmeter.
This tool can be applied on all files in the folder using the following script:
set path =%path%;%DHI_MIKE_2025%; | (sets path) |
After running the script item 2 in all the dfs0 files in the folder will be defined as a water level item.
FURTHER INFORMATION AND USEFUL LINKS
[Manuals and User Guides]
User Guide. MIKE ZERO. (Chapter 5.4 Batch Execution)
MIKE Zero Toolbox User Guide
MIKE for developers docs