BCO Python Library
This library was created during my time at the Max Planck Institute for Meteorology. It is a python library with the purpose of making the measurements data of the institute more accessible to the scientists. The library is used to read, process and visualize the data. What makes it especially useful is the possibility to lazily download the data from the servers of the institute. This makes it possible to work with the data remotely without having to know the details of the data structure or the location of the data on the servers.
The following notebook shows how easy the process of loading and plotting the data is:
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>
Deleting temporary files:¶
In [6]:
rad.close()
Successfully deleted all temporary files