NCL Sample Scripts Dennis Shea Climate and Global Dynamics Division Climate Analysis Section.

Slides:



Advertisements
Similar presentations
EziLink RESULTS Training Session 1 – Show and Tell For the Ministry of Forests, Lands and Natural Resource Operations.
Advertisements

Climate Specific Tools: The cdutil Package. cdutil - overview The cdutil Package contains a collection of sub- packages useful to deal with Climate Data.
Chapter 51 Scripting With JSP Elements JavaServer Pages By Xue Bai.
Diagnostics of CESM Model NCL Post-process software Wen-Ien Yu.
Statistical tools in Climatology René Garreaud
Community Analysis and Visualization Tools for the Geosciences Sylvia Murphy Don Middleton Mary Haley National Center for Atmospheric Research Computational.
NCL NCL stands for NCAR Command Language. It is similar to IDL and MATLAB. It is most convenient for reading NetCDF files and plotting maps, but there.
FORTRAN Short Course Week 4 Kate Thayer-Calder March 10, 2009.
Tutorial on the Manipulation of Netcdf Climate Data: Application to Statistically Downscaled Climate Projections Michael Notaro Nelson Institute Center.
1 Agenda Views Pages Web Parts Navigation Office Wrap-Up.
The NCAR Command Language (NCL) Ethan Alpert Visualization and Enabling Technologies Section, SCD, NCAR.
NCL and PyNGL Community data analysis and visualization software 2005 User Forum, May  CISL/IMAGe/SCD Mary Haley,
1 NetCDF and Self-Describing Data Kate Hedstrom January 2010
ElVis Developments for Simulation and Analysis Programs Tarun Pondicherry Summer 2006 Science Ed High School Intern Eliot Feibush, Mentor 8/16/2006.
The HDF Group September 28, 2010HDF/HDF-EOS Workshop XIV1 Easy Access of HDF data via NCL/IDL/MATLAB Kent Yang, Tong Qi, Ziying Li, Yi.
Dennis Shea National Center for Atmospheric Research
NCL Introduction Dennis Shea National Center for Atmospheric Research.
Basic File Input and Output Copyright © Software Carpentry 2011 This work is licensed under the Creative Commons Attribution License See
Slides based on lectures from the NCL workshop Also see the NCL homepage.
NetCDF Operators 1 netCDF Operators [NCO]
Best Practices for Managing Scanned Imagery Peter Becker.
Introduction Dennis Shea NCAR is sponsored by the National Science Foundation.
Matlab Programming for Engineers Dr. Bashir NOURI Introduction to Matlab Matlab Basics Branching Statements Loops User Defined Functions Additional Data.
Preparing and Deploying Data to ArcPad Juan Luera.
VistA Imaging Workstation Configuration. October The information in this documentation includes functionality of the software after the installation.
File IO Dennis Shea National Center for Atmospheric Research pdf Vis5D png NCAR is sponsored by the National Science Foundation Shapefiles.
Advanced Utilities Extending ncgen to support the netCDF-4 Data Model Dr. Dennis Heimbigner Unidata netCDF Workshop August 3-4, 2009.
Learning Unity. Getting Unity
The HDF Group HDF/HDF-EOS Workshop XV1 Tools to Improve the Usability of NASA HDF Data Kent Yang and Joe Lee The HDF Group April 17, 2012.
35 PC-HYSPLIT WORKSHOP Example Simulations Presented on the following slides are several basic trajectory and dispersion simulations and meteorological.
Return to Outline Copyright © 2011 by Maribeth H. Price 3-1 Labeling and annotation.
CKD Workshop  30 March 2011  Jim Kinter  Data Lessons from Project Athena GrADS Station Data Model Used for in situ observational data Individual reports.
Climate Forecasting Unit CFU R common diagnostics CFU_load CFU_season CFU_clim CFU_anoCFU_anocrossvalid CFU_plotclimCFU_plotano CFU_smoothing CFU_trend.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Introduction to MATLAB 7 for Engineers William J. Palm.
Eurasia Institute of Earth Sciences Istanbul Technical University NCL Introduction Deniz Bozkurt web.itu.edu.tr/bozkurtd ITU Eurasia Institute of Earth.
The HDF Group Introduction to netCDF-4 Elena Pourmal The HDF Group 110/17/2015.
Dennis Shea National Center for Atmospheric Research
Empirical Orthogonal Functions (EOFs) successive eigenvalues should be distinct – if not, the eigenvalues and associated patterns are noise – 1 from 2,
SCD User Briefing NCL and PyNGL Visualization for the Geosciences Don Middleton with presentation material developed by Luca Cinquini, Mary Haley, Fred.
Arrays. Review of last lecture Overview of computer languages Overview of IDL Strength of IDL: (1) Interactive/compiled modes; (2) Array-oriented; (3)
Week 9 : Text processing (Reading and writing files)
Mapdraw ats315. Today’s goal: Drawing a map in the graphics window! Drawing a map in the graphics window!
Java OceanAtlas A Cross-Platform Application for Visualization and Selection of Oceanographic Profile Data John R. Osborne
Java OceanAtlas A Cross-Platform Application for Visualization and Selection of Oceanographic Profile Data John R. Osborne ftp://odf.ucsd.edu/pub/OceanAtlas/
Math 252: Math Modeling Eli Goldwyn Introduction to MATLAB.
NetCDF Operators 1 netCDF Operators [NCO]
TSC Visual Post Processor Mio Suzuki Summer 2003 Undergraduate Internship Princeton Plasma Physics Laboratory 14 August 2003.
Introduction Dennis Shea NCAR is sponsored by the National Science Foundation.
Precalculus Section 14.1 Add and subtract matrices Often a set of data is arranged in a table form A matrix is a rectangular.
NcBrowse: A Graphical netCDF File Browser Donald Denbo NOAA-PMEL/UW-JISAO
1-2 What is the Matlab environment? How can you create vectors ? What does the colon : operator do? How does the use of the built-in linspace function.
Libcf – A CF Convention Library for NetCDF Ed Hartnett Unidata Program Center Boulder Colorado June 11, 2007.
FLIGHT PATH GUI David Alfego Josh Harrison. PURPOSE  Trials flown in Microsoft Flight Simulator X  Data collected according to coordinates of each flight.
Transition from EnSight V9 to V10 Boot strap training Anders Grimsrud, President January 2012.
Reading and Writing Image Files
File Input / Output Dennis Shea Input Output
NCL繪圖流程簡介 (改寫自NCL官方網頁投影片).
ArcGIS Pro Mapping and Visualization
Tips and Tricks for Creating Story Maps
Introduction to FERRET
Features in the Quad State Space Model
NetCDF 資料格式介紹 NCL 變數設定介紹
National Scientific Library at Tbilisi State University
Use of Mathematics using Technology (Maltlab)
NetCDF and Scientific Data Standard
Libcf – A CF Convention Library for NetCDF
JavaScript CS 4640 Programming Languages for Web Applications
Tour of NCL Website Modified by R. Grotjahn
NCL variable based on a netCDF variable model
Presentation transcript:

