Skip to content

Commit

Permalink
update 1.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
olivierpascalhenry committed Sep 4, 2019
1 parent af75c10 commit 6f24f8f
Show file tree
Hide file tree
Showing 16 changed files with 62 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}


Expand Down
Binary file not shown.
Binary file not shown.
5 changes: 5 additions & 0 deletions Documentation/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion PKG-INFO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Version:
-------

EGADS Lineage 1.0.3
EGADS Lineage 1.1.0


Developments:
Expand Down
4 changes: 2 additions & 2 deletions doc/source/alg_development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
9 changes: 7 additions & 2 deletions doc/source/tutorial.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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}``

Expand Down Expand Up @@ -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].

Expand Down
18 changes: 11 additions & 7 deletions egads/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__author__ = "ohenry"
__date__ = "2018-03-05 10:59"
__version__ = "1.4"
__version__ = "1.5"


import logging
Expand All @@ -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
Expand All @@ -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('*****************************************')
Expand All @@ -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
Expand Down Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion egads/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '1.0.3'
__version__ = '1.1.0'
__branch__ = 'Lineage'
3 changes: 1 addition & 2 deletions egads/algorithms/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -13,4 +13,3 @@
import egads.algorithms.thermodynamics
import egads.algorithms.transforms
import egads.algorithms.radiation
import egads.algorithms.user
50 changes: 26 additions & 24 deletions egads/utils/egads_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion egads_lineage.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions egads_lineage.egg-info/SOURCES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down

0 comments on commit 6f24f8f

Please sign in to comment.