<div dir="ltr"><div>"The [R] software can not recognize the lat/lon. So I need to convert my NCL
script to a NetCDF file in an easily readable way for the R."</div><div>====</div><br><div><br></div><div>ncl-talk does not have much experience with R.</div><div><br></div><div>The description "The [R] software can not recognize the lat/lon."</div><div><br></div><div>Perhaps, the fact the the XLAT and XLONG are three dimensional (Time, south_north, west_east) causes the problem?</div><div>I do not think ncl-talk is going to learn R's reading of netCDF files. <br></div><div>***That is your responsibility. ***</div><div>======================</div><div>NOT TESTED</div><div>====================<br></div><div><br></div><div><br></div><div> load "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"</div><div><pre><br> inNC = "<a href="http://wef_chem.nc">wef_chem.nc</a>" ; original file<br> f = addfile(inNC, "r")
<br></pre><pre> Times = f->Times ; char Times(Time, DateStrLen) ;<br> ;<br> ; <a href="https://www.ncl.ucar.edu/Document/Functions/WRF_contributed/wrf_times_c.shtml">https://www.ncl.ucar.edu/Document/Functions/WRF_contributed/wrf_times_c.shtml </a> <br> ;<br> <b>time = wrf_times_c</b>( Times, 3 ) ; yyyymmddhh (integer)
time!0 = "time" ; name the dimension<br></pre><pre> time&time = time <br></pre><pre> TAUAER2 = f->TAUAER2<br> TAUAER2!0 = "time"<br> TAUAER2&time = time<br> <br> TAUAER3 = f->TAUAER3<br> TAUAER3!0 = "time"<br> TAUAER3&time = time<br><br></pre><pre> xlat_2d = f->XLAT(0,:,:) ; 3D->2D<br> xlong_2d = f->XLONG(0,:,:) <br></pre><pre> printVarSummaary(time)<br></pre><pre> printVarSummaary(xlat_2d)<br> printVarSummaary(xlong_2d)<br><pre> printVarSummaary(TAUAER2) <br> printVarSummaary(TAUAER3)<br><br><pre><pre><pre>;-----------------------------<br></pre><pre> newNC = "<a href="http://setarah.nc">setarah.nc</a>"</pre><pre> <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml"><strong>system</strong></a>("/bin/rm -f + newNC) ; remove any pre-existing file
ncOUT = <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml"><strong>addfile</strong></a>(newNC ,"c") ; open OUTPUT netCDF file
;===================================================================
; create global attributes of the file (optional)
;===================================================================
fAtt = True ; assign file attributes
fAtt@title = "REWRITE of " + inNC
fAtt@source_file = inNC
;;fAtt@Conventions = "None"
fAtt@creation_date = <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml"><strong>systemfunc</strong></a> ("date")
<a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/fileattdef.shtml"><strong>fileattdef</strong></a>( ncOUT, fAtt ) ; add new attributes
</pre></pre></pre></pre></pre><pre> ncOUT->time = time<br></pre><pre> ncOUT->XLAT = xlat_2d<br> <br> ncOUT->XLONG = xlong_2d<br><br></pre><pre> ncOUT->TAUAER2 = TAUAER2<br> ncOUT->TAUAER3 = TAUAER3<br> <br></pre></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sun, Oct 30, 2022 at 11:31 AM Setareh Rahimi via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu">ncl-talk@mailman.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"><div>Dear all NCL users,</div><div>Using R software, I want to plot aerosol optical depth (AOD) from the WRF-chem model. Once import the model output in the R, the software can not recognize the lat/lon. So I need to convert my NCL script to a NetCDF file in an easily readable way for the R. How can I convert my NCL script (which includes converted time, lat/lon, and calculate AOD) to a new NetCDF file, please? The script and the model output have been attached.<div class="gmail_chip gmail_drive_chip" style="width:396px;height:18px;max-height:18px;background-color:rgb(245,245,245);padding:5px;color:rgb(34,34,34);font-family:arial;font-style:normal;font-weight:bold;font-size:13px;border:1px solid rgb(221,221,221);line-height:1"><a href="https://drive.google.com/file/d/1K7lEFyBtr3B88PHF6QWhMRB9yc_ORn3e/view?usp=drive_web" style="display:inline-block;max-width:366px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;text-decoration:none;padding:1px 0px;border:medium none" aria-label="wef_chem.nc.gz" target="_blank"><img style="vertical-align: bottom; border: medium none;" src="https://ssl.gstatic.com/docs/doclist/images/icon_10_generic_list.png"> <span dir="ltr" style="color:rgb(17,85,204);text-decoration:none;vertical-align:bottom">wef_chem.nc.gz</span></a><img style="opacity: 0.55; float: right; display: none;"></div></div><div><br>-- <br><div dir="ltr">S.Rahimi<br><br></div></div></div>
_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="https://mailman.ucar.edu/mailman/listinfo/ncl-talk" rel="noreferrer" target="_blank">https://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
</blockquote></div>