<div dir="ltr">Dear NCL-Experts,<div><b><br></b></div><div><b>[Problem]</b></div><div>I am calculating equivalent potential temperature (thetae) from a wrfout file and save the variable to netcdf file.</div><div><br></div><div>I am calculating theta using the wrf_eth function instead of the wrf_user_getvar.</div><div>I cant figure out how to save the calculated thetae with the correct lat lon and pressure level.</div><div>Although there is no error in the script, I cant process the output file (i.e., still non-cdf compliant).</div><div><br></div><div>Any suggestions on how I can fix this in NCL?</div><div><br></div><div><b>[What I have so far]</b></div><div>My script is as follows:</div><div><br></div><div>,**************************************************************************************</div><div>;This file calculates the equivalent potential temperature from a wrfout file</div><div>;**************************************************************************************</div><div><br></div><div>begin<br>   nc_file = addfile("../WRF-4.0.3/test/em_real/G3D_Thompson_ACM2_120s/<a href="http://wrfout_d01_2017-01-12_00_00_00.nc">wrfout_d01_2017-01-12_00_00_00.nc</a>","r")<br>   T  = nc_file->T<br>   P  = nc_file->P<br>   PB = nc_file->PB<br>   qv = nc_file->QVAPOR<br><br>   T  = T + 300.        ; potential temperature in K.<br>   P  = P + PB          ; full pressure in Pa.<br>   tk = wrf_tk( P , T ) ; temperature in K.<br>   thetae = wrf_eth ( qv, tk, P )<br><br>;************************************************</div><div>;Get the lat lon and pressure level</div><div>;************************************************<br>   lat = wrf_user_getvar(nc_file, "XLAT",-1)<br>   lon = wrf_user_getvar(nc_file, "XLONG",-1)<br>   lev = wrf_user_getvar(nc_file, "pressure",-1)<br><br>;************************************************</div><div>;lev= bottom to top; lon = east to west; lat = south to north</div><div>'************************************************</div><div>   thetae!1 = "lev"<br>   thetae!2 = "lat"<br>   thetae!3 = "lon"<br><br>;***********************************************<br>; save to a netcdf file<br>;***********************************************<br>  diro = "./"<br>  filo = "Thetae_G3D_Thomp_ACM2.nc"<br>  ptho = diro+filo<br>  system("/bin/rm -f "+ptho)<br>  ncdf = addfile(ptho,"c")<br><br>  fAtt = True<br>  fAtt@title         = "Equivalent Potential Temperature"<br>  fAtt@source_file   = "WRF G3D_Thompson_ACM2"<br>  fAtt@Conventions   = "None"<br>  fAtt@creation_date = systemfunc("date")<br>  fileattdef(ncdf,fAtt)            ; copy file attributes<br>  filedimdef(ncdf,"time",-1,True)<br>  ncdf->thetae = thetae<br>  ncdf->lat = lat<br>  ncdf->lon = lon<br>  ncdf->lev = lev<br>end<br><br></div><div>Sincerely,</div><div>Lynds</div></div>