Data Analysis and Visualisation in Climate Science
$7.99
Minimum price
$9.99
Suggested price

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 latest version is a substantial update of the book including 132 extra pages with many more code examples.

v1.0 includes the following updates:

  • code base update to Python 3.11
  • extensive new chapter on Xarray
  • plotting code examples updated
  • streamline plot examples added
  • introduction to pathlib library
  • introduction to Micromamba
  • broken cross-references and URLs fixed

v0.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

v0.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

About the Author

Sebastian Engelstaedter
Sebastian Engelstaedter

I am a scientist and data analyst working at the Climate Research Lab in the School of Geography and the Environment at the University of Oxford, UK. More details about my work can be found here: https://www.geog.ox.ac.uk/staff/sengelstaedter.html

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)
  • 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 Virtual Environments for Python
      • 6.2.5 Conda, Mamba or Micromamba?
      • 6.2.6 Micromamba
      • 6.2.7 Conda
    • 6.3 Python Code Development Solutions
      • 6.3.1 Python Code Editors
      • 6.3.2 Python IDEs
      • 6.3.3 Browser-based Python Code Editing
      • 6.3.4 The IPython Command Line
  • 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 A Brief 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 Managing Paths and Filenames Using pathlib
      • 7.5.2 String Formatting of Numbers
      • 7.5.3 Zero-padding Integer Values in Filenames
      • 7.5.4 Calculate Height from Geopotential with MetPy
  • 8 Python - Data Analysis with Xarray
    • 8.1 What is Xarray?
    • 8.2 Xarray Basics
      • 8.2.1 Xarray Terminology
      • 8.2.2 Import Xarray into Python Script
    • 8.3 Reading in netCDF Files Using Xarray
      • 8.3.1 Reading in a Single netCDF File
      • 8.3.2 Reading in Multiple netCDF Files
      • 8.3.3 Reading in Very Large (memory-intensive) netCDF Files
      • 8.3.4 Additional Considerations for Reading in netCDF Files
    • 8.4 DataSets vs DataArrays
    • 8.5 Exploring File Content
      • 8.5.1 Print DataSet
      • 8.5.2 Print DataArray
      • 8.5.3 Accessing DataArray Elements
    • 8.6 Dates and Times in Xarray
      • 8.6.1 Retrieving Date/Time Information Using Datetime Accessors
      • 8.6.2 Passing Date/Time Information to DataArray Methods
    • 8.7 Selections
      • 8.7.1 Selecting Variables
      • 8.7.2 sel() vs isel()
      • 8.7.3 Selecting Spatial Subsets (Geographical Regions)
      • 8.7.4 Selecting Vertical Levels
      • 8.7.5 Selecting Timesteps
    • 8.8 Resampling - Downsampling the Time Dimension
      • 8.8.1 Resampling to Daily Statistics
      • 8.8.2 Resampling to Monthly Statistics
      • 8.8.3 Resampling to Yearly Statistics
    • 8.9 Aggregation - Calculating Statistics Over Dimensions
      • 8.9.1 Aggregation Over the Time Domain
      • 8.9.2 Aggregation Over the Spatial Domain
      • 8.9.3 Aggregation Over the Vertical Domain
      • 8.9.4 Aggregation Over the Zonal Domain
      • 8.9.5 Aggregation Over the Meridional Domain
      • 8.9.6 Aggregation for Hovmöller Plots
    • 8.10 The Split-Apply-Combine Concept
      • 8.10.1 Group by Hour
      • 8.10.2 Group by Month
      • 8.10.3 Group by Season
    • 8.11 Interpolation
      • 8.11.1 Simple Interpolation Example
      • 8.11.2 Spatial Interpolation
      • 8.11.3 Interpolation Between two Geographical Points
    • 8.12 Xarray Computations
      • 8.12.1 Direct Application of Arithmetic Operation
      • 8.12.2 NumPy Universial Functions - ufunc()
      • 8.12.3 Xarray Universal Functions - apply_ufunc()
    • 8.13 Xarray MetPy Integration
    • 8.14 More Xarray Methods and Attributes to Explore
      • 8.14.1 Some Useful Xarray Methods
      • 8.14.2 Some Useful Xarray Attributes
    • 8.15 Xarray Plotting
    • 8.16 Applying Xarray in Climate Computations
      • 8.16.1 The 1997 Indian Ocean Dipole Event
      • 8.16.2 Rainfall Variability in the Sahel
      • 8.16.3 Winds at In Salah (Algeria)
  • 9 Python - Creating Plots
    • 9.1 Matplotlib
      • 9.1.1 Setting up a Plotting Page (Figure and Axes)
      • 9.1.2 Main Plotting Commands
      • 9.1.3 Colour Names and Colour Maps
    • 9.2 Line Plots
      • 9.2.1 Line Plot with Labels
      • 9.2.2 Line Plot with Arrows
      • 9.2.3 Multiple Lines Plot with Markers and Legend
      • 9.2.4 Multiple Lines Plot with two Scales
      • 9.2.5 Multiple Lines Plot with Standard Deviation
    • 9.3 Scatter Plots
      • 9.3.1 Scatter Plot with a Legend
      • 9.3.2 Scatter Plot with Divergent Colour Bar
      • 9.3.3 Scatter Plot on a Map with Colour Bar and Legend
      • 9.3.4 Adding Trend Line Based on Linear Regression
    • 9.4 Map Plots
      • 9.4.1 Cartopy Map Projections
      • 9.4.2 Cartopy Data Transformations
      • 9.4.3 High-Resolution Map Features
      • 9.4.4 Simple Map of SST Anomalies
      • 9.4.5 Map with Stipples for Statistical Significance
    • 9.5 Bar Graphs
      • 9.5.1 Anomalies Bar Graph
    • 9.6 Hovmöller Plots
      • 9.6.1 Hovmöller Plot with Time as a Function of Latitude
      • 9.6.2 Hovmöller Plot with Time as a Function of Pressure
    • 9.7 Vertical Cross-Section Plots
      • 9.7.1 Meridional Cross-Section
      • 9.7.2 Vertical Cross-Section Between two Points
    • 9.8 Skew-T Plots
      • 9.8.1 Brief Introduction to Skew-T Plots
      • 9.8.2 Simple Skew-T Plot
      • 9.8.3 Multiple Skew-T Plots
    • 9.9 Vector and Streamline Plots
      • 9.9.1 Black Wind Vectors on Filled Colour Contours
      • 9.9.2 Coloured Wind Vectors
      • 9.9.3 Streamline Plot
    • 9.10 Looping Through Multiple Panels
      • 9.10.1 Multiple Line Plots (axes.flat method)
      • 9.10.2 Multiple Line Plots (pop() function)
      • 9.10.3 Multiple Map Plots (axes.flat method)
  • 10 Data Analysis with CDO
    • 10.1 What is CDO?
    • 10.2 Useful CDO Resources
    • 10.3 Basic Syntax of CDO Commands
      • 10.3.1 CDO Options
      • 10.3.2 CDO Operator Categories
      • 10.3.3 Using Multiple CDO Operators
      • 10.3.4 CDO Operator Parameters
      • 10.3.5 CDO Command Input and Output Files
    • 10.4 Merging Files
    • 10.5 Selections
      • 10.5.1 Selecting Variables
      • 10.5.2 Selecting Spatial Subsets (Geographical Regions)
      • 10.5.3 Selecting Vertical Levels
      • 10.5.4 Selecting Time Subsets
    • 10.6 Basic Statistics
      • 10.6.1 Statistics over the Time Domain
      • 10.6.2 Statistics over the Spatial Domain
      • 10.6.3 Statistics over the Vertical Domain
      • 10.6.4 Statistics over the Zonal Domain
      • 10.6.5 Statistics over the Meridional Domain
      • 10.6.6 Statistics over Ensembles
    • 10.7 Interpolations
      • 10.7.1 Interpolation to a new horizontal grid (remapping)
      • 10.7.2 Interpolation in the Vertical Domain
      • 10.7.3 Interpolation in the Time Domain
    • 10.8 Basic Arithmetic
      • 10.8.1 Artithmetic Between Two Files
      • 10.8.2 Arithmetic Using a Constant Value
    • 10.9 Applying CDO in Climate Computations
      • 10.9.1 Indian Ocean Dipole Example
      • 10.9.2 Sahel Rainfall Variability Example
      • 10.9.3 Creating a Land-Sea Mask File
    • 10.10 Using CDO with Python
  • Appendix
    • 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.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earnedover $14 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

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub