Scheduled Downtime
On Friday 21 April 2023 @ 5pm MT, this website will be down for maintenance and expected to return online the morning of 24 April 2023 at the latest

Problems to postprocess SMOIS


New member
Hello, I want to postprocess SMOIS using wrf.getvar and it gives me the following error:

Traceback (most recent call last):
File "/datos/blazquez/wrf-getvar/./", line 671, in <module>
lanzar_corrida(ncfiles, f_ini_mes, f_fin_mes, interv_seconds, project, directorio_salida, vars_list)
File "/datos/blazquez/wrf-getvar/./", line 445, in lanzar_corrida
var_da_interp = interpolate(variable_da, pres, interp_lvls)
File "/datos/blazquez/wrf-getvar/./", line 188, in interpolate
variable_interp = wrf.interplevel(var_da, pressure, interp_levels)
File "/usr/local/lib/python3.9/dist-packages/wrf/", line 1730, in func_wrapper
return _set_horiz_meta(wrapped, instance, args, kwargs)
File "/usr/local/lib/python3.9/dist-packages/wrf/", line 801, in _set_horiz_meta
result = wrapped(*args, **kwargs)
File "/usr/local/lib/python3.9/dist-packages/wrf/", line 109, in interplevel
result = _interpz3d(field3d, vert, _desiredlev, missing)
File "/usr/local/lib/python3.9/dist-packages/wrf/", line 678, in func_wrapper
raise ValueError("argument 0 and 1 must have same rightmost "
ValueError: argument 0 and 1 must have same rightmost dimensions

Any idea of what is happening?

Ming Chen

Staff member
I guess you are using some python script from NCAR unidata to process the data. Note that the interpolate function is applied for interpolation from model level to pressure level. Personally I don't think it can be used to process soil data.
Please contact unidata for further assistance.


New member
Dear Ming Chen,

thank you for your answer . It seems that the script do not process 3D soil data. I will contact NCAR unidata.


New member
Hi, I have found this script to process SMOIS. Does anyone knows what is the meaning of "soil_weights"?

import numpy as np
import wrf

# Specify the path to the wrfout file
wrfout_file = 'path/to/' # Replace with your wrfout file path

# Open the wrfout file
wrfout = wrf.Dataset(wrfout_file)

# Extract the soil moisture variable
smois = wrfout.variables['SMOIS']

# Get the dimensions of the soil moisture variable
time_dim, soil_layer_dim, south_north_dim, west_east_dim = smois.shape

# Define the soil moisture weights for each soil layer
soil_weights = np.array([0.04, 0.1, 0.2, 0.4, 0.6, 0.8, 1.0]) # Replace with your specific soil moisture weights

# Calculate the total soil humidity
total_soil_humidity = np.zeros((time_dim, south_north_dim, west_east_dim))

for i in range(time_dim):
for j in range(south_north_dim):
for k in range(west_east_dim):
smois_profile = wrf.to_np(smois[i, :, j, k]) # Get the soil moisture profile for each grid point
total_soil_humidity[i, j, k] = np.sum(smois_profile * soil_weights)

# Print the total soil humidity values

# Close the wrfout file

Ming Chen

Staff member
Just take a quick look at the script. It seems that soil_weights are the depth of individual soil layers used in WRF.