# Path: topoflow/components/infil_base.py
# class infil_component( BMI_base.BMI_component):
#     def set_constants(self):       
#     def initialize(self, cfg_file=None, mode="nondriver",
#                    SILENT=False):
#     def update(self, dt=-1.0):
#     def finalize(self):
#     def build_layer_z_vector(self):
#     def build_layered_var(self, var_list_for_layers):
#     def set_computed_input_vars(self):
#     def check_input_types(self):
#     def update_surface_influx(self):
#     def update_infil_rate(self):
#     def adjust_infil_rate(self):
#     def update_IN_integral(self):
#     def update_Rg(self):
#     def update_Rg_integral(self):
#     def update_I(self):
#     def update_q0(self):
#     def check_infiltration(self):
#     def check_low_rainrate(self):
#     def open_input_files(self):
#     def read_input_files(self):
#     def close_input_files(self):
#     def update_outfile_names(self):
#     def open_output_files(self):
#     def write_output_files(self, time_seconds=None):
#     def close_output_files(self):
#     def save_grids(self):
#     def save_pixel_values(self):
#     def save_profiles(self):
#     def save_cubes(self):
#         ALL_SCALARS = (nmax == 1)
#         SM     = self.SM        # (2/3/13, new framework)
#         CHECK_LOW_RAIN = not(self.RICHARDS)
#         SM      = self.SM       # (2/3/13, new framework)
#             OK = np.isfinite( self.IN )
#             OK = (nbad == 0)
#             G  = model_input.read_next(self.G_unit[k], self.G_type[k], rti)
# 
# Path: topoflow/utils/model_input.py
# def open_file(var_type, input_file):
# def read_next2(self, var_name, rti, dtype='Float32', factor=1.0):
# def read_next(file_unit, var_type, rti, \
#               dtype='Float32', factor=1.0):
# def read_scalar(file_unit, dtype='Float32'):
# def read_grid(file_unit, rti, dtype='Float32'):
# def close_file(file_unit):
#     END_OF_FILE = (file_pos == file_size)
# 
# Path: topoflow/utils/tf_utils.py
# def TF_Print(string):
#     """Print a string to the TopoFlow output log window."""
# 
#     #------------------------------------------
#     # For now, just print to terminal window.
#     # Later, this will be method in tf_gui.py.
#     #------------------------------------------
#     print string
# 
# def TF_String(number, FORMAT=None):
# 
#     return idl_func.string(number, format=FORMAT).strip()


import numpy as np
from topoflow.components import infil_base
from topoflow.utils import model_input
from topoflow.utils.tf_utils import TF_Print, TF_String
        #--------------------------------------------
        MID_PONDING = ((dIp > 0) and (dIp < (r * self.dt)))
        if (MID_PONDING):    
            print 'MID_PONDING occurred.'
            #--------------------------
            # For this case: Ip = Ip2
            #--------------------------
            self.tp = t_start + (dIp / r)    #(r gt Ks, above)
            self.fp = r
        
        #------------------------------------------
        # Does ponding occur at end of timestep ?
        #------------------------------------------
        #   Ip(r_n) < Ia(n-1) < Ip(r_{n-1})
        #   [Ip(r_n) - Ia(n-1)] < 0  AND
        #    Ia(n-1) < Ip(r_{n-1})
        #------------------------------------------
        END_PONDING = ((dIp < 0) and (self.I < Ip1) and not(MID_PONDING))
        if (END_PONDING):    
            print 'END_PONDING occurred.'
            #-----------------------------
            # For this case: Ip = self.I
            #-----------------------------
            self.tp = t_end
            self.fp = (top / self.I) + Ks
        
        #--------------------------
        # For debugging & testing
        #--------------------------
        if (MID_PONDING or END_PONDING):    

# Path: topoflow/components/infil_base.py
# class infil_component( BMI_base.BMI_component):
#     def set_constants(self):       
#     def initialize(self, cfg_file=None, mode="nondriver",
#                    SILENT=False):
#     def update(self, dt=-1.0):
#     def finalize(self):
#     def build_layer_z_vector(self):
#     def build_layered_var(self, var_list_for_layers):
#     def set_computed_input_vars(self):
#     def check_input_types(self):
#     def update_surface_influx(self):
#     def update_infil_rate(self):
#     def adjust_infil_rate(self):
#     def update_IN_integral(self):
#     def update_Rg(self):
#     def update_Rg_integral(self):
#     def update_I(self):
#     def update_q0(self):
#     def check_infiltration(self):
#     def check_low_rainrate(self):
#     def open_input_files(self):
#     def read_input_files(self):
#     def close_input_files(self):
#     def update_outfile_names(self):
#     def open_output_files(self):
#     def write_output_files(self, time_seconds=None):
#     def close_output_files(self):
#     def save_grids(self):
#     def save_pixel_values(self):
#     def save_profiles(self):
#     def save_cubes(self):
#         ALL_SCALARS = (nmax == 1)
#         SM     = self.SM        # (2/3/13, new framework)
#         CHECK_LOW_RAIN = not(self.RICHARDS)
#         SM      = self.SM       # (2/3/13, new framework)
#             OK = np.isfinite( self.IN )
#             OK = (nbad == 0)
#             G  = model_input.read_next(self.G_unit[k], self.G_type[k], rti)
# 
# Path: topoflow/utils/model_input.py
# def open_file(var_type, input_file):
# def read_next2(self, var_name, rti, dtype='Float32', factor=1.0):
# def read_next(file_unit, var_type, rti, \
#               dtype='Float32', factor=1.0):
# def read_scalar(file_unit, dtype='Float32'):
# def read_grid(file_unit, rti, dtype='Float32'):
# def close_file(file_unit):
#     END_OF_FILE = (file_pos == file_size)
# 
# Path: topoflow/utils/tf_utils.py
# def TF_Print(string):
#     """Print a string to the TopoFlow output log window."""
# 
#     #------------------------------------------
#     # For now, just print to terminal window.
#     # Later, this will be method in tf_gui.py.
#     #------------------------------------------
#     print string
# 
# def TF_String(number, FORMAT=None):
# 
#     return idl_func.string(number, format=FORMAT).strip()


# Path: topoflow/components/infil_green_ampt.py
import numpy as np
from topoflow.components import infil_base
from topoflow.utils import model_input
from topoflow.utils.tf_utils import TF_Print, TF_String

        #--------------------------------------------
        MID_PONDING = ((dIp > 0) and (dIp < (r * self.dt)))
        if (MID_PONDING):    
            print 'MID_PONDING occurred.'
            #--------------------------
            # For this case: Ip = Ip2
            #--------------------------
            self.tp = t_start + (dIp / r)    #(r gt Ks, above)
            self.fp = r
        
        #------------------------------------------
        # Does ponding occur at end of timestep ?
        #------------------------------------------
        #   Ip(r_n) < Ia(n-1) < Ip(r_{n-1})
        #   [Ip(r_n) - Ia(n-1)] < 0  AND
        #    Ia(n-1) < Ip(r_{n-1})
        #------------------------------------------
        END_PONDING = ((dIp < 0) and (self.I < Ip1) and not(MID_PONDING))
        if (END_PONDING):    
            print 'END_PONDING occurred.'
            #-----------------------------
            # For this case: Ip = self.I
            #-----------------------------
            self.tp = t_end
            self.fp = (top / self.I) + Ks
        
        #--------------------------
        # For debugging & testing
        #--------------------------
        if (MID_PONDING or END_PONDING):    

            TF_Print('tp = ' + str(self.tp))