from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
$('div.input').show();
}
code_show = !code_show
}
$( document ).ready(code_toggle);
</script>
The raw code for this IPython notebook is by default hidden for easier reading.
To toggle on/off the raw code, click <a href="javascript:code_toggle()">here</a>.''')
# Necessary packages/modules to import
import pandas as pd
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import warnings
warnings.filterwarnings('ignore')
import xlrd
### conda install plotly
### pip install cufflinks --upgrade
import cufflinks as cf
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
Two automatic weather stations (AWS) were mounted in the skiing area of Patscherkofel on 23rd of March 2018 to investigate whether artificial snow has an impact on the change of reflectivity of shortwave radiation and consequently an impact on the surface energy budget. For this purpose two CNR4 Net Radiometer were installed, which measure the incoming and outgoing longwave(LW) and shortwave(SW) radiation. First, both were placed in natural finish terrain on snow next to a ski slope. On the 6th of April 2018, one station was moved on to the ski slope. The measurement period was from 23rd of March until the 9th of May. It has to be mentioned that there was a huge amount of natural snow in this winter and we do not know how much artificial snow actually was produced, so it is hard to quantify how strong the effect actually is.
# read Patscherkofel data
df1 = pd.read_table('CR6_Patscherkofel_1_Table1_Logger_15052018.dat', skiprows=[2,3], header = 1, delimiter=',', index_col=0, parse_dates=True)
df2 = pd.read_table('CR6_Patscherkofel_2_Table1_Logger_15052018.dat',skiprows=[2,3], header = 1, delimiter=',', index_col=0, parse_dates=True)
# only those values during the measurement period
df3 = df1.loc['2018-03-24':'2018-05-08']
df4 = df2.loc['2018-03-24':'2018-05-08']
#Convert data to numeric data:
df3.PTemp_C_Avg=pd.to_numeric(df3.PTemp_C_Avg, errors='coerce')
df3.BattV_Avg=pd.to_numeric(df3.BattV_Avg, errors='coerce')
df3.BattV_Max=pd.to_numeric(df3.BattV_Max, errors='coerce')
df3.BattV_Min=pd.to_numeric(df3.BattV_Min, errors='coerce')
df3.SWUpper_Avg=pd.to_numeric(df3.SWUpper_Avg, errors='coerce')
df3.SWLower_Avg=pd.to_numeric(df3.SWLower_Avg, errors='coerce')
df3.LWUpper_Avg=pd.to_numeric(df3.LWUpper_Avg, errors='coerce')
df3.LWLower_Avg=pd.to_numeric(df3.LWLower_Avg, errors='coerce')
df3.CNR4TC_Avg=pd.to_numeric(df3.CNR4TC_Avg, errors='coerce')
df3.CNR4TK_Avg=pd.to_numeric(df3.CNR4TK_Avg, errors='coerce')
#
df4.PTemp_C_Avg=pd.to_numeric(df4.PTemp_C_Avg, errors='coerce')
df4.BattV_Avg=pd.to_numeric(df4.BattV_Avg, errors='coerce')
df4.BattV_Max=pd.to_numeric(df4.BattV_Max, errors='coerce')
df4.BattV_Min=pd.to_numeric(df4.BattV_Min, errors='coerce')
df4.SWUpper_Avg=pd.to_numeric(df4.SWUpper_Avg, errors='coerce')
df4.SWLower_Avg=pd.to_numeric(df4.SWLower_Avg, errors='coerce')
df4.LWUpper_Avg=pd.to_numeric(df4.LWUpper_Avg, errors='coerce')
df4.LWLower_Avg=pd.to_numeric(df4.LWLower_Avg, errors='coerce')
df4.CNR4TC_Avg=pd.to_numeric(df4.CNR4TC_Avg, errors='coerce')
df4.CNR4TK_Avg=pd.to_numeric(df4.CNR4TK_Avg, errors='coerce')
Figure 1 shows the minimum battery voltage for both stations. In the first days problems occured with the battery of Patscherkofel 1 and 2, which can be seen by decreasing minimum voltage (at the evening of 26.03.2018). So, no data was recorded between 00:10 and 11:18 at March 27th. The issue was solved by maintenance work of Wolfgang Gurgiser on this same day. Due to the heavy snowfall, the solar panels got covered with snow and hence the batteries could not be recharged on the day 2018-03-26. So the voltage was sinking up to the minimum of 11 V in the night and the station went out of power.
Snow might have covered Patscherkofel 1 station at March 29th, as the battery was not recharged compared to Patscherkofel 2.
That means that also possible snow cover over the instrument has to be taken into account when dealing with AWS data.
In the period between March 30th to May 9th, both batteries were recharged in a daily cycle. So, the solar panels seemed to work well and we can expect that there were no strong snowfalls during this period.
df4['BattV_Min_1'] = df3['BattV_Min']
df4['BattV_Min_2'] = df4['BattV_Min']
plt.figure(figsize=(16,6))
plt.title('Fig.1: Minimum Battery Voltages at Patscherkofel stations (BattV_Min)')
plt.plot(df3['BattV_Min'], label='Patscherkofel 1')
plt.plot(df4['BattV_Min'], label='Patscherkofel 2')
plt.xlabel('Timeline')
plt.ylabel('Voltage [V]')
plt.grid()
plt.legend();
We decided to exclude those measurements, where negative radiation data was detected (e.g. on 2018-03-26 in the late afternoon).
# exclude negative radiation data:
df3['SWLower_Avg_1'] = np.where(df3.SWLower_Avg<=0, np.NaN, df3.SWLower_Avg)
df3['SWUpper_Avg_1'] = np.where(df3.SWUpper_Avg<=0, np.NaN, df3.SWUpper_Avg)
df4['SWLower_Avg_2'] = np.where(df4.SWLower_Avg<=0, np.NaN, df4.SWLower_Avg)
df4['SWUpper_Avg_2'] = np.where(df4.SWUpper_Avg<=0, np.NaN, df4.SWUpper_Avg)
df3['LWLower_Avg_1'] = np.where(df3.LWLower_Avg<=0, np.NaN, df3.LWLower_Avg)
df3['LWUpper_Avg_1'] = np.where(df3.LWUpper_Avg<=0, np.NaN, df3.LWUpper_Avg)
df4['LWLower_Avg_2'] = np.where(df4.LWLower_Avg<=0, np.NaN, df4.LWLower_Avg)
df4['LWUpper_Avg_2'] = np.where(df4.LWUpper_Avg<=0, np.NaN, df4.LWUpper_Avg)
# add Patscherkofel 1 radiation data into the Patscherkofel 2 dataframe,
# in order to compare them directly in the cufflinks-plot below
df4['SWLower_Avg_1']=df3['SWLower_Avg_1']
df4['SWUpper_Avg_1']=df3['SWUpper_Avg_1']
df4['LWLower_Avg_1']=df3['LWLower_Avg_1']
df4['LWUpper_Avg_1']=df3['LWUpper_Avg_1']
## problem: don't link values if np.NaN in between ...
import plotly.offline as py
import plotly.graph_objs as go
cf.go_offline() # required to use plotly offline (no account required).
py.init_notebook_mode() # graphs charts inline (IPython).
data1 = go.Scatter(
x = df4.index,
y = df4['SWUpper_Avg_1'],
name='SW incoming 1',
line = dict(color = 'orange'),
opacity = 1
)
data2 = go.Scatter(
x = df4.index,
y = df4['SWUpper_Avg_2'],
name='SW incoming 2',
line = dict(color = 'red'),
opacity = 0.6
)
data3 = go.Scatter(
x = df4.index,
y = df4['SWLower_Avg_1'],
name='SW outgoing 1',
line = dict(color = 'blue'),
opacity = 1
)
data4 = go.Scatter(
x = df4.index,
y = df4['SWLower_Avg_2'],
name='SW outgoing 2',
line = dict(color = 'green'),
opacity = 0.6
)
trace0 = go.Scatter(
x=[df4.index[28000]],
y=[1420],
text=['relocation: Patscherkofel 2 on ski slope'],
mode='text',
showlegend=False,
connectgaps = False,
)
data = [data1,data2,data3,data4,trace0]
layout = go.Layout(
title = 'Fig.2: Shortwave Radiation measurements at the Patscherkofel stations',
yaxis=dict(
title='W/m²'),
xaxis=dict(
title='Timeline'),
shapes=[dict({
'type': 'line',
'x0': '2018-04-06 13:00:00',
'y0': 0,
'x1': '2018-04-06 13:00:00',
'y1': 1390,
'line': {
'color': 'grey',
'width': 4
}})])
fig = go.Figure(data = data, layout=layout)
plot_url = py.iplot(fig)