How to use the tonic.models.vic.grid_params 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 / ncparam2ascii.py View on Github external
message = """
*** ---------------------------------------------------------------------- ***
Notes about RASM soil parameter file generations:
 - To fill in missing grid cells 'mask' variable must be the same as the
   domain file mask.
 - Inactive grid cells will have a dummy line printed for all variables except
   the lons/lats.
 - Any grid cells with nans will be copied from the previous line without nans
   or FILL_VALUEs.
*** --------------------------------------------------------------------- ***\n
    """

    print(message)

    # ---------------------------------------------------------------- #
    c = grid_params.cols(nlayers=3)
    f = grid_params.format(nlayers=3)

    c.soil_param['Nveg'] = np.array([0])
    f.soil_param['Nveg'] = '%1i'

    numcells = data['mask'].size

    arrayshape = (numcells, 1 + np.max([np.max(cols) for v, cols in
                                        iteritems(c.soil_param)]))
    soil_params = np.empty(arrayshape)
    dtypes = ['%1i'] * arrayshape[1]
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # find nearest real grid cell for all grid cells where frozen soil mask is
    # active
github UW-Hydro / tonic / tonic / models / vic / ncparam2ascii.py View on Github external
def snow(data, xinds, yinds, snow_file):
    """Write VIC formatted snowband parameter file"""
    try:
        snow_bands = data['AreaFract'].shape[0]
    except:
        snow_bands = 5

    c = grid_params.cols(snow_bands=snow_bands)
    f = grid_params.format(snow_bands=snow_bands)

    arrayshape = (len(xinds), 1 + np.max([np.max(c.snow_param[var])
                                          for var in c.snow_param]))
    snow_params = np.zeros(arrayshape)
    dtypes = [0] * arrayshape[1]

    for var in c.snow_param:
        if data[var].ndim == 2:
            snow_params[:, c.snow_param[var]] = np.atleast_2d(
                data[var][yinds, xinds]).transpose()
        elif data[var].ndim == 3:
            snow_params[:, c.snow_param[var]] = np.atleast_2d(
                data[var][:, yinds, xinds]).transpose()
        for col in c.snow_param[var]:
            dtypes[col] = f.snow_param[var]
github UW-Hydro / tonic / tonic / models / vic / ncparam2ascii.py View on Github external
def snow(data, xinds, yinds, snow_file):
    """Write VIC formatted snowband parameter file"""
    try:
        snow_bands = data['AreaFract'].shape[0]
    except:
        snow_bands = 5

    c = grid_params.cols(snow_bands=snow_bands)
    f = grid_params.format(snow_bands=snow_bands)

    arrayshape = (len(xinds), 1 + np.max([np.max(c.snow_param[var])
                                          for var in c.snow_param]))
    snow_params = np.zeros(arrayshape)
    dtypes = [0] * arrayshape[1]

    for var in c.snow_param:
        if data[var].ndim == 2:
            snow_params[:, c.snow_param[var]] = np.atleast_2d(
                data[var][yinds, xinds]).transpose()
        elif data[var].ndim == 3:
            snow_params[:, c.snow_param[var]] = np.atleast_2d(
                data[var][:, yinds, xinds]).transpose()
        for col in c.snow_param[var]:
            dtypes[col] = f.snow_param[var]
github UW-Hydro / tonic / tonic / models / vic / ncparam2ascii.py View on Github external
*** ---------------------------------------------------------------------- ***
Notes about RASM soil parameter file generations:
 - To fill in missing grid cells 'mask' variable must be the same as the
   domain file mask.
 - Inactive grid cells will have a dummy line printed for all variables except
   the lons/lats.
 - Any grid cells with nans will be copied from the previous line without nans
   or FILL_VALUEs.
*** --------------------------------------------------------------------- ***\n
    """

    print(message)

    # ---------------------------------------------------------------- #
    c = grid_params.cols(nlayers=3)
    f = grid_params.format(nlayers=3)

    c.soil_param['Nveg'] = np.array([0])
    f.soil_param['Nveg'] = '%1i'

    numcells = data['mask'].size

    arrayshape = (numcells, 1 + np.max([np.max(cols) for v, cols in
                                        iteritems(c.soil_param)]))
    soil_params = np.empty(arrayshape)
    dtypes = ['%1i'] * arrayshape[1]
    # ---------------------------------------------------------------- #

    # ---------------------------------------------------------------- #
    # find nearest real grid cell for all grid cells where frozen soil mask is
    # active
    # This is needed because the RASM mask is often different than existing