forked from ecmwf/metview-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUC-07-bufr.py
More file actions
95 lines (71 loc) · 2.92 KB
/
UC-07-bufr.py
File metadata and controls
95 lines (71 loc) · 2.92 KB
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
"""
Metview Python use case
UC-07. The Analyst compute simple differences between observations and analysis
and plot the values
BUFR version - BUFR is not tabular or gridded, but we can use Metview Python
framework to extract a particular parameter to a tabular format (geopoints)
--------------------------------------------------------------------------------
1. Analyst retrieves the analysis from a gridded data file
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
2. Analyst retrieves an observational parameter from a tabular or a gridded file
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
3. Analyst calculates the difference between the observational data and the
analysis and classified the field values according to the magnitude of the
difference
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
4. Analyst customises many features of his graph in order to create
publication-quality plots
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
5. Analyst plots the data
--------------------------------------------------------------------------------
"""
import metview as mv
# define a view over the area of interest
area_view = mv.geoview(
map_area_definition = 'corners',
area = [45.83,-13.87,62.03,8.92]
)
t2m_grib = mv.read('./t2m_grib.grib')
obs_3day = mv.read('./obs_3day.bufr')
t2m_gpt = mv.obsfilter(
parameter = '012004',
output = 'geopoints',
data = obs_3day
)
diff = t2m_grib - t2m_gpt
diff_symb = mv.msymb(
legend = True,
symbol_type = 'marker',
symbol_table_mode = 'advanced',
)
mv.setoutput(mv.png_output(output_width = 1000, output_name = './obsdiff1'))
mv.plot(area_view, diff, diff_symb)
# Extract geopoints that are hotter by 1 deg or more
#hotter = mv.filter(diff, diff >= 1)
hotter = diff.filter(diff >= 1)
# Extract geopoints that are colder by 1 deg or more
#colder = mv.filter(diff, diff <= -1)
colder = diff.filter(diff <= -1)
# Get geopoints that are within +/-1
#exact = mv.filter(diff, (diff > -1) * (diff < 1))
exact = diff.filter((diff > -1) * (diff < 1))
# Symbol visdefs for each classification
red = mv.msymb(
symbol_type = 'marker',
symbol_colour = 'red'
)
blue = mv.msymb(
symbol_type = 'marker',
symbol_colour = 'blue'
)
grey = mv.msymb(
symbol_type = 'marker',
symbol_colour = 'grey'
)
# plot the 'exact' data set with visdef 'grey', 'hotter' with 'red', etc.
mv.setoutput(mv.png_output(output_width = 1000, output_name = './obsdiff2'))
mv.plot(area_view, exact, grey, hotter, red, colder, blue)