<jupyter_start><jupyter_text>Cal<jupyter_code>import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
matplotlib.style.use('seaborn-notebook')
import matplotlib.patches as patches
plt.rcParams['figure.figsize'] = (14, 6)
# Load data for new snow line
REGION_ID = 3031
nsl = pd.read_csv(r"C:\Users\kmu\PycharmProjects\APS\aps\scripts\tmp\new_snow_line_{0}_20201201.csv".format(REGION_ID),
                  sep=";", header=0)
nsl.head()
# group by date and keep only the highest value
nsl_gr = nsl.groupby("Date").max()
nsl_gr.describe()
nsl_gr.plot(y='Altitude');
aw = pd.read_csv(r"C:\Users\kmu\PycharmProjects\varsomdata\localstorage\norwegian_avalanche_warnings_season_20_21.csv",
                 sep=";", header=0, index_col=0,
                 usecols=["index", "region_id", "region_name", "danger_level", "date_valid", "mountain_weather_precip_region", "mountain_weather_freezing_level", "mountain_weather_fl_hour_of_day_start", "mountain_weather_fl_hour_of_day_stop"],
                 parse_dates=["date_valid"])
for c in aw.columns:
    print(c)
aw.head(10)
aw_region = aw[aw["region_id"]==REGION_ID]
aw_region.describe()
aw_region.plot(x="date_valid", y="mountain_weather_freezing_level")  # mountain_weather_precip_region
df_merged = nsl_gr.join(aw_region.set_index("date_valid"), how='left', lsuffix='nsl_', rsuffix='aw_', sort=False)
df_merged.describe()
plt.plot(df_merged.index, df_merged["mountain_weather_freezing_level"], label="Varsom nullgradsgrense")
plt.bar(df_merged.index, df_merged["mountain_weather_precip_region"]*10, label="Varsom gjen. nedbør (x10)")
plt.plot(df_merged.index, df_merged["Altitude"], label="APS ny snøfallgrense")

plt.legend();
plt.plot(df_merged.index, df_merged["mountain_weather_freezing_level"], label="Varsom nullgradsgrense")
plt.bar(df_merged.index, df_merged["mountain_weather_precip_region"]*10, label="Varsom gjen. nedbør (x10)")
plt.plot(df_merged.index, np.clip(df_merged["Altitude"], a_min=0, a_max=None), label="APS ny snøfallgrense")

plt.legend();
new_minus_pub = np.clip(df_merged["Altitude"], a_min=0, a_max=None) - df_merged["mountain_weather_freezing_level"]
print(np.mean(new_minus_pub), np.min(new_minus_pub), np.max(new_minus_pub)) 
plt.bar(df_merged.index, df_merged["mountain_weather_precip_region"]*10, label="Varsom gjen. nedbør (x10)", alpha=0.3)
plt.plot(df_merged.index, new_minus_pub, label="Differenase");<jupyter_output>-12.17182897348873 -505.0152587890625 401.7392578125
{'fraction_non_alphanumeric': 0.14527162977867203, 'fraction_numerical': 0.03460764587525151, 'mean_word_length': 7.398648648648648, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '474229', 'license': 'MIT', 'n_tokens_mistral': 1042, 'n_tokens_neox': 947, 'n_words': 136, 'path': 'aps/notebooks/new_snow_line_plot.ipynb', 'repo_name': 'kmunve/APS', 'size': '2485'}