<jupyter_start><jupyter_text>Plot Temperature and Heat FluxesPlot the temperature and heat flux data file from the parametricscheme.py script.These 5 plots are produced:  * Temperature and Heat Fluxes - Separate Plots  * Heat Fluxes - Combined Plot  * Surface Temperature  * Radiative Fluxes  * Surface Fluxes  Load and Check DataYou may need to edit the fn (filename), location (latitude & longitude) and year variables.<jupyter_code>ls ../data
fn = "../data/data.csv"
location = 'Lat ' + str(47.6928) + ' Long ' + str(-122.3038)
year = 2011

df = pd.read_csv(fn, sep="\t")

print("Shape:")
print(df.shape)
print("\nInfo:")
print(df.info())
print("\nSummary stats:")
display(df.describe())
print("\nData:")
df<jupyter_output>Shape:
(25, 11)

Info:
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 25 entries, 0 to 24
Data columns (total 11 columns):
 #   Column  Non-Null Count  Dtype  
---  ------  --------------  -----  
 0   Day     25 non-null     int64  
 1   Hour    25 non-null     int64  
 2   Minute  25 non-null     int64  
 3   Q_S     25 non-null     float64
 4   Q_Ld    25 non-null     float64
 5   Q_Lu    25 non-null     float64
 6   Q_H     25 non-null     float64
 7   Q_E     25 non-null     float64
 8   Q_G     25 non-null     float64
 9   d_T_s   25 non-null     float64
 10  T_s     25 non-null     float64
dtypes: float64(8), int64(3)
memory usage: 2.3 KB
None

Summary stats:<jupyter_text>--- Temperature and Heat Fluxes - Separate Plots<jupyter_code>date_fmt = '{}-%m-%d'.format(year)
df['datetime'] = pd.to_datetime(pd.to_datetime(df['Day'], format='%j').dt.strftime(date_fmt)) + \
  pd.to_timedelta(df.Hour, unit='h') + \
  pd.to_timedelta(df.Minute, unit='m')

df_subset = df.drop(['Day', 'Hour', 'Minute', 'd_T_s'], axis=1)
df_subset.plot.line(x='datetime', subplots=True)
plt.xlabel('Date time');<jupyter_output><empty_output><jupyter_text>--- Heat Fluxes - Combined Plot<jupyter_code>doy = ' Day ' + str(df.loc[0, 'Day'])
plot_title = location + doy

df_flux = df_subset.drop('T_s', axis=1)
df_flux.plot.line(x='datetime')
plt.legend(loc='center left', bbox_to_anchor=(1, 0.5))
plt.ylabel('Radiative & surface flux')
plt.title(plot_title)
plt.xlabel('Date time');<jupyter_output><empty_output><jupyter_text>--- Surface Temperature<jupyter_code>df.plot(x='datetime', y='T_s', color='pink')
plt.title(plot_title)
plt.ylabel('Surface Temperature ($^\circ$F)')
plt.xlabel('Date time');<jupyter_output><empty_output><jupyter_text>--- Radiative Fluxes<jupyter_code>df_rad_flux = df_subset.drop(['Q_H','Q_E','Q_G','T_s'], axis=1)
df_rad_flux['N_R'] = df_rad_flux['Q_S'] + df_rad_flux['Q_Ld'] - df_rad_flux['Q_Lu']
df_rad_flux.plot.line(x='datetime', color=['blue','orange','green','black'])
plt.legend(['Q_S - Solar', 'Q_Ld - Downwelling', 'Q_Lu - Upwelling', 'N_R - Net radiation'], 
           loc='center left', bbox_to_anchor=(1, 0.5))
plt.ylabel('Radiative flux')
plt.xlabel('Date time')
plt.title(plot_title);<jupyter_output><empty_output><jupyter_text>--- Surface Fluxes<jupyter_code>df_surf_flux = df_subset.drop(['Q_S','Q_Lu','Q_Ld','T_s'], axis=1)
df_surf_flux['N_S'] = df_surf_flux['Q_H'] + df_surf_flux['Q_E'] + df_surf_flux['Q_G']
df_surf_flux.plot.line(x='datetime', color=['red','purple','brown','black'], )
plt.legend(['Q_H - Sensible','Q_E - Latent','Q_G - Ground','N_S - Net surface flux'], 
           loc='center left', bbox_to_anchor=(1, 0.5))
plt.ylabel('Surface flux')
plt.xlabel('Date time')
plt.title(plot_title);<jupyter_output><empty_output><jupyter_text>--- ArchivalArchive code, markdown, history and formatted notebooks.Assumes all pdf, html, latex etc dependencies are installed.**WARNING** Will overwrite existing files.<jupyter_code>notebook = "plot_temperature_and_fluxes.ipynb"
# !jupyter nbconvert --to script {notebook}
# !jupyter nbconvert --execute --to html {notebook}
# !jupyter nbconvert --execute --to pdf {notebook}
# !jupyter nbconvert --to pdf {notebook}

%rm history.txt
%history -f history.txt

!jupyter nbconvert --to python {notebook}
sleep(5)
!jupyter nbconvert --to markdown {notebook}
sleep(5)
!jupyter nbconvert --to html {notebook}<jupyter_output>[NbConvertApp] Converting notebook plot_temperature_and_fluxes.ipynb to python
[NbConvertApp] Writing 3633 bytes to plot_temperature_and_fluxes.py
[NbConvertApp] Converting notebook plot_temperature_and_fluxes.ipynb to markdown
[NbConvertApp] Support files will be in plot_temperature_and_fluxes_files/
[NbConvertApp] Making directory plot_temperature_and_fluxes_files
[NbConvertApp] Making directory plot_temperature_and_fluxes_files
[NbConvertApp] Making directory plot_temperature_and_fluxes_files
[NbConvertApp] Writing 15500 bytes to plot_temperature_and_fluxes.md
[NbConvertApp] Converting notebook plot_temperature_and_fluxes.ipynb to html
[NbConvertApp] Writing 687242 bytes to plot_temperature_and_fluxes.html
{'fraction_non_alphanumeric': 0.14707095709570958, 'fraction_numerical': 0.02557755775577558, 'mean_word_length': 5.06125, 'pattern_counts': {'":': 0, '<': 28, '<?xml version=': 0, '>': 28, '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': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '614525', 'license': 'MIT', 'n_tokens_mistral': 1967, 'n_tokens_neox': 1788, 'n_words': 390, 'path': 'notebooks/plot_temperature_and_fluxes.ipynb', 'repo_name': 'shie-ld/surface-temperature-forecasting', 'size': '4848'}