|
|
**Note**: *features described in this page are only available using the tool as a (Python/R) library.*
|
|
|
|
|
|
Bear in mind the initial steps that are always valid before using the tool, in Python:
|
|
|
|
|
|
```
|
|
|
from mapgenerator.plotting import plotmap # import mapgenerator plotting library
|
|
|
pm = plotmap.PlotMap() # create an instance of the class "PlotMap"
|
|
|
|
|
|
```
|
|
|
or, in R:
|
|
|
|
|
|
```
|
|
|
library(reticulate) # load R/Python interface library
|
|
|
plotmap <- import("mapgenerator.plotting.plotmap") # import mapgenerator plotting library
|
|
|
pm <- plotmap$PlotMap() # create an instance of the class *PlotMap*
|
|
|
|
|
|
```
|
|
|
|
|
|
Once done that, you have your *pm* object (instance of *PlotMap* class). All *attributes* and *methods (functions)* can be assigned/modified/executed by this object.
|
|
|
|
|
|
**Assign and modify options through attributes**
|
|
|
|
|
|
All options have their own default value. Calling plotting functions (*plot* or *aplot*) their values can be modified or not. For example:
|
|
|
|
|
|
```
|
|
|
pm.plot(srcfiles='test.nc', srcvars='tas', resolution='h', ..., optionX=valueX)
|
|
|
```
|
|
|
is the same of:
|
|
|
```
|
|
|
pm.srcfiles = 'test.nc'
|
|
|
pm.srcvars = 'tas'
|
|
|
pm.resolution = 'h'
|
|
|
...
|
|
|
pm.optionX = valueX
|
|
|
pm.plot()
|
|
|
```
|
|
|
The difference is that in the first case values are not stored (except *srcfiles* and *srcvars* that are always stored because are the two mandatory options for let the function working) and in the second yes. After executing the plotting function you will find, in the first case:
|
|
|
```
|
|
|
pm.resolution
|
|
|
|
|
|
```
|
|
|
empty, as the default value (None). While in the second case:
|
|
|
```
|
|
|
pm.resolution
|
|
|
'h'
|
|
|
```
|
|
|
The value has been stored.
|
|
|
|
|
|
**Manage configuration files through functions**
|
|
|
|
|
|
Three functions (methods) are available:
|
|
|
|
|
|
1. *loadConf*: loads options from existing configuration file. Input parameters are:
|
|
|
|
|
|
* section - the section of the configuration file (default=None)
|
|
|
* fpath - full path of the configuration file. If None reads *config_dir* and *config_file* variables (default=None)
|
|
|
* reset - if True, reset all options to default before load new values (default=False)
|
|
|
|
|
|
2. *writeConf*: writes current configuration to file. Input parameters are:
|
|
|
|
|
|
* section - the section of the configuration file
|
|
|
* fpath - full path of the conf file. If None reads *config_dir* and *config_file* variables (default=None)
|
|
|
|
|
|
3. *resetConf*: reset configuration to defaults. It doesn't require any option.
|
|
|
|
|
|
**IMPORTANT**: In case of crash of *plot* or *aplot* function execution, *pm.resetConf()* is required, otherwise it will not work. As alternative option the *pm* object can be created again.
|
|
|
|
|
|
**Go [Home](home)**
|
|
|
|
|
|
**Back to [Options](options)**
|
|
|
|
|
|
**Forward to [Examples](examples)** |