NCL Sample Scripts Dennis Shea Climate and Global Dynamics Division Climate Analysis Section

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" f = addfile("erai_ mon.msl_psl.nc","r") ; open file [hdf,grib] p = f->SLP ; (time,lat,lon) ; ( 252,121,240) printVarSummary(p) ; netCDF variable model wks = gsn_open_wks("ps","parvis_1") ; open a PS file plot = gsn_csm_contour_map(wks,p(0,:,:),False) ; default plot ; uses attributes, coordinates B+W graphic NetCDF [NCL] Variable model p = f->SLP NCL reads data values attributes coordinate arrays as a single data object. scalar or array valuesattributescoords p accessed via & _FillValue long_name missing_value units etc. time latitude longitude etc

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" f = addfile("erai_ mon.msl_psl.nc","r") ; open file [hdf,grib] p = f->SLP ; (time,lat,lon) ; ( 252,121,240) printVarSummary(p) ; netCDF variable model wks = gsn_open_wks("ps","parvis_1") ; open a PS file plot = gsn_csm_contour_map(wks,p(0,:,:),False) ; default plot ; uses attributes, coordinates Variable: p Type: float Total Size: bytes values Number of Dimensions: 3 Dimensions and sizes:[time | 252] x [latitude | 121] x [longitude | 240] Coordinates: time: [ ] latitude: [ ] longitude: [ ] Number Of Attributes: 4 _FillValue :1e+20 units :hPa long_name :Mean sea level pressure missing_value :1e+20 “printVarSummary(p)” output

