diff --git a/src/CiteSoftLocal.py b/frhodo/CiteSoftLocal.py similarity index 100% rename from src/CiteSoftLocal.py rename to frhodo/CiteSoftLocal.py diff --git a/src/UI/error_window.ui b/frhodo/UI/error_window.ui similarity index 100% rename from src/UI/error_window.ui rename to frhodo/UI/error_window.ui diff --git a/src/UI/graphics/arrowdown.png b/frhodo/UI/graphics/arrowdown.png similarity index 100% rename from src/UI/graphics/arrowdown.png rename to frhodo/UI/graphics/arrowdown.png diff --git a/src/UI/graphics/check_icon.png b/frhodo/UI/graphics/check_icon.png similarity index 100% rename from src/UI/graphics/check_icon.png rename to frhodo/UI/graphics/check_icon.png diff --git a/src/UI/graphics/main_icon.png b/frhodo/UI/graphics/main_icon.png similarity index 100% rename from src/UI/graphics/main_icon.png rename to frhodo/UI/graphics/main_icon.png diff --git a/src/UI/graphics/x_icon.png b/frhodo/UI/graphics/x_icon.png similarity index 100% rename from src/UI/graphics/x_icon.png rename to frhodo/UI/graphics/x_icon.png diff --git a/src/UI/main_window.ui b/frhodo/UI/main_window.ui similarity index 100% rename from src/UI/main_window.ui rename to frhodo/UI/main_window.ui diff --git a/src/UI/save_dialog.ui b/frhodo/UI/save_dialog.ui similarity index 100% rename from src/UI/save_dialog.ui rename to frhodo/UI/save_dialog.ui diff --git a/src/calculate/__init__.py b/frhodo/__init__.py similarity index 100% rename from src/calculate/__init__.py rename to frhodo/__init__.py diff --git a/src/appdirs.py b/frhodo/appdirs.py similarity index 100% rename from src/appdirs.py rename to frhodo/appdirs.py diff --git a/src/bonmin/bonmin-linux64/bonmin b/frhodo/bonmin/bonmin-linux64/bonmin similarity index 100% rename from src/bonmin/bonmin-linux64/bonmin rename to frhodo/bonmin/bonmin-linux64/bonmin diff --git a/src/bonmin/bonmin-linux64/coin-license.txt b/frhodo/bonmin/bonmin-linux64/coin-license.txt similarity index 100% rename from src/bonmin/bonmin-linux64/coin-license.txt rename to frhodo/bonmin/bonmin-linux64/coin-license.txt diff --git a/src/bonmin/bonmin-osx/bonmin b/frhodo/bonmin/bonmin-osx/bonmin similarity index 100% rename from src/bonmin/bonmin-osx/bonmin rename to frhodo/bonmin/bonmin-osx/bonmin diff --git a/src/bonmin/bonmin-osx/coin-license.txt b/frhodo/bonmin/bonmin-osx/coin-license.txt similarity index 100% rename from src/bonmin/bonmin-osx/coin-license.txt rename to frhodo/bonmin/bonmin-osx/coin-license.txt diff --git a/src/bonmin/bonmin-win64/bonmin.exe b/frhodo/bonmin/bonmin-win64/bonmin.exe similarity index 100% rename from src/bonmin/bonmin-win64/bonmin.exe rename to frhodo/bonmin/bonmin-win64/bonmin.exe diff --git a/src/bonmin/bonmin-win64/coin-license.txt b/frhodo/bonmin/bonmin-win64/coin-license.txt similarity index 100% rename from src/bonmin/bonmin-win64/coin-license.txt rename to frhodo/bonmin/bonmin-win64/coin-license.txt diff --git a/src/bonmin/bonmin-win64/libipoptfort.dll b/frhodo/bonmin/bonmin-win64/libipoptfort.dll similarity index 100% rename from src/bonmin/bonmin-win64/libipoptfort.dll rename to frhodo/bonmin/bonmin-win64/libipoptfort.dll diff --git a/src/calculate/optimize/__init__.py b/frhodo/calculate/__init__.py similarity index 100% rename from src/calculate/optimize/__init__.py rename to frhodo/calculate/__init__.py diff --git a/src/calculate/convert_units.py b/frhodo/calculate/convert_units.py similarity index 100% rename from src/calculate/convert_units.py rename to frhodo/calculate/convert_units.py diff --git a/src/calculate/integrate.py b/frhodo/calculate/integrate.py similarity index 100% rename from src/calculate/integrate.py rename to frhodo/calculate/integrate.py diff --git a/src/calculate/mech_fcns.py b/frhodo/calculate/mech_fcns.py similarity index 99% rename from src/calculate/mech_fcns.py rename to frhodo/calculate/mech_fcns.py index 65e731b..707d945 100644 --- a/src/calculate/mech_fcns.py +++ b/frhodo/calculate/mech_fcns.py @@ -7,10 +7,11 @@ import cantera as ct from cantera import interrupts, cti2yaml#, ck2yaml, ctml2yaml import numpy as np -from calculate import reactors, shock_fcns, integrate -import ck2yaml from timeit import default_timer as timer +from . import reactors, shock_fcns, integrate +from .. import ck2yaml + class Chemical_Mechanism: def __init__(self): diff --git a/src/calculate/optimize/CheKiPEUQ_from_Frhodo.py b/frhodo/calculate/optimize/CheKiPEUQ_from_Frhodo.py similarity index 98% rename from src/calculate/optimize/CheKiPEUQ_from_Frhodo.py rename to frhodo/calculate/optimize/CheKiPEUQ_from_Frhodo.py index d311152..00351b6 100644 --- a/src/calculate/optimize/CheKiPEUQ_from_Frhodo.py +++ b/frhodo/calculate/optimize/CheKiPEUQ_from_Frhodo.py @@ -6,19 +6,14 @@ except: #import pathlib #sys.path.append(pathlib.Path(__file__).parent.absolute()) # add directory of **this** file to path - import calculate.optimize.CheKiPEUQ_local as CKPQ + import frhodo.calculate.optimize.CheKiPEUQ_local as CKPQ try: import CheKiPEUQ.UserInput as UserInput except: - import calculate.optimize.CheKiPEUQ_local.UserInput as UserInput + from .CheKiPEUQ_local import UserInput -try: - import CiteSoft -except: - #import pathlib #The below lines are to allow CiteSoftLocal to be called regardless of user's working directory. - #sys.path.append(pathlib.Path(__file__).parent.absolute()) # add directory of **this** file to path - import CiteSoftLocal as CiteSoft +import frhodo.CiteSoftLocal as CiteSoft #get things ready for CiteSoft entry... software_name = "CheKiPEUQ Bayesian Parameter Estimation" diff --git a/src/calculate/optimize/CheKiPEUQ_integration_notes.txt b/frhodo/calculate/optimize/CheKiPEUQ_integration_notes.txt similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_integration_notes.txt rename to frhodo/calculate/optimize/CheKiPEUQ_integration_notes.txt diff --git a/src/calculate/optimize/CheKiPEUQ_local/CombinationGeneratorModule.py b/frhodo/calculate/optimize/CheKiPEUQ_local/CombinationGeneratorModule.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/CombinationGeneratorModule.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/CombinationGeneratorModule.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/InverseProblem.py b/frhodo/calculate/optimize/CheKiPEUQ_local/InverseProblem.py similarity index 99% rename from src/calculate/optimize/CheKiPEUQ_local/InverseProblem.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/InverseProblem.py index 38799cc..2251cff 100644 --- a/src/calculate/optimize/CheKiPEUQ_local/InverseProblem.py +++ b/frhodo/calculate/optimize/CheKiPEUQ_local/InverseProblem.py @@ -9,16 +9,13 @@ from collections.abc import Iterable #import mumce_py.Project as mumce_pyProject #FIXME: Eric to fix plotting/graphing issue described in issue 9 -- https://github.com/AdityaSavara/ODE-KIN-BAYES-SG-EW/issues/9 #import mumce_py.solution mumce_pySolution -try: - import CiteSoft -except: - #import pathlib #The below lines are to allow CiteSoftLocal to be called regardless of user's working directory. - #sys.path.append(pathlib.Path(__file__).parent.absolute()) # add directory of **this** file to path - import CiteSoftLocal as CiteSoft + +import frhodo.CiteSoftLocal as CiteSoft + try: import UnitTesterSG.nestedObjectsFunctions as nestedObjectsFunctions -except: - import calculate.optimize.CheKiPEUQ_local.nestedObjectsFunctionsLocal as nestedObjectsFunctions +except ImportError: + import frhodo.calculate.optimize.CheKiPEUQ_local.nestedObjectsFunctionsLocal as nestedObjectsFunctions class parameter_estimation: #Inside this class, a UserInput namespace is provided. This has dictionaries of UserInput choices. diff --git a/src/calculate/optimize/CheKiPEUQ_local/LICENSE.txt b/frhodo/calculate/optimize/CheKiPEUQ_local/LICENSE.txt similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/LICENSE.txt rename to frhodo/calculate/optimize/CheKiPEUQ_local/LICENSE.txt diff --git a/src/calculate/optimize/CheKiPEUQ_local/MANUAL.txt b/frhodo/calculate/optimize/CheKiPEUQ_local/MANUAL.txt similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/MANUAL.txt rename to frhodo/calculate/optimize/CheKiPEUQ_local/MANUAL.txt diff --git a/src/calculate/optimize/CheKiPEUQ_local/UserInput.py b/frhodo/calculate/optimize/CheKiPEUQ_local/UserInput.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/UserInput.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/UserInput.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/__init__.py b/frhodo/calculate/optimize/CheKiPEUQ_local/__init__.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/__init__.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/__init__.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/mumpce_custom_plotting_example.py b/frhodo/calculate/optimize/CheKiPEUQ_local/mumpce_custom_plotting_example.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/mumpce_custom_plotting_example.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/mumpce_custom_plotting_example.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/nestedObjectsFunctionsLocal.py b/frhodo/calculate/optimize/CheKiPEUQ_local/nestedObjectsFunctionsLocal.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/nestedObjectsFunctionsLocal.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/nestedObjectsFunctionsLocal.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/parallel_processing.py b/frhodo/calculate/optimize/CheKiPEUQ_local/parallel_processing.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/parallel_processing.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/parallel_processing.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/plotting_functions.py b/frhodo/calculate/optimize/CheKiPEUQ_local/plotting_functions.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/plotting_functions.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/plotting_functions.py diff --git a/src/calculate/optimize/CheKiPEUQ_local/test_pytest.py b/frhodo/calculate/optimize/CheKiPEUQ_local/test_pytest.py similarity index 100% rename from src/calculate/optimize/CheKiPEUQ_local/test_pytest.py rename to frhodo/calculate/optimize/CheKiPEUQ_local/test_pytest.py diff --git a/src/plot/__init__.py b/frhodo/calculate/optimize/__init__.py similarity index 100% rename from src/plot/__init__.py rename to frhodo/calculate/optimize/__init__.py diff --git a/src/calculate/optimize/fit_coeffs.py b/frhodo/calculate/optimize/fit_coeffs.py similarity index 99% rename from src/calculate/optimize/fit_coeffs.py rename to frhodo/calculate/optimize/fit_coeffs.py index 4b5af1c..e53827c 100644 --- a/src/calculate/optimize/fit_coeffs.py +++ b/frhodo/calculate/optimize/fit_coeffs.py @@ -12,8 +12,9 @@ from timeit import default_timer as timer import itertools -from calculate.convert_units import OoM, Bisymlog -from calculate.optimize.misc_fcns import penalized_loss_fcn, set_arrhenius_bnds, min_pos_system_value, max_pos_system_value +from ..convert_units import OoM, Bisymlog +from ..optimize.misc_fcns import penalized_loss_fcn, set_arrhenius_bnds, min_pos_system_value, max_pos_system_value +import frhodo Ru = ct.gas_constant # Ru = 1.98720425864083 @@ -134,7 +135,7 @@ def ln_arrhenius_jac(T, *args): return popt -path = {'main': pathlib.Path(sys.argv[0]).parents[0].resolve()} +path = {'main': pathlib.Path(frhodo.__file__).parents[0].resolve()} # TODO (wardlt) - Make a globally-accessible Path OS_type = platform.system() if OS_type == 'Windows': path['bonmin'] = path['main'] / 'bonmin/bonmin-win64/bonmin.exe' diff --git a/src/calculate/optimize/fit_coeffs_pygmo.py b/frhodo/calculate/optimize/fit_coeffs_pygmo.py similarity index 99% rename from src/calculate/optimize/fit_coeffs_pygmo.py rename to frhodo/calculate/optimize/fit_coeffs_pygmo.py index 1fc8716..fbaf8d6 100644 --- a/src/calculate/optimize/fit_coeffs_pygmo.py +++ b/frhodo/calculate/optimize/fit_coeffs_pygmo.py @@ -12,8 +12,9 @@ from timeit import default_timer as timer import itertools -from calculate.convert_units import OoM -from calculate.optimize.misc_fcns import penalized_loss_fcn, set_arrhenius_bnds +import frhodo +from ..convert_units import OoM +from ..optimize.misc_fcns import penalized_loss_fcn, set_arrhenius_bnds Ru = ct.gas_constant # Ru = 1.98720425864083 @@ -50,7 +51,7 @@ def ln_arrhenius_k(T, Ea, ln_A, n): # LPL, HPL, Fcent def fit_arrhenius(rates, T, x0=[], coefNames=default_arrhenius_coefNames, bnds=[], loss='linear'): def fit_fcn_decorator(x0, alter_idx, jac=False): def set_coeffs(*args): - coeffs = x0 + coeffs = x0git for n, idx in enumerate(alter_idx): coeffs[idx] = args[n] return coeffs @@ -118,7 +119,7 @@ def ln_arrhenius_jac(T, *args): return popt -path = {'main': pathlib.Path(sys.argv[0]).parents[0].resolve()} +path = {'main': pathlib.Path(frhodo.__file__).parents[0].resolve()} # TODO (wardlt) - Make a globally-accessible Path OS_type = platform.system() if OS_type == 'Windows': path['bonmin'] = path['main'] / 'bonmin/bonmin-win64/bonmin.exe' diff --git a/src/calculate/optimize/fit_fcn.py b/frhodo/calculate/optimize/fit_fcn.py similarity index 98% rename from src/calculate/optimize/fit_fcn.py rename to frhodo/calculate/optimize/fit_fcn.py index e32db8d..dd40365 100644 --- a/src/calculate/optimize/fit_fcn.py +++ b/frhodo/calculate/optimize/fit_fcn.py @@ -10,11 +10,11 @@ from scipy import stats from copy import deepcopy -from calculate.mech_fcns import Chemical_Mechanism -from calculate.convert_units import OoM, Bisymlog -from calculate.optimize.misc_fcns import weighted_quantile, outlier, penalized_loss_fcn -from calculate.optimize.fit_coeffs import fit_coeffs -from calculate.optimize.CheKiPEUQ_from_Frhodo import CheKiPEUQ_Frhodo_interface +from ..mech_fcns import Chemical_Mechanism +from ..convert_units import OoM, Bisymlog +from ..optimize.misc_fcns import weighted_quantile, outlier, penalized_loss_fcn +from ..optimize.fit_coeffs import fit_coeffs +from ..optimize.CheKiPEUQ_from_Frhodo import CheKiPEUQ_Frhodo_interface mpMech = {} def initialize_parallel_worker(mech_dict, species_dict, coeffs, coeffs_bnds, rate_bnds): diff --git a/src/calculate/optimize/mech_optimize.py b/frhodo/calculate/optimize/mech_optimize.py similarity index 99% rename from src/calculate/optimize/mech_optimize.py rename to frhodo/calculate/optimize/mech_optimize.py index f15a6d0..7cca45c 100644 --- a/src/calculate/optimize/mech_optimize.py +++ b/frhodo/calculate/optimize/mech_optimize.py @@ -12,10 +12,10 @@ from scipy import stats -from calculate.optimize.optimize_worker import Worker -from calculate.optimize.fit_fcn import update_mech_coef_opt -from calculate.optimize.misc_fcns import rates, set_bnds -from calculate.optimize.fit_coeffs import fit_generic as Troe_fit +from ..optimize.optimize_worker import Worker +from ..optimize.fit_fcn import update_mech_coef_opt +from ..optimize.misc_fcns import rates, set_bnds +from ..optimize.fit_coeffs import fit_generic as Troe_fit Ru = ct.gas_constant default_arrhenius_coefNames = ['activation_energy', 'pre_exponential_factor', 'temperature_exponent'] diff --git a/src/calculate/optimize/misc_fcns.py b/frhodo/calculate/optimize/misc_fcns.py similarity index 99% rename from src/calculate/optimize/misc_fcns.py rename to frhodo/calculate/optimize/misc_fcns.py index 8e38a9d..6653c27 100644 --- a/src/calculate/optimize/misc_fcns.py +++ b/frhodo/calculate/optimize/misc_fcns.py @@ -8,6 +8,8 @@ import cantera as ct import pathlib, sys +import frhodo + Ru = ct.gas_constant min_pos_system_value = (np.finfo(float).tiny*(1E20))**(1/2) @@ -20,7 +22,7 @@ # interpolation function for Z from loss function -path = {'main': pathlib.Path(sys.argv[0]).parents[0].resolve()} +path = {'main': pathlib.Path(frhodo.__file__).parents[0].resolve()} path['Z_tck_spline.dat'] = path['main'] / 'data/loss_partition_fcn_tck_spline.dat' tck = [] diff --git a/src/calculate/optimize/optimize_worker.py b/frhodo/calculate/optimize/optimize_worker.py similarity index 98% rename from src/calculate/optimize/optimize_worker.py rename to frhodo/calculate/optimize/optimize_worker.py index 5fb4019..4f2d900 100644 --- a/src/calculate/optimize/optimize_worker.py +++ b/frhodo/calculate/optimize/optimize_worker.py @@ -12,8 +12,9 @@ from timeit import default_timer as timer -from calculate.optimize.fit_fcn import initialize_parallel_worker, Fit_Fun -from calculate.optimize.misc_fcns import rates +from ..optimize.fit_fcn import initialize_parallel_worker, Fit_Fun +from ..optimize.misc_fcns import rates +import frhodo debug = True @@ -210,7 +211,7 @@ class WorkerSignals(QObject): 'Optimization failed: Out of memory', 'Optimization failed: Roundoff errors limited progress', 'Optimization failed: Forced termination'] -path = {'main': pathlib.Path(sys.argv[0]).parents[0].resolve()} +path = {'main': pathlib.Path(frhodo.__file__).parents[0].resolve()} # TODO (wardlt) - Make a globally-accessible Path OS_type = platform.system() if OS_type == 'Windows': path['bonmin'] = path['main'] / 'bonmin/bonmin-win64/bonmin.exe' diff --git a/src/calculate/reactors.py b/frhodo/calculate/reactors.py similarity index 99% rename from src/calculate/reactors.py rename to frhodo/calculate/reactors.py index 2c9bdbe..bd4480c 100644 --- a/src/calculate/reactors.py +++ b/frhodo/calculate/reactors.py @@ -7,8 +7,8 @@ import cantera as ct from cantera import interrupts, cti2yaml#, ck2yaml, ctml2yaml import numpy as np -from calculate import shock_fcns, integrate -import ck2yaml +from . import shock_fcns, integrate +import frhodo.ck2yaml from timeit import default_timer as timer diff --git a/src/calculate/shock_fcns.py b/frhodo/calculate/shock_fcns.py similarity index 100% rename from src/calculate/shock_fcns.py rename to frhodo/calculate/shock_fcns.py diff --git a/src/calculate/smooth_data.py b/frhodo/calculate/smooth_data.py similarity index 100% rename from src/calculate/smooth_data.py rename to frhodo/calculate/smooth_data.py diff --git a/src/ck2yaml.py b/frhodo/ck2yaml.py similarity index 100% rename from src/ck2yaml.py rename to frhodo/ck2yaml.py diff --git a/src/colors.py b/frhodo/colors.py similarity index 100% rename from src/colors.py rename to frhodo/colors.py diff --git a/src/config_io.py b/frhodo/config_io.py similarity index 100% rename from src/config_io.py rename to frhodo/config_io.py diff --git a/src/data/loss_partition_fcn_tck_spline.dat b/frhodo/data/loss_partition_fcn_tck_spline.dat similarity index 100% rename from src/data/loss_partition_fcn_tck_spline.dat rename to frhodo/data/loss_partition_fcn_tck_spline.dat diff --git a/src/error_window.py b/frhodo/error_window.py similarity index 100% rename from src/error_window.py rename to frhodo/error_window.py diff --git a/src/help_menu.py b/frhodo/help_menu.py similarity index 100% rename from src/help_menu.py rename to frhodo/help_menu.py diff --git a/src/ipopt/ipopt-linux64/coin-license.txt b/frhodo/ipopt/ipopt-linux64/coin-license.txt similarity index 100% rename from src/ipopt/ipopt-linux64/coin-license.txt rename to frhodo/ipopt/ipopt-linux64/coin-license.txt diff --git a/src/ipopt/ipopt-linux64/ipopt b/frhodo/ipopt/ipopt-linux64/ipopt similarity index 100% rename from src/ipopt/ipopt-linux64/ipopt rename to frhodo/ipopt/ipopt-linux64/ipopt diff --git a/src/ipopt/ipopt-osx/coin-license.txt b/frhodo/ipopt/ipopt-osx/coin-license.txt similarity index 100% rename from src/ipopt/ipopt-osx/coin-license.txt rename to frhodo/ipopt/ipopt-osx/coin-license.txt diff --git a/src/ipopt/ipopt-osx/ipopt b/frhodo/ipopt/ipopt-osx/ipopt similarity index 100% rename from src/ipopt/ipopt-osx/ipopt rename to frhodo/ipopt/ipopt-osx/ipopt diff --git a/src/ipopt/ipopt-win64/coin-license.txt b/frhodo/ipopt/ipopt-win64/coin-license.txt similarity index 100% rename from src/ipopt/ipopt-win64/coin-license.txt rename to frhodo/ipopt/ipopt-win64/coin-license.txt diff --git a/src/ipopt/ipopt-win64/ipopt.exe b/frhodo/ipopt/ipopt-win64/ipopt.exe similarity index 100% rename from src/ipopt/ipopt-win64/ipopt.exe rename to frhodo/ipopt/ipopt-win64/ipopt.exe diff --git a/src/ipopt/ipopt-win64/libipoptfort.dll b/frhodo/ipopt/ipopt-win64/libipoptfort.dll similarity index 100% rename from src/ipopt/ipopt-win64/libipoptfort.dll rename to frhodo/ipopt/ipopt-win64/libipoptfort.dll diff --git a/src/main.py b/frhodo/main.py similarity index 93% rename from src/main.py rename to frhodo/main.py index e3712c9..29c8f57 100644 --- a/src/main.py +++ b/frhodo/main.py @@ -5,21 +5,20 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. -version = '1.3.1' import os, sys, platform, multiprocessing, pathlib, ctypes # os.environ['QT_API'] = 'pyside2' # forces pyside2 +from typing import Tuple from qtpy.QtWidgets import QMainWindow, QApplication, QMessageBox from qtpy import uic, QtCore, QtGui - import numpy as np -# from timeit import default_timer as timer -from plot.plot_main import All_Plots as plot -from misc_widget import MessageWindow -from calculate import mech_fcns, reactors, convert_units -import appdirs, options_panel_widgets, sim_explorer_widget -import settings, config_io, save_widget, error_window, help_menu +from .plot.plot_main import All_Plots as plot +from .misc_widget import MessageWindow +from .calculate import mech_fcns, reactors, convert_units +from .version import __version__ +from . import appdirs, options_panel_widgets, sim_explorer_widget +from . import settings, config_io, save_widget, error_window, help_menu if os.environ['QT_API'] == 'pyside2': # Silence warning: "Qt WebEngine seems to be initialized from a plugin." QApplication.setAttribute(QtCore.Qt.AA_ShareOpenGLContexts) @@ -31,7 +30,7 @@ QApplication.setAttribute(QtCore.Qt.AA_UseHighDpiPixmaps, True) # set main folder -path = {'main': pathlib.Path(sys.argv[0]).parents[0].resolve()} +path = {'main': pathlib.Path(__file__).parents[0].resolve()} # set appdata folder using AppDirs library (but just using the source code file) dirs = appdirs.AppDirs(appname='Frhodo', roaming=True, appauthor=False) @@ -86,7 +85,7 @@ def __init__(self, app, path): self.initialize_settings() # ~ 4 sec # Setup help menu - self.version = version + self.version = __version__ help_menu.HelpMenu(self) def initialize_settings(self): # TODO: Solving for loaded shock twice @@ -290,17 +289,31 @@ def run_single(self, event=None, t_save=None, rxn_changed=False): # def raise_error(self): # assert False - -if __name__ == '__main__': + +def launch_gui() -> Tuple[QApplication, Main]: + """Launch the GUI + + Returns: + - The QApplication instance + - Link to the main window + """ if platform.system() == 'Windows': # this is required for pyinstaller on windows multiprocessing.freeze_support() - if getattr(sys, 'frozen', False): # if frozen minimize console immediately + if getattr(sys, 'frozen', False): # if frozen minimize console immediately ctypes.windll.user32.ShowWindow(ctypes.windll.kernel32.GetConsoleWindow(), 0) - + app = QApplication(sys.argv) sys.excepthook = error_window.excepthookDecorator(app, path, shut_down) - main = Main(app, path) + main_window = Main(app, path) + return app, main_window + + +def main(): + """Launch the GUI and then block until it finishes""" + # Launch the application + app, main_window = launch_gui() + + # Pass the exit code forward sys.exit(app.exec_()) - diff --git a/src/mech_widget.py b/frhodo/mech_widget.py similarity index 99% rename from src/mech_widget.py rename to frhodo/mech_widget.py index 1963f32..052858c 100644 --- a/src/mech_widget.py +++ b/frhodo/mech_widget.py @@ -2,17 +2,17 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. +from copy import deepcopy import sys, ast, re -import misc_widget + import cantera as ct import numpy as np -from copy import deepcopy -from functools import partial from scipy.optimize import root_scalar from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore -from timeit import default_timer as timer +from . import misc_widget + def silentSetValue(obj, value): obj.blockSignals(True) # stop changing text from signaling diff --git a/src/misc_widget.py b/frhodo/misc_widget.py similarity index 99% rename from src/misc_widget.py rename to frhodo/misc_widget.py index 36f3e59..ccaebcf 100644 --- a/src/misc_widget.py +++ b/frhodo/misc_widget.py @@ -6,7 +6,7 @@ import numpy as np from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore -from calculate.convert_units import OoM +from .calculate.convert_units import OoM # Regular expression to find floats. Match groups are the whole string, the # whole coefficient, the decimal part of the coefficient, and the exponent diff --git a/src/options_panel_widgets.py b/frhodo/options_panel_widgets.py similarity index 99% rename from src/options_panel_widgets.py rename to frhodo/options_panel_widgets.py index a88b59e..f5bb4a4 100644 --- a/src/options_panel_widgets.py +++ b/frhodo/options_panel_widgets.py @@ -3,17 +3,20 @@ # directory for license and copyright information. import pathlib, os, sys +from copy import deepcopy + import numpy as np from scipy.optimize import minimize import nlopt -import mech_widget, misc_widget, thermo_widget, series_viewer_widget, save_output -from calculate import shock_fcns -from calculate.optimize.mech_optimize import Multithread_Optimize -from calculate.convert_units import OoM -from settings import double_sigmoid from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore -from copy import deepcopy + +from . import mech_widget, misc_widget, thermo_widget, series_viewer_widget, save_output +from .calculate import shock_fcns +from .calculate.optimize.mech_optimize import Multithread_Optimize +from .calculate.convert_units import OoM +from .settings import double_sigmoid + class Initialize(QtCore.QObject): diff --git a/frhodo/plot/__init__.py b/frhodo/plot/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/src/plot/base_plot.py b/frhodo/plot/base_plot.py similarity index 99% rename from src/plot/base_plot.py rename to frhodo/plot/base_plot.py index 57f01cd..946fab9 100644 --- a/src/plot/base_plot.py +++ b/frhodo/plot/base_plot.py @@ -24,9 +24,9 @@ #mpl.use("module://mplcairo.qt") # This implements mplcairo, faster/more accurate. Issues with other OSes? import numpy as np -from calculate.convert_units import Bisymlog -from plot.custom_mplscale import * -from plot.custom_mpl_ticker_formatter import * +from ..calculate.convert_units import Bisymlog +from .custom_mplscale import * +from .custom_mpl_ticker_formatter import * from timeit import default_timer as timer diff --git a/src/plot/custom_mpl_ticker_formatter.py b/frhodo/plot/custom_mpl_ticker_formatter.py similarity index 100% rename from src/plot/custom_mpl_ticker_formatter.py rename to frhodo/plot/custom_mpl_ticker_formatter.py diff --git a/src/plot/custom_mplscale.py b/frhodo/plot/custom_mplscale.py similarity index 99% rename from src/plot/custom_mplscale.py rename to frhodo/plot/custom_mplscale.py index 935aaeb..d1c949d 100644 --- a/src/plot/custom_mplscale.py +++ b/frhodo/plot/custom_mplscale.py @@ -6,7 +6,7 @@ from matplotlib import scale as mplscale import numpy as np -from calculate.convert_units import Bisymlog +from frhodo.calculate.convert_units import Bisymlog class AbsoluteLogScale(mplscale.LogScale): name = 'abslog' diff --git a/src/plot/draggable.py b/frhodo/plot/draggable.py similarity index 100% rename from src/plot/draggable.py rename to frhodo/plot/draggable.py diff --git a/src/plot/optimization_plot.py b/frhodo/plot/optimization_plot.py similarity index 99% rename from src/plot/optimization_plot.py rename to frhodo/plot/optimization_plot.py index 1bc5a36..d30a072 100644 --- a/src/plot/optimization_plot.py +++ b/frhodo/plot/optimization_plot.py @@ -2,12 +2,12 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. -import colors +from frhodo import colors import matplotlib as mpl import numpy as np -from plot.base_plot import Base_Plot +from .base_plot import Base_Plot colormap = colors.colormap(reorder_from=1, num_shift=4) diff --git a/src/plot/plot_main.py b/frhodo/plot/plot_main.py similarity index 88% rename from src/plot/plot_main.py rename to frhodo/plot/plot_main.py index b0cd415..771b59b 100644 --- a/src/plot/plot_main.py +++ b/frhodo/plot/plot_main.py @@ -2,7 +2,7 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. -from plot import raw_signal_plot, signal_plot, sim_explorer_plot, optimization_plot, plot_widget +from . import raw_signal_plot, signal_plot, sim_explorer_plot, optimization_plot, plot_widget class All_Plots: # container to hold all plots diff --git a/src/plot/plot_widget.py b/frhodo/plot/plot_widget.py similarity index 99% rename from src/plot/plot_widget.py rename to frhodo/plot/plot_widget.py index b668e57..034d928 100644 --- a/src/plot/plot_widget.py +++ b/frhodo/plot/plot_widget.py @@ -7,7 +7,7 @@ from qtpy import QtWidgets, QtGui, QtCore from copy import deepcopy -import misc_widget +from .. import misc_widget class Observable_Widgets(QtCore.QObject): def __init__(self, parent): diff --git a/src/plot/raw_signal_plot.py b/frhodo/plot/raw_signal_plot.py similarity index 98% rename from src/plot/raw_signal_plot.py rename to frhodo/plot/raw_signal_plot.py index dd7b7e1..1139caa 100644 --- a/src/plot/raw_signal_plot.py +++ b/frhodo/plot/raw_signal_plot.py @@ -9,8 +9,8 @@ import numpy as np from scipy import stats -from plot.base_plot import Base_Plot -from plot.draggable import Draggable +from .base_plot import Base_Plot +from .draggable import Draggable class Plot(Base_Plot): diff --git a/src/plot/signal_plot.py b/frhodo/plot/signal_plot.py similarity index 99% rename from src/plot/signal_plot.py rename to frhodo/plot/signal_plot.py index f543c12..31d1468 100644 --- a/src/plot/signal_plot.py +++ b/frhodo/plot/signal_plot.py @@ -8,9 +8,9 @@ import numpy as np from scipy import stats -from calculate.convert_units import OoM -from plot.base_plot import Base_Plot -from plot.draggable import Draggable +from frhodo.calculate.convert_units import OoM +from .base_plot import Base_Plot +from .draggable import Draggable def shape_data(x, y): diff --git a/src/plot/sim_explorer_plot.py b/frhodo/plot/sim_explorer_plot.py similarity index 98% rename from src/plot/sim_explorer_plot.py rename to frhodo/plot/sim_explorer_plot.py index cbb41c4..a420b87 100644 --- a/src/plot/sim_explorer_plot.py +++ b/frhodo/plot/sim_explorer_plot.py @@ -5,8 +5,8 @@ import matplotlib as mpl import numpy as np -from plot.base_plot import Base_Plot -from plot.draggable import DraggableLegend +from .base_plot import Base_Plot +from .draggable import DraggableLegend class Plot(Base_Plot): diff --git a/src/save_output.py b/frhodo/save_output.py similarity index 99% rename from src/save_output.py rename to frhodo/save_output.py index 9f30668..2162e63 100644 --- a/src/save_output.py +++ b/frhodo/save_output.py @@ -4,10 +4,10 @@ import numpy as np from tabulate import tabulate -import soln2ck -import pathlib # from cantera import ck2cti # Maybe later use ck2cti.Parser.writeCTI to write cti file +from . import soln2ck + class Save: def __init__(self, parent): self.parent = parent diff --git a/src/save_widget.py b/frhodo/save_widget.py similarity index 100% rename from src/save_widget.py rename to frhodo/save_widget.py diff --git a/src/series_viewer_widget.py b/frhodo/series_viewer_widget.py similarity index 99% rename from src/series_viewer_widget.py rename to frhodo/series_viewer_widget.py index d7e6c77..a3dc9f8 100644 --- a/src/series_viewer_widget.py +++ b/frhodo/series_viewer_widget.py @@ -2,7 +2,7 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. -from calculate import shock_fcns +from .calculate import shock_fcns import numpy as np from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore diff --git a/src/settings.py b/frhodo/settings.py similarity index 99% rename from src/settings.py rename to frhodo/settings.py index 471727c..40738bd 100644 --- a/src/settings.py +++ b/frhodo/settings.py @@ -10,8 +10,8 @@ from scipy.interpolate import CubicSpline from qtpy import QtCore -from calculate.convert_units import OoM, RoundToSigFigs -from calculate.smooth_data import dual_tree_complex_wavelet_filter +from .calculate.convert_units import OoM, RoundToSigFigs +from .calculate.smooth_data import dual_tree_complex_wavelet_filter min_pos_system_value = (np.finfo(float).tiny*(1E20))**(1/2) max_pos_system_value = (np.finfo(float).max*(1E-20))**(1/2) diff --git a/src/sim_explorer_widget.py b/frhodo/sim_explorer_widget.py similarity index 98% rename from src/sim_explorer_widget.py rename to frhodo/sim_explorer_widget.py index 21648dc..5754be5 100644 --- a/src/sim_explorer_widget.py +++ b/frhodo/sim_explorer_widget.py @@ -3,13 +3,12 @@ # directory for license and copyright information. import numpy as np -from calculate import shock_fcns -import mech_widget, misc_widget, thermo_widget, series_viewer_widget, save_output from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore from copy import deepcopy -import re -from timeit import default_timer as timer + +from .calculate import shock_fcns +from . import mech_widget, misc_widget, thermo_widget, series_viewer_widget, save_output class SIM_Explorer_Widgets(QtCore.QObject): def __init__(self, parent): diff --git a/src/soln2ck.py b/frhodo/soln2ck.py similarity index 100% rename from src/soln2ck.py rename to frhodo/soln2ck.py diff --git a/src/thermo_widget.py b/frhodo/thermo_widget.py similarity index 96% rename from src/thermo_widget.py rename to frhodo/thermo_widget.py index 023607b..c92159d 100644 --- a/src/thermo_widget.py +++ b/frhodo/thermo_widget.py @@ -2,15 +2,11 @@ # and licensed under BSD-3-Clause. See License.txt in the top-level # directory for license and copyright information. -import sys, ast, re -import misc_widget -import cantera as ct -import numpy as np -from copy import deepcopy -from scipy.optimize import root_scalar from qtpy.QtWidgets import * from qtpy import QtWidgets, QtGui, QtCore +from . import misc_widget + def silentSetValue(obj, value): obj.blockSignals(True) # stop changing text from signaling obj.setValue(value) diff --git a/frhodo/version.py b/frhodo/version.py new file mode 100644 index 0000000..3b949b4 --- /dev/null +++ b/frhodo/version.py @@ -0,0 +1,4 @@ +"""Single source of truth for package version""" +# https://packaging.python.org/en/latest/guides/single-sourcing-package-version/ + +__version__ = '1.3.1' diff --git a/frhodo_environment.yml b/frhodo_environment.yml index bcb685d..73381d0 100644 --- a/frhodo_environment.yml +++ b/frhodo_environment.yml @@ -2,12 +2,11 @@ name: frhodo channels: - numba - cantera/label/dev - - numba - conda-forge - defaults dependencies: - cantera=2.6.0a1 - - ipopt=3.14.4 + - ipopt=3.14.* - matplotlib=3.5.1 - nlopt=2.7.0 - numba=0.54.1 @@ -22,4 +21,5 @@ dependencies: - tabulate=0.8.9 - pip: - dtcwt==0.12.0 - - rbfopt==4.2.2 \ No newline at end of file + - rbfopt==4.2.2 + - -e . diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..15d522c --- /dev/null +++ b/setup.py @@ -0,0 +1,20 @@ +from setuptools import setup, find_packages +from pathlib import Path + +# single source of truth for package version +version_ns = {} +with (Path("frhodo") / "version.py").open() as f: + exec(f.read(), version_ns) +version = version_ns['__version__'] + +setup( + name='frhodo', + version='0.0.1', + packages=find_packages(), + description='Simulate experimental data and optimize chemical kinetics mechanisms with this GUI-based application', + entry_points={ + 'console_scripts': [ + 'frhodo=frhodo.main:main' + ] + } +)