Tutorial on the Manipulation of Netcdf Climate Data: Application to Statistically Downscaled Climate Projections Michael Notaro Nelson Institute Center.

Slides:



Advertisements
Similar presentations
Summary Statistics/Simple Graphs in SAS/EXCEL/JMP.
Advertisements

 Use the Left and Right arrow keys or the Page Up and Page Down keys to move between the pages. You can also click on the pages to move forward.  To.
Climate Predictability Tool (CPT)
Excel Charts – Basic Skills Creating Charts in Excel.
TANKS Software Operation First time in this software you need to add the meteorological data for your facility into the database To do this you will need.
Cosc 4750 Getting Started in UNIX Don’t be afraid of the prompt, in linux it can be your best friend. In some cases, the only way to do certain things.
Elizabeth North UMCES Horn Point Laboratory Using Surfer 8.0 UMCES HPL May 30, 2006.
By Hrishikesh Gadre Session II Department of Mechanical Engineering Louisiana State University Engineering Equation Solver Tutorials.
1 An Introduction to IBM SPSS PSY450 Experimental Psychology Dr. Dwight Hennessy.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
Geographic Information Systems
Technical Support: (989) GIS and Mapping Procedures in ArcMap 9.x Creating an ArcMap Project Editing an ArcMap Project Printing an ArcMap Project.
T UTORIAL OF U NIX C OMMAND & SHELL SCRIPT S 5027 Professor: Dr. Shu-Ching Chen TA: Samira Pouyanfar Spring 2015.
Very Quick & Basic Unix Steven Newhouse Unix is user-friendly. It's just very selective about who its friends are.
The Canadian Climate Impacts Scenarios (CCIS) Project is funded by the Climate Change Action Fund and provides climate change scenarios and related information.
Introduction to SPSS (For SPSS Version 16.0)
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
CS 141 Labs are mandatory. Attendance will be taken in each lab. Make account on moodle. Projects will be submitted via moodle.
Using Macs and Unix Nancy Griffeth January 6, 2014 Funding for this workshop was provided by the program “Computational Modeling and Analysis of Complex.
Unix Primer. Unix Shell The shell is a command programming language that provides an interface to the UNIX operating system. The shell is a “regular”
Linux environment ● Graphical interface – X-window + window manager ● Text interface – terminal + shell.
Climate Predictability Tool (CPT) Ousmane Ndiaye and Simon J. Mason International Research Institute for Climate and Society The Earth.
Chapter Four UNIX File Processing. 2 Lesson A Extracting Information from Files.
LINDSEY BREWER CSSCR (CENTER FOR SOCIAL SCIENCE COMPUTATION AND RESEARCH) UNIVERSITY OF WASHINGTON September 17, 2009 Introduction to SPSS (Version 16)
CARLSON SOFTWARE CONFERENCE DANIEL V. SYPERSMA VICTOR GRAPHICS.
Climate data sets: introduction two perspectives: A. What varieties of data are available? B. What data helps you to identify...
Demographic Profiles of Agency Clients - Part 2 Next, we will create a table and a column chart for the conservator field in my database. Because we are.
1 The EDIT Program The Edit program is a full screen text editor that allows you to: Create text files Create text files Edit an existing text files Edit.
Getting Started With AutoCAD ENGR 2 Week #1 Laboratory.
Manatees of Florida. Standard: MAFS.912.S-ID.1.1: Represent data with plots on the real number line (dot plots, histograms, and box plots). MAFS.912.S-ID.1.3:
NetCDF Operators 1 netCDF Operators [NCO]
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Using Climatic data in Diva GIS Franck Theeten, Royal Museum for central Africa Cabin training 2013.
© Crown copyright Met Office An Introduction to Linux, PP utilities, CDO and NCL Bangkok Workshop, 26 th February– 1 st March 2013.
Climate Data Formats Deniz Bozkurt
IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures Angela Des Jardins
Chapter 1 : The Linux System Part 2 Lecture 2 11/14/
WFM 6311: Climate Risk Management © Dr. Akm Saiful Islam WFM 6311: Climate Change Risk Management Akm Saiful Islam Lecture-7:Extereme Climate Indicators.
Climate Predictability Tool (CPT) Ousmane Ndiaye and Simon J. Mason International Research Institute for Climate and Society The Earth.
Unix Commands PowerPoint Presentation developed for LS 560 Information Technology online class - University of Alabama by Debey Sklenar TENacious Cohort.
Office of Research and Development National Exposure Research Laboratory, Atmospheric Modeling and Analysis Division Using Dynamical Downscaling to Project.
NCL Sample Scripts Dennis Shea Climate and Global Dynamics Division Climate Analysis Section.
External Executable Tools The Master's Touch David L. Blankenship.
Introduction to Drafting and Design In order to begin our drawing we have to set the drawing limits or the paper size.
The Canadian Climate Impacts Scenarios (CCIS) Project is funded by the Climate Change Action Fund and provides climate change scenarios and related information.
AN INTRO TO UNIX/LINUX COMMANDS BY: JIAYANG WANG.
Positioning Objects with CSS and Tables
Unix Fundamentals CS 127. File navigation cd - change directory cd /var/log cd /etc/apache2 cd ~/Desktop ~ is a shortcut for the home directory.
Basic Unix Commands. Listing files and directories ● ls:command is used to list the files and ● directories in present working directory ● ls command.
ICE UNIX TUTORIAL. File System Commands cd – change directory cd – change directory ls – list contents ls – list contents rm – remove/delete rm – remove/delete.
An electronic document that stores various types of data.
Dr. Sajib Datta Jan 16,  The website is up.  Course lectures will be uploaded there ◦ Check regularly for assignments and update.
NetCDF Operators 1 netCDF Operators [NCO]
Linux Tutorial Lesson Two *Getting Help in Linux *Data movement and manipulation *Relative and Absolute path *Processes Note: see chapter 1,2,3 from Linux.
CS 120 Extra: The CS1 Server Tarik Booker CS 120.
Learning Unix/Linux Based on slides from: Eric Bishop.
NcBrowse: A Graphical netCDF File Browser Donald Denbo NOAA-PMEL/UW-JISAO
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
Geocoding Chapter 16 GISV431 &GEN405 Dr W Britz. Georeferencing, Transformations and Geocoding Georeferencing is the aligning of geographic data to a.
Tutorial of Unix Command & shell scriptS 5027
Getting started with CentOS Linux
Prepared by: Eng. Maryam Adel Abdel-Hady
Global Circulation Models
Tutorial of Unix Command & shell scriptS 5027
Tutorial of Unix Command & shell scriptS 5027
Downloading and Preparing GIS Precipitation Data Layers
Tutorial of Unix Command & shell scriptS 5027
Getting started with CentOS Linux
NCL variable based on a netCDF variable model
Lab 2: Terminal Basics.
Presentation transcript:

