# 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/components/snow_base.py
# class snow_component( BMI_base.BMI_component ):
#     def set_constants(self):
#     def latent_heat_of_sublimation(self):
#     def initialize(self, cfg_file=None, mode="nondriver",
#                    SILENT=False):
#     def update(self, dt=-1.0):
#     def finalize(self):
#     def set_computed_input_vars(self):
#     def check_input_types(self):
#     def initialize_computed_vars(self):
#     def update_meltrate(self):
#     def enforce_max_meltrate(self):
#     def update_SM_integral(self):
#     def update_swe(self):
#     def update_depth(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):
#         T = self.T_air
#         T_IS_GRID = self.is_grid('T_air')
#         P_IS_GRID = self.is_grid('P_snow')
#         H0_SNOW_IS_SCALAR = self.is_scalar('h0_snow')
#         H0_SWE_IS_SCALAR  = self.is_scalar('h0_swe') 


import numpy as np
from topoflow.utils import model_input
from topoflow.components import snow_base
    #------------------------------------------------------------
    # Note: Cp_snow is a constant set in the "set_constants()"
    #       function in snow_base.py.
    #------------------------------------------------------------
    #       vol_SM was "basin_cumulative_snow_meltwater_volume"
    #------------------------------------------------------------
    _output_var_names = [
        'model__time_step',                                   # dt 
        'snowpack__degree-day_coefficient',                   # c0   (read from CFG)
        'snowpack__degree-day_threshold_temperature',         # T0   (read from CFG)
        'snowpack__domain_time_integral_of_melt_volume_flux', # vol_SM
        'snowpack__depth',                                    # h_snow
        'snowpack__initial_depth',                            # h0_snow
        'snowpack__initial_liquid-equivalent_depth',          # h0_swe
        'snowpack__liquid-equivalent_depth',                  # h_swe
        'snowpack__melt_volume_flux',                         # SM (MR is used for ice)
        'snowpack__z_mean_of_mass-per-volume_density' ]       # rho_snow
        #------------------------------------------------------------        
        # None of these should be needed for the Degree-Day method.
        #------------------------------------------------------------
        # 'snowpack__z_mean_of_mass-specific_isobaric_heat_capacity',       # Cp_snow 
                    
    _var_name_map = {
        'atmosphere_bottom_air__temperature':                 'T_air',
        'atmosphere_water__snowfall_leq-volume_flux':         'P_snow',
        'land_surface__temperature':                          'T_surf',        
        'water-liquid__mass-per-volume_density':              'rho_H2O',
        #------------------------------------------------------------------
        'model__time_step':                                   'dt',
        'snowpack__domain_time_integral_of_melt_volume_flux': 'vol_SM',

# 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/components/snow_base.py
# class snow_component( BMI_base.BMI_component ):
#     def set_constants(self):
#     def latent_heat_of_sublimation(self):
#     def initialize(self, cfg_file=None, mode="nondriver",
#                    SILENT=False):
#     def update(self, dt=-1.0):
#     def finalize(self):
#     def set_computed_input_vars(self):
#     def check_input_types(self):
#     def initialize_computed_vars(self):
#     def update_meltrate(self):
#     def enforce_max_meltrate(self):
#     def update_SM_integral(self):
#     def update_swe(self):
#     def update_depth(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):
#         T = self.T_air
#         T_IS_GRID = self.is_grid('T_air')
#         P_IS_GRID = self.is_grid('P_snow')
#         H0_SNOW_IS_SCALAR = self.is_scalar('h0_snow')
#         H0_SWE_IS_SCALAR  = self.is_scalar('h0_swe') 


# Path: topoflow/components/snow_degree_day.py
import numpy as np
from topoflow.utils import model_input
from topoflow.components import snow_base

    #------------------------------------------------------------
    # Note: Cp_snow is a constant set in the "set_constants()"
    #       function in snow_base.py.
    #------------------------------------------------------------
    #       vol_SM was "basin_cumulative_snow_meltwater_volume"
    #------------------------------------------------------------
    _output_var_names = [
        'model__time_step',                                   # dt 
        'snowpack__degree-day_coefficient',                   # c0   (read from CFG)
        'snowpack__degree-day_threshold_temperature',         # T0   (read from CFG)
        'snowpack__domain_time_integral_of_melt_volume_flux', # vol_SM
        'snowpack__depth',                                    # h_snow
        'snowpack__initial_depth',                            # h0_snow
        'snowpack__initial_liquid-equivalent_depth',          # h0_swe
        'snowpack__liquid-equivalent_depth',                  # h_swe
        'snowpack__melt_volume_flux',                         # SM (MR is used for ice)
        'snowpack__z_mean_of_mass-per-volume_density' ]       # rho_snow
        #------------------------------------------------------------        
        # None of these should be needed for the Degree-Day method.
        #------------------------------------------------------------
        # 'snowpack__z_mean_of_mass-specific_isobaric_heat_capacity',       # Cp_snow 
                    
    _var_name_map = {
        'atmosphere_bottom_air__temperature':                 'T_air',
        'atmosphere_water__snowfall_leq-volume_flux':         'P_snow',
        'land_surface__temperature':                          'T_surf',        
        'water-liquid__mass-per-volume_density':              'rho_H2O',
        #------------------------------------------------------------------
        'model__time_step':                                   'dt',
        'snowpack__domain_time_integral_of_melt_volume_flux': 'vol_SM',

        'snowpack__degree-day_coefficient':                   'c0',