Maria Chara Karypidou
Maria Chara Karypidou

Reputation: 63

How to calculate moisture flux divergence in python

I want to calculate moisture flux divergence (MFD) over southern Africa. I use u and v wind components at 850 hPa and specific humidity at 850 hPa, for a specific day. I have followed the steps described here: Calculating wind divergence of u and v using Python, np.gradient and here: https://earthscience.stackexchange.com/questions/8418/how-to-calculate-water-vapor-flux-divergence-from-temperature-relative-humidity

The code I am using is the following:

from matplotlib.cm import get_cmap
from __future__ import print_function
from netCDF4 import Dataset,num2date,date2num
from matplotlib.colors import from_levels_and_colors
from cartopy import crs
from cartopy.feature import NaturalEarthFeature, COLORS
#
import metpy.calc as mpcalc
import xarray as xr
import cartopy.crs as ccrs
import matplotlib
import cartopy.feature as cfe
import numpy as np
import matplotlib.pyplot as plt
import datetime
#
#############################################################################################################
####################################### Calculate Moisture Divergence ####################################### 
#############################################################################################################
#
root_dir = '/users/pr007/mkaryp/'
nc = Dataset(root_dir+'merge_SAF.nc')
#
v = np.array(nc.variables['va850'][0,:,:])                    
u = np.array(nc.variables['ua850'][0,:,:])
q = np.array(nc.variables['hus850'][0,:,:])        
#
lon=nc.variables['lon'][:]
lat=nc.variables['lat'][:]
#
qu = q*u
qv = q*v  
#
# Compute dx and dy spacing for use in divergence calculation
dx, dy = mpcalc.lat_lon_grid_deltas(lon, lat)
# Calculate horizontal moisture flux divergence using https://unidata.github.io/MetPy/latest/api/generated/metpy.calc.divergence.html
HMC = (np.array(mpcalc.divergence(qu, qv, dx=dx, dy=dy)))
#

The output is shown below:Moisture Flux Divergence for a specific day

Div = (np.array(mpcalc.divergence(u, v, dx=dx, dy=dy)))

However, when I use u and v (instead of qu and qv) in the divergence function (mpcalc.divergence), the output is spatially identical (shown here:Wind divergence for the same day (as in previous plot)). '''

I am wondering whether there is a more meaningful way to calculate moisture flux divergence in python.

Thank you!

Upvotes: 3

Views: 2343

Answers (1)

Serge Ballesta
Serge Ballesta

Reputation: 148975

Long time I have not played with divergence, wind and specific humidity... But mathematics and atmospheric physics should not have changed so much. On a strict mathematical point of view, we have the following relation for the moisture flux divergence:

div(quv) = q div(uv) + grad(q).uv

(in English because I cannot write nice formulas here: the moisture flux divergence is the wind divergence multiplied by the moisture value plus the scalar product of the wind vector by the gradient of the moisture field)

And if my meteorological memories are not too bad, I would assume that in most situations at 850 hPa, the variation of moisture is less important than the variation of the wind, and the first term should be greater than the second. Furthermore, we have few measure points at 850 hPa and above so the fields are smoothed. So AFAIK, it is not a surprise that the wind divergence and the moisture flux divergence look spatially close.

Upvotes: 1

Related Questions