Tutorial on the Manipulation of Netcdf Climate Data: Application to Statistically Downscaled Climate Projections Michael Notaro Nelson Institute Center for Climatic Research University of Wisconsin-Madison th Annual Conference of The Wildlife Society

NCO Observational Data The source of observed data was roughly 4100 weather stations measuring daily maximum/minimum temperature and precipitation during in ten of the central-eastern North American Landscape Conservation Cooperatives (LCCs), from the NWS Cooperative Observer Program. Model Projection Data The climate output that was analyzed was produced by 9 GCMs from the Coupled Model Intercomparison Project Phase 3, according to 3 emission scenarios (A2, A1B, B1). The coarse climate projections were downscaled to a 0.1° lat x 0.1° lon grid over 10 LCCs and debiased against observed temperature/precipitation from station observations within the NWS Cooperative Observer Program. By interpolating and debiasing probability distribution functions and their attributes, a realistic representation of the variance and extremes of temperature/precipitation was achieved, in addition to a realistic representation of the means of both variables. In computing the projected changes in a variable, the difference in the mean of that variable was computed from to either or CMIP3 Models CCCMA_CGCM3_1 = Canadian Centre for Climate Modelling and Analysis CNRM_CM3 = Meteo-France / Centre National de Recherches Meteorologiques CSIRO_MK3_0 = CSIRO Atmospheric Research, Australia CSIRO_MK3_5 = CSIRO Atmospheric Research, Australia GFDL_CM2_0 = US Department of Commerce / NOAA / Geophysical Fluid Dynamics Laboratory GISS_MODEL_E_R = NASA / Goddard Institute for Space Studies, US MIUB_ECHO_G = Meteorological Institute University of Bonn, Germany MPI ECHAM5 = Max Planck Institute for Meteorology, Germany MRI_CGCM2_3_2a = Meteorological Research Institute, Japan Project Funding The statistical downscaling project was funded by: (1) Michigan DNR through an EPA grant with the Great Lakes Restoration Initiative, (2) Upper Midwest and Great Lakes LCC, and (3) Wisconsin Focus on Energy. The downscaling was performed by Dr. David Lorenz. STATISTICAL DOWNSCALING

