How to use the tonic.models.vic.grid_params.Cols function in tonic

To help you get started, we’ve selected a few tonic examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
def veg_class(vegl_file, veglib_photo=False,
              c=Cols(veglib_fcan=False, veglib_photo=False)):
    """
    Load the entire vegetation library file into a dictionary of lists.
    """

    print('reading {0}'.format(vegl_file))

    data = []
    sep = ' '
    lib_bare_idx = None
    row = 0
    with open(vegl_file, 'r') as f:
        for line in f:
            words = line.split()
            if row == 0:
                col_desc = len(words) - 1
            elif line.startswith('#'):
github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
spatial_frost=spatial_frost,
                     spatial_snow=spatial_snow,
                     july_tavg_supplied=july_tavg_supplied))

    if cells is None:
        cells = len(soil_dict['gridcell'])

    if snow_file:
        snow_dict = snow(snow_file, soil_dict, c=Cols(snow_bands=snow_bands))
    else:
        snow_dict = False

    if vegl_file:
        veglib_dict, lib_bare_idx = veg_class(vegl_file,
                                              veglib_photo=veglib_photo,
                                              c=Cols(veglib_fcan=veglib_fcan,
                                                     veglib_photo=veglib_photo))
        veg_classes = len(veglib_dict['Veg_class'])
    else:
        veglib_dict = False
        lib_bare_idx = None

    if veg_file:
        veg_dict = veg(veg_file, soil_dict, veg_classes,
                       max_roots, cells, blowing_snow,
                       vegparam_lai, vegparam_fcan,
                       vegparam_albedo, lai_src,
                       fcan_src, alb_src)
    else:
        veg_dict = False

    if lake_file:
github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
def soil(in_file, c=Cols(nlayers=3, organic_fract=False,
                         spatial_frost=False, spatial_snow=False,
                         july_tavg_supplied=False)):
    """
    Load the entire soil file into a dictionary of numpy arrays.
    Also reorders data to match gridcell order of soil file.
    """
    print('reading {0}'.format(in_file))
    data = np.loadtxt(in_file)

    soil_dict = OrderedDict()
    for var, columns in c.soil_param.items():
        if var in ['gridcell', 'run_cell', 'fs_active']:
            soil_dict[var] = np.squeeze(data[:, columns]).astype(int)
        else:
            soil_dict[var] = np.squeeze(data[:, columns])
github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
the parameter data, if nc_file = False, the dictionary of grids is
    returned.
    """
    print('making gridded parameters now...')

    soil_dict = soil(soil_file, c=Cols(nlayers=nlayers,
                     organic_fract=organic_fract,
                     spatial_frost=spatial_frost,
                     spatial_snow=spatial_snow,
                     july_tavg_supplied=july_tavg_supplied))

    if cells is None:
        cells = len(soil_dict['gridcell'])

    if snow_file:
        snow_dict = snow(snow_file, soil_dict, c=Cols(snow_bands=snow_bands))
    else:
        snow_dict = False

    if vegl_file:
        veglib_dict, lib_bare_idx = veg_class(vegl_file,
                                              veglib_photo=veglib_photo,
                                              c=Cols(veglib_fcan=veglib_fcan,
                                                     veglib_photo=veglib_photo))
        veg_classes = len(veglib_dict['Veg_class'])
    else:
        veglib_dict = False
        lib_bare_idx = None

    if veg_file:
        veg_dict = veg(veg_file, soil_dict, veg_classes,
                       max_roots, cells, blowing_snow,
github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
def snow(snow_file, soil_dict, c=Cols(snow_bands=5)):
    """
    Load the entire snow file into a dictionary of numpy arrays.
    Also reorders data to match gridcell order of soil file.
    """

    print('reading {0}'.format(snow_file))

    data = np.loadtxt(snow_file)

    snow_dict = OrderedDict()
    for var in c.snow_param:
        snow_dict[var] = data[:, c.snow_param[var]]

    # Make gridcell order match that of soil_dict
    cell_nums = snow_dict['cellnum'].astype(np.int)
    indexes = np.zeros_like(soil_dict['gridcell'], dtype=np.int)
github UW-Hydro / tonic / tonic / models / vic / grid_params.py View on Github external
blowing_snow=False, vegparam_lai=False,
              vegparam_fcan=False, vegparam_albedo=False,
              lai_src='FROM_VEGLIB', fcan_src='FROM_DEFAULT',
              alb_src='FROM_VEGLIB', lake_profile=False):
    """
    Make grid uses routines from params.py to read standard vic format
    parameter files.  After the parameter files are read, the files are placed
    onto the target grid using nearest neighbor mapping.  If a land mask is
    present in the target grid it will be used to exclude areas in the ocean.
    Finally, if the nc_file = 'any_string.nc', a netcdf file be written with
    the parameter data, if nc_file = False, the dictionary of grids is
    returned.
    """
    print('making gridded parameters now...')

    soil_dict = soil(soil_file, c=Cols(nlayers=nlayers,
                     organic_fract=organic_fract,
                     spatial_frost=spatial_frost,
                     spatial_snow=spatial_snow,
                     july_tavg_supplied=july_tavg_supplied))

    if cells is None:
        cells = len(soil_dict['gridcell'])

    if snow_file:
        snow_dict = snow(snow_file, soil_dict, c=Cols(snow_bands=snow_bands))
    else:
        snow_dict = False

    if vegl_file:
        veglib_dict, lib_bare_idx = veg_class(vegl_file,
                                              veglib_photo=veglib_photo,