Example #1
0
def DegreeDayDynamicArray(model_name, T_min, T_max):
    """Function to assemble a dataframe for calculating Degree Day using dynamic arrays. Takes either a name of a model or the named range itself.

    :param model: Named Range of the model which will be evaluated. The Excel cell name / named range
    :param T_min: Daily minimum temperature
    :param T_max: Daily maximum temperature
    """
    try:
        prepared_model_name = fk.load_model(model_name)

        # format the equation terms, evalueate the equation and return the result.
        inputs_for_DegreeDay = pd.DataFrame({'T_min': T_min, 'T_max': T_max})
        return fk.evaluate_koala_model(prepared_model_name, inputs_for_DegreeDay)

    except Exception as err:
            return str(err)
Example #2
0
def DegreeDayByName(model_name, T_min, T_max):
    """Function to assemble a dataframe for calculating Degree Day.

    :param model: Text name (string) of the model which will be evaluated. The Excel cell name / named range
    :param T_min: Daily minimum temperature
    :param T_max: Daily maximum temperature
    """

    if model_name not in fk.koala_models.keys():
        model = None
        wb = xw.books.active
        for name in wb.names:
            if model_name == name.name:
                model = xw.Range(model_name)
                fk.generate_model_graph(model)

        if model is None:
            return 'Model "%s" has not been loaded into cache, if named range exists check spelling.' % model_name

    inputs_for_DegreeDay = pd.DataFrame({'T_min': np.array([T_min]), 'T_max': np.array([T_max])})
    return fk.evaluate_koala_model(model_name, inputs_for_DegreeDay)