Origin 2021b brings improved support for importing and analyzing data stored in NetCDF files. NetCDF is a popular data file format for climate scientists, so we geared our features towards their needs.
In this blog post, I’ll introduce many of the features based on functional grouping. It will serve as a reference for subsequent blog posts where various features will be utilized to produce different analysis and graphing outcomes.
Note: you can download the NetCDF file from here (it is zipped).
NetCDF files are hierarchical by design, allowing the storage of single or multiple dimensional data variables. Additionally, NetCDF files can contain attributes associated with the data variables or the entire file itself. Origin’s NetCDF Data Connector allows the user to select a variable from a file and import it. Typically, single-dimensional variables are best imported into Origin Workbooks while multidimensional variables are best imported into Matrixbooks.
For climate science type data, users are typically concerned with multidimensional variables such as sea surface temperature or precipitation. This type of variable is gridded along a set of “standard” dimensions-
time (a date-time),
lat (latitude), and
lon (longitude). Sometimes there is a forth dimension that is many times labelled as
Let’s look at the basic steps of importing a multidimensional variable from a NetCDF file.
- From the Data menu in Origin, select Connect to File->NetCDF.
- Select a NetCDF file (*.nc or *.nc4).
- The Data Connector Browser dialog will appear. Observe the hierarchy of the variables in the left panel along with attributes display in the right panel.
- Select a multidimensional variable and click the Select Data to Import button.
- Optionally, specify Import Options (This will be discussed next).
- Click the OK button.
- The multidimensional variable will be imported as a stack of matrices in a matrixbook (we’ll learn more about this a bit later).
In the Data Connector Browser dialog, clicking the Import Options button opens a sub-dialog that allows specifying various options to control what is imported.
- From & To: data-time range to import.
- Time Axis for Skipping: Read m records and skip n records and repeat. For example, if data is monthly, Read:
11would read one month and skip 11 then repeat for the entire date-time range.
- Averaging: Perform an average based on an Interval and either Sampling by Across Years or Consecutive. For example, Sampling:
mwould calculate an aggregate average for each month for the date-time range.
- Longitude Shift: By convention, longitudes for NetCDF variables are based on a ~0 to ~360 degree mapping. Enabling this allows it to be shifted to ~-180 to ~180 degree mapping.
- Latitude Flip: Based on how a variable is stored, it may be imported “upside down”. This option corrects for that.
- Subregion: Specify a longitudinal and/or latitudinal subregion to import.
- Formula (v): Apply a mathematical formula to the data during import.
vrepresent the data value. for example,
(v*9/5)+32would shift temperate data from Celsius to Fahrenheit.
As I previous mentioned, a multidimensional variable is typically brought into stack of matrices in a matrixbook. More correctly, the stack resides in a Matrixsheet. The following features of matrixbook, sheet, and stack are relevant to imported NetCDF data. Here is a matrixbook with imported data:
Most items in the illustration are fairly clear but three require explanations:
Navigator: similar to the Data Connector Browser, the Navigator displays the hierarchy of the entire imported file. You can right-click on different multidimensional variable to import that variable into another matrixsheet. The Import Options from the first imported sheet will carry over to the newly imported sheet.
Data Connector icon: clicking the icon provide access to a number of features with the important ones being: re-importing the data, unlocking the imported data, removing the Data Connector, and, perhaps most importantly, access to the Import Options dialog to change import settings.
Mini Toolbar: provides buttons for important settings including Missing Value Color, Slider or Thumbnails, and Dimensions/Labels (see below).
The Dimensions/Labels feature provides access to the Long Name 、 Units labels for the X, Y, and Z dimensions of the matrix stack.
One last thing (it’s not on the Mini Toolbar). You can apply a color palette to the matrix stack via the regular Palette toolbar button.
Note that, from now on in this post, you will see that the matrix stack has had Missing Value Color and a Palette applied to it.
Region of Interest Features
Region of interests (ROIs) can be added to a matrix stack in order to operate on a subregion of the data in the stack. The animated illustration below shows how to create an ROI and the features associated with one.
You start by selecting the tool from the toolbar (there are different-shapes), and then dragging it onto the stack to create an ROI. You can add multiple ROIs to the same stack by changing the previous ROI‘s name (see below).
To work with an ROI, double-click on it to open a dialog to:
- Set its Name.
- Set its Coordinates.
You can also right-click to access a context menu of features including:
- Copy Positions 、 Paste Positions to another ROI.
- Export ROI positions to a file.
- Import ROI positions from a file and apply to the current ROI.
- Create New matrix stack from the ROI.
- Extract as XYZ data from stack to a worksheet.
- Generate an Intensity Profile for one or all ROIs and output to a worksheet. An Intensity Profile allows you to generate a statistic for the data within the ROI for each individual matrix in the stack. The generated data is 2D and is suitable for 2D graphing or analysis.
Note: In a future blog post, I’ll show you how you can create an ROI from a shape file!
Matrix Analysis Features
The Matrix 、 Analysis menus contain four analytical features applicable to NetCDF data.
- Pixel Extraction: Extracts values for an XY coordinate pair from every matrix in a stack. Output goes to a worksheet. Note: you can use the Screen Reader tool to pick out the point prior to opening the dialog from the menu.
- Linear Fit: Performs a linear fit of every XY coordinate pair in a matrix stack. Output goes to a new matrix stack.
- Descriptive Statistics: Calculates descriptive statistics for every XY coordinate pair in a matrix stack. Output goes to a new matrix stack.
- Subtract: Subtract matrices from each other. Output goes to a new matrix stack.
Subtract requires two matrix stacks (technically Matrixsheets)- A 、 B. B is subtracted from A. You can:
- Subtract the active matrix in B from the active one in A.
- Subtract the first matrix in B from the active one in A.
- Subtract the same matrix in B as the active one in A.
- Subtract the entire B stack from the A stack.
Not bad- just needed a little explanation!
The Intensity Profile 、 Pixel Extraction features generate 2D worksheet-based data and Origin has many well-known 2D graph types.
But what about matrix stack data? In this case, the primary graph type is the Image Plot. Image Plots are easy to make. You can add a world map, and even convert a single image plot into a Browser Graph. Watch:
This concludes this reference blog. We will add additional blog posts in the future demonstrating the various features in action. Thanks for taking the time to read through.