Example #1
0
def calculate(process_name, tasks, results):
    print('[%s] evaluation routine starts' % process_name)

    while True:
        new_value = tasks.get()
        if new_value == "None":
            print('[%s] evaluation routine quits' % process_name)

            # Indicate finished
            results.put(-1)
            break
        else:
            # Initialise icestupa object
            location = new_value
            icestupa = Icestupa(location)

            # Derive all the input parameters
            icestupa.derive_parameters()
            # icestupa.read_input()

            # Generate results
            icestupa.melt_freeze()

            # Summarise and save model results
            icestupa.save()

            # Read Output
            # icestupa.read_output()

            # Create figures for web interface
            icestupa.summary_figures()

            # Compute result and mimic a long-running task
            compute = icestupa.df.iceV.max()

            # Output which process received the value
            print('[%s] received value: %s' % (process_name, new_value))
            print('[%s] calculated max ice volume: %.1f' %
                  (process_name, compute))

            # Add result to the queue
            results.put(compute)

    return
Example #2
0
        # level=logging.WARNING,
        level=logging.INFO,
        logger=logger,
    )

    answers = dict(
        # location="Schwarzsee 2019",
        location="Guttannen 2021",
        # location="Gangles 2021",
        run="yes",
        # run="no",
    )

    # Initialise icestupa object
    # icestupa = Icestupa(answers["location"], params='best')
    icestupa = Icestupa(answers["location"])

    if answers["run"] == "yes":
        # Derive all the input parameters
        icestupa.derive_parameters()

        # Generate results
        icestupa.melt_freeze(test=True)
        # icestupa.melt_freeze()

        # Summarise and save model results
        icestupa.save()

        # Create figures for web interface
        icestupa.summary_figures()
    else:
Example #3
0
    CB91_Blue = "#2CBDFE"
    CB91_Green = "#47DBCD"
    CB91_Pink = "#F3A0F2"
    CB91_Purple = "#9D2EC5"
    CB91_Violet = "#661D98"
    CB91_Amber = "#F5B14C"

    # index = pd.date_range(start ='1-1-2022',
    #      end ='1-1-2024', freq ='D', name= "When")
    # df_out = pd.DataFrame(columns=locations,index=index)

    fig, ax = plt.subplots(len(locations), 1, sharex='col')

    for i, location in enumerate(locations):
        SITE, FOLDER = config(location)
        icestupa = Icestupa(location)
        icestupa.read_output()
        icestupa.self_attributes()

        variance = []
        mean = []
        evaluations = []

        data = un.Data()
        # filename1 = FOLDER['sim']+ "SE_full.h5"
        filename1 = FOLDER['sim'] + "full.h5"
        filename2 = FOLDER['sim'] + "fountain.h5"
        # filename1 = FOLDER['sim']+ "efficiency.h5"
        # print(data)

        if location == 'schwarzsee19':
Example #4
0
sys.path.append(
    os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))

from src.utils.settings import config
from src.models.methods.metadata import get_parameter_metadata
from src.models.icestupaClass import Icestupa

