<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hi all,<div class=""><br class=""></div><div class="">I am having a problem with the wrf_cape_3d code. When I run it, I get the following error: </div><div class=""><br class=""></div><div class=""><font face="Courier" class="">"If p,q,t,z are 3-dimensional (time x lev x lat x lon), psfc,zsfc must be 2-dimensional (lat x lon)"</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class="">However, my p,q,t,and z variables are all 3-D and my psfc, and zsfc, are 2-D (as required). </div><div class=""><br class=""></div><div class="">I am running NCL Version 6.2.1</div><div class=""><br class=""></div><div class="">Below is a copy of my code:</div><div class=""><br class=""></div><div class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</font><br class=""><font face="Courier" class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</font><br class=""><font face="Courier" class="">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">begin</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">; Read netCDF files and extract variables</font><br class=""><br class=""><font face="Courier" class=""> h48_t_file = addfile("/Users/andrea/Documents/gigaLES/data/TWPICE_gigaLES_3D_TABS_0000086400.nc","r")</font><br class=""><font face="Courier" class=""> h48_q_file = addfile("/Users/andrea/Documents/gigaLES/data/TWPICE_gigaLES_3D_QV_0000086400.nc","r")</font><br class=""><br class=""><font face="Courier" class=""> h48_t = rm_single_dims(h48_t_file->TABS) ; Read in variables and remove</font><br class=""><font face="Courier" class=""> h48_q = rm_single_dims(h48_q_file->QV) ; singleton time dimension</font><br class=""><br class=""><font face="Courier" class=""> p = h48_t_file->pres</font><br class=""><font face="Courier" class=""> x = h48_t_file->x</font><br class=""><font face="Courier" class=""> y = h48_t_file->y</font><br class=""><font face="Courier" class=""> z = h48_t_file->z</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">; Moisture is in specific humidity. Need to convert to mixing ratio</font><br class=""><font face="Courier" class="">; r = q / (1 - q)</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class=""> h48_r = h48_q ; Copy metadata</font><br class=""><br class=""><font face="Courier" class=""> h48_q_mask = h48_q<span class="Apple-tab-span" style="white-space:pre">                </span>; Copy metadata</font><br class=""><font face="Courier" class=""> </font><font face="Courier" class="">h48_q_mask@_FillValue = 0.0 ; Set FillValue to 0 to minimize computational problems with CAPE function</font></div><div class=""><font face="Courier" class=""> h48_q_mask = mask(h48_q,h48_q.eq.1,False) ; Mask values of 1 to avoid dividing by zero</font><br class=""><br class=""><font face="Courier" class=""> h48_r = (/ h48_q / (1 - h48_q_mask) /) ; Do math on values only</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">; NCL CAPE function requires two additional values, which we define here</font><br class=""><font face="Courier" class="">; 1. Surface height</font><br class=""><font face="Courier" class=""> zsf = 0.0</font><br class=""><font face="Courier" class="">; 2. Surface pressures</font><br class=""><font face="Courier" class=""> psf = 1013.25</font><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">; Scalar values need to be conformed to a grid in order to be used by the function</font><br class=""><font face="Courier" class="">; First, the surface height and pressure become 2D</font><br class=""><br class=""><font face="Courier" class=""> ny = dimsizes(h48_t(:,0,0)) ; Find size of each dimension</font><br class=""><font face="Courier" class=""> nx = dimsizes(h48_t(0,:,0))</font><br class=""><font face="Courier" class=""> nz = dimsizes(h48_t(0,0,:))</font><br class=""><br class=""><font face="Courier" class=""> zsf_grid1 = conform_dims( (/ny,nx,1/) , zsf , 2 )</font><br class=""><font face="Courier" class=""> psf_grid1 = conform_dims( (/ny,nx,1/) , psf , 2 )</font><br class=""><br class=""><font face="Courier" class="">; Remove the singleton dimension</font><br class=""><br class=""><font face="Courier" class=""> zsf_grid = rm_single_dims(zsf_grid1)</font><br class=""><font face="Courier" class=""> psf_grid = rm_single_dims(psf_grid1)</font><br class=""><br class=""><font face="Courier" class="">; Second, the pressure and height become 3D</font><br class=""><br class=""><font face="Courier" class=""> p_3d = conform_dims( (/ny,nx,nz/) , p , 2 )</font><br class=""><font face="Courier" class=""> z_3d = conform_dims( (/ny,nx,nz/) , z , 2 )</font><br class=""><br class=""><br class=""><font face="Courier" class="">;-------------------------------------------------------------------------------</font><br class=""><font face="Courier" class="">; Calculate CAPE and CIN using NCL's wrf_cape_3d function</font><br class=""><br class=""><font face="Courier" class=""> cape_cin48 = wrf_cape_3d(p_3d,h48_t,h48_r,z_3d,zsf_grid,psf_grid,False)</font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class=""><font face="Courier" class=""><br class=""></font></div><div class="">This is where I run into errors. Doing a printVarSummary on all of the variables used in the wf_cape_3d function gives:</div><div class=""><br class=""></div><div class=""><font face="Menlo" style="font-size: 11px;" class="">Variable: zsf_grid<br class="">Type: float<br class="">Total Size: 16777216 bytes<br class=""> 4194304 values<br class="">Number of Dimensions: 2<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[2048] x [2048]<br class="">Coordinates: <br class=""><br class="">Variable: psf_grid<br class="">Type: float<br class="">Total Size: 16777216 bytes<br class=""> 4194304 values<br class="">Number of Dimensions: 2<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[2048] x [2048]<br class="">Coordinates: <br class=""><br class="">Variable: p_3d<br class="">Type: double<br class="">Total Size: 8556380160 bytes<br class=""> 1069547520 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[2048] x [2048] x [255]<br class="">Coordinates: <br class=""><br class="">Variable: z_3d<br class="">Type: double<br class="">Total Size: 8556380160 bytes<br class=""> 1069547520 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[2048] x [2048] x [255]<br class="">Coordinates: <br class=""><br class="">Variable: h48_t<br class="">Type: float<br class="">Total Size: 4278190080 bytes<br class=""> 1069547520 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[y | 2048] x [x | 2048] x [z | 255]<br class="">Coordinates: <br class=""> y: [ 50..204750]<br class=""> x: [ 50..204750]<br class=""> z: [ 25..26685.83203]<br class="">Number Of Attributes: 1<br class=""> time :<span class="Apple-tab-span" style="white-space: pre;">        </span> 20<br class=""><br class="">Variable: h48_r<br class="">Type: float<br class="">Total Size: 4278190080 bytes<br class=""> 1069547520 values<br class="">Number of Dimensions: 3<br class="">Dimensions and sizes:<span class="Apple-tab-span" style="white-space: pre;">        </span>[y | 2048] x [x | 2048] x [z | 255]<br class="">Coordinates: <br class=""> y: [ 50..204750]<br class=""> x: [ 50..204750]<br class=""> z: [ 25..26685.83203]<br class="">Number Of Attributes: 2<br class=""> _FillValue :<span class="Apple-tab-span" style="white-space: pre;">        </span> 0<br class=""> time :<span class="Apple-tab-span" style="white-space: pre;">        </span> 20</font><br class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class="">Thank you!</div><div class=""><br class=""></div><div class="">Andrea</div></body></html>