Metview's documentation is now on readthedocs!

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

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

XXXX

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

Netcdf Plot TypeGeo Matrix
Netcdf Latitude Variablelatitude
Netcdf Longitude Variablelongitude
Netcdf Value Variablev2d

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.

Create both a Vertical Profile View and a Vertical Profile Data icon and edit both to see the differences. All the parameters related to the visualisation of the result are only in the View icon, and the Data parameter exists only in the Data icon.

Dealing only with the Data icon now, drop the supplied input GRIB icon t_atmos.grib into the Data parameter box. Set the Point to whatever you like and save the icon. Now if you right-click and examine the icon, you will see the resulting netCDF file in the NetCDF Examiner. You can also save the result into a file for storage.

All of this can also be put into a macro, where the resulting netcdf variable can be further manipulated before being written to file (or visualised).

Write a short macro which computes a vertical profile from the data (use the Vertical Profile Data icon that you already set up) and writes the result to a file. To write a netcdf variable to a file, the syntax is the same as for any other data type:

write('output_file', data)

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.

This example shows a geopoints file containing dry bulb temperature at 2m (PARAMETER = 12004).

 

#GEO
PARAMETER = 12004
lat        long    level  date       time    value
#DATA
36.15      -5.35     0   19970810    1200    300.9
34.58      32.98     0   19970810    1200    301.6
41.97      21.65     0   19970810    1200    299.4
45.03       7.73     0   19970810    1200    294
45.67       9.7      0   19970810    1200    302.2
44.43       9.93     0   19970810    1200    293.4

If you have observation data which you wish to import into Metview, Geopoints is probably the best format because:

  1. it is easy to write data into this format
  2. Metview has lots of functions to manipulate data in this format

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 coloured_symbols icon into the Display Window to get a better view of the data.

Manipulating geopoints in Macro

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

gp = read('geopoints.gpt')
print('Num points: ', count(gp))
print('Min value: ', minvalue(gp))
print('Max value: ', maxvalue(gp))

Perform a simple data manipulation and return the result to Metview's user interface:

 return gp*100

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.

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.

The distance() function returns a new geopoints variable based on its input geopoint, where each point's value has been replaced by the distance of that point from the given location. The description of this function follows:

geopoints distance ( geopoints,number,number )
geopoints distance ( geopoints,list )

Returns geopoints with the value of each point being the distance in meters from the given geographical location. The location may be specified by supplying either two numbers (latitude and longitude respectively) or a 2-element list containing latitude and longitude in that order. The location should be specified in degrees.

 

Choose a location and use this function to compute the distances of the points from it. Assign the result to a variable called distances and return it to the user interface to examine the numbers.

Now we will see a boolean operator in action. The expression distances < 10000 will return a new geopoints variable where, for each point, if the input value was less than 10000, the resulting value will be 1; otherwise the resulting value will be zero. So the resulting geopoints will have a collection of ones and zeros. Confirm that this is the case.

The filter() function, from the documentation:

geopoints filter ( geopoints,geopoints )

A filter function to extract a subset of its geopoints input using a second geopoints as criteria. The two input geopoints must have the same number of values. The resulting output geopoints contains the values of the first geopoints where the value of the second geopoints is non-zero. It is usefully employed in conjunction with the comparison operators :

freeze = filter(temperature,temperature < 273.15)

The variable freeze will contain a subset of temperature where the value is below 273.15.

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

Converting between geopoints and GRIB

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

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.

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.

 

Station,Lat,Lon,T2m
1,71.1,28.23,271.3
2,70.93,-8.67,274.7
. . .

 

 

 

  • No labels