[ncl-talk] Save output as a NetCDF or tiff file

Dennis Shea shea at ucar.edu
Fri Nov 10 09:46:50 MST 2023


netCDF operator  'ncks' to extract a variable from a netCDF file and copy
it to another

%> ncks -v xxx Model.nc XXX.nc

where 'xxx' is the name of the variable on the model file
===============================
    AOD

       *system*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml>("/bin/rm
-f AOD.nc")    ; remove any pre-existing file
       ncdf = *addfile*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml>("AOD.nc"
,"c")  ; open output netCDF file

    ;===================================================================
    ; create global attributes of the file (optional)
    ;===================================================================
       fAtt               = True            ; assign file attributes
       fAtt at title         = "Derived AOD"
       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>(
ncdf, fAtt )            ; copy file attributes

    ;===================================================================
    ; make time an UNLIMITED dimension; recommended  for most applications
    ;===================================================================
       *filedimdef*
<https://www.ncl.ucar.edu/Document/Functions/Built-in/filedimdef.shtml>(ncdf,"time",-1,True)

    ;===================================================================
    ; output variables directly; NCL will call appropriate functions
    ; to write the meta data associated with each variable
    ;===================================================================
       ncdf->AOD  = AOD

================================
See
*https://www.ncl.ucar.edu/Applications/method_1.shtml
<https://www.ncl.ucar.edu/Applications/method_1.shtml>*

On Fri, Nov 10, 2023 at 1:02 AM Setareh Rahimi via ncl-talk <
ncl-talk at mailman.ucar.edu> wrote:

> Dear all,
> I have calculated Aerosol Optical Depth (AOD) from WRF-Chem output using
> "TAUAER2" and "TAUAER3" variables (script attached). Instead of using the
> created AOD to plot it, I would like to save the AOD as a NetCDF or tiff
> file. So how can I do this, please?
> I have another question. How can I extract one variable from the model
> output and save it as a NetCDF or tiff file?
> Please help me with these issues.
> Kind regards,
>
> --
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20231110/fb85dee6/attachment.htm>


More information about the ncl-talk mailing list