[ncl-talk] How to convert NCL script to a NetCDF file?
Dennis Shea
shea at ucar.edu
Fri Nov 4 09:38:29 MDT 2022
Hi Setarah,
My knowledge of R is rudimentary. I have used R for statistics only. It was
used to make sure NCL statistical functions worked correctly.
I have never used R's graphics. Hence, I can offer no guidance of the plot.
Sorry,
D
On Fri, Nov 4, 2022 at 8:56 AM Setareh Rahimi <setareh.rahimi at gmail.com>
wrote:
> Dear Dennis,
> Many thanks for your consideration. I executed the script and then
> imported the new NetCDF file to R software. However, lat/lon did not
> change. I attached the plot from the R. May I ask you to please advise me
> in this regard?
> Best wishes,
>
> On Mon, Oct 31, 2022 at 3:17 AM Dennis Shea <shea at ucar.edu> wrote:
>
>> "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."
>> ====
>>
>>
>> ncl-talk does not have much experience with R.
>>
>> The description "The [R] software can not recognize the lat/lon."
>>
>> Perhaps, the fact the the XLAT and XLONG are three dimensional (Time,
>> south_north, west_east) causes the problem?
>> I do not think ncl-talk is going to learn R's reading of netCDF files.
>> ***That is your responsibility. ***
>> ======================
>> NOT TESTED
>> ====================
>>
>>
>> load
>> "$NCARG_ROOT/lib/ncarg/nclscripts/wrf/WRF_contributed.ncl"
>>
>>
>> inNC = "wef_chem.nc" ; original file
>> f = addfile(inNC, "r")
>>
>>
>> Times = f->Times ; char Times(Time, DateStrLen) ;
>> ;
>> ; https://www.ncl.ucar.edu/Document/Functions/WRF_contributed/wrf_times_c.shtml
>> ;
>> *time = wrf_times_c*( Times, 3 ) ; yyyymmddhh (integer)
>> time!0 = "time" ; name the dimension
>>
>> time&time = time
>>
>> TAUAER2 = f->TAUAER2
>> TAUAER2!0 = "time"
>> TAUAER2&time = time
>>
>> TAUAER3 = f->TAUAER3
>> TAUAER3!0 = "time"
>> TAUAER3&time = time
>>
>> xlat_2d = f->XLAT(0,:,:) ; 3D->2D
>> xlong_2d = f->XLONG(0,:,:)
>>
>> printVarSummaary(time)
>>
>> printVarSummaary(xlat_2d)
>> printVarSummaary(xlong_2d)
>>
>> printVarSummaary(TAUAER2)
>> printVarSummaary(TAUAER3)
>>
>> ;-----------------------------
>>
>> newNC = "setarah.nc"
>>
>> *system* <https://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml>("/bin/rm -f + newNC) ; remove any pre-existing file
>> ncOUT = *addfile* <https://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>(newNC ,"c") ; open OUTPUT netCDF file
>>
>> ;===================================================================
>> ; create global attributes of the file (optional)
>> ;===================================================================
>> fAtt = True ; assign file attributes
>> fAtt at title = "REWRITE of " + inNC
>> fAtt at source_file = inNC
>> ;;fAtt at Conventions = "None"
>> fAtt at creation_date = *systemfunc* <https://www.ncl.ucar.edu/Document/Functions/Built-in/systemfunc.shtml> ("date")
>> *fileattdef* <https://www.ncl.ucar.edu/Document/Functions/Built-in/fileattdef.shtml>( ncOUT, fAtt ) ; add new attributes
>>
>> ncOUT->time = time
>>
>> ncOUT->XLAT = xlat_2d
>>
>> ncOUT->XLONG = xlong_2d
>>
>> ncOUT->TAUAER2 = TAUAER2
>> ncOUT->TAUAER3 = TAUAER3
>>
>>
>> On Sun, Oct 30, 2022 at 11:31 AM Setareh Rahimi via ncl-talk <
>> ncl-talk at mailman.ucar.edu> wrote:
>>
>>> Dear all NCL users,
>>> 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.
>>> wef_chem.nc.gz
>>> <https://drive.google.com/file/d/1K7lEFyBtr3B88PHF6QWhMRB9yc_ORn3e/view?usp=drive_web>
>>>
>>> --
>>> S.Rahimi
>>>
>>> _______________________________________________
>>> ncl-talk mailing list
>>> ncl-talk at mailman.ucar.edu
>>> List instructions, subscriber options, unsubscribe:
>>> https://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>>
>>
>
> --
> S.Rahimi
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221104/1a728798/attachment.htm>
More information about the ncl-talk
mailing list