grass icon indicating copy to clipboard operation
grass copied to clipboard

[Feat] add the ability to use function parameter files for all the GRASS functions with runtime overrides

Open spaine916 opened this issue 11 months ago • 3 comments

Is your feature request related to a problem? Please describe.

I have multiple definitions of parameters created for a GRASS function and I have to entered them at run time. I often forget the definitions and key them in incorrectly which is frustrating. It is also difficult to try out various options as all the parameters have to be entered each time. This would also provide stored parameter files for working in the modelling domain.

Describe the solution you'd like

Use parameter configuration files for all the GRASS functions. Provide the ability to use runtime overrides. The configuration file creation, saving and editing would be done with a text editor. The configuration file would have:

  • Header information with a user defined description.
  • Parameters for the function name and configuration file name.
  • The flags and parameter definitions for the specific function.

Describe alternatives you've considered

I create text files with parameters and flags that I then use for reference when I type in the command line parameters.

Additional context

The example below is a definition of r.relief for a terrain with ridges running NE to SW. This configuration (MyMapShade.cfg) will run using the specified flags and parameters and defaults for the rest of them.

#This configuration is defined for MyMap which has ridges running NE to SW
function =r.relief
configuration=MyMapShade.cfg
input=DEM20
output=Shade
altitude=65
azimuth=135
zscal=3
scale=1
units=intl
#cfgsave=MyMapShade.cfg
--overwrite
#--help
#--verbose
--quiet
#--ui

This file would be defined as a concatenation of the function file name as:

  • r.relief.MyMapShade.cfg

This would provide easy searching for function specific configuration files.

The configuration file can then be assigned to the function with the following GRASS command:

#read directly from file.
r.relief cfg=MyMapShade.cfg

It would execute as.

r.relief input=DEM20 output=Shade10AM altitude=65 azimuth=135 zscal=3 scale=1 units=intl

Runtime overrides could be used to allow easy what if executions without overwriting the configuration file. Any parameter or flag added to the command would override the value from the configuration file at run time. For example, a user could vary the sun direction and height to find the combination that shows the best shading for their area of interest.

r.relief cfg=MyMapShade azimuth=120 altitude=45

This lets a user simply vary the parameter they want to investigate until they are ready to update the configuration file or create a new one.

If a user wanted to save the existing command line configuration they could use the cfgsave parameter to define the name of an output configuration file. The cfgsave will take the existing command line configuration and write it out to the named configuration file. The cfgsave parameter could be used to create a new configuration file with a new file name as well as edit an existing configuration file by using the current configuration file name.

Configuration files would provide a way to store parameters for any function for later reuse in the command line environment.

It should also be possible to use the configuration files in the modelling environment to define the execution of a function in the modelling process definition.

The full implementation into the GUI environment for all functions would require the addition of a scrolling edit field for configuration files and a save button. There would also need to be some additional behavior added to the GUI code behind to handle the read and write of parameter definitions in the GUI fields. I can provide details for this is it is required.

spaine916 avatar Nov 18 '24 18:11 spaine916