Quacken8 / MagneticDisconnectSimulator

Python simulator of disconnection of solar magnetic field from its roots inpsired by Schüssler and Rempel (2018)
1 stars 0 forks source link

Add configuration settings #8

Open mejroslav opened 1 year ago

mejroslav commented 1 year ago

You can add configuration settings to your code using configparser. This enables you to quickly change the datasources, algorithms etc without changing the code (say no more to huge commented code blocks).

Concept

  1. Create config.ini file that looks like this:
    
    [general]
    datafile=path/to/datafile
    algorithm=rungekutta8
    outuput=path/to/output

[logging] level=debug logfile=path/to/logfile

2. The flow should be the following (not sure about fallbacks....)

```python
import configparser

config = configparser.ConfigParser()
config.read("config.ini")

...

self.Algorithm = config.get("general", "algorithm", fallback="RungeKutta8")
self.LogFile = config.get("logging", "logfile", fallback=None)

...
if self.Algorithm == "RungeKutta8":
    ...

You can also add default settings and much more...