if __name__ == "__main__":
    locations = ["gangles21", "guttannen21"]
    # locations = ['guttannen21',  'gangles21']
    # locations = ['guttannen21']

    for ctr, location in enumerate(locations):
        SITE, FOLDER = config(location)
        icestupa = Icestupa(location)
        icestupa.read_output()

        print(icestupa.df.loc[icestupa.df.Discharge > 0, 'Discharge'].count())
        print(icestupa.df.loc[icestupa.df.fountain_froze >= SITE['D_F'] * 60,
                              'fountain_runoff'].count())

        icestupa.df.loc[icestupa.df.Qfreeze == 0, 'Qfreeze'] = np.nan
        icestupa.df.loc[icestupa.df.Qmelt == 0, 'Qmelt'] = np.nan
        icestupa.df.loc[icestupa.df.Discharge == 0, 'fountain_froze'] = np.nan
        icestupa.df['melted'] /= 60
        icestupa.df['fountain_froze'] /= 60
        print(icestupa.df.fountain_froze.max())

        icestupa.df = icestupa.df.rename(
            {
Example #5
0
    # params = ['IE', 'A_I', 'Z', 'SA_corr', 'DX']
    # params = ['DX', 'SA_corr']
    params = ['Z', 'SA_corr', 'DX']
    kind = ['volume', 'area']

    sns.set(style="darkgrid")
    fig, ax = plt.subplots(nrows=len(kind),
                           ncols=len(params),
                           sharey="row",
                           figsize=(18, 8))

    for obj in kind:
        # Creating an empty Dataframe with column names only
        dfx = pd.DataFrame(columns=params)
        for ctr, location in enumerate(locations):
            icestupa = Icestupa(location)
            SITE, FOLDER = config(location)
            icestupa.read_output()

            file_path = 'cv-' + obj + '-'
            file_path += '-'.join('{}'.format(key) for key in params)

            df = pd.read_csv(FOLDER['sim'] + file_path)
            df = df.set_index('rmse').sort_index().reset_index()
            df['params'] = df['params'].apply(literal_eval)

            num_selected = int(0.1 * df.shape[0])
            num_total = df.shape[0]
            print()
            print("\tObjective %s Site %s" % (obj, location))
            print("\tSelected %s out of %s" % (num_selected, num_total))
Example #6
0
sys.path.append(
    os.path.dirname(
        os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))

from src.utils.settings import config
from src.models.methods.metadata import get_parameter_metadata
from src.models.icestupaClass import Icestupa

if __name__ == "__main__":
    # locations = ["gangles21", "guttannen21"]
    locations = ["gangles21"]

    fig, ax = plt.subplots()
    for ctr, location in enumerate(locations):
        SITE, FOLDER = config(location)
        icestupa = Icestupa(location)
        icestupa.read_output()
        icestupa.df = icestupa.df[:icestupa.last_hour]

        df = icestupa.df[[
            "Qs",
            "Ql",
            "SW",
            "LW",
            "Qf",
            "Qg",
            "SA",
            "T_a",
            "v_a",
            "RH",
            "Discharge",
Example #7
0
from src.utils.settings import config

if __name__ == "__main__":

    # Main logger
    logger = logging.getLogger(__name__)
    coloredlogs.install(
        fmt="%(funcName)s %(levelname)s %(message)s",
        level=logging.WARNING,
        # level=logging.INFO,
        logger=logger,
    )

    location = 'schwarzsee19'

    # Initialise icestupa object
    icestupa = Icestupa(location)
    # Derive all the input parameters
    icestupa.derive_parameters()
    with cProfile.Profile() as pr:
        # Generate results
        icestupa.melt_freeze()
    # # Summarise and save model results
    # icestupa.summary()
    # # Create figures for web interface
    # icestupa.summary_figures()

    stats = pstats.Stats(pr)
    stats.sort_stats(pstats.SortKey.TIME)
    stats.print_stats("get_temp")
Example #8
0
    ]
    zip_iterator = zip(names, names_label)
    param_dictionary = dict(zip_iterator)

    evaluations = []
    percent_change = []
    efficiency_change = []
    site = []
    param = []
    result = []
    freeze_rate = []
    melt_rate = []
    fig, ax = plt.subplots()
    for location in locations:
        SITE, FOLDER = config(location)
        icestupa = Icestupa(location)
        icestupa.read_output()
        icestupa.self_attributes()
        feature_name = "efficiency"

        icestupa.se = (icestupa.M_water +
                       icestupa.M_ice) / icestupa.M_input * 100

        for j in range(0, icestupa.df.shape[0]):
            if icestupa.df.loc[j, "fountain_froze"] != 0:
                freeze_rate.append([
                    get_parameter_metadata(location)["shortname"],
                    j,
                    icestupa.df.loc[j, "fountain_froze"] / 60,
                ])
            if icestupa.df.loc[j, "melted"] != 0:
Example #9
0
    location = st.sidebar.radio(
        "built at",
        # ( "Guttannen 2021","Gangles 2021", "Diavolezza 2021","Guttannen 2020", "Schwarzsee 2019"),
        # ("Guttannen 2021", "Gangles 2021", "Guttannen 2020", "Schwarzsee 2019"),
        # ("Guttannen 2021", "Gangles 2021", "Guttannen 2020", "Schwarzsee 2019"),
        ("Gangles 2021", "Guttannen 2021", "Guttannen 2020"),
        # ("Guttannen 2021", "Guttannen 2020", "Schwarzsee 2019"),
    )

    # location = "Gangles 2021"
    # trigger = "Manual"

    SITE, FOLDER = config(location)

    icestupa = Icestupa(location)
    icestupa.read_output()
    icestupa.self_attributes()

    df_in = icestupa.df
    (
        input_cols,
        input_vars,
        output_cols,
        output_vars,
        derived_cols,
        derived_vars,
    ) = vars(df_in)

    # df_in = df_in[df_in.columns.drop(list(df_in.filter(regex="Unnamed")))]
    # df_in = df_in.set_index("When")
Example #10
0
        fmt="%(funcName)s %(levelname)s %(message)s",
        level=logging.ERROR,
        logger=logger,
    )
    answers = dict(
        # location="Schwarzsee 2019",
        location="Guttannen 2021",
        # location="Gangles 2021",
        trigger="Manual",
    )

    # Get settings for given location and trigger
    SITE, FOUNTAIN, FOLDER, *args = config(answers["location"])

    # Initialise icestupa object
    icestupa = Icestupa(answers["location"])

    cmap = plt.cm.rainbow  # define the colormap
    norm = mpl.colors.Normalize(vmin=-100, vmax=0)
    sm = plt.cm.ScalarMappable(cmap=cmap, norm=norm)
    sm.set_array([])

    filename = FOLDER["sim"] + "/DX_sim.csv"
    filename2 = FOLDER["sim"] + "/DX_sim.h5"
    figures = FOLDER["sim"] + "/DX_sim.pdf"
    filename = FOLDER["sim"] + "/Tune_sim.csv"
    figures = FOLDER["sim"] + "/Tune_sim.pdf"

    df = pd.read_csv(filename, sep=",")
    logger.info(df)
Example #11
0
        fmt="%(funcName)s %(levelname)s %(message)s",
        # level=logging.WARNING,
        level=logging.INFO,
        logger=logger,
    )

    # locations = ['gangles21', 'guttannen21', 'guttannen20']
    locations = ['gangles21', 'guttannen21']

    fig, ax = plt.subplots()
    custom_colors = sns.color_palette("Set1", len(locations))

    for i, location in enumerate(locations):
        SITE, FOLDER = config(location)

        icestupa = Icestupa(location)
        icestupa.self_attributes()
        icestupa.read_output()

        # icestupa.df = icestupa.df[1:-1]
        icestupa.df = icestupa.df[1:icestupa.last_hour - 1]

        df_c = pd.read_csv(
            FOLDER["raw"] + location + "_drone.csv",
            sep=",",
            header=0,
            parse_dates=["When"],
        )

        #         a_pred = []
        #         a_true = df_c.Area.values