Figure 2 – Online Resource#

Figure02 supp
import os
import sys
import numpy as np
from datetime import datetime
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
import matplotlib.transforms as mtransforms
sys.path.append('../../')
import python_codes.theme as theme

theme.load_style()

# paths
path_savefig = '../../Paper/Figures'
path_outputdata = '../../static/data/processed_data'
path_inputdata = '../../static/data/raw_data'

# figure parameters
station = 'South_Namib_Station'
tmin, tmax = datetime(2017, 6, 3), datetime(2017, 6, 10)
Data = np.load(os.path.join(path_outputdata, 'Data_final.npy'), allow_pickle=True).item()

# Loading and recomputing some raw data
path_insitu = os.path.join(path_inputdata, 'measured_wind_data/in_situ_wind_data_' + station + '.npy')
Data_insitu = np.load(path_insitu, allow_pickle=True).item()
#
t_insitu = Data_insitu['time']
U_insitu = Data_insitu['velocity']
# putting angles in trigo. ref.
Orientation_insitu = (270 - Data_insitu['direction']) % 360


# ### Figure
fig, axarr = plt.subplots(2, 1, figsize=(theme.fig_width, 0.85*theme.fig_width),
                          constrained_layout=True, sharex=True)

axarr[0].plot(t_insitu, Orientation_insitu, label='Raw data', color=theme.color_insitu)
axarr[0].plot(Data[station]['time'], Data[station]['Orientation_insitu'], label='Binned data',
              color=theme.color_insitu_sub)
#
axarr[1].plot(t_insitu, U_insitu, label='Raw data', color=theme.color_insitu)
axarr[1].plot(Data[station]['time'], Data[station]['U_insitu'], label='1hr-averaged data',
              color=theme.color_insitu_sub)
#
axarr[0].set_ylabel(r'Wind orientation, $\theta~[^{\circ}]$')
axarr[0].set_ylim(0, 360)
axarr[0].set_yticks([0, 90, 180, 270, 360])
axarr[1].set_ylabel(r'Wind velocity at 2.6 m, $[\textup{m}~\textup{s}^{-1}]$')
axarr[1].set_ylim(bottom=0)
axarr[1].set_xlim(tmin, tmax)
axarr[1].set_xlabel(r'Days in June 2017')
myFmt = mdates.DateFormatter('%d')
axarr[1].xaxis.set_major_formatter(myFmt)
plt.legend(loc='upper center')


trans = mtransforms.ScaledTranslation(4/72, -4/72, fig.dpi_scale_trans)
for label, ax in zip([r'\textbf{a}', r'\textbf{b}'], axarr.flatten()):
    ax.text(0.0, 1.0, label, transform=ax.transAxes + trans, va='top')


fig.align_labels()
plt.savefig(os.path.join(path_savefig, 'Figure2_supp.pdf'))
plt.show()

Total running time of the script: ( 0 minutes 1.418 seconds)

Gallery generated by Sphinx-Gallery