# Path: topoflow/utils/BMI_base.py
# def unit_test():
#     def __init__(self):
#     def get_status(self):
#     def get_attribute(self, att_name):
#     def get_grid_shape(self, long_var_name):
#     def get_grid_spacing(self, long_var_name):
#     def get_grid_origin(self, long_var_name):
#     def get_grid_attribute(self, long_var_name, att_name):
#     def read_grid_info(self):
#     def get_input_var_names(self):
#     def get_output_var_names(self):
#     def get_var_name(self, long_var_name):
#     def get_var_units(self, long_var_name):
#     def get_var_rank(self, long_var_name):
#     def get_var_type(self, long_var_name):
#     def get_var_itemsize(self, long_var_name):
#     def get_var_nbytes(self, long_var_name):
#     def get_values(self, long_var_name):
#     def set_values(self, long_var_name, value):
#     def get_values_at_indices(self, long_var_name, IDs):
#     def set_values_at_indices(self, long_var_name, IDs, values):
#     def get_time_step(self):
#     def get_time_units(self):
#     def get_start_time(self):
#     def get_current_time(self):
#     def get_end_time(self):
#     def initialize(self, cfg_file=None, mode="nondriver"):
#     def finalize(self):
#     def run_model(self, cfg_directory=None, cfg_prefix=None,
#                   n_steps=5):
#     def check_finished(self):
#     def initialize_time_vars(self, units='seconds'):
#     def update_time(self, dt=-1):
#     def print_time_and_value(self, var, var_name='Q_out',
#                              units_name='[m^3/s]',
#                              interval=2.0,
#                              PRINT_INDEX=False):
#     def get_run_time_string(self, proc_name='component',
#                             sec_digits=4, seconds=None,
#                             SILENT=None):
#     def print_run_time(self, proc_name='component',
#                        sec_digits=4, seconds=None,
#                        SILENT=None):
#     def print_final_report(self, comp_name='BMI component',
#                            mode='nondriver'):
#     def print_traceback(self, caller_name='TopoFlow'):
#     def read_path_info(self):
#     def getattr_TF(self, var_name, index):
#     def setattr_TF(self, var_name, value, index):
#     def read_config_file(self):
#     def initialize_config_vars(self):
#     def set_computed_input_vars( self):
#     def initialize_basin_vars( self ):
#     def prepend_directory(self, file_list, INPUT=True):
#     def check_directories(self):
#     def initialize_scalar(self, value=0.0, dtype='float64'):
#     def initialize_grid(self, value=0.0, dtype='float64'):
#     def initialize_var(self, var_type, value=0.0, dtype='float64'):
#     def update_var(self, var_name, value):
#     def is_scalar(self, var_name):
#     def is_vector(self, var_name):
#     def is_grid(self, var_name):
# class BMI_component:
#         COMPUTABLE = (dt_type == 'fixed') and (hasattr(self, 'n_steps'))
#                 COMPUTABLE = False  # (overrides COMPUTABLE above)
#             TIMES_UP = (self.time_index >= self.n_steps)
#             TIMES_UP = (self.time >= self.stop_time)
#             TIMES_UP = (self.dz_max < self.dz_tolerance)
#             COMMENT = (line[0] == '#')
#             COMMENT = (line[0] == '#')
#                 READ_SCALAR   = False
#                 READ_FILENAME = False
#                     SUBSCRIPT = True
#                     SUBSCRIPT = False
#                         READ_SCALAR = True
#                         READ_FILENAME = True
#                         READ_FILENAME = True
#                     SAVE_FLAG = False
#                         SAVE_FLAG = True
# 
# Path: topoflow/utils/cfg_files.py
# def unit_test():
# def skip_header(file_unit, n_lines=4):
# def get_yes_words():
# def read_words(file_unit, word_delim=None):
# def read_list(file_unit, dtype_list=None, dtype='string',
#               word_delim=None):
# def read_key_value_pair(file_unit, key_delim=':', SILENT=True):
# def read_line_after_key(file_unit, key_delim=':'):
# def read_words_after_key(file_unit, key_delim=':',
#                          word_delim=None, n_words=None):
# def read_list_after_key(file_unit, dtype_list=None, dtype='string',
#                         key_delim=':', word_delim=None):
# def read_value(file_unit, dtype='string', key_delim=':'):
# def var_type_code(var_type):
# def read_input_option(file_unit, key_delim=':', word_delim=None):
# def read_output_option(file_unit, key_delim=':', word_delim=None):


import numpy as np
import glob
import os
from topoflow.utils import BMI_base
from topoflow.utils import cfg_files as cfg
# 
#      initialize()
#      update()
#      finalize()
#      set_computed_input_vars()
#---------------------------------
#      read_input_files()
#      read_source_data()
#      read_sink_data()
#      read_canal_data()
#----------------------------
#      update_sources()
#      update_sinks()
#      update_canals()
#
#--------------------------------------------------------------------



#---------------------------------------------------------------------
class diversions_component( BMI_base.BMI_component ):
 
    def initialize(self, cfg_file=None, mode="nondriver",
                   SILENT=False):

        if not(SILENT):
            print ' '
            print 'Diversions component: Initializing...'
        
        self.status   = 'initializing'  # (OpenMI 2.0 convention)

