Objectives
- Set-up a cartesian projection for the Cross section
- Configure the axis
- Load a netCDF file, and understand the information needed by Magics.
- Apply a shading
- Position the legend box
- Add a text.
You will need to download
- The Xsection netCDF Data
- and later
... the full solution
Setting of the cartesian projection
We want to show our Cross section in the following cartesian system:
- The vertical coordinate system is a logarithmic axis from 1000 hPa to 200 hPa.
- The horizontal coordinate system is a geoline axis from [50oN, 90oW] to [30oN, 60oW]
Have a look at the subpage documentation to learn how to setup a cartesian projection .
We just have to add 2 axis (1 vertical, 1 horizontal ) to materialise it on the plot. For backward compatibility, we have only one maxis object, the orientation is defined using the parameter axis_orientation.
Parameters to check
Useful subpage parameters |
---|
subpage_map_projection |
subpage_x_axis_type |
subpage_y_axis_type |
subpage_x_min_latitude |
subpage_x_min_longitude |
subpage_x_max_latitude |
subpage_x_max_longitude |
subpage_y_min |
subpage_y_max |
Adjusting the axis
By specialising the axis, you can improve your axis visualisation.
Have a look at the Axis Documentation to browse the possibilities.
Now, try to improve the readability of the line by specialising the horizontal axis.
Parameters to check
Useful axis parameters |
---|
axis_type |
axis_tick_label_height |
axis_tick_label_colour |
axis_grid |
axis_title |
Loading the netCDF data
In this exercise, we want to visualise a matrix stored in a netCDF file. netCDF is a very generic format, and can contain a lot of data. We will need to set up some information in order to explain to Magics which variable to plot, and how to interpret it.
The mnetcdf data action comes with a parameter list that can be found in the netCDF Input Page.
But first, let's see what is inside our netCDF Data
netCDF section { dimensions: levels = 85 ; longitude = 144 ; latitude = 144 ; p15220121030000000000001_1 = 2 ; p15220121030000000000001_2 = 144 ; orography_x_values = 144 ; orography_y1_values = 144 ; orography_y2_values = 144 ; variables: double levels(levels) ; double longitude(longitude) ; double latitude(latitude) ; double p13820121030000000000001(levels, longitude) ;
We want to display the variable p13820121030000000000001, and inform Magics that the dimensions of the matrix are described in the 2 variables levels and longitude.
The range of the vorticity values is quite small, then we would like to apply a scaling factor of 100000.
We will then just apply a basic contouring.
Parameters to check
Useful netCDF parameters |
---|
netcdf_filename |
netcdf_value_variable |
netcdf_field_scaling_factor |
netcdf_y_variable |
netcdf_x_variable |
netcdf_x_auxiliary_variable |
Creating a nice shading
Now, we just create a nice polygon shading.
The list of levels we want to use is : [-200., -100., -75., -50., -30., -20., -15., -13., -11., -9., -7., -5., -3., -1., 1., 3., 5., 7., 9., 11., 13., 15., 20., 30., 50., 75., 100., 200].
and the list of colours is : ["rgb(0,0,0.3)", "rgb(0,0,0.5)", "rgb(0,0,0.7)", "rgb(0,0,0.9)", "rgb(0,0.15,1)", "rgb(0,0.3,1)", "rgb(0,0.45,1)", "rgb(0,0.6,1)", "rgb(0,0.75,1)", "rgb(0,0.85,1)", "rgb(0.2,0.95,1)", "rgb(0.45,1,1)", "rgb(0.75,1,1)", "none", "rgb(1,1,0)","rgb(1,0.9,0)", "rgb(1,0.8,0)", "rgb(1,0.7,0)", "rgb(1,0.6,0)", "rgb(1,0.5,0)", "rgb(1,0.4,0)", "rgb(1,0.3,0)", "rgb(1,0.15,0)", "rgb(0.9,0,0)", "rgb(0.7,0,0)", "rgb(0.5,0,0)", "rgb(0.3,0,0)"],
Do not forget to turn the legend on ...
You could quickly check Contour Documentation
Parameters to check
Useful contour parameters |
---|
contour_level_selection_type |
contour_level_list |
contour_shade |
contour_shade_method |
contour_shade_colour_method |
contour_shade_colour_list |
legend |
Position the legend
By default, the legend is is positioned at the top of the plot. In this exercise we want to put see our legend on a column mode on the right of the plot.
The Information about the positional mode can be found in the Legend Documentation
Parameters to check
Useful legend parameters |
---|
legend |
legend_display_type |
legend_box_mode |
legend_box_x_position |
legend_box_y_position |
legend_box_x_length |
legend_box_y_length |
legend_box_blanking |
legend_border |
add a Title
Last thing to do here .. We add a title to the top..
Here we will use a combination of User text and automatic text ( read from the netCDF global attribute title)
To get the automatic title, you have to use the following tag <magics_title/>
Check the Text Plotting Page for more information
Parameters to check
Useful Text parameters |
---|
text_lines |
text_font_size |
text_colour |
text_font_style |
1 Comment
Yonghui Weng
I have installed Magics in my MacBook Pro with macOS 10.13.6, and encounter segmentation fault when run this example. Detail log are:
where Thread 8 crashed. Any idea? Thanks!