Data Analysis and Visualisation in Climate Science
Data Analysis and Visualisation in Climate Science
A Programmer's Guide
About the Book
Master the tools well so you can focus on the science
The book is in a good shape now and a final version is planned to be released by the end of 2022. The next update will included a wind rose example, list comprehensions, introduction to pathlib and sections on xarray and pandas.
Version 0.3 includes the following updates:
- code updated to Python 3.8
- code example for trend line plot using linear regression
- section added on glob.glob()
- introduction to f-strings and associated code updates
- minor code updates
- hi-resolution Cartopy map features
- fixed skew-t plot monotonicity issue
- improved solutions for creating sequences of dates
- some more NumPy solutions
- fixed some cross-references
Version 0.2 includes the following updates:
- Hovmoeller plots updated and additional example added
- Unnecessary np.meshgrid() commands removed from code examples
- Improved code for contour plot time axis formatting
- Working with Dates/Times section added (datetime module)
- Wind vector plot section added including examples
- Skew-T plot section added including examples
- Section on multiple line plots updated
- Plotting variables added to Table 8.1.2.1
- ax.quiver() command added to Table 8.1.2.1
- ax.subplots() commands updated (nrows and ncols)
- Typos fixed
- Cross-references and table/code/figure numbering fixed
Table of Contents
-
- Preface
- Acknowledgements
-
1 Introduction
- 1.1 Overview and Objective
- 1.2 Concept of Local and Remote Machines
- 1.3 Software
-
2 Climate Data
- 2.1 Climate Data Overview
- 2.2 Data Use Licences
- 2.3 Data Quality
- 2.4 Accessing Climate Data
-
2.5 Types of Climate Data
- 2.5.1 Analyses and Reanalyses Products
- 2.5.2 Climate and NWP Model Output
- 2.5.3 Point observations
-
2.6 Data File Formats
- 2.6.1 Plain Text and ASCII
- 2.6.2 Binary
- 2.6.3 GRIB
- 2.6.4 netCDF
- 2.6.5 PP
-
3 Unix
-
3.1 Introduction to Unix
- 3.1.1 Linux Distributions
- 3.1.2 Desktop versus Server
- 3.1.3 High Performance Computing on a Server
-
3.2 Accessing a Remote Server
- 3.2.1 Remote Server Login Details
- 3.2.2 Virtual Private Network (VPN)
- 3.2.3 X Window System (X11 forwarding)
- 3.2.4 Connecting to a Remote Server
-
3.3 First Steps on the Unix server
- 3.3.1 The Terminal Window
- 3.3.2 The Shell
- 3.3.3 Linux Directory Structure and Home Directory
- 3.3.4 Quota
- 3.3.5 File Transfer to and from the Server
- 3.3.6 Mapping the Linux Home Directory as a Remote Network Drive
-
3.4 Some More Unix Server Basics
- 3.4.1 Unix Command Syntax}
- 3.4.2 Manual Pages
- 3.4.3 Editing Text Files
- 3.4.4 Full versus Relative Paths
- 3.4.5 Special Characters
-
3.5 Working with Files and Directories
- 3.5.1 Creating Text Files and Directories
- 3.5.2 Listing Files and Directories
- 3.5.3 Moving Around in the Directory Tree
- 3.5.4 Copying, Moving, Renaming and Deleting Files and Directories
-
3.6 Advanced Unix Commands
- 3.6.1 Examining Text Files
- 3.6.2 File and Directory Properties
- 3.6.3 File Permissions
- 3.6.4 Changing File Permissions and Ownership
- 3.6.5 Changing the Unix Account Password
- 3.6.6 Redirecting Command Output
- 3.6.7 Finding Files
- 3.6.8 File Compression and Archives
- 3.6.9 Download Files from the Command Line
-
3.7 Long-running Jobs
- 3.7.1 GNU Screen (recommended)
-
3.1 Introduction to Unix
-
4 Multi-dimensional Gridded Datasets
- 4.1 The Earth’s Coordinate System and Realms
- 4.2 The Model Grid
- 4.3 Grid Indexing and Geographical Referencing of Data Points
- 4.4 The Time Dimension
-
4.5 Horizontal Resolutions and Grid Types
- 4.5.1 Spectral Resolution
- 4.5.2 Full and Reduced Gaussian Grid
- 4.5.3 Regular latitude-longitude grid
-
4.6 Vertical Level Types
- 4.6.1 Pressure, Potential Temperature and Potential Vorticity Levels
- 4.6.2 Sigma (Model) Levels
- 4.6.3 Sigma-Hybrid Levels
-
5 The netCDF File Format
- 5.1 Introduction to the netCDF File Format
-
5.2 netCDF File Headers
- 5.2.1 Exploring netCDF File Headers with ncdump
- 5.2.2 Exploring netCDF File Headers with CDO
- 5.2.3 Exploring netCDF File Headers with ncview
- 5.3 Packed netCDF Files
- 5.4 netCDF File Format Conventions
-
6 Python - Concepts and Work Environment
- 6.1 Python Overview
-
6.2 Python Concepts
- 6.2.1 Python Modules and Packages
- 6.2.2 Package Dependencies
- 6.2.3 Package Managers, Repositories and Channels
- 6.2.4 Python Virtual Environments
-
6.3 Conda
- 6.3.1 Creating a Conda Environment
- 6.3.2 Activating and Deactivating Conda Environments
- 6.3.3 Installing Python Packages
- 6.3.4 Listing and Deleting Conda Environments
-
6.4 Python Code Development
- 6.4.1 Python Code Editors
- 6.4.2 Python IDEs
- 6.4.3 Browser-based Python Code Editing
-
7 Python - Programming Basics
-
7.1 Basic Python Programming Building Blocks
- 7.1.1 Declaring Variables
- 7.1.2 Variable Types and Conversion Between them
- 7.1.3 Functions
- 7.1.4 Methods and Attributes
- 7.1.5 Controlling the Code Flow
-
7.2 Applying Python in Climate Data Analysis
- 7.2.1 Error Messages when Running Code
- 7.2.2 Looping Through Input Files
- 7.2.3 Reading Data Files Into NumPy Variables
- 7.2.4 Executing Unix System Commands from Within Python
-
7.3 Introduction to Numpy
- 7.3.1 Creating Numpy Arrays
- 7.3.2 Indexing NumPy Arrays
- 7.3.3 Saving and Loading NumPy Variables
- 7.3.4 Some NumPy Solutions
-
7.4 Working with Dates and Times
- 7.4.1 Creating Date Objects
-
7.4.2 Converting Datetime Objects to Strings (
strftime
) - 7.4.3 Creating a NumPy Array with Datetime Objects
-
7.5 Tips and Solutions
- 7.5.1 String Formatting of Numbers
- 7.5.2 Zero-padding Integer Values in Filenames
- 7.5.3 Calculate Height from Geopotential with MetPy
-
7.1 Basic Python Programming Building Blocks
-
8 Python - Creating Plots
-
8.1 Matplotlib
- 8.1.1 Setting up Plotting Page (Figure and Axes)
- 8.1.2 Main Plotting Commands
- 8.1.3 Colour Names and Colour Maps
-
8.2 Line Plots
- 8.2.1 Line Plot with Labels
- 8.2.2 Line Plot with Arrows
- 8.2.3 Multiple Lines Plot with Markers and Legend
- 8.2.4 Multiple Lines Plot with two Scales
- 8.2.5 Multiple Lines Plot with Standard Deviation
-
8.3 Scatter Plots
- 8.3.1 Scatter Plot with a Legend
- 8.3.2 Scatter Plot with Divergent Colour Bar
- 8.3.3 Scatter Plot on a Map with Colour Bar and Legend
- 8.3.4 Adding Trend Line Based on Linear Regression
-
8.4 Map Plots
- 8.4.1 Cartopy Map Projections and Data Transformation
- 8.4.2 High-Resolution Map Features
- 8.4.3 Simple Map of SST Anomalies
- 8.4.4 Map with Stipples for Statistical Significance
-
8.5 Bar Graphs
- 8.5.1 Anomalies Bar Graph
-
8.6 Hovmöller Plots
- 8.6.1 Hovmöller Plot with Time as a Function of Latitude
- 8.6.2 Hovmöller Plot with Time as a Function of Pressure
-
8.7 Vertical Cross-Section Plots
- 8.7.1 Meridional Cross-Section
- 8.7.2 Vertical Cross-Section Between two Points
-
8.8 Skew-T Plots
- 8.8.1 Brief Introduction to Skew-T Plots
- 8.8.2 Simple Skew-T Plot
- 8.8.3 Multiple Skew-T Plots
-
8.9 Vector and Streamline Plots
- 8.9.1 Black Wind Vectors on Filled Colour Contours
- 8.9.2 Coloured Wind Vectors
-
8.10 Looping Through Multiple Panels
-
8.10.1 Multiple Line Plots (
axes.flat
method) -
8.10.2 Multiple Line Plots (
pop()
function) -
8.10.3 Multiple Map Plots (
axes.flat
method)
-
8.10.1 Multiple Line Plots (
-
8.1 Matplotlib
-
9 Data Analysis with CDO
- 9.1 What is CDO?
- 9.2 Useful CDO Resources
-
9.3 Basic Syntax of CDO Commands
- 9.3.1 CDO Options
- 9.3.2 CDO Operator Categories
- 9.3.3 Using Multiple CDO Operators
- 9.3.4 CDO Operator Parameters
- 9.3.5 CDO Command Input and Output Files
- 9.4 Merging Files
-
9.5 Selections
- 9.5.1 Selecting Variables
- 9.5.2 Selecting Spatial Subsets (Geographical Regions)
- 9.5.3 Selecting Vertical Levels
- 9.5.4 Selecting Time Subsets
-
9.6 Basic Statistics
- 9.6.1 Statistics over the Time Domain
- 9.6.2 Statistics over the Spatial Domain
- 9.6.3 Statistics over the Vertical Domain
- 9.6.4 Statistics over the Zonal Domain
- 9.6.5 Statistics over the Meridional Domain
- 9.6.6 Statistics over Ensembles
-
9.7 Interpolations
- 9.7.1 Interpolation to a new horizontal grid (remapping)
- 9.7.2 Interpolation in the Vertical Domain
- 9.7.3 Interpolation in the Time Domain
-
9.8 Basic Arithmetic
- 9.8.1 Artithmetic Between Two Files
- 9.8.2 Arithmetic Using a Constant Value
-
9.9 Applying CDO in Climate Computations
- 9.9.1 Indian Ocean Dipole Example
- 9.9.2 Sahel Rainfall Variability Example
- 9.9.3 Creating a Land-Sea Mask File
- 9.10 Using CDO with Python
-
Appendix
- References
- List of Acronyms
- Notes
The Leanpub 60-day 100% Happiness Guarantee
Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.
See full terms
80% Royalties. Earn $16 on a $20 book.
We pay 80% royalties. That's not a typo: you earn $16 on a $20 sale. If we sell 5000 non-refunded copies of your book or course for $20, you'll earn $80,000.
(Yes, some authors have already earned much more than that on Leanpub.)
In fact, authors have earnedover $12 millionwriting, publishing and selling on Leanpub.
Learn more about writing on Leanpub
Free Updates. DRM Free.
If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).
Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.
Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.
Learn more about Leanpub's ebook formats and where to read them