NetCDF [NCL] Variable model p = f->SLP NCL reads data values attributes coordinate arrays as a single data object. scalar or array valuesattributescoords p accessed via & _FillValue long_name missing_value units etc. time latitude longitude etc Variable: p Type: float Total Size: bytes values Number of Dimensions: 3 Dimensions and sizes:[time | 252] x [latitude | 121] x [longitude | 240] Coordinates: time: [ ] latitude: [ ] longitude: [ ] Number Of Attributes: 4 _FillValue :1e+20 units :hPa long_name :Mean sea level pressure missing_value :1e+20 “printVarSummary(p)” output

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" f = addfile("erai_ mon.msl_psl.nc","r") ; open file [hdf,grib] p = f->SLP ; (time,lat,lon) ; ( 252,121,240) printVarSummary(p) ; netCDF variable model wks = gsn_open_wks("ps","parvis_1") ; open a PS file plot = gsn_csm_contour_map(wks,p(0,:,:),False) ; default plot

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" f = addfile("erai_ mon.msl_psl.nc","r") ; open file p = f->SLP ; (time,lat,lon) ; ( 252,121,240) pJan = dim_avg_n_Wrap(p(0::12,:,:), 0) ; Jan mean over all years printVarSummary(pJan) wks = gsn_open_wks("ps","parvis_2") ; open PS file gsn_define_colormap(wks,"amwg") ; load predefined color map res = True ; visualization options = True ; color on = True ; span all colors = True ; let NCL pick spacing = "ERAI: : January" plot = gsn_csm_contour_map(wks,pJan,res) Calculating a January monthly mean Variable: pJan Type: float Total Size: bytes values Number of Dimensions: 2 Dimensions and sizes:[latitude | 121] x [longitude | 240] Coordinates: latitude: [ ] longitude: [ ] Number Of Attributes: 5 missing_value :1e+20 long_name :Mean sea level pressure units :hPa _FillValue :1e+20 average_op_ncl :dim_avg_n over dimension(s): time

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" f = addfile("erai_ mon.msl_psl.nc","r") ; open file p = f->SLP(6::12,{0:90},:) ; July ; (20,61,240) w = sqrt(cos( *p&latitude) ) ; weights[*] wp = p*conform(p, w, 1) ; wp[*][*][*] copy_VarCoords(p, wp) x = wp(latitude|:,longitude|:,time|:) ; reorder data neof = 3 eof = eofunc_Wrap(x, neof, False) eof_ts = eofunc_ts_Wrap (x, eof, False) printVarSummary( eof ) ; examine EOF variables printVarSummary( eof_ts ) Calculating EOFS, writing a NetCDF file (next page)

Variable: eof Type: float Total Size: bytes values Number of Dimensions: 3 Dimensions and sizes:[evn | 3] x [latitude | 61] x [longitude | 240] Coordinates: evn: [1..3] latitude: [ 0..90] longitude: [ ] Number Of Attributes: 6 eval_transpose :( , , ) eval :( , , ) pcvar :( , , ) matrix :covariance method :transpose _FillValue :1e+20 Variable: eof_ts Type: float Total Size: 252 bytes 63 values Number of Dimensions: 2 Dimensions and sizes:[evn | 3] x [time | 21] Coordinates: evn: [1..3] time: [ ] Number Of Attributes: 3 ts_mean :( , , ) matrix :covariance _FillValue :1e+20 “ printVarSummary ” output

