Example of using the Radiation class, retrieving the data via ftp server

In [1]:
import BCO
from BCO.Instruments import Radiation
import matplotlib.pyplot as plt
from matplotlib.dates import HourLocator, DateFormatter, DayLocator

Set up ftp-usage:

In [2]:
BCO.settings.set_ftp(True)
BCO.settings.path_to_ftp_file("/home/tobias/Documents/ftp_access.txt")
Successfully loaded username and password

Initiate a new instance with data from the 1st January 2018 to the 3rd January 2018:

In [3]:
rad = Radiation("20180101","20180103")
Downloading Radiation__Deebles_Point__DownwellingRadiation__1s__20180101.nc.bz2
Downloading Radiation__Deebles_Point__DownwellingRadiation__1s__20180102.nc.bz2
Downloading Radiation__Deebles_Point__DownwellingRadiation__1s__20180103.nc.bz2

Load some variables:

In [4]:
lw = rad.getRadiation("LW")
sw = rad.getRadiation("SW","direct")
time = rad.getTime()
Scattering needs to be one of: direct ,diffuse ,global
Longwaveradiation at the surface is only measured as diffuse radiation. Setting scattering to diffuse!

Plotting the just loaded data:

In [5]:
fig,ax = plt.subplots(figsize=(12,4))

hours = HourLocator(byhour=[0,6,12,18])
days = DayLocator()

h_fmt = DateFormatter("%H:00")
d_fmt = DateFormatter("\n%x")

ax.plot(time,lw,label="lw")
ax.plot(time,sw,label="sw")

ax.xaxis.set_minor_locator(hours)
ax.xaxis.set_minor_formatter(h_fmt)
ax.xaxis.set_major_locator(days)
ax.xaxis.set_major_formatter(d_fmt)

ax.set_xlabel("Time [UTC]")
ax.set_ylabel("Irradiance [Wm$^{-2}}$]")

ax.legend()

Out[5]:
<matplotlib.legend.Legend at 0x7f76b2b81a20>
../_images/examples_FTP-example_9_1.png

Deleting temporary files:

In [6]:
rad.close()
Successfully deleted all temporary files