diff --git a/Documentation/EGADS Algorithm Handbook - LATEX/cover/alg_cover.tex b/Documentation/EGADS Algorithm Handbook - LATEX/cover/alg_cover.tex index 47e3f8a..7d10303 100644 --- a/Documentation/EGADS Algorithm Handbook - LATEX/cover/alg_cover.tex +++ b/Documentation/EGADS Algorithm Handbook - LATEX/cover/alg_cover.tex @@ -24,7 +24,7 @@ \setlength{\voffset}{.0cm} \logoeufar -\title{EUFAR, Olivier Henry}{}{EGADS Lineage Algorithm Handbook}{Version 1.0.3} +\title{EUFAR, Olivier Henry}{}{EGADS Lineage Algorithm Handbook}{Version 1.1.0} %\author{}{} diff --git a/Documentation/EGADS Lineage Algorithm Handbook - v1.0.3.pdf b/Documentation/EGADS Lineage Algorithm Handbook - v1.1.0.pdf similarity index 99% rename from Documentation/EGADS Lineage Algorithm Handbook - v1.0.3.pdf rename to Documentation/EGADS Lineage Algorithm Handbook - v1.1.0.pdf index 4c5d469..8dbdda6 100644 Binary files a/Documentation/EGADS Lineage Algorithm Handbook - v1.0.3.pdf and b/Documentation/EGADS Lineage Algorithm Handbook - v1.1.0.pdf differ diff --git a/Documentation/EGADS Lineage Documentation - v1.0.3.pdf b/Documentation/EGADS Lineage Documentation - v1.1.0.pdf similarity index 95% rename from Documentation/EGADS Lineage Documentation - v1.0.3.pdf rename to Documentation/EGADS Lineage Documentation - v1.1.0.pdf index e5a2e0b..808cadf 100644 Binary files a/Documentation/EGADS Lineage Documentation - v1.0.3.pdf and b/Documentation/EGADS Lineage Documentation - v1.1.0.pdf differ diff --git a/Documentation/changelog.txt b/Documentation/changelog.txt index 55efeb8..6fe394d 100644 --- a/Documentation/changelog.txt +++ b/Documentation/changelog.txt @@ -10,6 +10,11 @@ To fix list: ------------ +September 4 2019, Release version 1.1.0 +======================================= +The configuration file and user algorithm structure have been moved to a dedicated directory in the $HOME folder (Windows, Linux and MacOS), to avoid issues when Python is installed in a system folder. Read the documentation for more details. + + August 14 2019, Release version 1.0.3 ===================================== FIXED: diff --git a/PKG-INFO b/PKG-INFO index 0ea5eda..3cae000 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: egads-lineage -Version: 1.0.3 +Version: 1.1.0 Summary: EGADS: EUFAR General Airborne Data-processing Software Home-page: https://github.com/EUFAR/egads/tree/Lineage Author: EUFAR, Olivier Henry diff --git a/README.md b/README.md index 7cb7e21..371fdbc 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ Version: ------- -EGADS Lineage 1.0.3 +EGADS Lineage 1.1.0 Developments: diff --git a/doc/source/alg_development.rst b/doc/source/alg_development.rst index ffc64a4..23bf0ba 100644 --- a/doc/source/alg_development.rst +++ b/doc/source/alg_development.rst @@ -77,9 +77,9 @@ Within the file itself, there are one rule to respect and several elements in th The algorithm itself gets written in the _algorithm method and uses variables passed in by the user. The variables which arrive here are simply scalar or arrays, and if the source is an instance of EgadsData, the variables will be converted to the units you specified in the InputUnits of the algorithm metadata. 7. Integration of the algorithm in EGADS - Once the algorithm file is ready, the user has to move it in the appropriate directory in the ``./egads/algorithms/user`` directory. Once it has been done, the ``__init__.py`` file has to be modified to declare the new algorithm. The following line can be added to the ``__init__.py`` file: ``from the_name_of_the_file import *``. + Once the algorithm file is ready, the user has to move it in the appropriate directory in the ``$HOME/.egads_lineage/user_algorithms`` directory. Once it has been done, the ``__init__.py`` file has to be modified to declare the new algorithm. The following line can be added to the ``__init__.py`` file: ``from the_name_of_the_file import *``. - If the algorithm requires a new directory, the user has to create it in the ``user`` directory, move the file inside and create a ``__init__.py`` file to declare the new directory and the algoritm to EGADS. A template can be found in ``./egads/algorithms/user/file_templates/init_template.py`` and is shown below: + If the algorithm requires a new directory, the user has to create it in the ``user`` directory, move the file inside and create a ``__init__.py`` file to declare the new directory and the algoritm to EGADS. A template can be found in ``doc/source/example_files/init_template.py`` and is shown below: .. literalinclude:: example_files/init_template.py diff --git a/doc/source/conf.py b/doc/source/conf.py index 005dbb1..7a7694a 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -48,9 +48,9 @@ # built documents. # # The short X.Y version. -version = '1.0.3' +version = '1.1.0' # The full version, including alpha/beta/rc tags. -release = '1.0.3' +release = '1.1.0' # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/doc/source/tutorial.rst b/doc/source/tutorial.rst index 56106a0..797cc46 100644 --- a/doc/source/tutorial.rst +++ b/doc/source/tutorial.rst @@ -1022,7 +1022,7 @@ This file has been created with the following commands: Working with algorithms ************************ -Algorithms in EGADS are stored in the :mod:`egads.algorithms` module, and separated into sub-modules by category (microphysics, thermodynamics, radiation, etc). Each algorithm follows a standard naming scheme, using the algorithm's purpose and source: +Algorithms in EGADS are stored in the :mod:`egads.algorithms` module for embedded algorithms and in :mod:`egads.user_algorithms` module for user-defined algorithms. They are separated into sub-modules by category (microphysics, thermodynamics, radiation, etc). Each algorithm follows a standard naming scheme, using the algorithm's purpose and source: ``{CalculatedParameter}{Detail}{Source}`` @@ -1082,13 +1082,18 @@ Algorithms in EGADS generally accept and return arguments of :class:`~.EgadsData To call an algorithm, simply pass in the required arguments, in the order they are described in the algorithm help function. An algorithm call, using the ``VelocityTasCnrm`` in the previous section as an example, would therefore be the following: >>> V_p = egads.algorithms.thermodynamics.VelocityTasCnrm().run(T_s, P_s, dP, - cpa, Racpa) + cpa, Racpa) where the arguments ``T_s``, ``P_s``, ``dP``, etc are all assumed to be previously defined in the program scope. In this instance, the algorithm returns an :class:`~.EgadsData` instance to ``V_p``. To run the algorithm, but return a standard data type (scalar or array of doubles), set the ``return_Egads`` flag to ``false``. >>> V_p = egads.algorithms.thermodynamics.VelocityTasCnrm(return_Egads=False). run(T_s, P_s, dP, cpa, Racpa) +If an algorithm has been created by a user and is not embedded by default in EGADS, it should be called like this: + + >>> V_p = egads.user_algorithms.thermodynamics.VelocityTasCnrm().run(T_s, P_s, dP, + cpa, Racpa) + .. NOTE:: When injecting a variable in an EgadsAlgorithm, the format of the variable should follow closely the documentation of the algorithm. If the variable is a scalar, and the algorithm needs a vector, the scalar should be surrounded by brackets: 52.123 -> [52.123]. diff --git a/egads/__init__.py b/egads/__init__.py index b50f2e7..7a553b5 100644 --- a/egads/__init__.py +++ b/egads/__init__.py @@ -1,6 +1,6 @@ __author__ = "ohenry" __date__ = "2018-03-05 10:59" -__version__ = "1.4" +__version__ = "1.5" import logging @@ -9,6 +9,7 @@ import quantities import configparser import sys +import pathlib from ._version import __version__ from ._version import __branch__ from .utils.egads_utils import _create_user_algorithms_structure @@ -28,11 +29,12 @@ else: frozen = False -path = os.path.abspath(os.path.dirname(__file__)) -_create_option_dictionary(path) + +user_path = str(pathlib.Path.home().joinpath('.egads_lineage')) +_create_option_dictionary(user_path) config_dict = configparser.ConfigParser() -config_dict.read(os.path.join(path, 'egads.ini')) -_create_log_system(config_dict, path) +config_dict.read(os.path.join(user_path, 'egads.ini')) +_create_log_system(config_dict, user_path) logging.info('*****************************************') logging.info('EGADS ' + __version__ + ' is starting ...') logging.info('*****************************************') @@ -48,8 +50,10 @@ import egads.core import egads.core.metadata -_create_user_algorithms_structure(path) +_create_user_algorithms_structure(user_path) +sys.path.append(user_path) import egads.algorithms +import user_algorithms from .input import get_file_list from .core.egads_core import * from .tests.test_all import test @@ -77,7 +81,7 @@ def set_options(log_level=None, log_path=None, check_update=None): if check_update is not None: config_dict.set('OPTIONS', 'check_update', str(check_update)) if log_level or log_path or check_update: - set_options_file = open(os.path.join(path, 'egads.ini'), 'w') + set_options_file = open(os.path.join(user_path, 'egads.ini'), 'w') config_dict.write(set_options_file) set_options_file.close() diff --git a/egads/_version.py b/egads/_version.py index 394b7ed..746e7c4 100644 --- a/egads/_version.py +++ b/egads/_version.py @@ -1,2 +1,2 @@ -__version__ = '1.0.3' +__version__ = '1.1.0' __branch__ = 'Lineage' diff --git a/egads/algorithms/__init__.py b/egads/algorithms/__init__.py index 66bb0b2..c5d122a 100644 --- a/egads/algorithms/__init__.py +++ b/egads/algorithms/__init__.py @@ -4,7 +4,7 @@ __author__ = "ohenry" __date__ = "2018-03-05 11:13" -__version__ = "1.1" +__version__ = "1.2" import egads.algorithms.comparisons import egads.algorithms.corrections @@ -13,4 +13,3 @@ import egads.algorithms.thermodynamics import egads.algorithms.transforms import egads.algorithms.radiation -import egads.algorithms.user \ No newline at end of file diff --git a/egads/utils/egads_utils.py b/egads/utils/egads_utils.py index f82acb6..2868aa3 100644 --- a/egads/utils/egads_utils.py +++ b/egads/utils/egads_utils.py @@ -9,14 +9,16 @@ import pathlib -def _create_option_dictionary(main_path): +def _create_option_dictionary(user_path): config_dict = configparser.ConfigParser() - if not os.path.exists(os.path.join(main_path, 'egads.ini')): - ini_file = open(os.path.join(main_path, 'egads.ini'), 'w') + if not pathlib.Path(pathlib.Path(user_path).joinpath('egads.ini')).is_file(): + if not pathlib.Path(user_path).is_dir(): + pathlib.Path(user_path).mkdir() + ini_file = open(os.path.join(user_path, 'egads.ini'), 'w') config_dict.add_section('LOG') config_dict.add_section('OPTIONS') - config_dict.set('LOG', 'level', 'INFO') - config_dict.set('LOG', 'path', main_path) + config_dict.set('LOG', 'level', 'DEBUG') + config_dict.set('LOG', 'path', user_path) config_dict.set('OPTIONS', 'check_update', 'False') config_dict.write(ini_file) ini_file.close() @@ -43,42 +45,42 @@ def _create_log_system(config_dict, default_path): logging.error('egads - logging system - path from ini file not found, using default path') -def _create_user_algorithms_structure(main_path): - logging.debug('egads - egads_utils.py - create_user_algorithms_structure - main_path ' + str(main_path)) - user_path = os.path.join(main_path, 'algorithms/user/') - if not os.path.isdir(user_path): +def _create_user_algorithms_structure(user_path): + logging.debug('egads - egads_utils.py - create_user_algorithms_structure - user_path ' + str(user_path)) + algo_path = str(pathlib.Path(user_path).joinpath('user_algorithms')) + if not pathlib.Path(algo_path).is_dir(): logging.debug('egads - egads_utils.py - create_user_algorithms_structure - no user folder detected, ' 'creating user structure') - os.makedirs(user_path) + pathlib.Path(algo_path).mkdir() init_string = ('__author__ = "Olivier Henry"\n' + '__date__ = "2019/05/06 11:45"\n' + '__version__ = "1.0"\n\n' - + 'import egads.algorithms.user.comparisons\n' - + 'import egads.algorithms.user.corrections\n' - + 'import egads.algorithms.user.mathematics\n' - + 'import egads.algorithms.user.microphysics\n' - + 'import egads.algorithms.user.thermodynamics\n' - + 'import egads.algorithms.user.transforms\n' - + 'import egads.algorithms.user.radiation\n') - init_file = open(user_path + '__init__.py', 'w') + + 'import user_algorithms.comparisons\n' + + 'import user_algorithms.corrections\n' + + 'import user_algorithms.mathematics\n' + + 'import user_algorithms.microphysics\n' + + 'import user_algorithms.thermodynamics\n' + + 'import user_algorithms.transforms\n' + + 'import user_algorithms.radiation\n') + init_file = open(algo_path + '/__init__.py', 'w') init_file.write(init_string) init_file.close() user_folder = ['comparisons', 'corrections', 'mathematics', 'microphysics', 'thermodynamics', 'transforms', 'radiation'] for folder in user_folder: - logging.debug('egads - egads_utils.py - create_user_algorithms_structure - creating [user/' + folder + '] ' - + 'folder') - os.makedirs(os.path.join(user_path, folder)) + logging.debug('egads - egads_utils.py - create_user_algorithms_structure - creating [user_algorithms/' + + folder + '] folder') + pathlib.Path(pathlib.Path(algo_path).joinpath(folder)).mkdir() init_string = ('__author__ = "Olivier Henry"\n' + '__date__ = "2019/05/06 11:45"\n' + '__version__ = "1.0"\n\n' + 'import logging\n\n' + 'try:\n' - + " logging.info('egads [user/" + folder + "] algorithms have been loaded')\n" + + " logging.info('egads [user_algorithms/" + folder + "] algorithms have been loaded')\n" + 'except Exception as e:\n' - + " logging.error('an error occured during the loading of a [user/" + folder + + " logging.error('an error occured during the loading of a [user_algorithms/" + folder + "] algorithm: ' + str(e))\n") - init_file = open(os.path.join(user_path, folder) + '/__init__.py', 'w') + init_file = open(str(pathlib.Path(algo_path).joinpath(folder)) + '/__init__.py', 'w') init_file.write(init_string) init_file.close() else: diff --git a/egads_lineage.egg-info/PKG-INFO b/egads_lineage.egg-info/PKG-INFO index 6861696..24ae6ba 100644 --- a/egads_lineage.egg-info/PKG-INFO +++ b/egads_lineage.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 1.2 Name: egads-lineage -Version: 1.0.3 +Version: 1.1.0 Summary: EGADS: EUFAR General Airborne Data-processing Software Home-page: https://github.com/EUFAR/egads/tree/Lineage Author: EUFAR, Olivier Henry diff --git a/egads_lineage.egg-info/SOURCES.txt b/egads_lineage.egg-info/SOURCES.txt index 592ba2d..4829ed9 100644 --- a/egads_lineage.egg-info/SOURCES.txt +++ b/egads_lineage.egg-info/SOURCES.txt @@ -3,8 +3,8 @@ MANIFEST.in README.md setup.cfg setup.py -Documentation/EGADS Lineage Algorithm Handbook - v1.0.3.pdf -Documentation/EGADS Lineage Documentation - v1.0.3.pdf +Documentation/EGADS Lineage Algorithm Handbook - v1.1.0.pdf +Documentation/EGADS Lineage Documentation - v1.1.0.pdf Documentation/changelog.txt Documentation/EGADS Algorithm Handbook - LATEX/EGADS_alg_doc.tex Documentation/EGADS Algorithm Handbook - LATEX/example.py diff --git a/setup.py b/setup.py index 033b63a..4562afe 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ doclines = __doc__.split('\n') setup(name='egads-lineage', - version='1.0.3', + version='1.1.0', description=doclines[0], long_description='\n'.join(doclines[2:]), author='EUFAR, Olivier Henry',