-
Notifications
You must be signed in to change notification settings - Fork 4
Interacting with Server
To make the interaction with the server easier we provided a minimal API and one can run scenarios from Matlab. Doing something similar in R is also straightforward and will be implemented in the future.
See here
The required Matlab functions are available as part of the gwtools repository.
The first step is to launch the server. To do so under a powershell execute the following
MantisServer.exe -c .\mantisConfig.ini
wait a minute and when you see the message Mantis Server Ready...
you can proceed to the next phase
In the Matlab workspace set up the path to the Mantis client executable
client_prog = 'path\to\MantisClient.exe';
Obtain a list of all scenario options
scenario = MantisInputs();
Scenario is a struct with multiple options.
The options infile
and outfile
are the names of the files where the input and output data will be written. The output file will be deleted every time the Mantis runs.
Let's set up a scenario
scenario.Regions = {'Subregion10','Subregion11'};
scenario.loadScen = 'SWAT1';
scenario.Crops = [-9 0.5];
Then we can simulate the scenario using
[btc, tf] = runMantis(scenario, client_prog);
Calculate and plot the percentiles
tmp = prctile(btc,[10:10:90]);
plot(tmp')
To quit the server run the following
runMantis([], client_prog, 'quit');