<div dir="ltr"><div class="gmail_default" style="font-size:small">I don't know if this got addressed, but it's a WRF question, so I'm forwarding to the wrfhelp folks.</div><div class="gmail_default" style="font-size:small"><br></div><div class="gmail_default" style="font-size:small">--Mary</div><div class="gmail_default" style="font-size:small"><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 28, 2015 at 2:44 PM, Andrea Jenney <span dir="ltr"><<a href="mailto:andrea@atmos.colostate.edu" target="_blank">andrea@atmos.colostate.edu</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi all,<div><br></div><div>I am having a problem with the wrf_cape_3d code. When I run it, I get the following error: </div><div><br></div><div><font face="Courier">"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><font face="Courier"><br></font></div><div>However, my p,q,t,and z variables are all 3-D and my psfc, and zsfc, are 2-D (as required). </div><div><br></div><div>I am running NCL Version 6.2.1</div><div><br></div><div>Below is a copy of my code:</div><div><br></div><div><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl"</font><br><font face="Courier">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl"</font><br><font face="Courier">load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl"</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">begin</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">; Read netCDF files and extract variables</font><br><br><font face="Courier"> h48_t_file = addfile("/Users/andrea/Documents/gigaLES/data/TWPICE_gigaLES_3D_TABS_0000086400.nc","r")</font><br><font face="Courier"> h48_q_file = addfile("/Users/andrea/Documents/gigaLES/data/TWPICE_gigaLES_3D_QV_0000086400.nc","r")</font><br><br><font face="Courier"> h48_t = rm_single_dims(h48_t_file->TABS) ; Read in variables and remove</font><br><font face="Courier"> h48_q = rm_single_dims(h48_q_file->QV) ; singleton time dimension</font><br><br><font face="Courier"> p = h48_t_file->pres</font><br><font face="Courier"> x = h48_t_file->x</font><br><font face="Courier"> y = h48_t_file->y</font><br><font face="Courier"> z = h48_t_file->z</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">; Moisture is in specific humidity. Need to convert to mixing ratio</font><br><font face="Courier">; r = q / (1 - q)</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier"> h48_r = h48_q ; Copy metadata</font><br><br><font face="Courier"> h48_q_mask = h48_q<span style="white-space:pre-wrap">                </span>; Copy metadata</font><br><font face="Courier"> </font><font face="Courier">h48_q_mask@_FillValue = 0.0 ; Set FillValue to 0 to minimize computational problems with CAPE function</font></div><div><font face="Courier"> h48_q_mask = mask(h48_q,h48_q.eq.1,False) ; Mask values of 1 to avoid dividing by zero</font><br><br><font face="Courier"> h48_r = (/ h48_q / (1 - h48_q_mask) /) ; Do math on values only</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">; NCL CAPE function requires two additional values, which we define here</font><br><font face="Courier">; 1. Surface height</font><br><font face="Courier"> zsf = 0.0</font><br><font face="Courier">; 2. Surface pressures</font><br><font face="Courier"> psf = 1013.25</font><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">; Scalar values need to be conformed to a grid in order to be used by the function</font><br><font face="Courier">; First, the surface height and pressure become 2D</font><br><br><font face="Courier"> ny = dimsizes(h48_t(:,0,0)) ; Find size of each dimension</font><br><font face="Courier"> nx = dimsizes(h48_t(0,:,0))</font><br><font face="Courier"> nz = dimsizes(h48_t(0,0,:))</font><br><br><font face="Courier"> zsf_grid1 = conform_dims( (/ny,nx,1/) , zsf , 2 )</font><br><font face="Courier"> psf_grid1 = conform_dims( (/ny,nx,1/) , psf , 2 )</font><br><br><font face="Courier">; Remove the singleton dimension</font><br><br><font face="Courier"> zsf_grid = rm_single_dims(zsf_grid1)</font><br><font face="Courier"> psf_grid = rm_single_dims(psf_grid1)</font><br><br><font face="Courier">; Second, the pressure and height become 3D</font><br><br><font face="Courier"> p_3d = conform_dims( (/ny,nx,nz/) , p , 2 )</font><br><font face="Courier"> z_3d = conform_dims( (/ny,nx,nz/) , z , 2 )</font><br><br><br><font face="Courier">;-------------------------------------------------------------------------------</font><br><font face="Courier">; Calculate CAPE and CIN using NCL's wrf_cape_3d function</font><br><br><font face="Courier"> cape_cin48 = wrf_cape_3d(p_3d,h48_t,h48_r,z_3d,zsf_grid,psf_grid,False)</font></div><div><font face="Courier"><br></font></div><div><font face="Courier"><br></font></div><div>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><br></div><div><font face="Menlo" style="font-size:11px">Variable: zsf_grid<br>Type: float<br>Total Size: 16777216 bytes<br> 4194304 values<br>Number of Dimensions: 2<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[2048] x [2048]<br>Coordinates: <br><br>Variable: psf_grid<br>Type: float<br>Total Size: 16777216 bytes<br> 4194304 values<br>Number of Dimensions: 2<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[2048] x [2048]<br>Coordinates: <br><br>Variable: p_3d<br>Type: double<br>Total Size: <a href="tel:8556380160" value="+18556380160" target="_blank">8556380160</a> bytes<br> 1069547520 values<br>Number of Dimensions: 3<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[2048] x [2048] x [255]<br>Coordinates: <br><br>Variable: z_3d<br>Type: double<br>Total Size: <a href="tel:8556380160" value="+18556380160" target="_blank">8556380160</a> bytes<br> 1069547520 values<br>Number of Dimensions: 3<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[2048] x [2048] x [255]<br>Coordinates: <br><br>Variable: h48_t<br>Type: float<br>Total Size: 4278190080 bytes<br> 1069547520 values<br>Number of Dimensions: 3<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[y | 2048] x [x | 2048] x [z | 255]<br>Coordinates: <br> y: [ 50..204750]<br> x: [ 50..204750]<br> z: [ 25..26685.83203]<br>Number Of Attributes: 1<br> time :<span style="white-space:pre-wrap">        </span> 20<br><br>Variable: h48_r<br>Type: float<br>Total Size: 4278190080 bytes<br> 1069547520 values<br>Number of Dimensions: 3<br>Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[y | 2048] x [x | 2048] x [z | 255]<br>Coordinates: <br> y: [ 50..204750]<br> x: [ 50..204750]<br> z: [ 25..26685.83203]<br>Number Of Attributes: 2<br> _FillValue :<span style="white-space:pre-wrap">        </span> 0<br> time :<span style="white-space:pre-wrap">        </span> 20</font><br><br></div><div><br></div><div><br></div><div><br>Thank you!</div><span class="HOEnZb"><font color="#888888"><div><br></div><div>Andrea</div></font></span></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>