fpex0.example.exampleFit API documentation

# fpex0.example.exampleFit

View Source

     1from fpex0 import fpex0
     2from fpex0.example.exampleSetup import exampleSetup, importExampleMeasurements
     3
     4import time
     5
     6
     7def exampleFit():
     8    """
     9    Runs an example fit with:
    10    - An example fpex0 setup configuration, retrieved by `fpex0.example.exampleSetup.exampleSetup()` (check for details)
    11    - Example data, contained in the fpex0/example/ID407-rate_*.json files
    12    - A Fraser-Suzuki initial distribution
    13    - The scipy solve_ivp BDF integrator to solve the Fokker Planck equation
    14    - The scipy least_squares optimizer to fit the example measurements
    15
    16    <br>
    17    No in- or output. Prints information and a solution parameter vector. <br>
    18    """
    19    # make example setup
    20    print("Creating an example setup.")
    21    FPEX0setup = exampleSetup()
    22
    23    # import the example data
    24    print("Importing example data.")
    25    FPEX0setup = importExampleMeasurements(FPEX0setup, gridskip=2)
    26
    27    # modify some configuration (as example)
    28    print("Setting integration options.")
    29    FPEX0setup.Integration.options["rtol"] = 1e-8
    30    FPEX0setup.Integration.options["atol"] = 1e-14
    31
    32    # fitting
    33    print("\nSolving the fitting problem:")
    34    refTime = time.time()
    35    fit = fpex0.fit(FPEX0setup)
    36    duration = time.time() - refTime
    37    print("Fit complete.")
    38    print(f"Fit time: {duration}s.")
    39    print(f"Solution found: p = {fit.x}")
    40
    41if __name__=='__main__':
    42    exampleFit()

def exampleFit(): View Source

     8def exampleFit():
     9    """
    10    Runs an example fit with:
    11    - An example fpex0 setup configuration, retrieved by `fpex0.example.exampleSetup.exampleSetup()` (check for details)
    12    - Example data, contained in the fpex0/example/ID407-rate_*.json files
    13    - A Fraser-Suzuki initial distribution
    14    - The scipy solve_ivp BDF integrator to solve the Fokker Planck equation
    15    - The scipy least_squares optimizer to fit the example measurements
    16
    17    <br>
    18    No in- or output. Prints information and a solution parameter vector. <br>
    19    """
    20    # make example setup
    21    print("Creating an example setup.")
    22    FPEX0setup = exampleSetup()
    23
    24    # import the example data
    25    print("Importing example data.")
    26    FPEX0setup = importExampleMeasurements(FPEX0setup, gridskip=2)
    27
    28    # modify some configuration (as example)
    29    print("Setting integration options.")
    30    FPEX0setup.Integration.options["rtol"] = 1e-8
    31    FPEX0setup.Integration.options["atol"] = 1e-14
    32
    33    # fitting
    34    print("\nSolving the fitting problem:")
    35    refTime = time.time()
    36    fit = fpex0.fit(FPEX0setup)
    37    duration = time.time() - refTime
    38    print("Fit complete.")
    39    print(f"Fit time: {duration}s.")
    40    print(f"Solution found: p = {fit.x}")

Runs an example fit with:

- An example fpex0 setup configuration, retrieved by `fpex0.example.exampleSetup.exampleSetup()` (check for details)
- Example data, contained in the fpex0/example/ID407-rate_*.json files
- A Fraser-Suzuki initial distribution
- The scipy solve_ivp BDF integrator to solve the Fokker Planck equation
- The scipy least_squares optimizer to fit the example measurements

No in- or output. Prints information and a solution parameter vector.