File IO Dennis Shea National Center for Atmospheric Research pdf Vis5D png NCAR is sponsored by the National Science Foundation Shapefiles.

Slides:



Advertisements
Similar presentations
M AT L AB Programming: scripts & functions. Scripts It is possible to achieve a lot simply by executing one command at a time on the command line (even.
Advertisements

Single Variable and a Lot of Variables The declaration int k; float f; reserve one single integer variable called k and one single floating point variable.
Combining NCL and Fortran in C-shell
Utilizing the GDB debugger to analyze programs Background and application.
The NCAR Command Language (NCL) and the NetCDF Data Format Research Tools Presentation Matthew Janiga 10/30/2012.
Streaming NetCDF John Caron July What does NetCDF do for you? Data Storage: machine-, OS-, compiler-independent Standard API (Application Programming.
The Future of NetCDF Russ Rew UCAR Unidata Program Center Acknowledgments: John Caron, Ed Hartnett, NASA’s Earth Science Technology Office, National Science.
NetCDF An Effective Way to Store and Retrieve Scientific Datasets Jianwei Li 02/11/2002.
FORTRAN Short Course Week 4 Kate Thayer-Calder March 10, 2009.
Guide To UNIX Using Linux Third Edition
Introduction to Array The fundamental unit of data in any MATLAB program is the array. 1. An array is a collection of data values organized into rows and.
Introduction to NetCDF Russ Rew, UCAR Unidata ICTP Advanced School on High Performance and Grid Computing 13 April 2011.
Status of netCDF-3, netCDF-4, and CF Conventions Russ Rew Community Standards for Unstructured Grids Workshop, Boulder
The NCAR Command Language (NCL) Ethan Alpert Visualization and Enabling Technologies Section, SCD, NCAR.
1 NetCDF and Self-Describing Data Kate Hedstrom January 2010
Chapter 5: Data Input and Output Department of Computer Science Foundation Year Program Umm Alqura University, Makkah Computer Programming Skills
Netcdf course Intro CF convention Netcdf excercises.
Lesson 11-Locating, Printing, and Archiving User Files.
Multidimensional Data and GIS Steve Kopp Nawajish Noman ESRI.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
A Metadata Based Approach For Supporting Subsetting Queries Over Parallel HDF5 Datasets Vignesh Santhanagopalan Graduate Student Department Of CSE.
NCL Introduction Dennis Shea National Center for Atmospheric Research.
Slides based on lectures from the NCL workshop Also see the NCL homepage.
Chapter 10: File-System Interface Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Jan 1, 2005 Chapter 10: File-System.
The netCDF-4 data model and format Russ Rew, UCAR Unidata NetCDF Workshop 25 October 2012.
NetCDF Operators 1 netCDF Operators [NCO]
Introduction Dennis Shea NCAR is sponsored by the National Science Foundation.
Deutscher Wetterdienst
Integrating netCDF and OPeNDAP (The DrNO Project) Dr. Dennis Heimbigner Unidata Go-ESSP Workshop Seattle, WA, Sept
Project 4 : SciDAC All Hands Meeting, September 11-13, 2002 A. Choudhary, W. LiaoW. Gropp, R. Ross, R. Thakur Northwestern UniversityArgonne National Lab.
Accessing Remote Datasets using the DAP protocol through the netCDF interface. Dr. Dennis Heimbigner Unidata netCDF Workshop August 3-4, 2009.
Advanced Utilities Extending ncgen to support the netCDF-4 Data Model Dr. Dennis Heimbigner Unidata netCDF Workshop August 3-4, 2009.
Brief Overview: GRIB, HDF, WRF.nc
Chris Lynnes, NASA Goddard Space Flight Center NASA/Goddard EARTH SCIENCES DATA and INFORMATION SERVICES CENTER (GES DISC) Analyzing.
Climate Data Formats Deniz Bozkurt
Introduction to Programming the WWW I CMSC Winter 2003.
Using Text Files in Excel File I/O Methods. Working With Text Files A file can be accessed in any of three ways: –Sequential access: By far the most common.
Eurasia Institute of Earth Sciences Istanbul Technical University NCL Introduction Deniz Bozkurt web.itu.edu.tr/bozkurtd ITU Eurasia Institute of Earth.
NCL Sample Scripts Dennis Shea Climate and Global Dynamics Division Climate Analysis Section.
An Update on COLA’s Software Development Jennifer M. Adams and Brian Doty.
The HDF Group Introduction to netCDF-4 Elena Pourmal The HDF Group 110/17/2015.
Dennis Shea National Center for Atmospheric Research
16. Python Files I/O Printing to the Screen: The simplest way to produce output is using the print statement where you can pass zero or more expressions,
Data File Formats: netCDF by Tom Whittaker University of Wisconsin-Madison SSEC/CIMSS 2009 MUG Meeting June, 2009.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
UC 2006 Tech Session 1 NetCDF in ArcGIS 9.2. UC 2006 Tech Session2 Overview Introduction to Multidimensional DataIntroduction to Multidimensional Data.
CF 2.0 Coming Soon? (Climate and Forecast Conventions for netCDF) Ethan Davis ESO Developing Standards - ESIP Summer Mtg 14 July 2015.
Developing Conventions for netCDF-4 Russ Rew, UCAR Unidata June 11, 2007 GO-ESSP.
NetCDF Operators 1 netCDF Operators [NCO]
C Programming Day 2. 2 Copyright © 2005, Infosys Technologies Ltd ER/CORP/CRS/LA07/003 Version No. 1.0 Union –mechanism to create user defined data types.
Introduction Dennis Shea NCAR is sponsored by the National Science Foundation.
NcBrowse: A Graphical netCDF File Browser Donald Denbo NOAA-PMEL/UW-JISAO
Utilities for netCDF-4 Dr. Dennis Heimbigner Unidata Advanced netCDF Workshop July 25, 2011.
Unidata Infrastructure for Data Services Russ Rew GO-ESSP Workshop, LLNL
NetCDF Data Model Details Russ Rew, UCAR Unidata NetCDF 2009 Workshop
FILES AND EXCEPTIONS Topics Introduction to File Input and Output Using Loops to Process Files Processing Records Exceptions.
Other Projects Relevant (and Not So Relevant) to the SODA Ideal: NetCDF, HDF, OLE/COM/DCOM, OpenDoc, Zope Sheila Denn INLS April 16, 2001.
File Input / Output Dennis Shea Input Output
DAP+NETCDF Using the netCDF-4 Data Model
(Network Common Data Form)
TIGGE Archives and Access
NetCDF 資料格式介紹 NCL 變數設定介紹
National Scientific Library at Tbilisi State University
MATLAB: Structures and File I/O
Topics Introduction to File Input and Output
Chapter Four UNIX File Processing.
HDF-EOS Workshop XXI / The 2018 ESIP Summer Meeting
Topics Introduction to File Input and Output
NCL variable based on a netCDF variable model
Topics Introduction to File Input and Output
Presentation transcript:

File IO Dennis Shea National Center for Atmospheric Research pdf Vis5D png NCAR is sponsored by the National Science Foundation Shapefiles

I/O formats Supported formats [ need not know structure of file]  netCDF [network Common Data Form; version 3, (some) 4]  HDF4/H5 [Hierarchical Data Format (Scientific Data Set only) ]  HDF-EOS [Earth Observing System; HDF4 and HDF5]  GRIB-1/2 [Grid in Binary; WMO standard; NCEP, ECMWF, FSL]  CCMHT [CCM History Tape; COS blocked only; ccm2nc]  Shapefile [ESRI: geospatial vector data format GIS]  Soon  complete netCDF4, HDF5 (partial support v6.0.0) Binary  sequential [F: open(_,form="unformatted", access="sequential")]  flat/direct [F: open(_,form="unformatted",access=direct",recl=_)] [C: write] ASCII  data organized in columns and rows  ‘complicated’ ascii formats: use NCL string (‘str_*’) functions  fortran or C to read; call from NCL

ncl_filedump ncl_filedump ncl_filedump [-c] [-v var1[,…]] [–h] file_name  command line utility with options  provides textual overview of any supported file’s contents  behavior analogous to Unidata’s ncdump -h  file_name must have a file type suffix on command line .nc.grb.hdf.hdfeos.he5.h5.ccm.shp [case insensitive ]  suffix used as identifier only, actual file need not have ncl_filedump file_name.[grb/nc/hdf/hdfeos] - output can be sent to file or viewer via Unix redirection/ pipe ncl_filedump foo.grb > foo.txt [send to file] ncl_filedump foo.hdf | less [send to viewer]

ncl_convert2nc  ncl_convert2nc gribFile(s) OPTIONS  command line utility  converts GRIB/HDF/SHAPE file(s) to netCDF  output name same as input with.nc extension  ncl_convert2nc –h  provides usage option information  ncl_convert2nc foo.grb  will create foo.nc  ncl_convert2nc foo.hdf –L –nc4c –cl 1  -L (files> 2GB); -nc4c (netCDF4); -cl 1 (compression lvl 1)

Interactive : File_IO_  demonstrate ncl_filedump, ncl_convert2nc

setfileoption  allows user to specify file-format-specific options  netCDF, GRIB and Binary options [currently]  sample usage of selected options  writing netCDF  setfileoption(f, "DefineMode",True)  setfileoption("nc","Format","LargeFile")  setfileoption("nc","Format",”netCDF4Classic")  reading GRIB  setfileoption("grb","ThinnedGridInterpolation", "cubic")  setfileoption("grb", "InitialTimeCoordinateType" \, "Numeric")  reading/writing Binary  setfileoption("bin", "ReadByteOrder", "LittleEndian")  setfileoption("bin", “WriteByteOrder", “BigEndian")

addfile (1 of 3) Used to open a supported format only f = addfile (file_name.ext, status )  file_name => any valid file name; string  ext => extension that identifies the type of file; string  netCDF: "nc" or "cdf" [read/write]  HDF: "hdf", "hdfeos”, "h5”, "he5" [read/write]  GRIB: "grb", "grib" [read only; GRIB1 or GRIB2]  CCMHT: "ccm" [read only]  SHAPE (GIS): ”shp" [read only]  extension not required to be attached to file  status [read/write status] "r", "c", "w"  f  reference/pointer to a single file; any valid variable name  may have attributes (file attributes or global attributes)

Examples: opening a single file  fin = addfile (" nc", "r")  fout = addfile ("./ncOutput.nc", "c")  fio = addfile ("/tmp/shea/sample.hdf", "w")  g = addfile ("/dss/dsxxx/Y12345.grb", "r" )  s = addfile ("foo.shp", ”r") addfile (2 of 3) Numerous functions to query contents of supported file  getfilevarnames  getfilevardims  getfilevaratts  getfilevardimsizes  getfilevartypes  isfilevar  isfilevaratt  isfilevardim  isfilevarcoord diri = "/fs/cgd/data0/shea/ccm/" fili = "testCCM” fin = addfile(diri+fili+".ccm", " r ") varNames = getfilevarnames (fin) if (isfilevarcoord(fin, "U", "lat") ) then … end if

addfile: OPeNDAP (3 of 3) OPeNDAP enabled: Open Source Project for Network Data Access Protocol  access a remote file over the internet  file must be located on an OPeNDAP server [max 64 files]  only certain operating systems are currently OPeNDAP enabled. NCL can perform OPeNDAP operations on supported systems. Some (CDC ) require registration.  works with addfile, addfiles, and isfilepresentaddfileaddfilesisfilepresent url_cdc = " fPath = “ncep.reanalysis/pressure/air.1948.nc" if ( isfilepresent(url_cdc+fPath) ) thenisfilepresent f = addfile ( url_cdc + fPath, "r") vNames = getfilevarnames(f)getfilevarnames if ( any (vNames).eq. ”T”) then t = f->T end if

Global [File] Attributes provide information about the file as a whole (if present) examples include:  Conventions being used (if any): CF-1.0, COARDS  source  case  title  history  references g = addfile ("01-11.nc", "r") atts = getvaratts (g) ; get the global attributes print (atts) ; print names of attributes print ; print just title attribute

Import Variable from Supported Fmt f = addfile ("foo.grb", "r") vNam = getfilevarnames (f) ; all variables on file or vNam = (/ "U", "V" /) ; manually specify do n=0,dimsizes(vNam)-1 x = f->$vNam (n)$ ; $..$ substitute string..... end do u = (/ f->U /) - read data values only and _FillValue attribute u = f->U  read variable and all meta data into memory [structure]  no space allowed to left/right of -> [ fatal error]  use "$" syntax to represent variable name if type string

printVarSummary(u) Prints out variable information overview  Type  Dimension information  Coordinate information (if present)  Attributes Variable: u Type: double Total Size: bytes values Number of Dimensions: 4 Dimensions / Sizes: [time | 1] x [lev | 18] x [lat | 64] x [lon | 128] Coordinates: time: [ ] lev: [ ] lat: [ ] lon: [ ] Number of Attributes: 2 long_name: zonal wind component units: m/s

Example: open, read, output netCDF begin ; optional ; fin = addfile ("in.nc, "r") ; open file and read in data u = fin->U ; import a variable fout = addfile("out.nc", "c") ; create reference to output file = "I/O Example 1" ; add a global attribute to the file ; ;Output variable u to netCDF file: ncrcat –v U in.nc out.nc ; fout->U2 = u ; Output variable u to nc file end ; only if begin is present Note: This method of netCDF creation has simple syntax. It can be slow but is commonly used.

Example: query file, system commands begin ; ; open file, create array of variable names, # of names ; fin = addfile ("./in.nc", "r") vars = (/"U", "V", "T" /) ; manual specification nvars = dimsizes (vars) ; ; use system to remove output file before creation ; system("/bin/rm –f out.nc") fout = addfile("out.nc", " c ") ; ; loop, query if variable on the file, then output to netCDF ; do n=0,nvars-1 if (isfilevar(fin, vars(n))) then fout->$vars(n)$ = fin->$vars(n)$ end if end do end

Import byte/short Variable (1 of 2) u = f->U ; read variable and meta data into memory (generally) user wants to convert to float - COARDS convention: scale value then add offset better to use contributed.ncl [short2flt, byte2flt] Variable: u Type: short byte Total Size: bytes bytes values values Dimensions and sizes: [time | 4] x [lev |17] x [lat | 73 ] x [lon |144 ] Number of Attributes: 4 long_name: zonal wind component units: m/s scale_factor: 0.15 [slope: 0.15] add_offset: -3.0 [intercept: -3.0] uf = + u = short2flt(f->u) ; u = byte2flt(f->u)

Import byte/short Variable (2 of 2) (often) HDF files do not conform to COARDS - add offset to value then scale better to use contributed.ncl [short2flt_hdf, byte2flt_hdf] uf = ( u + u = short2flt_hdf(f->u) ; u = byte2flt_hdf(f->u)

Simple netCDF [hdf] Creation - commonly used - writes all components of a variable [data object ;-) ]  may be inefficient (possibly, very inefficient)  use for file with few variables/records  can not directly create an unlimited dimension fout = addfile (“foo.nc", "c") = "Simple Example" fout->U = u fout->T = Temp fo = addfile ("…", "c") filedimdef (fo, "time", -1, True) ; create ud fo->U = u fo->T = Temp

Efficient netCDF Creation requires ‘a priori’ definition of file contents  must be done in other languages/tools also [F, C, IDL,..] NCL functions to predefine a netCDF/HDF file:  setfileoption: specify entering define mode  filevardef: define name(s) of one or more variables  filevarattdef: copy attributes from a variable to one or more file variables  filedimdef: defines dimensions including unlimited  fileattdef: copy attributes from a variable to a file as global attributes Less tedious than other languages

Example: Efficient netCDF Creation T = ….. fout = addfile("out.nc", "c") setfileoption (fout, "DefineMode",True)) ; enter define mode ; create global attributes fileAtt = True = systemfunc("date") fileattdef (fout, fileAtt) ; predefine coordinate variables dimNames = (/ "time", "lat", "lon"/) dimSizes = (/ -1, nlat, mlon/) ; -1 means unknown dimUnlim = (/ True, False, False/) filedimdef (fout, dimNames, dimSizes, dimUnlim) ; predefine variable names, type, and dimensions filevardef (fout, "time", typeof(time), getvardims(time)) filevardef (fout, "lat", typeof(lat), getvardims(lat) ) filevardef (fout, "lon", typeof(lon), getvardims(lon) ) filevardef (fout,”TMP”, typeof(T), getvardims( T ) ) ; create var attributes for each variable filevarattdef (fout, "TMP", T) ; output data values only [use (/… /) to strip meta data] fout->time = (/ time /) fout->lat = (/ lat /) fout->lon = (/ lon /) fout->TMP = (/ T /) ; note the different name on file

Creating Compressed netCDF compression (netCDF-4) reduces file size  climate models create many files; saving more variables  very high resolution forecast models creating compressed netCDF (2 steps)  setfileoption("nc","Format","NetCDF4Classic")  setfileoption("nc","CompressionLevel",5)  9 levels of compression possible  compression performance similar to NCO  cache/chunk size, variable structure, …  recommendation: use compression level 1  cpu increases significantly with compression  reductions of little to 90% … depends  SST will have significant reduction (land)  random number will have almost no reduction

NCL netCDF Creation Process variables  create variable in memory; assign values (X)  name dimensions (x!0 = "time" )  assign coordinate values (x&time = time )  define attributes = "m/s2" ) create a reference to the file  fout = addfile ( file_name, "c")  assign global (file) attributes write desired variables – simple approach: fout->X = x  efficient approach:  setfileoption, filevardef, filevarattdef, filedimdef, fileattdef  fout->Y = (/ y /) ; strip meta data

Contents of a well written netCDF variable Variables  long_name*  units*  _FillValue [if applicable]  missing_value [ “ ]  named dimensions  coordinate variable(s) Consider: T(:) = "Temperature" = ”degC" = 1.e+20 = T!0 = "time" T&time = time Result: T(time) *COARDS and CF conventions

Interactive : File_IO_2  demonstrate addfile f = addfile (“foo.nc", "r") print(f) ; overview of file contents ; like "ncdump -h" or ncl_filedump x = f->X printVarSummary( x ) ; ncdump –v x

Reading Binary/ASCII data 7 functions for reading binary:  fbinrecread: reads multiple unformatted sequential records [Fortran; ieee]  fbinnumrec: returns the number of unformatted sequential records [Fortran; ieee]  fbindirread: reads specified record from a Fortran direct access file [ieee]  fbinread: same as fbinrecread but reads only one ieee rec  craybinrecread: like fbinrecread but for COS blocked data  craybinnumrec: like fbinnumrec but for COS blocked data  cbinread: read binary created via C block IO function "write " 1 function for reading ASCII data:  asciiread [contributed.ncl: readAsciiTable]  use NCL str_* functions; Fortran/C to read complicated ASCII files all above functions allow data to be shaped  x = fbinrecread ("foo_ieee", rnum, (/10,20,30/), "float")  a = asciiread ("foo_ascii", (/64,128/), "float")

Writing Binary/ASCII data 4 procedures for writing (ieee) binary data  fbinrecwrite: write unformatted fortran sequential recs  fbindirwrite: write specified record; fortran direct access  fbinwrite: write a binary file containing a single record  cbinwrite: write binary file ; mimics C block IO "write“ setfileoption: can be used to alter default behavior 2 procedures to write ascii data  asciiwrite: write a file containing ASCII characters  writes a single flat ASCII file. One value per line.  No user control of format  write_matrix: write a multi-dim array to std out or to a file  user has format control … pretty-print  options for title and row numbering use Fortran/C to write complicated ASCII files.

netCDF,GRIB,HDF ==> binary fin = addfile ("in.nc", "r") ;.grb.hdf hdfeos u = fin->U v = fin->V t = fin->T fout = "out.bin" system ("/bin/rm –f "+fout) ; ; output binary: –1 means append to previous record ; setfileoption("bin", "WriteByteOrder", "BigEndian") fbinrecwrite (fout, -1, fin->time) fbinrecwrite (fout, -1, fin->lev) fbinrecwrite (fout, -1, fin->lat) fbinrecwrite (fout, -1, fni->lon) fbinrecwrite (fout, -1, u) fbinrecwrite (fout, -1, v) fbinrecwrite (fout, -1, t)

binary ==> netCDF ; read in data setfileoption("bin", “ReadByteOrder", “BigEndian") ; optional lat = fbinrecread ("./in.bin", 2, 64, "double") lon = fbinrecread ("./in.bin", 3,128, "double") u = fbinrecread ("./in.bin", 6, (/64,128/),"double") lat!0 = "lat" = "latitude" = "degrees_north" lon!0 = "lon" = "longitude" = "degrees_east” u!0 = "lat“ ; named dimensions u!1 = "lon" u&lat = lat ; coordinate variables u&lon = lon ; assign values = "zonal wind“ ; attributes = "m/s" fout = addfile ("out.nc", "c") ; output file = "Binary-to-netCDF" ; file attribute fout->U = u ; write variable to file

GrADS binary ==> netCDF (1 of 2) ; Grads control file ; daily precip 365 days ; DSET ^gpcp_1dd_v1.lnx.1999 ; UNDEF ; TITLE GPCP 1 Degree Daily (1DD) Precip Analysis (Version 1) ; OPTIONS little_endian ; XDEF 360 LINEAR ; YDEF 180 LINEAR ; ZDEF 01 LEVELS 1 2 ; TDEF 365 LINEAR 1JAN1999 1dy ; VARS 1 ; rain 1 99 ch01 GPCP 1DD Precip (mm/day) ; ENDVARS nlat = 180 ; YDEF mlon = 360 ; XDEF ntim = 365 ; TDEF setfileoption("bin","ReadByteOrder","LittleEndian") ; OPTIONS x = fbindirread("gpcp_1dd_v1.lnx.1999", 0 \,(/ntim,nlat,mlon/), "float")

read GrADS binary (2 of 2) x!0 = "time" x!1 = "lat" x!2 = "lon" x&time= time x&lat = latGlobeFo (nlat, "lat", "latitude", "degrees_north") x&lon = lonGlobeFo(mlon, "lon", "longitude", "degrees_east") = "GPCP 1DD Precip" ; VARS = "mm/day"

Reading Simple ASCII Table ; read in data ncols = 9 nrows = 3 ksoi = asciiread ("ascii.in", (/nrows,ncols/), "float") ; partition total array into individual vector arrays yrs = ksoi(:, 0) mon1 = ksoi(:, 1) data = ksoi(:, 1:) ; all but leftmost column ;if you were going to plot, you should assign meta data = ; manually assign

Read ASCII Table with Header Jan-to-Aug Southern Oscillation Index Year Jan Feb Mar Apr May Jun Jul Aug load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/contributed.ncl" ncols = 9 nhead = 2 ; number of lines to skip ksoi = readAsciiTable ("ascii.in", ncols, "float", nhead) yrs = ksoi(:, 0) col1 = ksoi(:, 1) data = ksoi(:,1:) ; all but leftmost column = ` Last argument could be string: ksoi = readAsciiTable ("ascii.in", ncols, "float", "Year")

write_matrix(x[*][*], fmt, opt) create an ASCII file opt = True = "foo.ascii" ; file name write_matrix (T, "5f7.2", opt) pretty-print 2D array to standard out - integer, float, double – user format control (fmt) – if not 2D use T=onedtond( ndtooned(TT), (/N,M/)) – T(7,5): write_matrix (T, "5f7.2", False)

using system to access remote files …. mssPath = "/SHEA/NCEP/" fnames = (/ "reAnal1","reAnal2" /) do nf = 0,dimsizes(fnames)-1 system("msrcp mss:/SHEA/NCEP/"+ fnames(nf)+”.“) f = addfile(fnames(nf)+".grb", "r") …… end do system (”msrcp mss:/SHEA/foo.nc.” ) system ("msrcp blah.grb mss:/SHEA/blah.grb” ) mscmd = "msrcp mss:/SHEA/NCEP/"+ fnames(nf)+”.“ print (“mscmd=“ + mscmd) system( mscmd )

Importing Multiple Files systemfunc: returns info from *nix  fnames = systemfunc ("ls reAnal*")  fpath = systemfunc("ls /mydata/reAnal*") ; full path  fils = systemfunc("cd "+path+ " ; ls reAnal*") where: path = "/my/data/" manually  fnames = (/ "file1", "file2",... /) path = "/fs/cgd/data0/shea/" fnames = (/ "reAnal1", "reAnal2", "reAnal3", "reAnal4"/) nfiles = dimsizes(fnames) do nf =0,nfiles-1 f = addfile (path+fnames(nf)+".grb", "r") …… end do

addfiles (1 of 2) span multiple supported files q = addfiles (fNames, "r")  fNames is a 1D array of file names (strings)  can be used for any supported format  technically, "q" is a variable of type list T = q[:]->T ; [:] read all files  read T [with meta data] from each file in list ‘q’  T must exist in each file and be same shape [rank]  a list is used to sequence results of addfiles  normal file variable selection is used with "[…]" lat = q[0]->lat ; [0] read from first file Z = q[2:6:2]->Z ; extract Z only from files 2,4,6

addfiles (2 of 2) 2 options on variable merging  ListSetType (a, "cat") [default; "cat" => concatenation]  ListSetType (a, "join") when to use "cat" and "join" [rule of thumb]  cat: continuous record  join: creating ensembles  a record dimension will be added netCDF Operator (NCO): cat  ncrcat join  ncecat

Example: Read "T" across 5 files ["cat"] [Each file has 12 months] fils = systemfunc ("ls./ann*.nc") f = addfiles (fils, "r") ListSetType(f, "cat") ; not necessary [default] T = f[:]->T printVarSummary(T) Variable: T Type: float Total Size: bytes values Attributes: 2 units: K long_name: temp Number of Dimensions: 4 Dimensions and sizes: [time|60] x [lev|5] x [lat | 48] x [lon | 96] Coordinates: time: [2349 … 4123] lat: [ ] lev: [85000 … 25000] lon: [ ]

addfiles: option ["join"] fils = systemfunc ("ls./ann*.nc") f = addfiles (fils, "r") ListSetType (f, "join") T = f[:]->T printVarSummary (T) Variable: T Type: float Total Size: bytes values Attributes: 2 units: K long_name: temperature Number of Dimensions: 4 Dim/sizes: [case | 5] x [time|12] x [lev|5] x [lat | 48] x [lon | 96] Coordinates: time: [2349 … 2683] lat: [ ] lev: [85000 … 25000] lon: [ ]