Skip to content

Commit fa17b15

Browse files
Merge pull request #222 from PyPSA/influx_feature_reduction
purge influx feature
2 parents ff17dd9 + 5f5efe3 commit fa17b15

File tree

7 files changed

+28
-42
lines changed

7 files changed

+28
-42
lines changed

RELEASE_NOTES.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Version 0.2.6
2525
* Due to ambiguity, conversion functions (`.pv(...)`, `.wind(...)` etc.) now raise an `ValueError` if shapes and matrix are given.
2626
* Atlite now supports calculating of heat pump coefficients of performance (https://github.com/PyPSA/atlite/pull/145).
2727
* Enabled the GitHub feature "Cite this repository" to generate a BibTeX file (Added a `CITATION.cff` file to the repository).
28+
* The function `SolarPosition` does not return the atmospheric insolation anymore. This data variable was not used by any of the currently supported modules.
2829

2930
**Bug fixes**
3031
* The solar position for ERA5 cutouts is now calculated for half a time step earlier (time-shift by `cutout.dt/2`) to account for the aggregated nature of

atlite/convert.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -909,9 +909,7 @@ def convert_line_rating(
909909

910910
if isinstance(ds, dict):
911911
Position = namedtuple("solarposition", ["altitude", "azimuth"])
912-
solar_position = Position(
913-
ds["solar_position: altitude"], ds["solar_position: azimuth"]
914-
)
912+
solar_position = Position(ds["solar_altitude"], ds["solar_azimuth"])
915913
else:
916914
solar_position = SolarPosition(ds)
917915
Phi_s = np.arccos(

atlite/datasets/era5.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,8 @@ def nullcontext():
4949
"influx_direct",
5050
"influx_diffuse",
5151
"albedo",
52-
"solar_position: altitude",
53-
"solar_position: azimuth",
54-
"solar_position: atmospheric insolation",
52+
"solar_altitude",
53+
"solar_azimuth",
5554
],
5655
"temperature": ["temperature", "soil temperature"],
5756
"runoff": ["runoff"],
@@ -173,7 +172,7 @@ def get_data_influx(retrieval_params):
173172
)
174173
)
175174
sp = SolarPosition(ds, time_shift=time_shift)
176-
sp = sp.rename({v: f"solar_position: {v}" for v in sp.data_vars})
175+
sp = sp.rename({v: f"solar_{v}" for v in sp.data_vars})
177176

178177
ds = xr.merge([ds, sp])
179178

atlite/datasets/sarah.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@
3333
"influx": [
3434
"influx_direct",
3535
"influx_diffuse",
36-
"solar_position: altitude",
37-
"solar_position: azimuth",
38-
"solar_position: atmospheric insolation",
39-
]
36+
"solar_altitude",
37+
"solar_azimuth",
38+
],
4039
}
4140
static_features = {}
4241

@@ -229,7 +228,7 @@ def get_data(cutout, feature, tmpdir, lock=None, **creation_parameters):
229228
with warnings.catch_warnings():
230229
warnings.simplefilter("ignore", DeprecationWarning)
231230
sp = SolarPosition(ds, time_shift="0H")
232-
sp = sp.rename({v: f"solar_position: {v}" for v in sp.data_vars})
231+
sp = sp.rename({v: f"solar_{v}" for v in sp.data_vars})
233232

234233
ds = xr.merge([ds, sp])
235234

atlite/pv/irradiation.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def DiffuseHorizontalIrrad(ds, solar_position, clearsky_model, influx):
2020
# Lauret et al. (2013):http://dx.doi.org/10.1016/j.renene.2012.01.049
2121

2222
sinaltitude = sin(solar_position["altitude"])
23-
atmospheric_insolation = solar_position["atmospheric insolation"]
23+
influx_toa = ds["influx_toa"]
2424

