IODA Bundle
bufr2ncCommon.py
Go to the documentation of this file.
1 #!/usr/bin/env python3
2 
3 from __future__ import print_function
4 
5 
6 ###########################################################################
7 # SUBROUTINES
8 ###########################################################################
9 
10 ###########################################################################
11 # CONSTANTS
12 ###########################################################################
13 
14 # Some handy constants. These become global variables in this script. Using
15 # naming convention of all caps to remind us that these are not to be changed.
16 
17 # MAX_STRING_LEN is good with 10 characters. This is the length of the long
18 # format for date and time. Most of the id labels are 6 or 8 characters.
19 MAX_STRING_LEN = 20
20 
21 # MAX_EVENTS will usually be limited to 255 due to an array size in the Fortran
22 # interface. In practice, there are typically a handful of events (4 or 5)
23 # since the events are related to the steps that are gone through to convert a
24 # raw BUFR file to a prepBUFR file (at NCEP). It is generally accepted that 20
25 # is a safe limit (instead of 255) for the max number of events, so set
26 # MAX_EVENTS to 20 to help conserve file space.
27 MAX_EVENTS = 20
28 
29 # MAX_LEVELS should be limited to 255 by a Fortran array size. This may need to
30 # change in the future since this number corresponds to the number of
31 # atmospheric levels in an observation.
32 MAX_LEVELS = 255
33 
34 # BUFR file types
35 BFILE_UNDEF = 0
36 BFILE_BUFR = 1
37 BFILE_PREPBUFR = 2
38 
39 # BUFR types
40 BTYPE_UNDEF = 0
41 BTYPE_HEADER = 1
42 BTYPE_DATA = 2
43 BTYPE_EVENT = 3
44 BTYPE_REP = 4
45 
46 # Data types
47 DTYPE_UNDEF = 0
48 DTYPE_STRING = 1 # for CCITT IA5 units in the BUFR table
49 DTYPE_INTEGER = 2 # for CODE TABLE, FLAG TABLE units in the BUFR table
50 DTYPE_FLOAT = 3 # for all other units in the BUFR table
51 DTYPE_UINT = 4 # for dimension coordinates
52 DTYPE_DOUBLE = 5 # temporary: for strings that are expected to be double
53 # in downstream flows (GSI)