NCO Interactive mapping website for examining the downscaled data

NCDUMP NCO NCVIEW NCL TOOLS Additional tools: Text editor: Emacs or vi Ghostview

NCO BASIC UNIX COMMANDS cd = change directory Example: cd /data/Share/workshop/20c3m ls = list files in a directory pwd = list the name of directory you are in mv = move (or rename) file Example: mv oldfile newfile Example: mv oldfile /data/Share/workshop/ cp = copy file Example: cp oldfile newfile mkdir = create a directory Example: mkdir dirname rm = delete file Example: rm filename rmdir = delete directory Example: rmdir dirname emacs = text editor Example: emacs = opens emacs Example: emacs & = opens emacs in background vi = text editor Example: vi = opens vi Example: vi filename = opens old or new file UNIX Tutorials:

NCO Change directory cd /data/Share/workshop/20c3m Open ncview and look at a temperature file for Ampersand puts ncview in background, so you can still type in terminal. ncview temp_01_1990.nc & Click on “tmax” button

NCO Variable: Maximum daily temperature 365 Days, beginning Jan 1, 1990 Range of values °C to °C Move your pointer across map & notice the x,y coordinates and associated temperature values change

NCO Click on Opts to set options Choose USA states Click OK State boundaries should appear

NCO Quit = Exit ncview 3gauss = Toggle among color schemes Inv P = flip the map vertically Inv C = Invert color map Range = Modify the max/min displayed values Bi-Lin = Either show raster boxes or interpolated values Print = Save the plot as a postscript file or send to a printer

NCO Click on ? The variable tmax is “maximum daily temperature” of type short with units of °C and a missing value of

NCO Click on, and >> to move backwards/forwards in time, just like on a DVD player.

NCO Click on any grid cell on map. A time series will appear of daily maximum temperatures during Move your pointer over time series to see data values. Click on Print button to save the plot as a postscript file. Click on Dump button to write actual data values to a text file.

NCO Click on 4 different grid cells on the map to compare their time series.

NCO NCDUMP ncdump –h prcp_01_1982.nc

NCO NCDUMP ncdump –c prcp_01_1982.nc List the actual latitudes, longitudes, times lon = , , , ……, -67 lat = 24.6, 24.7, 24.8, ……, 54.7 time = 0, 1, 2, ……, 364 The resolution is 0.1 degree. ncdump –k prcp_01_1982.nc Tells you “netCDF-4” Possible outcomes: Classic, 64-bit offset, netCDF-4, netCDF-4 classic model

NCO The temperature files, such as temp_01_1982.nc, contain multiple variables (tmax, tmin). Let’s say we want to create a new file, only containing tmin. ncks: “kitchen sink” ncks –v tmin temp_01_1982.nc newfile.nc (-v stands for variable) Now, to verify that it worked, use ncdump. ncdump –h newfile.nc The file only contains tmin, not tmax. So it worked.

