#Metview Macro

#  **************************** LICENSE START ***********************************
# 
#  Copyright 2019 ECMWF. This software is distributed under the terms
#  of the Apache License version 2.0. In applying this license, ECMWF does not
#  waive the privileges and immunities granted to it by virtue of its status as
#  an Intergovernmental Organization or submit itself to any jurisdiction.
# 
#  ***************************** LICENSE END ************************************
# 

#=============================================================================
# Function      : thermo_parcel_area
#
# Syntax        : thermo_parcel_area(parcel)
#                                          
# Category      : VISUAL
#
# OneLineDesc   : returns a set of coloured areas from a thermo parcel path
#
# Description   : Returns a set of coloured areas from a thermo parcel path
#
# Parameters    : parcel
# 
# Return Value  : a list of Input Visualisers that may be used in a plot() command
#
# Dependencies  : none
#
#==============================================================================

function thermo_parcel_area(parcel)

    pos_colour = 'RGB(0.9723,0.3846,0.4140)'
	neg_colour = 'RGB(0.4869,0.6589,0.9170)'
	return thermo_parcel_area(parcel, pos_colour, neg_colour)

end thermo_parcel_area

function thermo_parcel_area(parcel, pos_colour, neg_colour)

	if parcel = nil then
		return nil
	end if	
	
	area_lst = nil

	for i=1 to count(parcel.area) do	
		
		vis  = input_visualiser(
        	input_x_values  :   parcel.area[i].t,
        	input_y_values  :   parcel.area[i].p
        )
       
       	colour = neg_colour
       	if parcel.area[i].positive = 1 then
       		colour = pos_colour
		end if
                
        gr = mgraph(
        	graph_type : "area",        
        	graph_shade_colour: colour
        )      
       
       area_lst = area_lst & [vis, gr]
	end for       

	return area_lst

end thermo_parcel_area