# Path: topoflow/utils/BMI_base.py
# def unit_test():
#     def __init__(self):
#     def get_status(self):
#     def get_attribute(self, att_name):
#     def get_grid_shape(self, long_var_name):
#     def get_grid_spacing(self, long_var_name):
#     def get_grid_origin(self, long_var_name):
#     def get_grid_attribute(self, long_var_name, att_name):
#     def read_grid_info(self):
#     def get_input_var_names(self):
#     def get_output_var_names(self):
#     def get_var_name(self, long_var_name):
#     def get_var_units(self, long_var_name):
#     def get_var_rank(self, long_var_name):
#     def get_var_type(self, long_var_name):
#     def get_var_itemsize(self, long_var_name):
#     def get_var_nbytes(self, long_var_name):
#     def get_values(self, long_var_name):
#     def set_values(self, long_var_name, value):
#     def get_values_at_indices(self, long_var_name, IDs):
#     def set_values_at_indices(self, long_var_name, IDs, values):
#     def get_time_step(self):
#     def get_time_units(self):
#     def get_start_time(self):
#     def get_current_time(self):
#     def get_end_time(self):
#     def initialize(self, cfg_file=None, mode="nondriver"):
#     def finalize(self):
#     def run_model(self, cfg_directory=None, cfg_prefix=None,
#                   n_steps=5):
#     def check_finished(self):
#     def initialize_time_vars(self, units='seconds'):
#     def update_time(self, dt=-1):
#     def print_time_and_value(self, var, var_name='Q_out',
#                              units_name='[m^3/s]',
#                              interval=2.0,
#                              PRINT_INDEX=False):
#     def get_run_time_string(self, proc_name='component',
#                             sec_digits=4, seconds=None,
#                             SILENT=None):
#     def print_run_time(self, proc_name='component',
#                        sec_digits=4, seconds=None,
#                        SILENT=None):
#     def print_final_report(self, comp_name='BMI component',
#                            mode='nondriver'):
#     def print_traceback(self, caller_name='TopoFlow'):
#     def read_path_info(self):
#     def getattr_TF(self, var_name, index):
#     def setattr_TF(self, var_name, value, index):
#     def read_config_file(self):
#     def initialize_config_vars(self):
#     def set_computed_input_vars( self):
#     def initialize_basin_vars( self ):
#     def prepend_directory(self, file_list, INPUT=True):
#     def check_directories(self):
#     def initialize_scalar(self, value=0.0, dtype='float64'):
#     def initialize_grid(self, value=0.0, dtype='float64'):
#     def initialize_var(self, var_type, value=0.0, dtype='float64'):
#     def update_var(self, var_name, value):
#     def is_scalar(self, var_name):
#     def is_vector(self, var_name):
#     def is_grid(self, var_name):
# class BMI_component:
#         COMPUTABLE = (dt_type == 'fixed') and (hasattr(self, 'n_steps'))
#                 COMPUTABLE = False  # (overrides COMPUTABLE above)
#             TIMES_UP = (self.time_index >= self.n_steps)
#             TIMES_UP = (self.time >= self.stop_time)
#             TIMES_UP = (self.dz_max < self.dz_tolerance)
#             COMMENT = (line[0] == '#')
#             COMMENT = (line[0] == '#')
#                 READ_SCALAR   = False
#                 READ_FILENAME = False
#                     SUBSCRIPT = True
#                     SUBSCRIPT = False
#                         READ_SCALAR = True
#                         READ_FILENAME = True
#                         READ_FILENAME = True
#                     SAVE_FLAG = False
#                         SAVE_FLAG = True
# 
# Path: topoflow/utils/cfg_files.py
# def unit_test():
# def skip_header(file_unit, n_lines=4):
# def get_yes_words():
# def read_words(file_unit, word_delim=None):
# def read_list(file_unit, dtype_list=None, dtype='string',
#               word_delim=None):
# def read_key_value_pair(file_unit, key_delim=':', SILENT=True):
# def read_line_after_key(file_unit, key_delim=':'):
# def read_words_after_key(file_unit, key_delim=':',
#                          word_delim=None, n_words=None):
# def read_list_after_key(file_unit, dtype_list=None, dtype='string',
#                         key_delim=':', word_delim=None):
# def read_value(file_unit, dtype='string', key_delim=':'):
# def var_type_code(var_type):
# def read_input_option(file_unit, key_delim=':', word_delim=None):
# def read_output_option(file_unit, key_delim=':', word_delim=None):


# Path: topoflow/components/diversions_base.py
import numpy as np
import glob
import os
from topoflow.utils import BMI_base
from topoflow.utils import cfg_files as cfg

# 
#      initialize()
#      update()
#      finalize()
#      set_computed_input_vars()
#---------------------------------
#      read_input_files()
#      read_source_data()
#      read_sink_data()
#      read_canal_data()
#----------------------------
#      update_sources()
#      update_sinks()
#      update_canals()
#
#--------------------------------------------------------------------



#---------------------------------------------------------------------
class diversions_component( BMI_base.BMI_component ):
 
    def initialize(self, cfg_file=None, mode="nondriver",
                   SILENT=False):

        if not(SILENT):
            print ' '
            print 'Diversions component: Initializing...'
        
        self.status   = 'initializing'  # (OpenMI 2.0 convention)

        self.mode     = mode