NCO The downscaling data covers a large region, N, W. What if we wanted to extract precipitation data in Wisconsin only? ncks –d lat,42.,47.5 –d lon,-93.5,-86.5 prcp_01_1996.nc small.nc (remember to use decimal points) To check the data, ncview small.nc Our dataset is now much smaller, only containing data around Wisconsin.

NCO How can we compute the mean precipitation for July 1985? On the Julian calendar, starting with 0, July runs from day 181 to 211. First, extract only the July days from the file. ncks –d time,181,211 prcp_01_1985.nc july.nc Now, use the record averager, ncra. ncra july.nc julymean.nc We can view the results with ncview. ncview julymean.nc

NCO How can we compute the difference between the mean annual daily maximum temperature in 1990 and 1989? First, compute the annual mean for ncra temp_01_1989.nc 89.nc Second, compute the annual mean for ncra temp_01_1990.nc 90.nc Third, compute the difference between the two files using the operator, ncdiff. ncdiff 90.nc 89.nc diff.nc Finally, view the file with ncview. ncview diff.nc

NCO How can we extract daily precipitation (mm/d) from 1995 for Madison, Wisconsin and dump the values to a text file? Use ncdump to check the content of file prcp_01_1995.nc. ncdump –h prcp_01_1995.nc Notice that variable prcp is type short, with scale factor of & offset of If we print out values, they will not be easily used. They need to be converted to float. ncap2 –s ‘prcp=float(prcp)’ prcp_01_1995.nc float95.nc This created file float95.nc, containing precipitation in easily readable values. Now, let’s extract data values for Madison only. ncks –d lat,43.07 –d lon, float95.nc madison.nc Finally, let’s pipe those values to a text file. ncdump madison.nc > madison.txt Open madison.txt with a text editor (emacs, vi) to see the result.

NCO NCL: NCAR Command Language Every script should begin with load commands, to access key libraries. I’ll only show them once here, but always include them at the top. In a text editor, create a file called hello.ncl. Insert the following text and save. 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" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl” print(“hello”) * To save time, cut and paste these load commands out of file loadcommands. Now, run the script by: ncl script.ncl The word hello should be printed to the screen. You have run your first NCL script.

NCO NCL: NCAR Command Language Given that the downscaled data is so large, it was written in a compact format, specifically netcdf4. We need to specify that we’re working with this unique type of data. setfileoption = specifies the type of data we’ll be working with setfileoption(“nc”,”Format”,”NetCDF4Classic”) Then, we can open the netcdf4 file. addfile = opens a data file “r” means readable, “w” is writable This command allows us to open these types of data files: netcdf, grib, hdf4, hdfeos, hdf5, hdfeoss, ccm, shapefile a=addfile(“temp_01_1991.nc”,”r”)

NCO NCL: NCAR Command Language We can retrieve the latitude and longitude values from the file. lat=a->lat lon=a->lon We can print the latitude values. print(lat)

NCO NCL: NCAR Command Language Our current script: script.ncl 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" load "$NCARG_ROOT/lib/ncarg/nclscripts/csm/shea_util.ncl” setfileoption(“nc”,”Format”,”NetCDF4Classic”) a=addfile(“temp_01_1991.nc”,”r”) lat=a->lat lon=a->lon print(lat)

NCO NCL: NCAR Command Language Let’s also retrieve the variable tmax from the file. Remember that tmax was in a short format and so we want to convert it to float. short2flt = Converts short format into float, using the offset and scale factor We can check the attributes/dimensions of our new variable using the command printVarSummary. setfileoption(“nc”,”Format”,”NetCDF4Classic”) a=addfile(“temp_01_1991.nc”,”r”) lat=a->lat lon=a->lon tmax=short2flt(a->tmax) printVarSummary(tmax) Now run the script. Notice the dimensions (time,lat,lon) and type float.