; Create netCDF: no define mode [simple approach, can be slow] system("/bin/rm -f EOF.nc") ; remove any pre-existing file fout = addfile("EOF.nc", "c") ; new netCDF file = "EOFs of SLP " fout->EOF = eof fout->EOF_TS = eof_ts... the simple way... let NCL do it ; Create netCDF: define mode [classic programmatic approach, faster] dimp = dimsizes(p) ntim = dimp(0) nlat = dimp(1) mlon = dimp(2) system ("/bin/rm -f EOF_define.nc") ; remove any pre-existing file fo = addfile ("EOF_define.nc", "c") ; new netCDF file setfileoption (fo,"DefineMode",True) foAtts = True title = "EOFs of SLP " fileattdef ( fo, foAtts ) ; create file attribute(s) dimNames = (/"time", "latitude", "longitude", "evn"/) ; define dimensions dimSizes = (/ ntim, nlat, mlon, neof/) dimUnlim = (/ False, False, False, False/) filedimdef (fo,dimNames,dimSizes,dimUnlim) evn = eof & evn ; define variables filevardef (fo, "evn", typeof (evn), getvardims (evn)) filevardef (fo, "EOF", typeof (eof), getvardims (eof)) filevardef (fo, "EOF_TS", typeof (eof_ts), getvardims (eof_ts)) ; NCL will create *multiple* attributes filevarattdef (fo,"evn", evn) ; define variable attributes filevarattdef (fo,"EOF", eof) filevarattdef (fo,"EOF_TS", eof_ts) fo->evn = (/ evn /) ; (/.../) means ignore metadata fo->EOF = (/ eof /) fo->EOF_TS = (/ eof_ts /)... the efficient way... predefine file content Two ways to write NetCDF

diri = "/project/convection/ccsm/b40_1850_c02c_76jpf/” fili = systemfunc("cd "+diri+" ; ls b40_cam2.h0.01*nc”) ; 1200 files setfileoption("nc","SuppressClose",False) ) ; user can tell NCL to alter default mode f = addfiles(diri+fili, "r") ; 25 sec (NCO ncrcat 34 sec) t = f[:]->T ; [time|1200]x[lev|30]x[lat|96]x[lon|144] ; 7 sec tt = f[:]->T(:,{500},{-30:30},:) ; [time|1200]x[lat|32]x[lon|144] ; 2 sec Reading multiple (1200) files using “addfiles” netCDF Operators (NCO) can do the same thing ncrcat –v T CAM*nc CAM_T1.nc ncrcat –v T -d lev,18 –d lat 33,54 CAM*nc CAM_T2.nc

load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_code.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/gsn_csm.ncl" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" Begin fili = "PHC2_” + VAR + "_tx0.1v2.JAN.nc" f = addfile(diri + fili,"r") ; for demo, just 1st time and level nSkip = 2 ; make faster... nSkip >1 x = f->SALT(0,0,::nSkip,::nSkip) ; x(nlat,mlon) (2400 x 3600) = f->TLAT(::nSkip,::nSkip) ; 2D curvilinear coordinate arrays = f->TLONG(::nSkip,::nSkip) ;================================================= ; Create contours over a map ;================================================= wks = gsn_open_wks("ps","PHC2_"+VAR+"_"+nSkip) ; open a PS file gsn_define_colormap(wks,"amwg") ; choose colormap i = NhlNewColor(wks,0.8,0.8,0.8) ; add light gray to colormap res = True = True ; turn on color = "RasterFill" ; AreaFill, CellFill = False ; turn off contour lines = True ; use full colormap = -2 ; don't use gray for contours = True ; force cyclic value = "PostDraw" ; do map fill last = “LightGray" ; color of land plot = gsn_csm_contour_map(wks,x,res) end POP scalar example: ‘thinning’ array to speed up plotting

import Ngl, Nio # Open the NetCDF file. nf = Nio.open_file("mtemp.cdf","r") # Get lat/lon/temperature variables. lat = nf.variables["lat"][:] lon = nf.variables["lon"][:] T = nf.variables["t"][0,:,:] # Open a PS workstation. wks = Ngl.open_wks("ps","mecca") # Contour & scalar field resources. res = Ngl.Resources() res.sfXArray = lon res.sfYArray = lat res.cnFillOn = True # Draw contour plot. contour = Ngl.contour(wks,T,res) Ngl.end() PyNGL/PyNIO load "gsn_code.ncl" ; Open the NetCDF file. nf = addfile("mtemp.cdf","r") ; Get lat/lon/temperature variables. lat = nf->lat lon = nf->lon T = nf->t(0,:,:) ; Open a PS workstation. wks = gsn_open_wks("ps","mecca") ; Contour & scalar field resources. res = True = lon = lat = True = False ; Draw contour plot. contour = gsn_contour(wks,T,res) NCL Sample PyNGL/PyNIO and NCL/GSUN scripts