windborne 1.2.6__tar.gz → 1.2.8__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: windborne
3
- Version: 1.2.6
3
+ Version: 1.2.8
4
4
  Summary: A Python library for interacting with WindBorne Data and Forecasts API
5
5
  Author-email: WindBorne Systems <data@windbornesystems.com>
6
6
  Classifier: Programming Language :: Python :: 3
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "windborne"
7
- version = "1.2.6"
7
+ version = "1.2.8"
8
8
  description = "A Python library for interacting with WindBorne Data and Forecasts API"
9
9
  readme = {file = "README.md", content-type = "text/markdown"}
10
10
  authors = [
@@ -22,6 +22,7 @@ from .data_api import (
22
22
  from .forecasts_api import (
23
23
  get_point_forecasts,
24
24
  get_initialization_times,
25
+ get_historical_initialization_times,
25
26
  get_forecast_hours,
26
27
  get_generation_times,
27
28
 
@@ -64,6 +65,7 @@ __all__ = [
64
65
 
65
66
  "get_point_forecasts",
66
67
  "get_initialization_times",
68
+ "get_historical_initialization_times",
67
69
  "get_forecast_hours",
68
70
  "get_generation_times",
69
71
 
@@ -48,14 +48,6 @@ def verify_api_credentials(client_id, api_key):
48
48
  "For instructions, refer to https://windbornesystems.com/docs/api/cli#introduction or https://windbornesystems.com/docs/api/pip_data#introduction."
49
49
  )
50
50
 
51
- # Validate WB_CLIENT_ID format
52
- if is_valid_uuid_v4(client_id):
53
- raise NotImplementedError(
54
- "Personal API tokens are not yet supported. "
55
- "You will need to get a globally-authorizing API key. "
56
- "For questions, email data@windbornesystems.com."
57
- )
58
-
59
51
  if not (is_valid_uuid_v4(client_id) or is_valid_client_id_format(client_id)):
60
52
  raise ValueError(
61
53
  f"Your Client ID is misformatted: {client_id}. "
@@ -110,20 +102,10 @@ def make_api_request(url, params=None, as_json=True, retry_counter=0):
110
102
 
111
103
  client_id, api_key = get_verified_api_credentials()
112
104
 
113
- if is_valid_uuid_v4(client_id):
114
- token_id = client_id
115
- client_id = 'api_token'
116
-
117
- signed_token = jwt.encode({
118
- 'client_id': client_id,
119
- 'iat': int(time.time()),
120
- 'token_id': token_id
121
- }, api_key, algorithm='HS256')
122
- else:
123
- signed_token = jwt.encode({
124
- 'client_id': client_id,
125
- 'iat': int(time.time()),
126
- }, api_key, algorithm='HS256')
105
+ signed_token = jwt.encode({
106
+ 'client_id': client_id,
107
+ 'iat': int(time.time()),
108
+ }, api_key, algorithm='HS256')
127
109
 
128
110
  try:
129
111
  if params:
@@ -19,6 +19,7 @@ from . import (
19
19
 
20
20
  get_point_forecasts,
21
21
  get_initialization_times,
22
+ get_historical_initialization_times,
22
23
  get_forecast_hours,
23
24
  get_generation_times,
24
25
  get_full_gridded_forecast,
@@ -170,6 +171,8 @@ def main():
170
171
  'dewpoint_2m',
171
172
  'wind_u_10m',
172
173
  'wind_v_10m',
174
+ 'wind_u_100m',
175
+ 'wind_v_100m',
173
176
  'pressure_msl',
174
177
  '500/temperature',
175
178
  '500/wind_u',
@@ -249,6 +252,11 @@ def main():
249
252
  initialization_times_parser.add_argument('-i', '--intracycle', action='store_true', help='Use the intracycle forecast')
250
253
  initialization_times_parser.add_argument('-e', '--ens-member', help='Ensemble member (eg 1 or mean)')
251
254
 
255
+ # Historical Initialization Times Command
256
+ hist_initialization_times_parser = subparsers.add_parser('hist_init_times', help='Get available historical initialization times')
257
+ hist_initialization_times_parser.add_argument('-i', '--intracycle', action='store_true', help='Use the intracycle forecast')
258
+ hist_initialization_times_parser.add_argument('-e', '--ens-member', help='Ensemble member (eg 1 or mean)')
259
+
252
260
  # Forecast Hours Command
253
261
  forecast_hours_parser = subparsers.add_parser('forecast_hours', help='Get available forecast hours for WeatherMesh')
254
262
  forecast_hours_parser.add_argument('-i', '--intracycle', action='store_true', help='Use the intracycle forecast')
@@ -458,6 +466,9 @@ def main():
458
466
  elif args.command == 'init_times':
459
467
  get_initialization_times(print_response=True, ensemble_member=args.ens_member, intracycle=args.intracycle)
460
468
 
469
+ elif args.command == 'hist_init_times':
470
+ get_historical_initialization_times(print_response=True, ensemble_member=args.ens_member, intracycle=args.intracycle)
471
+
461
472
  elif args.command == 'forecast_hours':
462
473
  get_forecast_hours(print_response=True, ensemble_member=args.ens_member, intracycle=args.intracycle)
463
474
 
@@ -301,6 +301,23 @@ def get_initialization_times(print_response=False, ensemble_member=None, intracy
301
301
  return response
302
302
 
303
303
 
304
+ def get_historical_initialization_times(print_response=False, ensemble_member=None, intracycle=False):
305
+ """
306
+ Get historical initialization times for forecasts from our archive
307
+ These may be higher latency to fetch and cannot be used for custom point forecasting
308
+ """
309
+ params = {
310
+ 'ens_member': ensemble_member,
311
+ 'intracycle': intracycle
312
+ }
313
+ response = make_api_request(f"{FORECASTS_API_BASE_URL}/historical_initialization_times.json", params=params)
314
+
315
+ if print_response:
316
+ print("Available historical initialization times:")
317
+ for time in response:
318
+ print(f" - {time}")
319
+
320
+
304
321
  def get_forecast_hours(print_response=False, ensemble_member=None, intracycle=False):
305
322
  """
306
323
  Get available forecast hours for WeatherMesh
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: windborne
3
- Version: 1.2.6
3
+ Version: 1.2.8
4
4
  Summary: A Python library for interacting with WindBorne Data and Forecasts API
5
5
  Author-email: WindBorne Systems <data@windbornesystems.com>
6
6
  Classifier: Programming Language :: Python :: 3
File without changes
File without changes
File without changes