Skip to content

Commit

Permalink
commit_20210317_23:58
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiodelogu committed Mar 17, 2021
1 parent a36dfe1 commit 9e960ad
Show file tree
Hide file tree
Showing 36 changed files with 2,571 additions and 5,986 deletions.
24 changes: 14 additions & 10 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@ Changelog

Version 1.2.0 [2021-02-22]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataOrganizer_HMC_NRT.py
- FIX: bugs related to xarray library;
- FIX: bugs related to progressbar library
APP: HAT_DataPublisher_HMC_NRT.py
- FIX: bugs related to matplotlib=3.1.3 and cartopy=0.17 libraries
APP: HAT_RunAnalyzer_HMC_MAIN.py
- Release for HMC version 3.x.x

Version 1.1.5 [2019-10-22]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataManager_HMC_NRT.py
- ADD: method to set terrain variable in buffered datasets when is missed
- ADD: effective time steps information about computing gridded average or accumulated variable(s) skipping empty step(s)
- FIX: empty time steps condition in computing gridded average or accumulated variable(s)
Expand All @@ -19,37 +23,37 @@ Version 1.1.5 [2019-10-22]

Version 1.1.4 [2019-07-08]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataManager_HMC_NRT.py
- ADD: variables to datasets (soil moisture and accumulated rain time-series)
- ADD: management of tmp file(s) in a common system folder
- FIX: datasets finder according with operative chain requests

Version 1.1.3 [2019-05-27]
===========
APP: HAT_DataPublisher_HMC_NRT
APP: HAT_DataPublisher_HMC_NRT.py
- ADD: soil moisture and accumulated rain to time-series graph(s)

Version 1.1.2 [2019-05-16]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataManager_HMC_NRT.py
- FIX: bug about selecting gridded variables with mean equal to zero
- FIX: bug about out of range probabilistic runs
APP: HAT_DataPublisher_HMC_NRT
APP: HAT_DataPublisher_HMC_NRT.py
- FIX: bugs in data seeking and data plotting (hydrapp time-series and maps product)

Version 1.1.1 [2019-03-04]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataManager_HMC_NRT.py
- FIX: nasty bugs arisen in operative mode fixed

Version 1.1.0 [2019-03-22]
Version 1.1.0 [2019-02-22]
===========
APP: HAT_DataPublisher_HMC_NRT
APP: HAT_DataPublisher_HMC_NRT.py
- Beta release

Version 1.0.0 [2019-02-13]
===========
APP: HAT_DataManager_HMC_NRT
APP: HAT_DataManager_HMC_NRT.py
- Beta release

Version 0.0.1 [2019-01-16]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
__library__ = 'hat'
General command line:
python3 HAT_DataManager_HMC_NRT.py -settings_file configuration.json -time "YYYY-MM-DD HH:MM"
python3 HAT_RunOrganizer_HMC_NRT.py -settings_file configuration.json -time "YYYY-MM-DD HH:MM"
Version(s) in changelog file
"""
# -------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
"""
Hydrological Analysis Tool - DataPublisher for Hydrological Model Continuum - Near Real Time
Hydrological Analysis Tool - Analyzer_Datasets for Hydrological Model Continuum - Near Real Time
__date__ = '20210218'
__version__ = '1.2.0'
__author__ = 'Fabio Delogu (fabio.delogu@cimafoundation.org)'
__library__ = 'hat'
General command line:
python3 HAT_DataPublisher_HMC_NRT.py -settings_file configuration.json -time YYYYMMDDHHMM
python3 HAT_RunPublisher_HMC_NRT.py -settings_file configuration.json -time YYYYMMDDHHMM
Version(s) in changelog file
"""
Expand Down Expand Up @@ -45,7 +45,7 @@ def main():
# Version and algorithm information
sProgramVersion = '1.2.0'
sProjectName = 'HAT'
sAlgType = 'DataPublisher'
sAlgType = 'Analyzer_Datasets'
sAlgName = 'HMC NearRealTime'
# Time algorithm information
dStartTime = time.time()
Expand Down
199 changes: 199 additions & 0 deletions apps/Analyzer_Execution/HAT_RunAnalyzer_HMC_Main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
#!/usr/bin/python3
"""
Hydrological Analysis Tool - Analyzer_Execution
__date__ = '20210225'
__version__ = '1.5.0'
__author__ =
'Fabio Delogu (fabio.delogu@cimafoundation.org',
'Flavio Pignone (flavio.pignone@cimafoundation.org',
__library__ = 'HAT'
General command line:
python3 HAT_RunAnalyzer_HMC_Main.py -settings_file configuration.json -time "YYYY-MM-DD HH:MM"
Version(s):
20210225 (1.5.0) --> Beta release for HMC 3.x.x
20200605 (1.0.0) --> Beta release for HMC 2.x.x
"""

# -------------------------------------------------------------------------------------
# Complete library
import logging
import time
import os

from argparse import ArgumentParser

from lib_data_io_json import read_file_settings
from lib_utils_time import set_time

from driver_data_io_static import DriverStatic
from driver_data_io_dynamic import DriverDynamic
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Algorithm information
alg_version = '1.5.0'
alg_release = '2021-02-25'
alg_name = 'RUN ANALYZER'
# Algorithm parameter(s)
time_format = '%Y-%m-%d %H:%M'
# -------------------------------------------------------------------------------------


# -------------------------------------------------------------------------------------
# Script Main
def main():

# -------------------------------------------------------------------------------------
# Get algorithm settings
alg_settings, alg_time = get_args()

# Set algorithm settings
data_settings = read_file_settings(alg_settings)

# Set algorithm logging
set_logging(logger_file=os.path.join(data_settings['log']['folder_name'],
data_settings['log']['file_name']))
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Info algorithm
logging.info(' ============================================================================ ')
logging.info(' ==> ' + alg_name + ' (Version: ' + alg_version + ' Release_Date: ' + alg_release + ')')
logging.info(' ==> START ... ')
logging.info(' ')

# Time algorithm information
start_time = time.time()
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Organize time information
time_now, time_exec, time_range = set_time(
time_run_args=alg_time, time_run_file=data_settings['time']['time_now'],
time_format=time_format,
time_period=data_settings['time']['time_period'],
time_frequency=data_settings['time']['time_frequency'],
time_rounding=data_settings['time']['time_rounding'])
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Driver and method of static datasets
driver_data_static = DriverStatic(
src_dict=data_settings['data']['static'],
alg_ancillary=data_settings['algorithm']['ancillary'],
alg_template_tags=data_settings['algorithm']['template']
)
static_data_collection = driver_data_static.organize_static()
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Iterate over time range
for time_step in time_range:

# -------------------------------------------------------------------------------------
# Driver and method of dynamic datasets
driver_data_dynamic = DriverDynamic(
time_now=time_now,
time_exec=time_exec,
time_run=time_step,
static_data_collection=static_data_collection,
src_dict=data_settings['data']['dynamic']['source'],
anc_dict=data_settings['data']['dynamic']['ancillary'],
dest_dict=data_settings['data']['dynamic']['destination'],
alg_ancillary=data_settings['algorithm']['ancillary'],
alg_template_tags=data_settings['algorithm']['template'],
flag_cleaning_dynamic_source=data_settings['algorithm']['flags']['cleaning_dynamic_source'],
flag_cleaning_dynamic_analysis=data_settings['algorithm']['flags']['cleaning_dynamic_analysis'],
flag_cleaning_dynamic_destination=data_settings['algorithm']['flags']['cleaning_dynamic_destination'],
flag_cleaning_dynamic_tmp=data_settings['algorithm']['flags']['cleaning_dynamic_tmp'])

dynamic_data_collection = driver_data_dynamic.organize_dynamic_data()
analyze_data_collection, analyze_warnings_collection = driver_data_dynamic.analyze_dynamic_data(
dynamic_data_collection)
driver_data_dynamic.dump_dynamic_data(analyze_data_collection, analyze_warnings_collection)
driver_data_dynamic.clean_dynamic_tmp()
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------
# Info algorithm
alg_time_elapsed = round(time.time() - alg_time_start, 1)

logging.info(' ')
logging.info('[' + project_name + ' ' + alg_type + ' - ' + alg_name + ' (Version ' + alg_version +
' - Release ' + alg_release + ')]')
logging.info(' ==> TIME ELAPSED: ' + str(alg_time_elapsed) + ' seconds')
logging.info(' ==> ... END')
logging.info(' ==> Bye, Bye')
logging.info(' ============================================================================ ')
# -------------------------------------------------------------------------------------

# -------------------------------------------------------------------------------------


# -------------------------------------------------------------------------------------
# Method to get script argument(s)
def get_args():
parser_handle = ArgumentParser()
parser_handle.add_argument('-settings_file', action="store", dest="alg_settings")
parser_handle.add_argument('-time', action="store", dest="alg_time")
parser_values = parser_handle.parse_args()

if parser_values.alg_settings:
alg_settings = parser_values.alg_settings
else:
alg_settings = 'configuration.json'

if parser_values.alg_time:
alg_time = parser_values.alg_time
else:
alg_time = None

return alg_settings, alg_time

# -------------------------------------------------------------------------------------


# -------------------------------------------------------------------------------------
# Method to set logging information
def set_logging(logger_file='log.txt', logger_format=None):
if logger_format is None:
logger_format = '%(asctime)s %(name)-12s %(levelname)-8s ' \
'%(filename)s:[%(lineno)-6s - %(funcName)20s()] %(message)s'

# Remove old logging file
if os.path.exists(logger_file):
os.remove(logger_file)

# Set level of root debugger
logging.root.setLevel(logging.DEBUG)

# Open logging basic configuration
logging.basicConfig(level=logging.DEBUG, format=logger_format, filename=logger_file, filemode='w')

# Set logger handle
logger_handle_1 = logging.FileHandler(logger_file, 'w')
logger_handle_2 = logging.StreamHandler()
# Set logger level
logger_handle_1.setLevel(logging.DEBUG)
logger_handle_2.setLevel(logging.DEBUG)
# Set logger formatter
logger_formatter = logging.Formatter(logger_format)
logger_handle_1.setFormatter(logger_formatter)
logger_handle_2.setFormatter(logger_formatter)

# Add handle to logging
logging.getLogger('').addHandler(logger_handle_1)
logging.getLogger('').addHandler(logger_handle_2)

# -------------------------------------------------------------------------------------


# -------------------------------------------------------------------------------------
# Call script from external library
if __name__ == '__main__':
main()
# -------------------------------------------------------------------------------------
Loading

0 comments on commit 9e960ad

Please sign in to comment.