<div dir="ltr"><div>The following are NOT appropriate for WRF data (curvilinear grid). Delete these lines</div><div><br></div><div> thetae!1 = "lev"<br> thetae!2 = "lat"<br> thetae!3 = "lon"</div><div>=========================<br></div><div>[SNIP]</div><div><div>************************************************</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)</div><div>;***********************************************<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) ; <== ???? is there a dimension named 'time' ?<br> ncdf->THETAE = thetae<br> ncdf->XLAT= lat<br> ncdf->XLONG = lon<br> ncdf->LEV = lev</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Feb 29, 2020 at 2:17 AM Lyndz via ncl-talk <<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><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" target="_blank">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>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">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></blockquote></div>