File: mv_scm_vis.mv

package info (click to toggle)
metview 4.4.8%2Bdfsg.1-8
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 34,112 kB
  • ctags: 35,138
  • sloc: cpp: 185,595; ansic: 61,514; sh: 12,517; xml: 4,003; makefile: 3,583; yacc: 1,183; fortran: 762; lex: 761; perl: 333; f90: 41; python: 10
file content (180 lines) | stat: -rw-r--r-- 5,406 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
#!/usr/bin/metview 
# Metview Macro

# **************************** LICENSE START ***********************************
#
# Copyright 2013 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 ************************************



#---------------------------------------------------------------
# Read arguments
#---------------------------------------------------------------

args=arguments()

if count(args) = 0 then
	fail("No arguments specified!")
end if

print("Arguments: ",args)

plot_type          = args[1]
nc_filename_1      = args[2]
data_title_1       = args[3]
compare            = args[4]
nc_filename_2      = args[5]
data_title_2       = args[6]
comparison_mode    = args[7]
var_selection_type = args[8]
vars_1d            = args[9]
vars_2d            = args[10]
times              = args[11]
output_mode        = args[12]
output_file_path   = args[13]

num_args = count(args)
if num_args > 13 then
    x_min_list   = args[14]
    x_max_list   = args[15]
    y_min_list   = args[16]
    y_max_list   = args[17]
    val_min_list = args[18]
    val_max_list = args[19]
    grid         = args[20]
else
    x_min_list = nil
    grid       = 'off'
end if


if plot_type = 'TIME_HEIGHT_MATRIX' or plot_type = 'PROFILE' then
    vars = vars_2d
else
    vars = vars_1d
end if

# convert into an actual list and convert to lowercase (ASSUME that all var names are lowercase!)
vars = parse(lowercase(vars), ',')


# convert the time list into an actual list
times = parse(times, ',')



# check whether we have any valid x/y/value/min/max lists
xyminmax_def = ()

if x_min_list <> nil then

    # supplied on command-line, but could still be empty

    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'x_min_list', x_min_list)
    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'x_max_list', x_max_list)
    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'y_min_list', y_min_list)
    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'y_max_list', y_max_list)
    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'value_min_list', val_min_list)
    xyminmax_def = add_xyminmax_to_def(xyminmax_def, 'value_max_list', val_max_list)

end if



# force ps output if more than one variable to be plotted
#if count(vars) > 1 then
#    if output_mode = 'SCREEN' then
#        print('Plotting multiple parameters: will generate a PostScript file')
#        output_mode = 'POSTSCRIPT'
#    end if
#end if


# remove .ps extension if needed
if output_mode = 'POSTSCRIPT' then
    len = length(output_file_path)
    if len > 3 then
        if substring(output_file_path,len-2,len) = '.ps' then
            output_file_path = substring(output_file_path, 1, len-3)
        end if
    end if
end if


# 2nd netCDF file for comparison?
if compare = 'ON' then
    netcdf_2 = nc_filename_2
else
    netcdf_2 = nil
end if


# to make the mvl macro happy
if comparison_mode = 'dummy' then
    comparison_mode = 'overlay'
end if

if grid = 'dummy' then
    grid = 'off'
end if


#---------------------------------------------------------------
# Generate the plot
#---------------------------------------------------------------


# we supply a parameter definition with some preferences. If mode = interactive,
# then a user interface will appear so that the user can make further selections;
# otherwise the macro will run using only the arguments defined here (and will
# produce a PostScript file).

scm_plot_params = 
(
    mode            : 'batch',  # 'interactive' or 'batch'
    plot_type       : lowercase(plot_type),
    netcdf_1        : nc_filename_1, #'/var/tmp/cgi/bigdata/scm/scmfiles/scm_out.nc',
    netcdf_2        : netcdf_2, #'scm_out_2.nc', # should be nil, or omit the parameter if no comparison file
    title_1         : data_title_1, # to appear in the legend
    title_2         : data_title_2, # to appear in the legend
    comparison_mode : lowercase(comparison_mode),      # 'overlay' or 'difference'
    output_mode     : lowercase(output_mode),          # 'postscript' or 'screen'
    output_path     : output_file_path, #'/var/tmp/cgi/PERFORCE/metview_4/metview_maintenance/src/Scm/scm_out',      # only if mode='batch'. Do not supply an extension.
    param_selection : 'list',         # 'list', 'file' or 'all'
    param_list_path : nil,            # path to a text file containing each parameter name on a new line
    param_list      : vars,    # if param_selection is 'list'
    times           : times,
    xyminmax_def,
    grid            : grid
    #param_list      : ['t_skin', 'top_lwrad_clr', 'u_wind_10m'] # if param_selection is 'list'
    #param_list      : ['t', 'pot_temperature', 'q', 't_snow', 'sfc_sen_flx'] # if param_list_path not specified
)


mvl_plot_scm_data(scm_plot_params)


stop(0)


function add_xyminmax_to_def(def, par_name, xy)

    if type(xy) = 'string' then
        if xy = 'dummy' then
            return def   # nothing supplied, don't alter the definition
        else
            lst = parse(xy, ',')
            def[par_name] = lst
        end if
    else # must be a single number
        def[par_name] = [xy]
    end if

    return def

end add_xyminmax_to_def