Workflow 5: Searching and plotting#
In this short tutorial we’ll show how to retrieve some data and create a simple plot using one of our plotting functions.
As in the previous tutorial, we will start by setting up our temporary object store for our data. If you’ve already create your own local object store you can skip the next few steps and move onto the Searching section.
from openghg.tutorial import populate_surface_data
Let’s search for all the methane data from Tacolneston
from openghg.retrieve import search_surface ch4_results = search_surface(site="tac", species="ch4") ch4_results
Let’s take a look at the results property which is a pandas DataFrame object.
If we want to take a look at the data from the 185m inlet we can first retrieve the data from the object store and then create a quick timeseries plot. See the
SearchResults object documentation for more information.
data_185m = ch4_results.retrieve(inlet="185m")
NOTE: the plots created below may not show up on the online documentation version of this notebook.
You can make some simple changes to the plot using arguments
data_185m.plot_timeseries(title="Methane at Tacolneston", xlabel="Time", ylabel="Conc.", units="ppm")
Plot all the data#
We can also retrieve all the data, get a
all_ch4_tac = ch4_results.retrieve_all()
Then we can use the
plot_timeseries function from the
plotting submodule to compare measurements from different inlets. This creates a Plotly plot that should be interactive and and responsive, even with relatively large amounts of data.
from openghg.plotting import plot_timeseries plot_timeseries(data=all_ch4_tac, units="ppb")
Compare different sites#
We can easily compare data from different sites by doing a quick search to see what’s available
ch4_data = search_surface(species="ch4")
Then we refine our search to only retrieve the inlets we want
lower_inlets = search_surface(species="ch4", inlet=["42m", "54m"])
Then we can retrieve all the data and make a plot.
lower_inlet_data = lower_inlets.retrieve_all()
plot_timeseries(data=lower_inlet_data, title="Comparing CH4 measurements at Tacolneston and Bilsdale")
You can also search for different data types, say we want to find surface measurement data and emissions data at the same time. We can do that with the more generic
We need to first load in some emissions data
from openghg.tutorial import populate_flux_data
To search across different types we can use the more generic
from openghg.retrieve import search
results = search(species="ch4", data_type=["surface", "emissions"])