2525
if clearsky_model is None:
2626
clearsky_model = (
@@ -29,7 +29,7 @@ def DiffuseHorizontalIrrad(ds, solar_position, clearsky_model, influx):
2929

3030
# Reindl 1990 clearsky model
3131

32-
k = influx / atmospheric_insolation # clearsky index
32+
k = influx / influx_toa # clearsky index
3333
# k.values[k.values > 1.0] = 1.0
3434
# k = k.rename('clearsky index')
3535

@@ -82,7 +82,7 @@ def TiltedDiffuseIrrad(ds, solar_position, surface_orientation, direct, diffuse)
8282
# Hay-Davies Model
8383

8484
sinaltitude = sin(solar_position["altitude"])
85-
atmospheric_insolation = solar_position["atmospheric insolation"]
85+
influx_toa = ds["influx_toa"]
8686

8787
cosincidence = surface_orientation["cosincidence"]
8888
surface_slope = surface_orientation["slope"]
@@ -94,7 +94,7 @@ def TiltedDiffuseIrrad(ds, solar_position, surface_orientation, direct, diffuse)
9494
f = sqrt(direct / influx).fillna(0.0)
9595

9696
# anisotropy factor
97-
A = direct / atmospheric_insolation
97+
A = direct / influx_toa
9898

9999
# geometric factor
100100
R_b = cosincidence / sinaltitude
@@ -159,7 +159,7 @@ def TiltedIrradiation(
159159
altitude_threshold=1.0,
160160
):
161161

162-
influx_toa = solar_position["atmospheric insolation"]
162+
influx_toa = ds["influx_toa"]
163163

164164
def clip(influx, influx_max):
165165
# use .data in clip due to dask-xarray incompatibilities

atlite/pv/solar_position.py

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,14 @@ def SolarPosition(ds, time_shift="0H"):
5454

5555
# Act like a getter if these return variables are already in ds
5656
rvs = {
57-
"solar_position: azimuth",
58-
"solar_position: altitude",
59-
"solar_position: atmospheric insolation",
57+
"solar_azimuth",
58+
"solar_altitude",
6059
}
6160

6261
if rvs.issubset(set(ds.data_vars)):
6362
solar_position = ds[rvs]
6463
solar_position = solar_position.rename(
65-
{v: v.replace("solar_position: ", "") for v in rvs}
64+
{v: v.replace("solar_", "") for v in rvs}
6665
)
6766
return solar_position
6867

@@ -120,17 +119,7 @@ def SolarPosition(ds, time_shift="0H"):
120119
az.attrs["time shift"] = f"{time_shift}"
121120
az.attrs["units"] = "rad"
122121

123-
if "influx_toa" in ds:
124-
atmospheric_insolation = ds["influx_toa"].rename("atmospheric insolation")
125-
else:
126-
# [3]
127-
atmospheric_insolation = (1366.1 * (1 + 0.033 * cos(g)) * sin(alt)).rename(
128-
"atmospheric insolation"
129-
)
130-
atmospheric_insolation.attrs["time shift"] = f"{time_shift}"
131-
atmospheric_insolation.attrs["units"] = "W m**-2"
132-
133-
vars = {da.name: da for da in [alt, az, atmospheric_insolation]}
122+
vars = {da.name: da for da in [alt, az]}
134123
solar_position = xr.Dataset(vars)
135124

136125
return solar_position

test/test_dynamic_line_rating.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ def test_ieee_sample_case():
2626
"height": 0,
2727
"wnd_azimuth": 0,
2828
"influx_direct": 1027,
29-
"solar_position: altitude": np.pi / 2,
30-
"solar_position: azimuth": np.pi,
29+
"solar_altitude": np.pi / 2,
30+
"solar_azimuth": np.pi,
3131
}
3232

3333
psi = 90 # line azimuth
@@ -60,8 +60,8 @@ def test_oeding_and_oswald_sample_case():
6060
"height": 0,
6161
"wnd_azimuth": 0,
6262
"influx_direct": 0,
63-
"solar_position: altitude": np.pi / 2,
64-
"solar_position: azimuth": np.pi,
63+
"solar_altitude": np.pi / 2,
64+
"solar_azimuth": np.pi,
6565
}
6666
psi = 90 # line azimuth
6767
D = 0.0218 # line diameter
@@ -89,8 +89,8 @@ def test_suedkabel_sample_case():
8989
"height": 0,
9090
"wnd_azimuth": 0,
9191
"influx_direct": 0,
92-
"solar_position: altitude": np.pi / 2,
93-
"solar_position: azimuth": np.pi,
92+
"solar_altitude": np.pi / 2,
93+
"solar_azimuth": np.pi,
9494
}
9595
R = 0.0136 * 1e-3
9696
psi = 0 # line azimuth
@@ -113,8 +113,8 @@ def test_right_angle_in_different_configuration():
113113
"height": 0,
114114
"wnd_azimuth": 0,
115115
"influx_direct": 1027,
116-
"solar_position: altitude": np.pi / 2,
117-
"solar_position: azimuth": np.pi,
116+
"solar_altitude": np.pi / 2,
117+
"solar_azimuth": np.pi,
118118
}
119119
psi = 90 # line azimuth
120120
D = 0.02814 # line diameter
@@ -159,8 +159,8 @@ def test_angle_increase():
159159
"height": 0,
160160
"wnd_azimuth": 0,
161161
"influx_direct": 1027,
162-
"solar_position: altitude": np.pi / 2,
163-
"solar_position: azimuth": np.pi,
162+
"solar_altitude": np.pi / 2,
163+
"solar_azimuth": np.pi,
164164
}
165165
D = 0.02814 # line diameter
166166
Ts = 273 + 100 # max allowed line surface temp

0 commit comments

Comments
 (0)