Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Section
Column
width250px

Column
width60%
Panel

Objectives


  • Set-up a cylindrical projection over the United States.
  • Apply land-shading on the coastlines.
  • Load a grib GRIB file containing Mean-Sea level Presssure and visualise it using black isolines.
  • Load a grib GRIB file containing Precipitation  and visualise it using shading technique.
  • Add a legend.Add a text.
  • Draw the position of New-York City
  • Draw a line to materialise the Xsection we are going to visualise in a next tutorial
  • Add a text.

You will need to download


 

 

Setting of the geographical area

The Geographical geographical area we want to work with today is defined by its lower-left corner [20oN, 110oEW] and its upper-right corner [70oN, 30oEW].

Have a look at the  subpage documentation to learn how to setup a projection .

Section
Column
width50%
Info
titleParameters to check

 


 

Useful subpage parameters

subpage_lower_left_longitude

subpage_lower_left_latitude
subpage_upper_right_longitude
subpage_upper_right_latitude
Code Block
themeConfluence
languagepython
titlePython - Setting a projection
collapsetrue
from Magics.macro import *
#setting the output 
output = output(    
                output_formats = ['png'],
                output_name = "map_step1",
                output_name_first_page_number = "off"
        )
#settings of the geographical area 
area = mmap(subpage_map_projection="cylindrical",
        subpage_lower_left_longitude=-110.,
        subpage_lower_left_latitude=20.,
        subpage_upper_right_longitude=-30.,
        subpage_upper_right_latitude=70.,
    )    
#Using a default coastlines to see the result
plot(output, area, mcoast())
Column
width200px

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful Coastlines parameters

map_coastline_land_shade

map_coastline_land_shade_colour
map_coastline_colour
map_grid_colour
map_grid_line_style
Code Block
themeConfluence
languagepython
titlePython - Coastlines
collapsetrue
from Magics.macro import *
#setting the output 
output = output(    
                output_formats = ['png'],
                output_name = "map_step2",
                output_name_first_page_number = "off"
        )
#settings of the geographical area 
area = mmap(subpage_map_projection="cylindrical",
        subpage_lower_left_longitude=-110.,
        subpage_lower_left_latitude=20.,
        subpage_upper_right_longitude=-30.,
        subpage_upper_right_latitude=70.,
    )     
 #settings of the caostlines
coast = mcoast(map_coastline_land_shade = "on",
      map_coastline_land_shade_colour = "cream",
      map_grid_line_style = "dash",
      map_grid_colour = "grey",
      map_label = "on",
      map_coastline_colour = "grey")
plot(output, area, coast)
Column
width200px

 

 

...

The visualisation of any data in Magics is done by combining 2 kind of objects. One, the Data Action,  is used to define the data and explain to Magics how to interpret it, the other one is called Visual Action and will define the type of visualisation and its attributes.

In this example our data are in a grib GRIB file msl.grib. The Data Action to be used is mgrib in is documented in Grib Input Documentation.

The Visualisation visualisation we want to apply is a basic contouring mcont, using black for the lines and . We want an interval of 5 hPa , between isolines. We also want to add a an automatic legend, with our own text "Mean Sea Level Pressure". Follow the link to access the Contouring Documentation.

...

The goal of this exercise is to discover a bit more the diverse styles of visualisation offered by the mcont object.

We are pre-processed grib a GRIB field containing the precipitation accumulated in the last 6 hours of the valid time. We want to disable the automatic scaling appled by Magics and use our own scaling factor, in this case 1000.

...

The position of New York is [41oN, 74oEW], we can give this position to Magics using the minput object, documented in Input Data Page.

...

The stating point is [50oN, 90oEW], the end point is  [30oN, 60oEW] : it can be passed to Magics using the minput object, documented in Input Data Page.

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful input parameters

input_x_values

input_y_values
Useful Graph parameters
graph_line
graph_line_colour
Code Block
themeConfluence
languagepython
titlePython - Adding a line
collapsetrue
from Magics.macro import *
#setting the output 
output = output(    
                output_formats = ['png'],
                output_name = "map_step7",
                output_name_first_page_number = "off"
        )

             
#---------------------------------------
# definition of the previous layers 
# ...
# ...
#---------------------------------------
#definition of the Xsection Line
xsection = minput(
            input_x_values    =    [-7490., -60.],
            input_y_values    =    [4150., 30.]
            )
#definition of the graph
line = mgraph( 
            graph_line_colour    =    "black",
            graph_line_thickness    =    4
            )
plot(output, area, coast, precip, shading, msl, contour, new_york, point, xsection, line, legend)
Column
width200px

 

 

...

The text facility is documented in the Text Plotting Page.

Section
Column
width50%
Info
titleParameters to check

 


 

Useful Text parameters

text_lines

text_font_size
text_colour
text_font_style

 

 

Code Block
themeConfluence
languagepython
titlePython - Adding a text
collapsetrue
from Magics.macro import *
#setting the output 
output = output(    
                output_formats = ['png'],
                output_name = "map_step8",
                output_name_first_page_number = "off"
        )

             
#---------------------------------------
# definition of the previous layers 
# ...
# ...
#---------------------------------------
#definition of the text
title = mtext(text_lines=['Sandy', '30th of October 2012'],
            text_font_size = 0.8,
            text_colour= "charcoal",
            text_font_style='bold',
        )
plot(output, area, coast, precip, shading, msl, contour, new_york, point, xsection, line, legend, title)
Column
width200px

 

 

Go to the next step...

Go back to the main page ...