Versions Compared

Key

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

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful projection parameters

subpage_map_projection

subpage_x_axis_type
subpage_y_axis_type
subpage_x_min
subpage_y_min
subpage_x_max
subpage_y_max
Useful axis parameters
axis_orientation
axis_type
axis_grid

axis_grid_reference

axis_title
Code Block
themeConfluence
languagepython
titlePython - set-up of cartesian projection
collapsetrue
# importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="profile_step1")
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='regular',
    subpage_y_axis_type='logarithmic',   
    subpage_x_min=-70.,
    subpage_x_max=20.,
    subpage_y_min=1020.,
    subpage_y_max=10.,)
#define the vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='logarithmic',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Pressure',
    axis_title_font='arial',
    axis_title_font_style='bold',
    axis_title_height=1.,
    )
# define the horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',)
    
plot(output, projection, vertical, horizontal)
Column
width200px

 

 

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful input parameters

input_x_values

input_y_values
Useful graph parameters
graph_line_colour
graph_line_thickness
Code Block
themeConfluence
languagepython
titlePython - Input data for graph
collapsetrue
# importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="profile_step2")
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='regular',
    subpage_y_axis_type='logarithmic',   
    subpage_x_min=-70.,
    subpage_x_max=20.,
    subpage_y_min=1020.,
    subpage_y_max=10.,)
#define the vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='logarithmic',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Pressure',
    axis_title_font='arial',
    axis_title_font_style='bold',
    axis_title_height=1.,
    )
# define the horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',)
levels = [1.,2.,3,5,7,10,20,30,50,70,100,150,200,250,300,400,500,600,700,800,850,900,925,950,1000]
kelvin = numpy.array([263.118652344,254.822738647,242.517868042,223.301025391,219.254943848,216.710174561,216.507095337,
    215.398986816,211.643295288,207.18812561,207.172134399,217.097396851,
    223.809326172,235.13168335,243.377059937,260.635147095,272.02935791,
    272.145584106,273.448501587,279.562927246,281.745040894,285.503082275,287.543685913,289.284072876,292.170974731]) 
celsius = kelvin -273.16
# Define the input of the graph
data = minput(input_x_values = celsius,
        input_y_values = levels, )
#define the graph action.
graph = mgraph( legend='on' ,
            legend_user_text= 'Tempe', 
            graph_line_colour="navy", 
            graph_line_thickness= 3, )
    
plot(output, projection, vertical, horizontal, data, graph)
Column
width200px

 

 

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful input parameters

input_x_values

input_y_values
input_x_component_values
input_y_component_values
Useful graph parameters
graph_type
graph_flag_colour
graph_flag_length
legend
legend_user_text
Code Block
themeConfluence
languagepython
titlePython - Input data and Flags plotting
collapsetrue
# importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="profile_step2")
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='regular',
    subpage_y_axis_type='logarithmic',   
    subpage_x_min=-70.,
    subpage_x_max=20.,
    subpage_y_min=1020.,
    subpage_y_max=10.,)
#define the vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='logarithmic',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Pressure',
    axis_title_font='arial',
    axis_title_font_style='bold',
    axis_title_height=1.,
    )
# define the horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',)
levels = [1.,2.,3,5,7,10,20,30,50,70,100,150,200,250,300,400,500,600,700,800,850,900,925,950,1000]
kelvin = numpy.array([263.118652344,254.822738647,242.517868042,223.301025391,219.254943848,216.710174561,216.507095337,
    215.398986816,211.643295288,207.18812561,207.172134399,217.097396851,
    223.809326172,235.13168335,243.377059937,260.635147095,272.02935791,
    272.145584106,273.448501587,279.562927246,281.745040894,285.503082275,287.543685913,289.284072876,292.170974731]) 
celsius = kelvin -273.16
# Define the input of the graph
data = minput(input_x_values = celsius,
        input_y_values = levels, )
#define the graph action.
graph = mgraph( legend='on' ,
            legend_user_text= 'Tempe', 
            graph_line_colour="navy", 
            graph_line_thickness= 3, )
    
plot(output, projection, vertical, horizontal, data, graph)
Column
width200px

 

 

...

Section
Column
width50%
Info
titleParameters to check

 


 

Useful projection parameters

subpage_map_projection

subpage_x_axis_type
subpage_y_axis_type
subpage_x_date_min
subpage_y_min
subpage_x_date_max
subpage_y_max
Useful axis parameters
axis_orientation
axis_type
Code Block
themeConfluence
languagepython
titlePython - Date Coordinates system
collapsetrue
 # importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="time_serie_step1")
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='date',
    subpage_y_axis_type='regular',   
    subpage_x_date_min='2012-10-27 00:00:00',
    subpage_x_date_max='2012-11-02 12:00:00',
    subpage_y_max=1050.,
    subpage_y_min=950.,
    )
# Vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Pressure',
    axis_title_font='arial',
    axis_title_height=0.5,
    )
# Horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='date',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_line_style='dash',
    )
    
plot(output, projection, horizontal, vertical)
Column
width200px

 

 

 

Time Series: Using a CSV file as input of a curve

The values for our time series are in CSV (Comma-Separeted-Value) ascii file called msl.csv.

Code Block
titlefirst few lines of msl.csv
1,2012-10-27 00:00:00,1020.64125,0
2,2012-10-27 12:00:00,1017.261875,0.1220703125
3,2012-10-28 00:00:00,1014.27125,-9.58071727163e-21
4,2012-10-28 12:00:00,1011.97375,-2.80979885101e-20

The valid date is defined in the second column, the value of msl in the third.

This information need to be given to Magics . This can be done with the mtable data action.

The mgraph action will the be used to define the curev attributes. All the parameters can be found in the Graph Plotting Page.

You can always add a title using the mtext object.

Section
Column
width50%
Info
titleParameters to check

 


 

Useful table parameters

table_filename

table_variable_identifier_type
table_x_type
table_x_variable
table_y_variable
table_header_row
Useful graph parameters
graph_line_colour
legend
legend_user_text
Code Block
themeConfluence
languagepython
titlePython - Input data and Flags plotting
collapsetrue
# importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="time_serie_step2")
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='date',
    subpage_y_axis_type='regular',   
    subpage_x_date_min='2012-10-27 00:00:00',
    subpage_x_date_max='2012-11-02 12:00:00',
    subpage_y_max=1050.,
    subpage_y_min=950.,
    )
# Vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Pressure',
    axis_title_font='arial',
    axis_title_height=0.5,
    )
# Horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='date',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_line_style='dash',)
#load the csv file, and define how to interpret it
data = mtable(table_filename = "msl.csv",
    table_x_type='date',
    table_variable_identifier_type='index',
    table_x_variable = "2",
    table_y_variable = "3",
    table_header_row = 0
 )
#define the visualisation
graph = mgraph( legend='on' ,
    legend_user_text= '<font colour="navy" size="0.3"> Mean Sea Level</font>', 
    graph_line_colour="navy", 
    graph_line_thickness= 3, )
#add a title
title = mtext(
            text_lines= ['Mean Sea Level plotted as curve...', ],
            text_html= 'true',
            text_justification= 'left',
            text_font_size= 0.8,
            text_colour= 'charcoal',
        )
plot(output, projection, horizontal, vertical, data, graph, title)
Column
width200px

 

 Image Added

Time Series : Using Automatic Axis and bar plotting

Magics can automatically set-up the coordinates system according to the plotted data.

In this exercise, we will use this functionality to draw the time series of the precipitation.

  • The horizontal date coordinate system is set automatically.
  • The vertical coordinate system is regular going from 0 to 5

The data will be pass to Magics using arrays:

dates = ["2012-10-27 00:00:00","2012-10-27 12:00:00","2012-10-28 00:00:00",
        "2012-10-28 12:00:00","2012-10-29 00:00:00","2012-10-29 12:00:00",
        "2012-10-30 00:00:00","2012-10-30 12:00:00",
        "2012-10-31 00:00:00","2012-10-31 12:00:00",
        "2012-11-01 00:00:00","2012-11-01 12:00:00",
        "2012-11-02 00:00:00","2012-11-02 12:00:00"]
precip = [0.,0.1220703125,0.,0., 0., 3.16429138184,
            2.18200683594,1.75476074219,0,0,0,0,0,0.]

We want to display the information using bar plotting. 

We will perhaps need to check quickly

Section
Column
width50%
Info
titleParameters to check

 


 

Useful projection parameters

subpage_x_automatic

Useful input parameters

input_x_type

input_date_x_values
input_y_values
input_y2_values
Useful graph parameters
graph_type
graph_bar_line_colour
graph_shade_colour
legend
legend_user_text
Code Block
themeConfluence
languagepython
titlePython - Input data and Flags plotting
collapsetrue
# importing Magics module
from Magics.macro import *
# define the output
output = output(output_formats=['png'],
        output_name_first_page_number='off',
        output_name="time_serie_step3")
# Setting the cartesian view
projection = mmap(
    subpage_map_projection='cartesian',
    subpage_x_axis_type='date',
    subpage_y_axis_type='regular',   
    subpage_x_automatic='on',
    subpage_y_max=5.,
    subpage_y_min=0.,
    )
    
# Vertical axis
vertical = maxis(
    axis_orientation='vertical',
    axis_grid='on',
    axis_type='regular',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_reference_level=0.,
    axis_grid_reference_line_style='solid',
    axis_grid_reference_thickness=1,
    axis_grid_line_style='dash',
    axis_title='on',
    axis_title_text='Amount of rain',
    axis_title_font='arial',
    axis_title_height=0.5,
    )
# Horizontal axis
horizontal = maxis(
    axis_orientation='horizontal',
    axis_type='date',
    axis_tick_label_height=0.4,
    axis_tick_label_colour='charcoal',
    axis_grid='on',
    axis_grid_colour='charcoal',
    axis_grid_thickness=1,
    axis_grid_line_style='dash',
    )
dates = ["2012-10-27 00:00:00","2012-10-27 12:00:00","2012-10-28 00:00:00",
    "2012-10-28 12:00:00","2012-10-29 00:00:00","2012-10-29 12:00:00",
    "2012-10-30 00:00:00","2012-10-30 12:00:00",
    "2012-10-31 00:00:00","2012-10-31 12:00:00",
    "2012-11-01 00:00:00","2012-11-01 12:00:00",
    "2012-11-02 00:00:00","2012-11-02 12:00:00"]
    
precip = [0.,0.1220703125,0.,0., 0., 3.16429138184,
        2.18200683594,1.75476074219,0,0,0,0,0,0.]
#defining the data 
data = minput(
    input_x_type='date',
    input_date_x_values= dates,
    input_y2_values= precip,
    input_y_values= [0.] * len(precip),
     )
#defining the visualisation
bar = mgraph( legend='on' ,
        graph_type ='bar',
        graph_bar_line_colour = "navy",
        graph_shade_colour = "evergreen",
        legend_user_text= '<font colour ="evergreen" size="0.4"> Precipitation </font>', 
        graph_line_colour="navy", 
        graph_bar_width = 3600.00 *6,
        graph_line_thickness= 3, )
#adding a title  
title = mtext(
        text_lines=  ['Precipitation as Bar Plotting..', ],
        text_html= 'true',
        text_justification= 'left',
        text_font_size= 0.8,
        text_colour= 'charcoal',
    )
plot(output, projection, vertical, horizontal, data, bar, title)
Column
width200px

 

 Image Added