Read NOAA GML atmospheric trace-gas ASCII data files as pandas DataFrames.
Project description
noaa-gml-file-reader
Read NOAA GML atmospheric trace-gas ASCII data files as
pandas.DataFrame objects — one function,
read_data(path).
Problems this solves
Reach for this if you are trying to:
- Read NOAA GML (ESRL/GMD) CO₂ or CH₄ data files in Python without writing a bespoke header parser.
- Load Mauna Loa (or any station's) CO₂ data into a pandas DataFrame —
surface-flask (event, monthly) or in-situ hourly
ccggfiles. - Parse NOAA greenhouse-gas ASCII (
.txt) files whose#-commented headers and-999.99missing-value sentinels trip uppandas.read_csv. - Handle both the pre-2020 (GMD) and current (GML) header formats without knowing which dialect a given file uses — the reader auto-detects.
What this reads
NOAA's Global Monitoring Laboratory (GML) publishes long-term atmospheric
trace-gas measurements (CO₂, CH₄, and others) as whitespace-delimited ASCII
files with a #-commented header — surface-flask event and monthly
series, in-situ hourly/daily series, and more, at
gml.noaa.gov/aftp/data/trace_gases.
This package turns one of those files into a tidy DataFrame, with the header's
column names and the documented missing-value sentinels handled for you.
Lineage (GMD → GML). NOAA renamed ESRL's Global Monitoring Division (GMD) to the Global Monitoring Laboratory (GML) in 2020, and the file header format changed with it. This package was originally
noaa_esrl_gmd_file_reader(2020); v2 renames it to noaa-gml-file-reader (importnoaa_gml_file_reader) and reads the current header format. See the breaking-change note below.
Install
pip install noaa-gml-file-reader
Requires Python ≥ 3.10 and pandas ≥ 2.0.
Usage
from noaa_gml_file_reader import read_data
df = read_data("co2_mlo_surface-flask_1_ccgg_month.txt")
print(df.head())
Real output (from the committed test fixture of the above Mauna Loa monthly file):
site year month value
0 MLO 1969 8 322.50
1 MLO 1969 9 321.36
2 MLO 1969 10 320.74
3 MLO 1969 11 321.98
4 MLO 1969 12 323.78
Columns come straight from the file's header; numeric columns are numeric
(value is float64, year/month are int64), and NOAA's missing-value
sentinels (-999.99, -999.999, nan) are parsed as NaN.
Supported dialects
read_data auto-detects the header dialect — you don't need to know NOAA's
format history to read a file:
| dialect | header key | column names from | seen in |
|---|---|---|---|
| current | # header_lines : N |
the bare column row that is the last header line | flask event, in-situ (hourly) |
| legacy (2020) | # number_of_header_lines: N |
the # data_fields: header line |
flask monthly |
Supported products are those catalogued in docs/format-notes.md
(CO₂/CH₄ surface-flask event + monthly, CO₂ in-situ hourly, at MLO). The header
grammar is site- and gas-agnostic, so other stations/species in the same product
families parse the same way.
Errors
An unparseable file raises UnrecognizedFormatError (carrying the path and
the file's first line) rather than returning data:
from noaa_gml_file_reader import read_data, UnrecognizedFormatError
try:
df = read_data("not-a-noaa-file.txt")
except UnrecognizedFormatError as err:
print(err)
v2 breaking changes
v2 is a breaking release (hence the major bump):
- Renamed
noaa_esrl_gmd_file_reader→noaa_gml_file_reader(distributionnoaa-gml-file-reader). - Raises
UnrecognizedFormatErroron unrecognized/malformed input. v1 returned an empty DataFrame on any parse failure — silently indistinguishable from "the file had no data" — which meant v1 failed silently on every current (post-2020) NOAA file. If you relied on the empty-DataFrame behavior, catch the exception instead. - Relicensed AGPL-3.0 → MIT.
Data & citation
The data are NOAA GML's, not this package's. Please cite the measurements per NOAA GML's guidance — each product directory under gml.noaa.gov/aftp/data/trace_gases ships a species-specific README with the citation text and data providers (the file headers also carry contact and reciprocity information). This library only parses the files; it does not download them.
License
MIT — see LICENSE.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file noaa_gml_file_reader-2.0.2.tar.gz.
File metadata
- Download URL: noaa_gml_file_reader-2.0.2.tar.gz
- Upload date:
- Size: 32.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f592e0cc43dce1806398e8bce5513b5be66886198210e9991d614628b3bd6ce
|
|
| MD5 |
a2c499064063a8456a74ef1b52b8c69f
|
|
| BLAKE2b-256 |
2b5917693ce051a140a0522ca1aa3d219665a0a13596bf7583cc623030d0c2d5
|
Provenance
The following attestation bundles were made for noaa_gml_file_reader-2.0.2.tar.gz:
Publisher:
publish.yml on ErickShepherd/noaa-gml-file-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noaa_gml_file_reader-2.0.2.tar.gz -
Subject digest:
9f592e0cc43dce1806398e8bce5513b5be66886198210e9991d614628b3bd6ce - Sigstore transparency entry: 2135618945
- Sigstore integration time:
-
Permalink:
ErickShepherd/noaa-gml-file-reader@4c95e4cfa1c7c05243b59827ce6e92f1b6e40648 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/ErickShepherd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c95e4cfa1c7c05243b59827ce6e92f1b6e40648 -
Trigger Event:
release
-
Statement type:
File details
Details for the file noaa_gml_file_reader-2.0.2-py3-none-any.whl.
File metadata
- Download URL: noaa_gml_file_reader-2.0.2-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
54fe56d96e43411d5dfe2667dec43d75302f16aa35fd926d5be042afe37a68e5
|
|
| MD5 |
764ffca989ccb67058912ce9f2d837bd
|
|
| BLAKE2b-256 |
bd74d5ffcc52b48cc7be7d8ba83b7715e6cd42858e9d6906cd3fe9f900e2e7c1
|
Provenance
The following attestation bundles were made for noaa_gml_file_reader-2.0.2-py3-none-any.whl:
Publisher:
publish.yml on ErickShepherd/noaa-gml-file-reader
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
noaa_gml_file_reader-2.0.2-py3-none-any.whl -
Subject digest:
54fe56d96e43411d5dfe2667dec43d75302f16aa35fd926d5be042afe37a68e5 - Sigstore transparency entry: 2135619000
- Sigstore integration time:
-
Permalink:
ErickShepherd/noaa-gml-file-reader@4c95e4cfa1c7c05243b59827ce6e92f1b6e40648 -
Branch / Tag:
refs/tags/v2.0.2 - Owner: https://github.com/ErickShepherd
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4c95e4cfa1c7c05243b59827ce6e92f1b6e40648 -
Trigger Event:
release
-
Statement type: