[ncl-talk] How to convert NCL script to a NetCDF file?

Setareh Rahimi setareh.rahimi at gmail.com
Fri Nov 4 08:56:36 MDT 2022


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/9ac5d110/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 29 Jun.png
Type: image/png
Size: 32412 bytes
Desc: not available
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20221104/9ac5d110/attachment.png>


More information about the ncl-talk mailing list