Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

Metview has much functionality for meteorological data types stored in ECMWF's MARS archive, for example GRIB, BUFR and ODB. But not all data comes in these formats. Therefore Metview has facilities to handle various other data types, which we will explore here.

XXXX Download data.

Visualiser Icons

Some formats, such as GRIB, are easy to visualise in Metview - just right-click, Visualise. This is because they are quite constrained in their contents and have enough standardised meta-data for a program to understand how they should be plotted. Some other formats, such as netCDF and tables of ASCII data are not easily interpreted for automatic plotting (which variables/columns should be selected and what do they represent?). Metview introduces the concept of the Visualiser icon, which we will use in some of the following examples.

NetCDF

NetCDF is a binary file format for storing multi-dimensional arrays of data and has enjoys wide academic usage.

Examining netCDF

Right-click on the supplied netcdf.nc icon and choose examine to see its structure. It consists of multi-dimensional variables, each of which has its own set of attributes; the file also has a set of global attributes.

Visualising netCDF

Create a new NetCDF Visualiser icon. Edit it and drop the netcdf.nc icon into the NetCDF Data field. Set the following parameters:

...

Save the changes, and visualise this new icon. See how the settings in the visualiser icon correspond to the variable names in the data. Now visualise another field from the same file. Use the supplied shading_20_levels icon on the plots.

Exporting Cross Sections and Profiles as netCDF

Metview uses netCDF internally for the results of some computations. In particular, the analysis views (e.g. Cross Section ViewVertical Profile View) do this, but their result data is not available to the user. Therefore, each of these views has a corresponding Data view. If the intention is to simply plot the result, then the View icons are more useful. But to store the result data, the Data icon is required.

...

Your macro should be 3 lines long (well, 3 commands anyway) - one to read the input GRIB file, one to compute the profile and one to write the result to disk.

Geopoints

Format overview

Geopoints is the ASCII format used by Metview to handle spatially irregular data (e.g. observations). There are a number of variations on the format, but the default one is a 6-column layout. The columns do not have to be aligned, but there must be at least one whitespace character between each entry.

...

Variants of the format allow 2-dimensional variables to be stored (e.g. U/V or speed/direction wind components), and another variant stores only lat, lon and value for a more compact file.

Examining geopoints

Examine the supplied geopoints.gpt icon to confirm the contents of the file. The columns are sortable. You may wish to open the file in an external text editor to see exactly what it looks like.

Visualising geopoints

Visualise the icon. The visdef used for geopoints is Symbol Plotting, and its default behaviour is to plot the actual numbers on the map. This can become cluttered, and text rendering can be slow. Drop the supplied symb_colours icon into the Display Window to get a better view of the data.

Computing some statistics in Macro

First, we will print some information about our geopoints data. Create a new Macro icon, type this code and run it:

...

Save the macro and see its result by right-clicking on its icon and choosing examine or visualise. We could also have put a write() command into the macro to write the result to a geopoints file.

Finding geopoints points within 100km of a given location

As a more complex example, we will combine two functions in order to find the locations of the points within a certain distance of a given location. We will use the same geopoints file as before.

...

Use this in combination with what you have already done to produce a geopoints variable consisting only of the points within 100km of your chosen location. Plot the result to confirm it.

Saving geopoints data

Geopoints variables can be saved to disk using the write() command:

Code Block
languagepy
 write('my_computed_data.gpt', points)

Converting between geopoints and GRIB

? Needed? Already covered in the Processing Data part!  XXXXXX

Other ASCII Data

ASCII Table Data

Metview incorporates functionality to read, process and visualise data stored in ASCII table files, including the commonly-used CSV (comma-separated value) format.

Visualising ASCII table data

Look at the supplied file t2_20120304_1400_1200.csv. This is a standard CSV file, with a header row at the top, followed by one row per observation, one column per field.

...

Visualise this icon to plot the data, and apply the supplied symb_colours icon to get a nicer plot.

Converting ASCII Table data to geopoints format

Although Metview has some functionality for handling this type of data in Macro, it can do much more with the geopoints format. Therefore, if the data points are in geographic coordinates, one useful exercise is to read one of these files and convert it to geopoints.

...

The macro can now write this to disk, return it to the user interface or process it further using all the available geopoints functions.

ASCII Lat / Lon Matrices

Have a look at the supplied Lat Lon Matrix file with the edit action. This is a simple text format for storing regularly-spaced geographical matrix data, which Metview can directly import. As soon as you do anything with this file (e.g. visualise or examine), Metview internally converts it into GRIB format (leaving the original file untouched). In this way, we can import such data into Metview and have access to all its GRIB/fieldset functionality.

Reading/Writing General ASCII Data to/from Disk

XXXX Supply a text file!

ASCII files that are not in Geopoints, ASCII Table or Lat/Long Matrix format can be read using the read() function. It will return a list of strings - one string will contain the contents of one line of the file. Look at the supplied text file and see that it contains a list of codes for meteorological parameters:

...

  • the write() function always takes a filename as its first argument, and it can take a string as its second argument
  • it always overwrites an existing file of the same name, so there exists another function, append() which will add your string to a new line on an existing file
  • so you will need to call write() once with the first line of text, and append() once with the list of parameters
  • the list of parameters will need to be flattened out into a string with '/' as the separator - this will need to be done in a loop with a string variable initialised to '', and each element added with the & operator

ODB

XXX need some data!

ODB stands for Observational DataBase and is developed at ECMWF to manage very large observational data volumes through the ECMWF IFS/4DVAR-system. The data structure of an ODB database can be seen as a table of variables called columns. Right-click examine the ODB Database icon to see a list of the variables in the data. The Data tab provides access to the actual data itself. ODB data can be filtered using ODB/SQL queries. The supplied ODB Filter icon contains an ODB/SQL query to retrieve certain columns of data. Edit it - note that this pre-prepared icon is using the ODB Database icon. Look at the ODB Query field to get an idea of what data will be filtered. Now close the editor and examine the icon to see the filtered subset of data it has produced.

Extra Work

Optimisations to file writing

The last ASCII example could be made more optimal, which could be important if dealing with large amounts of data:

...