noaaplotter 1.0.0__py3-none-any.whl

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,232 @@
1
+ import datetime as dt
2
+ import json
3
+ import os
4
+ import warnings
5
+ from datetime import datetime, timedelta
6
+
7
+ import numpy as np
8
+ import pandas as pd
9
+ import polars as pl
10
+ import requests
11
+ import tqdm
12
+ from joblib import Parallel, delayed
13
+
14
+ from noaaplotter.utils.utils import assign_numeric_datatypes
15
+
16
+
17
+ # move some logic outside
18
+ def download_from_noaa(
19
+ output_file,
20
+ start_date,
21
+ end_date,
22
+ datatypes,
23
+ loc_name,
24
+ station_id,
25
+ noaa_api_token="",
26
+ n_jobs=4,
27
+ ):
28
+ # Data comes from the NCEI Access Data Service (
29
+ # https://www.ncei.noaa.gov/access/services/data/v1 ), a public endpoint
30
+ # that requires no token. `noaa_api_token` is accepted for backward
31
+ # compatibility (it was needed by the earlier token-based CDO API) but is
32
+ # not required — pass an empty string when no token is available.
33
+ # The service wants the bare station id ("USW00026616"). The "GHCND:"
34
+ # prefix is only used by the older CDO *catalog* and would make the data
35
+ # request silently return 0 rows — strip it so either form works.
36
+ if ":" in station_id:
37
+ station_id = station_id.split(":")[-1]
38
+
39
+ # Check if file exists and load it
40
+ if os.path.exists(output_file):
41
+ existing_df = pl.read_parquet(output_file).drop_nulls(subset="STATION")
42
+ existing_dates = set(existing_df["DATE"].to_list())
43
+ else:
44
+ existing_df = None
45
+ existing_dates = set()
46
+
47
+ # Convert datestrings to datetime
48
+ dt_start = datetime.strptime(start_date, "%Y-%m-%d")
49
+ dt_end = datetime.strptime(end_date, "%Y-%m-%d")
50
+
51
+ # Calculate date range
52
+ all_dates = set(pd.date_range(start=dt_start, end=dt_end).strftime("%Y-%m-%d"))
53
+ missing_dates = sorted(list(all_dates - existing_dates))
54
+
55
+ if not missing_dates:
56
+ print("No new data to download.")
57
+ return 0
58
+
59
+ # Find contiguous date ranges to download
60
+ date_ranges = []
61
+ range_start = missing_dates[0]
62
+ prev_date = datetime.strptime(missing_dates[0], "%Y-%m-%d")
63
+
64
+ for date_str in missing_dates[1:] + [None]: # Add None to handle the last range
65
+ if date_str is None or datetime.strptime(
66
+ date_str, "%Y-%m-%d"
67
+ ) - prev_date > timedelta(days=1):
68
+ date_ranges.append((range_start, prev_date.strftime("%Y-%m-%d")))
69
+ if date_str is not None:
70
+ range_start = date_str
71
+ prev_date = datetime.strptime(date_str, "%Y-%m-%d") if date_str else None
72
+
73
+ # Data Loading
74
+ print("Downloading missing data through NOAA API")
75
+ all_new_data = []
76
+
77
+ for start, end in date_ranges:
78
+ print(f"Downloading data from {start} to {end}")
79
+ n_days = (
80
+ datetime.strptime(end, "%Y-%m-%d") - datetime.strptime(start, "%Y-%m-%d")
81
+ ).days + 1
82
+ split_size = np.floor(1000 / len(datatypes))
83
+ split_range = np.arange(0, n_days, split_size)
84
+
85
+ datasets_list = Parallel(n_jobs=n_jobs)(
86
+ delayed(dl_noaa_api)(
87
+ i, datatypes, station_id, noaa_api_token, start, end, split_size
88
+ )
89
+ for i in tqdm.tqdm(split_range[:])
90
+ )
91
+
92
+ # Drop empty/None from datasets_list
93
+ datasets_list = [i for i in datasets_list if i is not None]
94
+ all_new_data.extend(datasets_list)
95
+
96
+ # Merge subsets and create DataFrame
97
+ if all_new_data:
98
+ df = pd.concat(all_new_data)
99
+ else:
100
+ df = None
101
+ if df is None or len(df) == 0 or not list(df.columns):
102
+ if existing_df is not None and len(existing_df) > 0:
103
+ # Nothing new to add (e.g. requested dates not yet published by NOAA).
104
+ # Keep the existing data instead of erroring.
105
+ print(
106
+ "No new data returned; keeping existing data "
107
+ f"({existing_df.height} rows) in {output_file}."
108
+ )
109
+ return 0
110
+ raise ValueError(
111
+ "No data returned from NOAA for station "
112
+ f"{station_id} in {start_date}..{end_date}. Use the bare station id "
113
+ "(e.g. 'USW00026616' — the 'GHCND:' prefix is stripped automatically) "
114
+ "and check the dates fall within the record."
115
+ )
116
+
117
+ df_pivot = assign_numeric_datatypes(df)
118
+ df_pivot["DATE"] = df_pivot.apply(
119
+ lambda x: datetime.fromisoformat(x["DATE"]).strftime("%Y-%m-%d"), axis=1
120
+ )
121
+
122
+ # Drop any API/index column that leaked into the frame, plus empty rows.
123
+ for c in list(df_pivot.columns):
124
+ if c.startswith("__index_level"):
125
+ df_pivot = df_pivot.drop(columns=[c])
126
+ df_pivot = df_pivot.dropna(subset=["DATE"])
127
+ if "TAVG" not in df_pivot.columns:
128
+ df_pivot["TAVG"] = None
129
+ if "SNOW" not in df_pivot.columns:
130
+ df_pivot["SNOW"] = None
131
+ final_cols = ["STATION", "NAME", "DATE", "PRCP", "SNOW", "TAVG", "TMAX", "TMIN"]
132
+ df_pivot["NAME"] = loc_name
133
+ df_new = df_pivot[final_cols].copy().drop_duplicates(subset=["DATE"], keep="last")
134
+
135
+ if existing_df is not None:
136
+ # Incremental run: keep only the freshly-downloaded rows and merge them
137
+ # over the existing cache. keep="last" lets the fresh rows win for the
138
+ # re-downloaded dates; every other existing date is left untouched. We
139
+ # deliberately do NOT build a full-window skeleton here — that used to
140
+ # create NaN rows for every already-cached day and corrupt the cache.
141
+ df_final = pd.concat(
142
+ [existing_df.to_pandas()[final_cols], df_new]
143
+ ).drop_duplicates(subset=["DATE"], keep="last")
144
+ else:
145
+ # Fresh run: build a skeleton over the full requested window so any
146
+ # dates the API didn't return become explicit NaN rows.
147
+ dr = pd.DataFrame(
148
+ pd.date_range(start=start_date, end=end_date).strftime("%Y-%m-%d"),
149
+ columns=["DATE"],
150
+ )
151
+ df_merged = pd.concat(
152
+ [df_pivot.set_index("DATE"), dr.set_index("DATE")],
153
+ join="outer",
154
+ axis=1,
155
+ sort=True,
156
+ )
157
+ df_merged["DATE"] = df_merged.index
158
+ df_merged["NAME"] = loc_name
159
+ df_final = df_merged[final_cols].copy()
160
+
161
+ # Ensure the observed-value columns are real floats (not strings). Parquet
162
+ # stores NaN as a null and polars reads it back as null — this avoids the
163
+ # "horizontal_mean expects numeric expressions, found ... (dtype=str)" error.
164
+ for c in ("PRCP", "SNOW", "TAVG", "TMAX", "TMIN"):
165
+ if c in df_final.columns:
166
+ df_final[c] = pd.to_numeric(df_final[c], errors="coerce").astype("float64")
167
+
168
+ # Defensive: drop any stray index columns and reset to a default index so
169
+ # to_parquet does not serialize the (date or integer) index as an extra
170
+ # `__index_level_0__` column.
171
+ for c in list(df_final.columns):
172
+ if c.startswith("__index_level"):
173
+ df_final = df_final.drop(columns=[c])
174
+ df_final = df_final.reset_index(drop=True)
175
+
176
+ print(f"Saving data to {output_file}")
177
+ df_final.to_parquet(output_file)
178
+ return 0
179
+
180
+
181
+ def dl_noaa_api(i, dtypes, station_id, noaa_api_token, date_start, date_end, split_size):
182
+ """
183
+ function to download from NOAA API
184
+ """
185
+ dt_start = dt.datetime.strptime(date_start, "%Y-%m-%d")
186
+ dt_end = dt.datetime.strptime(date_end, "%Y-%m-%d")
187
+
188
+ split_start = dt_start + timedelta(days=i)
189
+ split_end = dt_start + timedelta(days=i + split_size - 1)
190
+ split_end = min(split_end, dt_end)
191
+
192
+ date_start_split = split_start.strftime("%Y-%m-%d")
193
+ date_end_split = split_end.strftime("%Y-%m-%d")
194
+ if noaa_api_token:
195
+ warnings.warn(
196
+ "a NOAA token was supplied but is ignored: the endpoint in use "
197
+ "(https://www.ncei.noaa.gov/access/services/data/v1) is public and "
198
+ "needs no token.",
199
+ DeprecationWarning,
200
+ stacklevel=2,
201
+ )
202
+
203
+ # make the api call
204
+ request_url = "https://www.ncei.noaa.gov/access/services/data/v1"
205
+ request_params = dict(
206
+ dataset="daily-summaries",
207
+ dataTypes=dtypes, # ['PRCP', 'TMIN', 'TMAX'],
208
+ stations=station_id,
209
+ limit=1000,
210
+ startDate=date_start_split,
211
+ endDate=date_end_split,
212
+ units="metric",
213
+ format="json",
214
+ )
215
+ # token is not required by this endpoint; send it only if one is provided
216
+ # (kept for any legacy/optional use, harmless if ignored on the server)
217
+ r = requests.get(
218
+ request_url, params=request_params,
219
+ headers={"token": noaa_api_token} if noaa_api_token else {},
220
+ )
221
+
222
+ # workaround to skip empty returns (no data within period)
223
+ try:
224
+ # load the api response as a json
225
+ d = json.loads(r.text)
226
+ result = pd.DataFrame(d)
227
+ except json.JSONDecodeError:
228
+ print(
229
+ f"Warning: No data available for period {date_start_split} to {date_end_split}. Skipping."
230
+ )
231
+ result = None
232
+ return result
@@ -0,0 +1,49 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ ########################
5
+ # Credits here
6
+ # author: Ingmar Nitze, Alfred Wegener Institute for Polar and Marine Research
7
+ # contact: ingmar.nitze@awi.de
8
+ # version: 2021-09-11
9
+
10
+ ########################
11
+
12
+ # TODO: move to external file
13
+ def setup_monthly_plot_props(information, anomaly):
14
+ plot_kwargs = {}
15
+ if information.lower() == 'temperature':
16
+ plot_kwargs['cmap'] = 'RdBu_r'
17
+ plot_kwargs['fc_low'] = '#4393c3'
18
+ plot_kwargs['fc_high'] = '#d6604d'
19
+ if anomaly:
20
+ plot_kwargs['value_column'] = 'tmean_diff'
21
+ plot_kwargs['y_label'] = 'Temperature departure [°C]'
22
+ plot_kwargs['title'] = 'Monthly departure from climatological mean (1981-2010)'
23
+ plot_kwargs['legend_label_above'] = 'Above average'
24
+ plot_kwargs['legend_label_below'] = 'Below average'
25
+ else:
26
+ plot_kwargs['value_column'] = 'tmean_doy_mean'
27
+ plot_kwargs['y_label'] = 'Temperature [°C]'
28
+ plot_kwargs['title'] = 'Monthly Mean Temperature'
29
+ plot_kwargs['legend_label_above'] = 'Above freezing'
30
+ plot_kwargs['legend_label_below'] = 'Below freezing'
31
+
32
+ elif information.lower() == 'precipitation':
33
+ plot_kwargs['fc_low'] = '#d6604d'
34
+ plot_kwargs['fc_high'] = '#4393c3'
35
+ if anomaly:
36
+ plot_kwargs['cmap'] = 'RdBu'
37
+ plot_kwargs['value_column'] = 'prcp_diff'
38
+ plot_kwargs['y_label'] = 'Precipitation departure [mm]'
39
+ plot_kwargs['title'] = 'Monthly departure from climatological mean (1981-2010)'
40
+ plot_kwargs['legend_label_above'] = 'Above average'
41
+ plot_kwargs['legend_label_below'] = 'Below average'
42
+ else:
43
+ plot_kwargs['cmap'] = 'Blues'
44
+ plot_kwargs['value_column'] = 'prcp_sum'
45
+ plot_kwargs['y_label'] = 'Precipitation [mm]'
46
+ plot_kwargs['title'] = 'Monthly Precipitation'
47
+ plot_kwargs['legend_label_below'] = ''
48
+ plot_kwargs['legend_label_above'] = 'Monthly Precipitation'
49
+ return plot_kwargs
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/python
2
+ # -*- coding: utf-8 -*-
3
+
4
+ ########################
5
+ # Credits here
6
+ # author: Ingmar Nitze, Alfred Wegener Institute for Polar and Marine Research
7
+ # contact: ingmar.nitze@awi.de
8
+ # version: 2020-12-09
9
+
10
+ ########################
11
+ import datetime as dt
12
+ from datetime import timedelta
13
+ import requests, json
14
+ import pandas as pd
15
+
16
+
17
+ #import datetime
18
+
19
+
20
+ def parse_dates(date):
21
+ """
22
+
23
+ :param date:
24
+ :return:
25
+ """
26
+ if isinstance(date, str):
27
+ return dt.datetime.strptime(date, '%Y-%m-%d')
28
+ elif isinstance(date, dt.datetime) or isinstance(date, dt.date):
29
+ return date
30
+ else:
31
+ raise ('Wrong date format. Either use native datetime format or "YYYY-mm-dd"')
32
+
33
+
34
+ def calc_trailing_mean(df, length, feature, new_feature):
35
+ """
36
+ :param df:
37
+ :param length:
38
+ :param feature:
39
+ :param new_feature:
40
+ :return:
41
+
42
+ """
43
+ df[new_feature] = df[feature].rolling(length).mean()
44
+ return df
45
+
46
+
47
+ def parse_dates_YM(date):
48
+ """
49
+ :param date:
50
+ :return:
51
+ """
52
+ if isinstance(date, str):
53
+ return dt.datetime.strptime(date, '%Y-%m')
54
+ elif isinstance(date, dt.datetime):
55
+ return date
56
+ else:
57
+ raise('Wrong date format. Either use native datetime format or "YYYY-mm-dd"')
58
+
59
+
60
+ def dl_noaa_api(i, dtypes, station_id, noaa_api_token, date_start, date_end, split_size):
61
+ """
62
+ function to download from NOAA API
63
+ """
64
+ dt_start = dt.datetime.strptime(date_start, '%Y-%m-%d')
65
+ dt_end = dt.datetime.strptime(date_end, '%Y-%m-%d')
66
+
67
+ split_start = dt_start + timedelta(days=i)
68
+ split_end = dt_start + timedelta(days=i + split_size - 1)
69
+ if split_end > dt_end:
70
+ split_end = dt_end
71
+
72
+ date_start_split = split_start.strftime('%Y-%m-%d')
73
+ date_end_split = split_end.strftime('%Y-%m-%d')
74
+
75
+ # make the api call
76
+ request_url = 'https://www.ncei.noaa.gov/access/services/data/v1'
77
+ request_params = dict(
78
+ dataset = 'daily-summaries',
79
+ dataTypes = dtypes,#['PRCP', 'TMIN', 'TMAX'],
80
+ stations = station_id,
81
+ limit = 1000,
82
+ startDate = date_start_split,
83
+ endDate= date_end_split,
84
+ units='metric',
85
+ format='json'
86
+ )
87
+ r = requests.get(
88
+ request_url,
89
+ params=request_params,
90
+ headers={'token': noaa_api_token} if noaa_api_token else {})
91
+
92
+ # workaround to skip empty returns (no data within period)
93
+ try:
94
+ # load the api response as a json
95
+ d = json.loads(r.text)
96
+ result = pd.DataFrame(d)
97
+ except json.JSONDecodeError:
98
+ print(f"Warning: No data available for period {date_start_split} to {date_end_split}. Skipping.")
99
+ result = None
100
+ return result
101
+
102
+
103
+ def assign_numeric_datatypes(df):
104
+ for col in df.columns:
105
+ if df[col].dtype == 'object':
106
+ try:
107
+ df[col] = pd.to_numeric(df[col])
108
+ except:
109
+ pass
110
+ return df
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.4
2
+ Name: noaaplotter
3
+ Version: 1.0.0
4
+ Summary: Package to plot fancy climate/weather data of NOAA
5
+ Author-email: Ingmar Nitze <ingmar.nitze@awi.de>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/initze/noaaplotter
8
+ Project-URL: Repository, https://github.com/initze/noaaplotter
9
+ Project-URL: Issues, https://github.com/initze/noaaplotter/issues
10
+ Project-URL: Documentation, https://initze.github.io/noaaplotter
11
+ Keywords: climate,weather,NOAA,plotting
12
+ Classifier: License :: OSI Approved :: MIT License
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.11
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Programming Language :: Python :: 3 :: Only
17
+ Classifier: Topic :: Scientific/Engineering :: Atmospheric Science
18
+ Classifier: Intended Audience :: Science/Research
19
+ Requires-Python: >=3.11
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: pandas>=2.2
23
+ Requires-Dist: numpy<3,>=2
24
+ Requires-Dist: matplotlib>=3.9
25
+ Requires-Dist: requests
26
+ Requires-Dist: joblib>=1.4
27
+ Requires-Dist: tqdm>=4.67
28
+ Requires-Dist: polars>=1.18.0
29
+ Requires-Dist: pyarrow>=18.1.0
30
+ Requires-Dist: python-dotenv>=1.0.1
31
+ Requires-Dist: plotly>=5.18
32
+ Requires-Dist: narwhals>=1.20.1
33
+ Requires-Dist: cdsapi>=0.7
34
+ Requires-Dist: typer>=0.9.0
35
+ Provides-Extra: docs
36
+ Requires-Dist: mkdocs>=1.6; extra == "docs"
37
+ Requires-Dist: mkdocs-material>=9.5; extra == "docs"
38
+ Requires-Dist: mkdocstrings[python]>=1.0; extra == "docs"
39
+ Dynamic: license-file
40
+
41
+ # noaaplotter
42
+ A python package to create fancy plots with NOAA weather data (stations) and ERA5 reanalysis (by coordinates).
43
+
44
+ > 📚 **Docs & API reference:** [initze.github.io/noaaplotter](https://initze.github.io/noaaplotter)
45
+ >
46
+ > **Install:** `pip install noaaplotter`
47
+
48
+ ## Install
49
+
50
+ ### PyPI (recommended for end users)
51
+ ```bash
52
+ pip install noaaplotter
53
+ ```
54
+
55
+ ### From source (development)
56
+ ```bash
57
+ uv venv
58
+ uv pip install -e . # install this package + all dependencies
59
+ # or from GitHub:
60
+ uv pip install git+https://github.com/initze/noaaplotter.git
61
+ ```
62
+
63
+ ### Requirements
64
+ matplotlib, numpy, pandas, requests, joblib, tqdm, polars, pyarrow, plotly,
65
+ python-dotenv, typer (all listed in `pyproject.toml` and installed automatically).
66
+
67
+ ## Quick start (3 steps)
68
+
69
+ ```bash
70
+ # 1. Download data (no token needed — NOAA data comes from the public
71
+ # NCEI Access Data Service)
72
+ noaaplotter download-data -o data/kotzebue.parquet -sid USW00026616 -start 1970-01-01 -end 2021-12-31
73
+
74
+ # 2. Create a daily plot (temperature vs. climate + precipitation, incl. 7-day rolling sum)
75
+ noaaplotter plot-daily -infile data/kotzebue.parquet -start 1992-01-01 -end 1992-12-31 -t_range -45 25 -p_range 50 -save_plot figures/kotzebue_1992.png
76
+
77
+ # 3. ...or an interactive HTML plot
78
+ noaaplotter plot-daily -infile data/kotzebue.parquet -start 1992-01-01 -end 1992-12-31 --engine plotly -save_plot figures/kotzebue_1992.html
79
+ ```
80
+
81
+ ## Command Line Interface (CLI)
82
+
83
+ Unified command line interface: `noaaplotter <command> [OPTIONS]`.
84
+ Every command supports `-h` / `--help` for detailed usage.
85
+
86
+ ### `noaaplotter download-data`
87
+ Download weather data to a parquet file.
88
+
89
+ ```bash
90
+ # NOAA station (no token needed — public NCEI service)
91
+ noaaplotter download-data -o data/kotzebue.parquet -sid USW00026616 -start 1970-01-01 -end 2021-12-31
92
+
93
+ # ERA5 reanalysis by coordinates (open_meteo, no token needed)
94
+ noaaplotter download-data -o data/potsdam.parquet --source open_meteo -lat 52.4 -lon 13.05 -start 1980-01-01 -end 2021-12-31
95
+ ```
96
+
97
+ | Option | Meaning |
98
+ |---|---|
99
+ | `-o` / `--output-file` | output parquet file (required) |
100
+ | `-sid` / `--station-id` | NOAA station id, e.g. `USW00026616` (Kotzebue) |
101
+ | `-lat`, `-lon` | coordinates for `--source open_meteo` / `cds` |
102
+ | `-start`, `-end` | start / end date, `YYYY-MM-DD` |
103
+ | `-t` / `--token` | NOAA token (optional; the public endpoint needs none). Defaults to `NOAA_API_TOKEN` env / `.env` if set |
104
+ | `--source` | `noaa` (default), `open_meteo`, `cds` |
105
+ | `--datatypes` | `TMIN,TMAX,PRCP,SNOW` (NOAA only) |
106
+ | `-n_jobs` | parallel processes (NOAA only) |
107
+ | `-loc` | location name for the output file |
108
+
109
+ Data files are cached: re-running only fetches the missing dates.
110
+
111
+ ### `noaaplotter plot-daily`
112
+ Daily temperature (observed vs. climate mean ± 1σ, with anomaly fills) + precipitation (bars + 7-day rolling sum).
113
+
114
+ ```bash
115
+ noaaplotter plot-daily -infile data/kotzebue.parquet -start 1992-01-01 -end 1992-12-31 -t_range -45 25 -p_range 50 -save_plot figures/kotzebue_1992.png
116
+ noaaplotter plot-daily -infile data/kotzebue.parquet -start 2017-07-01 -end 2018-06-30 --snow_acc --engine plotly -save_plot figures/kotzebue_winter.html
117
+ ```
118
+
119
+ | Option | Meaning |
120
+ |---|---|
121
+ | `-infile` | input parquet/csv (required) |
122
+ | `-start`, `-end` | plot window, `YYYY-MM-DD` (end date may be in the future; the plot just stops at the last available data) |
123
+ | `-t_range` | temperature range `min max`, e.g. `-45 25` |
124
+ | `-p_range` | max precipitation value (mm) |
125
+ | `-s_range` | max snow accumulation (cm) |
126
+ | `--snow_acc` | show cumulative snowfall (winter season) |
127
+ | `-filtersize` | climate smoothing window in days (default 7) |
128
+ | `-figsize` | figure size in inches `width height` |
129
+ | `-title` | plot title |
130
+ | `-save_plot` | write the plot (`.png` for matplotlib, `.html` for plotly) |
131
+ | `--plot` | open in a browser/GUI |
132
+ | `--engine` | `matplotlib` (default) or `plotly` |
133
+ | `--full-series` | plotly only: include the entire observed record in the HTML plot — the view still opens on the selected period (default: plot only the selected period, smaller file) |
134
+
135
+ ### `noaaplotter plot-monthly`
136
+ Monthly bar chart of temperature or precipitation, with anomaly and trailing mean.
137
+
138
+ ```bash
139
+ # Absolute values
140
+ noaaplotter plot-monthly -infile data/kotzebue.parquet -start 1980-01-01 -end 2021-08-31 -type Temperature -trail 12 -save_plot figures/kotzebue_t.png
141
+
142
+ # Anomaly from climate (1981-2010)
143
+ noaaplotter plot-monthly -infile data/kotzebue.parquet -start 1980-01-01 -end 2021-08-31 -type Precipitation -trail 12 -anomaly -save_plot figures/kotzebue_p_anomaly.png
144
+ ```
145
+
146
+ | Option | Meaning |
147
+ |---|---|
148
+ | `-infile` | input parquet/csv (required) |
149
+ | `-start`, `-end` | plot window, `YYYY-MM-DD` |
150
+ | `-type` | `Temperature` (default) or `Precipitation` |
151
+ | `-trail` | trailing/rolling mean in months, e.g. `12` |
152
+ | `-anomaly` | show anomaly from the climate baseline |
153
+ | `-save_plot` | write the plot (`.png` / `.html`) |
154
+ | `--engine` | `matplotlib` (default) or `plotly` |
155
+
156
+ ## Examples
157
+
158
+ ### Download data
159
+ **Option 1 — NOAA Daily Summaries via CLI** (Kotzebue, 1970-2021)
160
+ * No token required — served by the public NCEI Access Data Service.
161
+
162
+ `noaaplotter download-data -o data/kotzebue.parquet -sid USW00026616 -start 1970-01-01 -end 2021-12-31`
163
+
164
+ **Option 2 — NOAA Daily Summaries via browser**
165
+ CSV files of "daily summaries" (https://www.ncdc.noaa.gov/cdo-web/search),
166
+ values: metric, file type: csv.
167
+
168
+ **Option 3 — ERA5 via CLI** (Potsdam, 13.05°E / 52.4°N, 1980-2021 — no token)
169
+ `noaaplotter download-data -o data/potsdam.parquet --source open_meteo -lat 52.4 -lon 13.05 -start 1980-01-01 -end 2021-12-31`
170
+
171
+ ### Daily Mean Temperature and Precipitation vs. Climate
172
+ Entire year 1 January until 31 December (e.g. 1992):
173
+
174
+ `noaaplotter plot-daily -infile data/kotzebue.parquet -start 1992-01-01 -end 1992-12-31 -t_range -45 25 -p_range 50 -save_plot figures/kotzebue_daily_1992.png`
175
+
176
+ ![Kotzebue daily 1992 — temperature (top) vs. climate ±1σ, precipitation (bottom) with 7-day rolling sum](figures/kotzebue_daily_1992.png)
177
+
178
+ ### Monthly aggregates
179
+ Temperature, absolute (12-month trailing mean):
180
+
181
+ `noaaplotter plot-monthly -infile data/kotzebue.parquet -start 1980-01-01 -end 2021-08-31 -type Temperature -trail 12 -save_plot figures/kotzebue_monthly_t.png`
182
+
183
+ ![Kotzebue monthly temperature](figures/kotzebue_monthly_t.png)
184
+
185
+ Temperature, anomaly from climate (1981-2010):
186
+
187
+ `noaaplotter plot-monthly -infile data/kotzebue.parquet -start 1980-01-01 -end 2021-08-31 -type Temperature -trail 12 -anomaly -save_plot figures/kotzebue_monthly_t_anomaly.png`
188
+
189
+ ![Kotzebue monthly temperature anomaly](figures/kotzebue_monthly_t_anomaly.png)
190
+
191
+ Precipitation, absolute (12-month trailing mean):
192
+
193
+ `noaaplotter plot-monthly -infile data/kotzebue.parquet -start 1980-01-01 -end 2021-08-31 -type Precipitation -trail 12 -save_plot figures/kotzebue_monthly_p.png`
194
+
195
+ ![Kotzebue monthly precipitation](figures/kotzebue_monthly_p.png)
196
+
197
+ ## Advanced Usage
198
+
199
+ ### Get help for any command
200
+ ```bash
201
+ noaaplotter --help
202
+ noaaplotter download-data --help
203
+ noaaplotter plot-daily --help
204
+ noaaplotter plot-monthly --help
205
+ ```
206
+
207
+ ### Interactive (plotly) plots
208
+ Use `--engine plotly` and save to `.html` to get interactive plots
209
+ (zoom, hover, range slider). Daily plots also show a 7-day rolling sum of precipitation.
210
+
211
+ ### Python API
212
+ The package is a normal Python library as well:
213
+ ```python
214
+ from noaaplotter import NOAAPlotter
215
+
216
+ n = NOAAPlotter("data/kotzebue.parquet", location="Kotzebue", climate_filtersize=7)
217
+ fig = n.plot_weather_series(start_date="1992-01-01", end_date="1992-12-31",
218
+ show_plot=False, return_plot=True, engine="plotly")
219
+ fig.write_html("figures/kotzebue_1992.html")
220
+ ```
@@ -0,0 +1,26 @@
1
+ noaaplotter/__init__.py,sha256=XqBRzyTsdF2G5UrQoTvZDc6NC9A5uVvZI8FRd4-ePCQ,528
2
+ noaaplotter/__main__.py,sha256=gFsYnmLBkg64j46w8i9e2PG-LAvfGVbAEJsX5mEIqvY,131
3
+ noaaplotter/noaaplotter.py,sha256=Aa5jGrsMfUACFEGjnQnb5kL-NaUscdpY9IAfLptFvNk,28312
4
+ noaaplotter/cli/__init__.py,sha256=TXwGrpETXNt7xAt6tpMZuN2I_yBsmG0lJdWgVoyN4eA,9877
5
+ noaaplotter/figures/__init__.py,sha256=Ntwba_zwhrQklIFY8hiZPJ-Q-UjEQpA_zhz81su7_Vc,227
6
+ noaaplotter/figures/plotly_daily.py,sha256=uRDj6RZyrbIlwv-bzfZyv-oDkFRwsWNM3PVFqNvm8Nk,13720
7
+ noaaplotter/figures/plotly_monthly.py,sha256=Ku8t0gyUIwRX7rONomtr5IHQu93-8xyFWr9IkwI44QY,2276
8
+ noaaplotter/scripts/download_data.py,sha256=b04Eend6PX7FDPlM_UVplN8KgprLmO5D-iQGs748moE,3989
9
+ noaaplotter/scripts/plot_daily.py,sha256=ytkZiy_-f3-AyAY-VKzIsZIib83_Iyj2olsrdOSXuOU,4773
10
+ noaaplotter/scripts/plot_monthly.py,sha256=Nb8QsLBjLCGPuDH7Yparl0biuaE5xebiKTRt88_jJuw,2837
11
+ noaaplotter/sources/__init__.py,sha256=GcK1XkL3AjyC3gppYaYAlxO0rxWDKV4N9U6wBNSZwSA,549
12
+ noaaplotter/sources/base.py,sha256=3fhZsoert6TWkiQuaOiPzffX8oyEtCi8jDwSMjna0lE,3156
13
+ noaaplotter/sources/cds.py,sha256=YV9NFp3AJGmTjJL92nQO-mUU-vq2eC7g5iDS9cSDz5g,6011
14
+ noaaplotter/sources/open_meteo.py,sha256=jVNX9vdBqDOGyGYTIxwJBdTDf3K43iWsPvzFQ4AbOn8,3638
15
+ noaaplotter/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
+ noaaplotter/utils/config.py,sha256=EzBn9hyIdyTs3LloclIwQmX1ipEJwiP9of7rLyFmI_Q,859
17
+ noaaplotter/utils/dataset.py,sha256=q4q9SLJljQx_-9RBFLXdsBriz_qXOjlWb1pC6IW45z4,14024
18
+ noaaplotter/utils/download_utils.py,sha256=0kmVZi6j_cNNyLI8ECNUEk5e7eNHJcujxttfineUSow,8834
19
+ noaaplotter/utils/plot_utils.py,sha256=X9A4oeAzH6sUIXaMSVPbN3hapeN1TyRWk2CMgJZZKn0,2107
20
+ noaaplotter/utils/utils.py,sha256=831g4njr9XKCWCQfxRE033-ayZgMn-CTLiSINCiRfrA,2898
21
+ noaaplotter-1.0.0.dist-info/licenses/LICENSE,sha256=8DbP0SbTSx_2uN5SjsXWDnXisPhvvOXhpFhjY4I6i7Y,1069
22
+ noaaplotter-1.0.0.dist-info/METADATA,sha256=09AEGU7ejNMUJjTkU7_Evw3gV-xFcYjs3WSciw1deIQ,9192
23
+ noaaplotter-1.0.0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
24
+ noaaplotter-1.0.0.dist-info/entry_points.txt,sha256=-4GRShMAD4jJ75fcDpAKmRmlvGQTviwfMMNlOUXLmjU,214
25
+ noaaplotter-1.0.0.dist-info/top_level.txt,sha256=DslSXAUBNUOuKIRPo7gt3GB7PC98NnfzMkB2lXV06n4,12
26
+ noaaplotter-1.0.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,5 @@
1
+ [console_scripts]
2
+ download_data = noaaplotter.scripts.download_data:main
3
+ noaaplotter = noaaplotter.__main__:app
4
+ plot_daily = noaaplotter.scripts.plot_daily:main
5
+ plot_monthly = noaaplotter.scripts.plot_monthly:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Ingmar Nitze
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ noaaplotter