Reputation: 11
I used the fire_emis tool to prepare FINN emissions for a WRF-Chem simimulation. I got multiple wrffirechemi files (i.e. 'wrffirechemi_d01_2020-03-15_10:00:00') and I am trying to plot the pm2.5 variable. However, I am having trouble doing so. Has anyone mapped wrffirechemi files, either in python or ncl?
Thank you, Nafi
Upvotes: 1
Views: 55
Reputation: 106
Not an expert in it but you can try doing this through xarray
, matplotlib
, and cartopy
. You need to first install these:
pip install xarray matplotlib cartopy
Now you can use xarray
to open the wrffirechemi
file. xarray
can handle NetCDF files which are commonly used for atmospheric and oceanographic data.
import xarray as xr
# Path to file
file_path = 'path_to_your_file/wrffirechemi_d01_2020-03-15_10:00:00'
data = xr.open_dataset(file_path)
Once file will be loaded, you can check the variables available in the dataset. If you're not sure of the exact name of the PM2.5 variable, you can print all variables names:
print(data.variables.keys())
This will help you identify the variable corresponding to PM2.5 emissions. I'm assuming that the variable is named PM2_5
.
For a basic plot, you can use xarray
's plotting capabilities. For more advanced geographic plots, you may use cartopy
.
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
# Simple plot with xarray (no geographic details)
data['PM2_5'].isel(time=0).plot() # 'isel' is used to select by integer index. Adjust as necessary.
plt.show()
# More detailed geographic plot with Cartopy
fig = plt.figure(figsize=(10, 5))
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines()
data['PM2_5'].isel(time=0).plot(ax=ax, transform=ccrs.PlateCarree(), x='lon', y='lat', cmap='viridis')
plt.show()
Untested but Hope it will help. Thanks
Upvotes: 1