How to use the tonic.models.vic.grid_params.format 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
def soil(data, xinds, yinds, soil_file):
    """Write VIC formatted soil parameter file"""
    c = grid_params.cols(nlayers=3)
    f = grid_params.format(nlayers=3)

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

    for var in c.soil_param:
        if data[var].ndim == 2:
            soil_params[:, c.soil_param[var]] = np.atleast_2d(
                data[var][yinds, xinds]).transpose()
        elif data[var].ndim == 3:
            soil_params[:, c.soil_param[var]] = np.atleast_2d(
                data[var][:, yinds, xinds]).transpose()
        for col in c.soil_param[var]:
            dtypes[col] = f.soil_param[var]