Sample Python code to analyze GEOS-Chem data¶
[1]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
import cartopy.crs as ccrs
np.seterr(invalid='ignore'); # disable a warning from matplotlib + cartopy
GEOS-Chem NetCDF diagnostics¶
[2]:
ls /home/ubuntu/tutorial/geosfp_4x5_standard/OutputDir/
GEOSChem.SpeciesConc.20160701_0000z.nc4
[3]:
ds = xr.open_dataset("/home/ubuntu/tutorial/geosfp_4x5_standard/OutputDir/"
"GEOSChem.SpeciesConc.20160701_0000z.nc4")
ds
[3]:
<xarray.Dataset>
Dimensions: (ilev: 73, lat: 46, lev: 72, lon: 72, time: 1)
Coordinates:
* time (time) datetime64[ns] 2016-07-01T00:10:00
* lev (lev) float64 0.9925 0.9775 0.9625 0.9475 0.9325 0.9175 ...
* ilev (ilev) float64 1.0 0.985 0.97 0.955 0.94 0.925 0.91 ...
* lat (lat) float64 -89.0 -86.0 -82.0 -78.0 -74.0 -70.0 -66.0 ...
* lon (lon) float64 -180.0 -175.0 -170.0 -165.0 -160.0 -155.0 ...
Data variables:
hyam (lev) float64 ...
hybm (lev) float64 ...
hyai (ilev) float64 ...
hybi (ilev) float64 ...
P0 float64 ...
AREA (lat, lon) float32 ...
SpeciesConc_CO (time, lev, lat, lon) float32 ...
SpeciesConc_O3 (time, lev, lat, lon) float32 ...
SpeciesConc_NO (time, lev, lat, lon) float32 ...
Attributes:
title: GEOS-Chem diagnostic collection: Species...
history:
format: CFIO
conventions: COARDS
ProdDateTime:
reference: www.geos-chem.org; wiki.geos-chem.org
contact: GEOS-Chem Support Team (geos-chem-suppor...
simulation_start_date_and_time: 2016-07-01 00:00:00z
simulation_end_date_and_time: 2016-07-01 00:20:00z
[4]:
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
ds['SpeciesConc_O3'][0,0].plot(cmap='jet', ax=ax)
plt.title('surface ozone');
GEOS-FP metfield¶
[5]:
ds_met = xr.open_dataset("~/ExtData/GEOS_4x5/GEOS_FP/2016/07/GEOSFP.20160701.I3.4x5.nc")
ds_met
[5]:
<xarray.Dataset>
Dimensions: (lat: 46, lev: 72, lon: 72, time: 8)
Coordinates:
* time (time) datetime64[ns] 2016-07-01 2016-07-01T03:00:00 ...
* lev (lev) float32 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0 10.0 11.0 ...
* lat (lat) float32 -90.0 -86.0 -82.0 -78.0 -74.0 -70.0 -66.0 -62.0 ...
* lon (lon) float32 -180.0 -175.0 -170.0 -165.0 -160.0 -155.0 -150.0 ...
Data variables:
PS (time, lat, lon) float32 ...
PV (time, lev, lat, lon) float32 ...
QV (time, lev, lat, lon) float32 ...
T (time, lev, lat, lon) float32 ...
Attributes:
Title: GEOS-FP instantaneous 3-hour parameters (I3), proc...
Contact: GEOS-Chem Support Team (geos-chem-support@as.harva...
References: www.geos-chem.org; wiki.geos-chem.org
Filename: GEOSFP.20160701.I3.4x5.nc
History: File generated on: 2016/08/04 09:56:57 GMT-0300
ProductionDateTime: File generated on: 2016/08/04 09:56:57 GMT-0300
ModificationDateTime: File generated on: 2016/08/04 09:56:57 GMT-0300
Format: NetCDF-4
SpatialCoverage: global
Conventions: COARDS
Version: GEOS-FP
Model: GEOS-5
Nlayers: 72
Start_Date: 20160701
Start_Time: 00:00:00.0
End_Date: 20160701
End_Time: 23:59:59.99999
Delta_Time: 030000
Delta_Lon: 5
Delta_Lat: 4
[6]:
ax = plt.axes(projection=ccrs.PlateCarree())
ds_met['T'][0,0].plot(cmap='jet', ax=ax)
ax.coastlines()
plt.title('surface temperature');