gcpy.examples.timeseries.plot_timeseries
Example of plotting timeseries data from GEOS-Chem and saving the output to a PDF file. You can modify this for your particular diagnostic output. This also contains a good overview of
This example script creates a PDF file with 2 pages.
Page 1:
O3 from the first model layer (from the “SpeciesConc” diagnostic collection is) plotted in blue.
O3 at 10 meter height (from the “SpeciesConc_10m” diagnostic collection) is plotted in red.
Page 2:
HNO3 from the first model layer (from the SpeciesConc diagnostic collection is) plotted in blue.
HNO3 at 10 meter height (from the SpeciesConc_10m diagnostic collection) is plotted in red.
You can of course modify this for your own particular applications.
Examples
Copy this file to a different folder and navigate to that folder.
Edit file paths, collection names, and coordinates in the main() routine.
Run the following commands.
$ conda activate gcpy_env (gcpy_env) $ ./plot_timeseries.py
References
Author: Bob Yantosca (GitHub: @yantosca), 23 Aug 2019
Functions
|
Returns a list of all files in a directory that match one or more substrings. |
|
Finds the index of a numpy array that is close to a value. |
|
Main program. |
|
Plots a timseries of data at a given (lat,lon) location. |
|
Returns an xarray Dataset containing timeseries data. |
- gcpy.examples.timeseries.plot_timeseries.find_files_in_dir(path, substrs)[source]
Returns a list of all files in a directory that match one or more substrings.
- gcpy.examples.timeseries.plot_timeseries.find_value_index(seq, val)[source]
Finds the index of a numpy array that is close to a value.
- Parameters:
seq (
numpy ndarray) – An array of numeric values.val (
number) – The value to search for in seq.
- Returns:
result – The index of seq that has a value closest to val.
- Return type:
integer
Notes
This algorithm was found on this page: https://stackoverflow.com/questions/48900977/find-all-indexes-of-a-numpy-array-closest-to-a-value
- gcpy.examples.timeseries.plot_timeseries.read_geoschem_data(path, collections)[source]
Returns an xarray Dataset containing timeseries data.
- Parameters:
- Returns:
ds – A Dataset object containing the GEOS-Chem diagnostic output corresponding to the collections that were specified.
- Return type:
xarray Dataset
- gcpy.examples.timeseries.plot_timeseries.plot_timeseries_data(ds, site_coords)[source]
Plots a timseries of data at a given (lat,lon) location.
- Parameters:
ds (
xarray Dataset) – Dataset containing GEOS-Chem timeseries data.site_coords (
tuple) – Contains the coordinate (lat, lon) of a site location at which the timeseries data will be plotted.