<div dir="ltr"><div>netCDF operator  'ncks' to extract a variable from a netCDF file and copy it to another<br></div><div><br></div><div>%> <code>ncks -v xxx Model.nc XXX.nc</code></div><div><code><br></code></div><div><code>where 'xxx' is the name of the variable on the model file</code></div><div><code>===============================</code></div><div><code>    AOD</code></div><div><pre>       <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/system.shtml"><strong>system</strong></a>("/bin/rm -f AOD.nc")    ; remove any pre-existing file
       ncdf = <a href="https://www.ncl.ucar.edu/Document/Functions/Built-in/addfile.shtml"><strong>addfile</strong></a>("AOD.nc" ,"c")  ; open output netCDF file

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

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

    ;===================================================================
    ; output variables directly; NCL will call appropriate functions
    ; to write the meta data associated with each variable
    ;===================================================================
       ncdf->AOD  = AOD        </pre></div><div><code>================================<br></code></div><div><code>See<br></code></div><div><b><a href="https://www.ncl.ucar.edu/Applications/method_1.shtml">https://www.ncl.ucar.edu/Applications/method_1.shtml</a></b></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Nov 10, 2023 at 1:02 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><font face="arial, sans-serif">Dear all,</font><div><font face="arial, sans-serif">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?</font></div></div><div><font face="arial, sans-serif">I have another question. How can I extract one variable from the model output and save it as a NetCDF or tiff file?</font></div><div><font face="arial, sans-serif">Please help me with these issues.</font></div><div><font face="arial, sans-serif">Kind regards,</font></div><div><font face="arial, sans-serif"><br></font></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature">S.Rahimi<br><br></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>