hefty 0.3.1__tar.gz → 0.3.2__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: hefty
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Some (relatively) lightweight short-term energy forecasting tools for solar, wind, and load.
5
5
  Author: Will Hobbs
6
6
  License-Expression: BSD-3-Clause
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "hefty"
7
- version = "0.3.1"
7
+ version = "0.3.2"
8
8
  description = "Some (relatively) lightweight short-term energy forecasting tools for solar, wind, and load."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11"
@@ -346,7 +346,8 @@ def get_solar_forecast(latitude, longitude, init_date, run_length,
346
346
  unmixed = ((mixed['hour_of_mixed_period'] * mixed['sdswrf']
347
347
  - (mixed['hour_of_mixed_period'] - mixed['int_len'])
348
348
  * mixed['sdswrf_prev']) / mixed['int_len'])
349
- df['ghi'] = unmixed
349
+ # clip to avoid occasional small negative ghi in GEFS, see GH #35
350
+ df['ghi'] = unmixed.clip(lower=0)
350
351
 
351
352
  elif model in {'ifs', 'ifs_ens', 'aifs', 'aifs_ens', 'cams'}:
352
353
  # for ifs ghi: cumulative J/m^s to average W/m^2 over the interval
@@ -407,7 +408,7 @@ def get_solar_forecast(latitude, longitude, init_date, run_length,
407
408
  df['ghi_csi'] = df['ghi'] / df['ghi_clear']
408
409
 
409
410
  # avoid divide by zero issues
410
- df.loc[df['ghi'] == 0, 'ghi_csi'] = 0
411
+ df.loc[df['ghi_clear'] == 0, 'ghi_csi'] = 0
411
412
 
412
413
  # 60min version of data, centered at bottom of the hour
413
414
  new_index = pd.date_range(df.index.min(),
@@ -828,7 +829,8 @@ def get_solar_forecast_fast(latitude, longitude, init_date, run_length,
828
829
  unmixed = ((mixed['hour_of_mixed_period'] * mixed['sdswrf']
829
830
  - (mixed['hour_of_mixed_period'] - mixed['int_len'])
830
831
  * mixed['sdswrf_prev']) / mixed['int_len'])
831
- df['ghi'] = unmixed
832
+ # clip to avoid occasional small negative ghi in GEFS, see GH #35
833
+ df['ghi'] = unmixed.clip(lower=0)
832
834
 
833
835
  elif model in ['ifs', 'ifs_ens', 'aifs', 'aifs_ens']:
834
836
  # for ifs ghi: cumulative J/m^s to average W/m^2 over the interval
@@ -879,7 +881,7 @@ def get_solar_forecast_fast(latitude, longitude, init_date, run_length,
879
881
  df['ghi_csi'] = df['ghi'] / df['ghi_clear']
880
882
 
881
883
  # avoid divide by zero issues
882
- df.loc[df['ghi'] == 0, 'ghi_csi'] = 0
884
+ df.loc[df['ghi_clear'] == 0, 'ghi_csi'] = 0
883
885
 
884
886
  # 60min version of data, centered at bottom of the hour
885
887
  new_index = pd.date_range(df.index.min(),
@@ -1268,7 +1270,7 @@ def get_solar_forecast_ensemble_subset(
1268
1270
  df['ghi_csi'] = df['ghi'] / df['ghi_clear']
1269
1271
 
1270
1272
  # avoid divide by zero issues
1271
- df.loc[df['ghi'] == 0, 'ghi_csi'] = 0
1273
+ df.loc[df['ghi_clear'] == 0, 'ghi_csi'] = 0
1272
1274
 
1273
1275
  # make a dummy column
1274
1276
  df['dummy'] = 0
@@ -1729,7 +1731,7 @@ def get_solar_forecast_ensemble(latitude, longitude, init_date, run_length,
1729
1731
  df['ghi_csi'] = df['ghi'] / df['ghi_clear']
1730
1732
 
1731
1733
  # avoid divide by zero issues
1732
- df.loc[df['ghi'] == 0, 'ghi_csi'] = 0
1734
+ df.loc[df['ghi_clear'] == 0, 'ghi_csi'] = 0
1733
1735
 
1734
1736
  # 60min version of data, centered at bottom of the hour
1735
1737
  new_index = pd.date_range(df.index.min(),
@@ -1869,7 +1871,8 @@ def get_solar_forecast_ensemble(latitude, longitude, init_date, run_length,
1869
1871
  unmixed = ((mixed['hour_of_mixed_period'] * mixed['sdswrf']
1870
1872
  - (mixed['hour_of_mixed_period'] - mixed['int_len'])
1871
1873
  * mixed['sdswrf_prev']) / mixed['int_len'])
1872
- df['ghi'] = unmixed
1874
+ # clip to avoid occasional small negative ghi in GEFS, see GH #35
1875
+ df['ghi'] = unmixed.clip(lower=0)
1873
1876
 
1874
1877
  # make 1min interval clear sky data covering our time range
1875
1878
  times = pd.date_range(
@@ -1905,7 +1908,7 @@ def get_solar_forecast_ensemble(latitude, longitude, init_date, run_length,
1905
1908
  df['ghi_csi'] = df['ghi'] / df['ghi_clear']
1906
1909
 
1907
1910
  # avoid divide by zero issues
1908
- df.loc[df['ghi'] == 0, 'ghi_csi'] = 0
1911
+ df.loc[df['ghi_clear'] == 0, 'ghi_csi'] = 0
1909
1912
 
1910
1913
  # 60min version of data, centered at bottom of the hour
1911
1914
  new_index = pd.date_range(df.index.min(),
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: hefty
3
- Version: 0.3.1
3
+ Version: 0.3.2
4
4
  Summary: Some (relatively) lightweight short-term energy forecasting tools for solar, wind, and load.
5
5
  Author: Will Hobbs
6
6
  License-Expression: BSD-3-Clause
@@ -20,7 +20,7 @@ def test_tz_warning():
20
20
 
21
21
 
22
22
  def test_hrrr_too_far():
23
- available_date = '2026-09-24 02:00'
23
+ available_date = '2026-09-24 02:00+00:00'
24
24
  run_length_needed = 43
25
25
  lead_time_to_start_needed = 1
26
26
  model = 'hrrr'
@@ -32,7 +32,7 @@ def test_hrrr_too_far():
32
32
 
33
33
 
34
34
  def test_gfs_way_too_far():
35
- available_date = '2026-09-24 00:00'
35
+ available_date = '2026-09-24 00:00+00:00'
36
36
  run_length_needed = 385
37
37
  lead_time_to_start_needed = 0
38
38
  model = 'gfs'
@@ -7,8 +7,10 @@ from hefty.solar import get_solar_forecast
7
7
 
8
8
  # ignore xarray FutureWarnings (see https://github.com/blaylockbk/Herbie/issues/525).
9
9
  # ignore grib file removal warnings
10
- @pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*')
11
- @pytest.mark.filterwarnings('ignore:.*In a future version.*')
10
+ pytestmark = [
11
+ pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*'),
12
+ pytest.mark.filterwarnings('ignore:.*In a future version.*')
13
+ ]
12
14
 
13
15
 
14
16
  def test_hrrr():
@@ -7,8 +7,10 @@ from hefty.solar import get_solar_forecast_ensemble
7
7
 
8
8
  # ignore xarray FutureWarnings (see https://github.com/blaylockbk/Herbie/issues/525).
9
9
  # ignore grib file removal warnings
10
- @pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*')
11
- @pytest.mark.filterwarnings('ignore:.*In a future version.*')
10
+ pytestmark = [
11
+ pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*'),
12
+ pytest.mark.filterwarnings('ignore:.*In a future version.*')
13
+ ]
12
14
 
13
15
 
14
16
  def test_gefs_dynamical():
@@ -7,8 +7,10 @@ from hefty.solar import get_solar_forecast_fast
7
7
 
8
8
  # ignore xarray FutureWarnings (see https://github.com/blaylockbk/Herbie/issues/525).
9
9
  # ignore grib file removal warnings
10
- @pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*')
11
- @pytest.mark.filterwarnings('ignore:.*In a future version.*')
10
+ pytestmark = [
11
+ pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*'),
12
+ pytest.mark.filterwarnings('ignore:.*In a future version.*')
13
+ ]
12
14
 
13
15
 
14
16
  def test_hrrr():
@@ -7,8 +7,10 @@ from hefty.wind import get_wind_forecast
7
7
 
8
8
  # ignore xarray FutureWarnings (see https://github.com/blaylockbk/Herbie/issues/525).
9
9
  # ignore grib file removal warnings
10
- @pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*')
11
- @pytest.mark.filterwarnings('ignore:.*In a future version.*')
10
+ pytestmark = [
11
+ pytest.mark.filterwarnings('ignore:.*Will not remove GRIB.*'),
12
+ pytest.mark.filterwarnings('ignore:.*In a future version.*')
13
+ ]
12
14
 
13
15
 
14
16
  def test_hrrr():
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes