fm35-decoder 0.1.2__tar.gz → 1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,32 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # Distribution / packaging
7
+ dist/
8
+ build/
9
+ *.egg-info/
10
+ *.egg
11
+
12
+ # Virtual environments
13
+ .venv/
14
+ venv/
15
+ env/
16
+
17
+ # Testing and caching
18
+ .pytest_cache/
19
+ .mypy_cache/
20
+ .ruff_cache/
21
+ .coverage
22
+ htmlcov/
23
+
24
+ # Editor / IDE
25
+ .vscode/
26
+ .idea/
27
+ *.swp
28
+ *.swo
29
+
30
+ # OS files
31
+ .DS_Store
32
+ Thumbs.db
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.5
2
+ Name: fm35_decoder
3
+ Version: 1.0
4
+ Summary: A Python tool to decode standard FM35 TEMP weather messages from upper-air observations.
5
+ Project-URL: Homepage, https://github.com/luciodaou/fm35_decoder
6
+ Project-URL: Bug Tracker, https://github.com/luciodaou/fm35_decoder/issues
7
+ Author: Lucio Daou
8
+ License-File: LICENSE
9
+ Classifier: License :: OSI Approved :: MIT License
10
+ Classifier: Operating System :: OS Independent
11
+ Classifier: Programming Language :: Python :: 3
12
+ Requires-Python: >=3.12
13
+ Requires-Dist: numpy>=2.0.0
14
+ Requires-Dist: pandas>=3.0.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: pytest; extra == 'dev'
17
+ Description-Content-Type: text/markdown
18
+
19
+ # FM35 Decoder
20
+
21
+ [![Ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=flat&logo=ko-fi&logoColor=white)](https://ko-fi.com/luciodaou)
22
+ [![PyPI - Version](https://img.shields.io/pypi/v/fm35_decoder.svg)](https://pypi.org/project/fm35_decoder)
23
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fm35_decoder.svg)](https://pypi.org/project/fm35_decoder)
24
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
25
+
26
+ A fast, robust Python tool to decode standard **WMO FM 35 TEMP** upper-air weather messages from radiosonde observations.
27
+
28
+ For an extensive plain-English guide referencing official WMO manuals, see [TEMP_DECODING.md](TEMP_DECODING.md).
29
+
30
+ ---
31
+
32
+ ## Installation
33
+
34
+ Install the package directly from PyPI:
35
+
36
+ ```bash
37
+ pip install fm35_decoder
38
+ ```
39
+
40
+ ---
41
+
42
+ ## Quickstart
43
+
44
+ Import the decoder and call `decode()` with the message parts (`TTAA`, `TTBB`, `TTCC`, `TTDD`):
45
+
46
+ ```python
47
+ from fm35_decoder import decode
48
+
49
+ # Your FM35/TEMP message parts
50
+ ttaa = "TTAA 73121 83779 99938 21224 01008 00163 ///// ///// 92843 20019 07506 85570 18650 36008 ..."
51
+ ttbb = "TTBB 73128 83779 00938 21224 11882 16804 22870 19856 33735 11056 44712 08616 55615 01218 ..."
52
+ ttcc = "TTCC 73123 83779 70865 71568 15020 50064 67574 12519 30380 58383 08535 88906 77162 26018 ..."
53
+ ttdd = "TTDD 7312/ 83779 11906 77162 22585 70370 33542 70970 44445 63978 55283 57785 21212 11935 ..."
54
+
55
+ df_main, df_special = decode(ttaa, ttbb, ttcc, ttdd)
56
+
57
+ # df_main: Clean vertical sounding profile (Pressure, Height, Temp, DewPoint, WindDir, WindSpeed)
58
+ # df_special: Metadata, Tropopause, Maximum Wind, and Cloud groups
59
+ print(df_main)
60
+ print(df_special)
61
+ ```
62
+
63
+ ---
64
+
65
+ ## Handling Non-Standard and Extreme Meteorological Data
66
+
67
+ Real-world atmospheric soundings and teletype GTS transmissions frequently contain non-standard encodings, extreme conditions, and transmission artifacts. `fm35_decoder` handles them deterministically per WMO regulations:
68
+
69
+ - **Variable Wind Direction ($dd = 99$)**:
70
+ In WMO Code Table 0877, a wind direction reported as `99` indicates variable wind direction. The decoder sets `WindDir = np.nan` in `df_main` while preserving the numeric `WindSpeed`. Crucially, variable winds are excluded from trigonometric vector ($U/V$) decomposition so they do not distort the vertical wind field.
71
+ - **5-Degree Directional Resolution ($fff \ge 500$)**:
72
+ In WMO FM 35, when the units digit of wind direction is $5^\circ$ (e.g., $275^\circ$), $500$ is added to the reported wind speed ($fff$) across both standard levels and maximum wind groups ($77P_mP_mP_m$). The decoder accurately separates the $5^\circ$ direction component from the true wind speed, avoiding the common $500\text{ kt}$ speed inflation bug.
73
+ - **Calm Wind ($0^\circ, 0\text{ kt}$)**:
74
+ Calm wind is represented as `WindDir = 0.0, WindSpeed = 0.0`. True non-calm winds blowing from North are assigned `360.0°`.
75
+ - **GTS Transmission Sequence Breaks**:
76
+ If network or teletype line noise drops an intermediate significant level in `TTBB` or `TTDD` (e.g., group sequence jumps directly from `22` to `44`), the decoder recovers automatically rather than terminating or discarding the remainder of the sounding.
77
+ - **Negative Geopotential Heights ($1000\text{ hPa}$ below sea level)**:
78
+ When a $1000\text{ hPa}$ surface lies below sea level or below ground, WMO encodes it as $500 + |h|$. The decoder detects this offset and outputs true negative geopotential heights (e.g., `00520` $\implies -20\text{ gpm}$).
79
+ - **Stratospheric Standard Levels ($P < 10\text{ hPa}$)**:
80
+ Soundings reaching the middle stratosphere in `TTCC` ($7, 5, 3, 2, 1\text{ hPa}$) are evaluated against extended standard atmosphere heights up to $47,800\text{ gpm}$.
81
+ - **Physical Super-Saturation Prevention**:
82
+ Temperature inversions can cause vertical DewPoint interpolation to cross above Temperature. The decoder strictly enforces $T_d \le T$ ($\text{RH} \le 100\%$).
83
+
84
+ ---
85
+
86
+ ## Meteorological Methodology
87
+
88
+ ### Vertical Interpolation
89
+ - **Temperature & Dewpoint**: Missing intermediate levels are filled via linear interpolation with respect to the **natural logarithm of pressure** ($\ln P$). This aligns with atmospheric thermodynamics on Skew-T / Log-P diagrams where temperature varies approximately linearly with $\ln P$.
90
+ - **Wind Vectors**: Wind speed and direction are decomposed into orthogonal **$U$ (zonal)** and **$V$ (meridional)** vector components. Each component is interpolated independently in $\ln P$ space before being recombined, preventing boundary artifacts across the $0^\circ/360^\circ$ North transition.
91
+
92
+ ### Hypsometric Geopotential Calculation
93
+ Missing geopotential heights are computed using the Hypsometric Equation:
94
+ $$Z_2 - Z_1 = \frac{R_d \cdot \bar{T}_v}{g_0} \ln\left(\frac{P_1}{P_2}\right)$$
95
+ The decoder incorporates **virtual temperature ($T_v$)** when moisture data is available, accounting for air density variations in warm and humid tropical boundary layers.
96
+
97
+ ---
98
+
99
+ ## Performance & Architecture
100
+
101
+ - **In-Memory WMO Code Tables**: Core WMO tables (3931, 0777, 2700, 0513, 1600, 0515, 0509, 3849, 3872, and Common Code Table C-2) are compiled directly into memory in `tables.py`, providing sub-microsecond table access with zero disk I/O overhead.
102
+ - **NumPy Vectorization**: Hypsometric height integration and vector wind calculations leverage NumPy array operations for speed when batch-processing large archives of historical radiosonde soundings.
103
+
104
+ ---
105
+
106
+ ## Output Data Structure
107
+
108
+ ### `df_main` (Vertical Profile)
109
+ ```
110
+ Pressure Height Temp DewPoint WindDir WindSpeed
111
+ 1000 163 20.4 18.0 10.0 8.0
112
+ 938 714 21.2 18.8 10.0 8.0
113
+ 925 843 20.0 18.1 75.0 6.0
114
+ 882 1249 16.8 16.4 23.0 8.5
115
+ 870 1366 19.8 13.8 15.0 10.0
116
+ 850 1570 18.6 13.6 360.0 8.0
117
+ ... ... ... ... ... ...
118
+ 30 23800 -58.3 -91.3 85.0 35.0
119
+ 20 26480 -55.2 -89.0 90.0 38.0
120
+ 10 31020 -44.1 NaN 95.0 42.0
121
+ ```
122
+
123
+ ### `df_special` (Metadata & Special Levels)
124
+ ```
125
+ Symbol Subject Description Value
126
+ h Cloud Base Height 600-1000m (2000-3300ft)
127
+ Nh Cloud Amount 8 oktas
128
+ CL Cloud Low Type Stratus nebulosus and/or Stratus fractus
129
+ CM Cloud Mid Type No CM clouds
130
+ CH Cloud High Type No CH clouds
131
+ sr Solar/Inst Solar Corr NOAA solar corrected
132
+ rara Solar/Inst Sonde Type Vaisala RS41/DigiCORA MW41 (Finland)
133
+ sasa Solar/Inst Tracking Radar (5 cm)
134
+ 8GGgg Solar/Inst Time 11:31
135
+ PtPtPt Tropopause Pressure 906hPa
136
+ TtTtTt Tropopause Temperature -77.1C
137
+ DtDt Tropopause Dewpoint -89.1C
138
+ dtdtftft Tropopause Wind 260/18kt
139
+ PmPmPm Max Wind Pressure 200hPa
140
+ dmdmfmfmfm Max Wind Wind 275/120kt
141
+ vbvb Max Wind Shear Below 14kt
142
+ vava Max Wind Shear Above 14kt
143
+ ```
144
+
145
+ ---
146
+
147
+ ## License
148
+
149
+ This project is licensed under the terms of the **MIT License**.
150
+ You are free to use, modify, and distribute this software with attribution to the original author.
@@ -0,0 +1,132 @@
1
+ # FM35 Decoder
2
+
3
+ [![Ko-fi](https://img.shields.io/badge/Ko--fi-F16061?style=flat&logo=ko-fi&logoColor=white)](https://ko-fi.com/luciodaou)
4
+ [![PyPI - Version](https://img.shields.io/pypi/v/fm35_decoder.svg)](https://pypi.org/project/fm35_decoder)
5
+ [![PyPI - Python Version](https://img.shields.io/pypi/pyversions/fm35_decoder.svg)](https://pypi.org/project/fm35_decoder)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
7
+
8
+ A fast, robust Python tool to decode standard **WMO FM 35 TEMP** upper-air weather messages from radiosonde observations.
9
+
10
+ For an extensive plain-English guide referencing official WMO manuals, see [TEMP_DECODING.md](TEMP_DECODING.md).
11
+
12
+ ---
13
+
14
+ ## Installation
15
+
16
+ Install the package directly from PyPI:
17
+
18
+ ```bash
19
+ pip install fm35_decoder
20
+ ```
21
+
22
+ ---
23
+
24
+ ## Quickstart
25
+
26
+ Import the decoder and call `decode()` with the message parts (`TTAA`, `TTBB`, `TTCC`, `TTDD`):
27
+
28
+ ```python
29
+ from fm35_decoder import decode
30
+
31
+ # Your FM35/TEMP message parts
32
+ ttaa = "TTAA 73121 83779 99938 21224 01008 00163 ///// ///// 92843 20019 07506 85570 18650 36008 ..."
33
+ ttbb = "TTBB 73128 83779 00938 21224 11882 16804 22870 19856 33735 11056 44712 08616 55615 01218 ..."
34
+ ttcc = "TTCC 73123 83779 70865 71568 15020 50064 67574 12519 30380 58383 08535 88906 77162 26018 ..."
35
+ ttdd = "TTDD 7312/ 83779 11906 77162 22585 70370 33542 70970 44445 63978 55283 57785 21212 11935 ..."
36
+
37
+ df_main, df_special = decode(ttaa, ttbb, ttcc, ttdd)
38
+
39
+ # df_main: Clean vertical sounding profile (Pressure, Height, Temp, DewPoint, WindDir, WindSpeed)
40
+ # df_special: Metadata, Tropopause, Maximum Wind, and Cloud groups
41
+ print(df_main)
42
+ print(df_special)
43
+ ```
44
+
45
+ ---
46
+
47
+ ## Handling Non-Standard and Extreme Meteorological Data
48
+
49
+ Real-world atmospheric soundings and teletype GTS transmissions frequently contain non-standard encodings, extreme conditions, and transmission artifacts. `fm35_decoder` handles them deterministically per WMO regulations:
50
+
51
+ - **Variable Wind Direction ($dd = 99$)**:
52
+ In WMO Code Table 0877, a wind direction reported as `99` indicates variable wind direction. The decoder sets `WindDir = np.nan` in `df_main` while preserving the numeric `WindSpeed`. Crucially, variable winds are excluded from trigonometric vector ($U/V$) decomposition so they do not distort the vertical wind field.
53
+ - **5-Degree Directional Resolution ($fff \ge 500$)**:
54
+ In WMO FM 35, when the units digit of wind direction is $5^\circ$ (e.g., $275^\circ$), $500$ is added to the reported wind speed ($fff$) across both standard levels and maximum wind groups ($77P_mP_mP_m$). The decoder accurately separates the $5^\circ$ direction component from the true wind speed, avoiding the common $500\text{ kt}$ speed inflation bug.
55
+ - **Calm Wind ($0^\circ, 0\text{ kt}$)**:
56
+ Calm wind is represented as `WindDir = 0.0, WindSpeed = 0.0`. True non-calm winds blowing from North are assigned `360.0°`.
57
+ - **GTS Transmission Sequence Breaks**:
58
+ If network or teletype line noise drops an intermediate significant level in `TTBB` or `TTDD` (e.g., group sequence jumps directly from `22` to `44`), the decoder recovers automatically rather than terminating or discarding the remainder of the sounding.
59
+ - **Negative Geopotential Heights ($1000\text{ hPa}$ below sea level)**:
60
+ When a $1000\text{ hPa}$ surface lies below sea level or below ground, WMO encodes it as $500 + |h|$. The decoder detects this offset and outputs true negative geopotential heights (e.g., `00520` $\implies -20\text{ gpm}$).
61
+ - **Stratospheric Standard Levels ($P < 10\text{ hPa}$)**:
62
+ Soundings reaching the middle stratosphere in `TTCC` ($7, 5, 3, 2, 1\text{ hPa}$) are evaluated against extended standard atmosphere heights up to $47,800\text{ gpm}$.
63
+ - **Physical Super-Saturation Prevention**:
64
+ Temperature inversions can cause vertical DewPoint interpolation to cross above Temperature. The decoder strictly enforces $T_d \le T$ ($\text{RH} \le 100\%$).
65
+
66
+ ---
67
+
68
+ ## Meteorological Methodology
69
+
70
+ ### Vertical Interpolation
71
+ - **Temperature & Dewpoint**: Missing intermediate levels are filled via linear interpolation with respect to the **natural logarithm of pressure** ($\ln P$). This aligns with atmospheric thermodynamics on Skew-T / Log-P diagrams where temperature varies approximately linearly with $\ln P$.
72
+ - **Wind Vectors**: Wind speed and direction are decomposed into orthogonal **$U$ (zonal)** and **$V$ (meridional)** vector components. Each component is interpolated independently in $\ln P$ space before being recombined, preventing boundary artifacts across the $0^\circ/360^\circ$ North transition.
73
+
74
+ ### Hypsometric Geopotential Calculation
75
+ Missing geopotential heights are computed using the Hypsometric Equation:
76
+ $$Z_2 - Z_1 = \frac{R_d \cdot \bar{T}_v}{g_0} \ln\left(\frac{P_1}{P_2}\right)$$
77
+ The decoder incorporates **virtual temperature ($T_v$)** when moisture data is available, accounting for air density variations in warm and humid tropical boundary layers.
78
+
79
+ ---
80
+
81
+ ## Performance & Architecture
82
+
83
+ - **In-Memory WMO Code Tables**: Core WMO tables (3931, 0777, 2700, 0513, 1600, 0515, 0509, 3849, 3872, and Common Code Table C-2) are compiled directly into memory in `tables.py`, providing sub-microsecond table access with zero disk I/O overhead.
84
+ - **NumPy Vectorization**: Hypsometric height integration and vector wind calculations leverage NumPy array operations for speed when batch-processing large archives of historical radiosonde soundings.
85
+
86
+ ---
87
+
88
+ ## Output Data Structure
89
+
90
+ ### `df_main` (Vertical Profile)
91
+ ```
92
+ Pressure Height Temp DewPoint WindDir WindSpeed
93
+ 1000 163 20.4 18.0 10.0 8.0
94
+ 938 714 21.2 18.8 10.0 8.0
95
+ 925 843 20.0 18.1 75.0 6.0
96
+ 882 1249 16.8 16.4 23.0 8.5
97
+ 870 1366 19.8 13.8 15.0 10.0
98
+ 850 1570 18.6 13.6 360.0 8.0
99
+ ... ... ... ... ... ...
100
+ 30 23800 -58.3 -91.3 85.0 35.0
101
+ 20 26480 -55.2 -89.0 90.0 38.0
102
+ 10 31020 -44.1 NaN 95.0 42.0
103
+ ```
104
+
105
+ ### `df_special` (Metadata & Special Levels)
106
+ ```
107
+ Symbol Subject Description Value
108
+ h Cloud Base Height 600-1000m (2000-3300ft)
109
+ Nh Cloud Amount 8 oktas
110
+ CL Cloud Low Type Stratus nebulosus and/or Stratus fractus
111
+ CM Cloud Mid Type No CM clouds
112
+ CH Cloud High Type No CH clouds
113
+ sr Solar/Inst Solar Corr NOAA solar corrected
114
+ rara Solar/Inst Sonde Type Vaisala RS41/DigiCORA MW41 (Finland)
115
+ sasa Solar/Inst Tracking Radar (5 cm)
116
+ 8GGgg Solar/Inst Time 11:31
117
+ PtPtPt Tropopause Pressure 906hPa
118
+ TtTtTt Tropopause Temperature -77.1C
119
+ DtDt Tropopause Dewpoint -89.1C
120
+ dtdtftft Tropopause Wind 260/18kt
121
+ PmPmPm Max Wind Pressure 200hPa
122
+ dmdmfmfmfm Max Wind Wind 275/120kt
123
+ vbvb Max Wind Shear Below 14kt
124
+ vava Max Wind Shear Above 14kt
125
+ ```
126
+
127
+ ---
128
+
129
+ ## License
130
+
131
+ This project is licensed under the terms of the **MIT License**.
132
+ You are free to use, modify, and distribute this software with attribution to the original author.
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "fm35_decoder"
3
- version = "0.1.2"
3
+ version = "1.0"
4
4
  description = "A Python tool to decode standard FM35 TEMP weather messages from upper-air observations."
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.12"