NCO NCL: NCAR Command Language Let’s try to print out the daily maximum temperature values for Madison from Recall that tmax had dimensions of time,lat,lon. When specifying the closest grid cell to Madison, provide the latitude and longitude inside { }. To acquire all time values, specify : for the time dimension. setfileoption(“nc”,”Format”,”NetCDF4Classic”) a=addfile(“temp_01_1991.nc”,”r”) tmax=short2flt(a->tmax) print(tmax(:,{43.07},{-89.40}))

NCO NCL: NCAR Command Language Let’s collect some basic statistics on a data file, specifically 1985’s precipitation. We’ll use the functions: avg, min, and max. setfileoption("nc","Format","NetCDF4Classic") a=addfile("prcp_01_1985.nc","r") prcp=short2flt(a->prcp) print(avg(prcp)) print(min(prcp)) print(max(prcp))

NCO NCL: NCAR Command Language Let’s say we want to plot a time series of Madison’s precipitation during First, let’s retrieve Madison’s values and print them to the screen as a check. setfileoption("nc","Format","NetCDF4Classic") a=addfile("prcp_01_1985.nc","r") prcp=short2flt(a->prcp) madison=prcp(:,{43.07},{-89.40}) print(madison)

NCO NCL: NCAR Command Language We want to plot time on x-axis and precipitation on y-axis. First, create a “workstation”, wks. We will be creating a postscript (ps) plot, named script.ps. setfileoption("nc","Format","NetCDF4Classic") a=addfile("prcp_01_1985.nc","r") prcp=short2flt(a->prcp) madison=prcp(:,{43.07},{-89.40}) wks=gsn_open_wks(“ps”,”script”) Time Temperature

NCO NCL: NCAR Command Language We will use the function gsn_csm_xy to make an XY plot. gsn_csm_xy(workstation, x-axis variable, y-axis variable, resource) For the x-axis, we will use “ispan(1,365,1)” which means a range of integers spanning from days 1 to 365 at a 1-day interval. For simplicity, assign “False” to resource options in gsn_csm_xy. setfileoption("nc","Format","NetCDF4Classic") a=addfile("prcp_01_1985.nc","r") prcp=short2flt(a->prcp) madison=prcp(:,{43.07},{-89.40}) wks=gsn_open_wks(“ps”,”script”) plot=gsn_csm_xy(wks,ispan(1,365,1),madison,False) Run the script. To view the plot, use ghostview in command line: gv script.ps

NCO NCL: NCAR Command Language Let’s now try plotting a spatial map of the mean climatological maximum temperatures for March (averaged across ). This information is contained in file temp_mean_1961_2000.nc. Let’s use ncdump to check the file’s content. ncdump –h temp_mean_1961_2000.nc Notice the dimensions of tmax: time 12 (one value per month) latitude 302 longitude 484

NCO NCL: NCAR Command Language Dimensions of tmax are time, lat, lon. To retrieve March only and all latitudes/longitudes, specify we want tmax(2,:,:). Remember the counting starts at zero, so March=2. setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) J0 F1 M2 A3 M4 J5 J6 A7 S8 O9 N10 D11

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Opens a new workstation Plot will be called script.ps

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Creates a new set of resources named res

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Specify to turn color fill on

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Our data is not global, or “cyclic”

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Specify the area to plot

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Show state and country boundaries

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Plot a contour map of march temperatures, using resources “res”

NCO NCL: NCAR Command Language setfileoption("nc","Format","NetCDF4Classic") a=addfile("temp_mean_1961_2000.nc","r") lat=a->lat lon=a->lon tmax=short2flt(a->tmax) march=tmax(2,:,:) wks = gsn_open_wks ("ps", "script") res=True = "AllBoundaries” plot = gsn_csm_contour_map_ce(wks,march, res) Now, run the script and use ghostview to display the plot. ncl script.ncl gv script.ps

NCO NCL: NCAR Command Language