pvlib 0.12.0__py3-none-any.whl → 0.13.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.
pvlib/iotools/sodapro.py CHANGED
@@ -7,7 +7,9 @@ import pandas as pd
7
7
  import requests
8
8
  import io
9
9
  import warnings
10
+ from pvlib import tools
10
11
 
12
+ from pvlib._deprecation import deprecated, renamed_kwarg_warning
11
13
 
12
14
  URL = 'api.soda-solardata.com'
13
15
 
@@ -43,10 +45,15 @@ SUMMATION_PERIOD_TO_TIME_STEP = {'0 year 0 month 0 day 0 h 1 min 0 s': '1min',
43
45
  '0 year 1 month 0 day 0 h 0 min 0 s': '1M'}
44
46
 
45
47
 
48
+ @renamed_kwarg_warning(
49
+ since='0.13.0',
50
+ old_param_name='server',
51
+ new_param_name='url',
52
+ removal="0.14.0")
46
53
  def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
47
54
  altitude=None, time_step='1h', time_ref='UT', verbose=False,
48
55
  integrated=False, label=None, map_variables=True,
49
- server=URL, timeout=30):
56
+ url=URL, timeout=30):
50
57
  """Retrieve irradiance and clear-sky time series from CAMS.
51
58
 
52
59
  Time-series of radiation and/or clear-sky global, beam, and
@@ -96,7 +103,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
96
103
  map_variables: bool, default: True
97
104
  When true, renames columns of the DataFrame to pvlib variable names
98
105
  where applicable. See variable :const:`VARIABLE_MAP`.
99
- server: str, default: :const:`pvlib.iotools.sodapro.URL`
106
+ url: str, default: :const:`pvlib.iotools.sodapro.URL`
100
107
  Base url of the SoDa Pro CAMS Radiation API.
101
108
  timeout : int, default: 30
102
109
  Time in seconds to wait for server response before timeout
@@ -143,9 +150,15 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
143
150
  e.g. `sza` becomes `solar_zenith`. See variable :const:`VARIABLE_MAP` for
144
151
  the complete mapping.
145
152
 
153
+ For large geospatial areas, CAMS offers a pre-calculated
154
+ gridded dataset [4]_ over land and coastal areas. This dataset
155
+ may not include the most recent data coverage and may not be
156
+ based on the most recent CAMS version. This dataset is not available
157
+ through pvlib.
158
+
146
159
  See Also
147
160
  --------
148
- pvlib.iotools.read_cams, pvlib.iotools.parse_cams
161
+ pvlib.iotools.read_cams
149
162
 
150
163
  Raises
151
164
  ------
@@ -155,13 +168,15 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
155
168
 
156
169
  References
157
170
  ----------
158
- .. [1] `CAMS solar radiation documentation
159
- <https://atmosphere.copernicus.eu/solar-radiation>`_
171
+ .. [1] `CAMS solar radiation time-series documentation. Climate Data Store.
172
+ <https://ads.atmosphere.copernicus.eu/datasets/cams-solar-radiation-timeseries>`_
160
173
  .. [2] `CAMS Radiation Automatic Access (SoDa)
161
174
  <https://www.soda-pro.com/help/cams-services/cams-radiation-service/automatic-access>`_
162
175
  .. [3] A. R. Jensen et al., pvlib iotools — Open-source Python functions
163
176
  for seamless access to solar irradiance data. Solar Energy. 2023. Vol
164
177
  266, pp. 112092. :doi:`10.1016/j.solener.2023.112092`
178
+ .. [4] `CAMS gridded solar radiation documentation.
179
+ <https://ads.atmosphere.copernicus.eu/datasets/cams-gridded-solar-radiation>`_
165
180
  """
166
181
  try:
167
182
  time_step_str = TIME_STEPS_MAP[time_step]
@@ -189,7 +204,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
189
204
  email = email.replace('@', '%2540') # Format email address
190
205
  identifier = 'get_{}'.format(identifier.lower()) # Format identifier str
191
206
 
192
- base_url = f"https://{server}/service/wps"
207
+ base_url = f"https://{url}/service/wps"
193
208
 
194
209
  data_inputs_dict = {
195
210
  'latitude': latitude,
@@ -202,7 +217,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
202
217
  'username': email,
203
218
  'verbose': verbose}
204
219
 
205
- # Manual formatting of the input parameters seperating each by a semicolon
220
+ # Manual formatting of the input parameters separating each by a semicolon
206
221
  data_inputs = ";".join([f"{key}={value}" for key, value in
207
222
  data_inputs_dict.items()])
208
223
 
@@ -214,7 +229,7 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
214
229
  }
215
230
 
216
231
  # The DataInputs parameter of the URL has to be manually formatted and
217
- # added to the base URL as it contains sub-parameters seperated by
232
+ # added to the base URL as it contains sub-parameters separated by
218
233
  # semi-colons, which gets incorrectly formatted by the requests function
219
234
  # if passed using the params argument.
220
235
  res = requests.get(base_url + '?DataInputs=' + data_inputs, params=params,
@@ -231,20 +246,22 @@ def get_cams(latitude, longitude, start, end, email, identifier='mcclear',
231
246
  # Successful requests returns a csv data file
232
247
  else:
233
248
  fbuf = io.StringIO(res.content.decode('utf-8'))
234
- data, metadata = parse_cams(fbuf, integrated=integrated, label=label,
235
- map_variables=map_variables)
249
+ data, metadata = read_cams(fbuf, integrated=integrated, label=label,
250
+ map_variables=map_variables)
236
251
  return data, metadata
237
252
 
238
253
 
239
- def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
254
+ def read_cams(filename, integrated=False, label=None, map_variables=True):
240
255
  """
241
- Parse a file-like buffer with data in the format of a CAMS Radiation or
242
- McClear file. The CAMS solar radiation services are described in [1]_.
256
+ Read a file or file-like buffer with data in the format of a CAMS
257
+ Radiation or McClear file.
258
+
259
+ The CAMS solar radiation services are described in [1]_.
243
260
 
244
261
  Parameters
245
262
  ----------
246
- fbuf: file-like object
247
- File-like object containing data to read.
263
+ filename: str, path-like, or buffer
264
+ Filename or in-memory buffer of a file containing data to read.
248
265
  integrated: boolean, default False
249
266
  Whether to return radiation parameters as integrated values (Wh/m^2)
250
267
  or as average irradiance values (W/m^2) (pvlib preferred units)
@@ -264,23 +281,31 @@ def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
264
281
 
265
282
  See Also
266
283
  --------
267
- pvlib.iotools.read_cams, pvlib.iotools.get_cams
284
+ pvlib.iotools.get_cams
268
285
 
269
286
  References
270
287
  ----------
271
- .. [1] `CAMS solar radiation documentation
272
- <https://atmosphere.copernicus.eu/solar-radiation>`_
288
+ .. [1] `CAMS solar radiation time-series documentation. Climate Data Store.
289
+ <https://ads.atmosphere.copernicus.eu/datasets/cams-solar-radiation-timeseries>`_
273
290
  """
274
291
  metadata = {}
275
- # Initial lines starting with # contain metadata
276
- while True:
277
- line = fbuf.readline().rstrip('\n')
278
- if line.startswith('# Observation period'):
279
- # The last line of the metadata section contains the column names
280
- names = line.lstrip('# ').split(';')
281
- break # End of metadata section has been reached
282
- elif ': ' in line:
283
- metadata[line.split(': ')[0].lstrip('# ')] = line.split(': ')[1]
292
+
293
+ with tools._file_context_manager(filename) as fbuf:
294
+
295
+ # Initial lines starting with # contain metadata
296
+ while True:
297
+ line = fbuf.readline().rstrip('\n')
298
+ if line.startswith('# Observation period'):
299
+ # The last line of the metadata section has the column names
300
+ names = line.lstrip('# ').split(';')
301
+ break # End of metadata section has been reached
302
+ elif ': ' in line:
303
+ key = line.split(': ')[0].lstrip('# ')
304
+ value = line.split(': ')[1]
305
+ metadata[key] = value
306
+
307
+ data = pd.read_csv(fbuf, sep=';', comment='#', header=None,
308
+ names=names)
284
309
 
285
310
  # Convert latitude, longitude, and altitude values from strings to floats
286
311
  for k_old in list(metadata.keys()):
@@ -296,8 +321,6 @@ def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
296
321
  metadata['Summarization (integration) period']]
297
322
  metadata['time_step'] = time_step
298
323
 
299
- data = pd.read_csv(fbuf, sep=';', comment='#', header=None, names=names)
300
-
301
324
  obs_period = data['Observation period'].str.split('/')
302
325
 
303
326
  # Set index as the start observation time (left) and localize to UTC
@@ -336,43 +359,5 @@ def parse_cams(fbuf, integrated=False, label=None, map_variables=True):
336
359
  return data, metadata
337
360
 
338
361
 
339
- def read_cams(filename, integrated=False, label=None, map_variables=True):
340
- """
341
- Read a CAMS Radiation or McClear file into a pandas DataFrame.
342
-
343
- CAMS Radiation and McClear are described in [1]_.
344
-
345
- Parameters
346
- ----------
347
- filename: str
348
- Filename of a file containing data to read.
349
- integrated: boolean, default False
350
- Whether to return radiation parameters as integrated values (Wh/m^2)
351
- or as average irradiance values (W/m^2) (pvlib preferred units)
352
- label : {'right', 'left}, optional
353
- Which bin edge label to label time-step with. The default is 'left' for
354
- all time steps except for '1M' which has a default of 'right'.
355
- map_variables: bool, default: True
356
- When true, renames columns of the Dataframe to pvlib variable names
357
- where applicable. See variable :const:`VARIABLE_MAP`.
358
-
359
- Returns
360
- -------
361
- data: pandas.DataFrame
362
- Timeseries data from CAMS Radiation or McClear.
363
- See :func:`pvlib.iotools.get_cams` for fields.
364
- metadata: dict
365
- Metadata available in the file.
366
-
367
- See Also
368
- --------
369
- pvlib.iotools.parse_cams, pvlib.iotools.get_cams
370
-
371
- References
372
- ----------
373
- .. [1] `CAMS solar radiation documentation
374
- <https://atmosphere.copernicus.eu/solar-radiation>`_
375
- """
376
- with open(str(filename), 'r') as fbuf:
377
- content = parse_cams(fbuf, integrated, label, map_variables)
378
- return content
362
+ parse_cams = deprecated(since="0.13.0", name="parse_cams",
363
+ alternative="read_cams")(read_cams)
pvlib/iotools/srml.py CHANGED
@@ -236,8 +236,7 @@ def get_srml(station, start, end, filetype='PO', map_variables=True,
236
236
  end = pd.to_datetime(end)
237
237
 
238
238
  # Generate list of months
239
- months = pd.date_range(
240
- start, end.replace(day=1) + pd.DateOffset(months=1), freq='1M')
239
+ months = pd.date_range(start.date().replace(day=1), end, freq='1MS')
241
240
  months_str = months.strftime('%y%m')
242
241
 
243
242
  # Generate list of filenames
pvlib/irradiance.py CHANGED
@@ -35,25 +35,30 @@ def get_extra_radiation(datetime_or_doy, solar_constant=1366.1,
35
35
  """
36
36
  Determine extraterrestrial radiation from day of year.
37
37
 
38
+ Specific references for each method are cited in the parameter descriptions
39
+ below, while a more general discussion of the different models may also be
40
+ found in [1]_ and [2]_.
41
+
38
42
  Parameters
39
43
  ----------
40
44
  datetime_or_doy : numeric, array, date, datetime, Timestamp, DatetimeIndex
41
45
  Day of year, array of days of year, or datetime-like object
42
46
 
43
47
  solar_constant : float, default 1366.1
44
- The solar constant.
48
+ The solar constant. [Wm⁻²]
45
49
 
46
- method : string, default 'spencer'
47
- The method by which the ET radiation should be calculated.
48
- Options include ``'pyephem', 'spencer', 'asce', 'nrel'``.
50
+ method : string, default `spencer`
51
+ The method by which the extraterrestrial radiation should be
52
+ calculated. Options include: `pyephem`, `spencer` [3]_, `asce` [4]_,
53
+ 'nrel' [6]_.
49
54
 
50
55
  epoch_year : int, default 2014
51
56
  The year in which a day of year input will be calculated. Only
52
- applies to day of year input used with the pyephem or nrel
57
+ applies to day of year input used with the `pyephem` or `nrel`
53
58
  methods.
54
59
 
55
60
  kwargs :
56
- Passed to solarposition.nrel_earthsun_distance
61
+ Passed to :py:func:`~pvlib.solarposition.nrel_earthsun_distance`.
57
62
 
58
63
  Returns
59
64
  -------
@@ -68,19 +73,23 @@ def get_extra_radiation(datetime_or_doy, solar_constant=1366.1,
68
73
  .. [1] M. Reno, C. Hansen, and J. Stein, "Global Horizontal Irradiance
69
74
  Clear Sky Models: Implementation and Analysis", Sandia National
70
75
  Laboratories, SAND2012-2389, 2012.
76
+ :doi:`10.2172/1039404`
71
77
 
72
- .. [2] http://solardata.uoregon.edu/SolarRadiationBasics.html, Eqs.
73
- SR1 and SR2
78
+ .. [2] J. A. Duffie, W. A. Beckman, N. Blair, "Solar Radiation", in Solar
79
+ Engineering of Thermal Processes, Photovoltaics and Wind, 5th ed,
80
+ New York, USA: J. Wiley and Sons, 2020, pp. 3-44.
81
+ :doi:`10.1002/9781119540328`
74
82
 
75
- .. [3] Partridge, G. W. and Platt, C. M. R. 1976. Radiative Processes
76
- in Meteorology and Climatology.
83
+ .. [3] J. W. Spencer, "Fourier series representation of the sun," Search,
84
+ vol. 2, p. 172, 1971.
77
85
 
78
- .. [4] Duffie, J. A. and Beckman, W. A. 1991. Solar Engineering of
79
- Thermal Processes, 2nd edn. J. Wiley and Sons, New York.
86
+ .. [4] R. G. Allen et al., Eds. The ASCE standardized reference
87
+ evapotranspiration equation. Reston, Va.: American Society of Civil
88
+ Engineers, 2005. :doi:`10.1061/9780784408056`
80
89
 
81
- .. [5] ASCE, 2005. The ASCE Standardized Reference Evapotranspiration
82
- Equation, Environmental and Water Resources Institute of the American
83
- Civil Engineers, Ed. R. G. Allen et al.
90
+ .. [6] I. Reda, A. Andreas, "Solar position algorithm for solar
91
+ radiation applications" NREL Golden, USA. NREL/TP-560-34302,
92
+ Revised 2008. :doi:`10.2172/15003974`
84
93
  """
85
94
 
86
95
  to_doy, to_datetimeindex, to_output = \
@@ -1618,7 +1627,7 @@ def ghi_from_poa_driesse_2023(surface_tilt, surface_azimuth,
1618
1627
  since='0.11.2',
1619
1628
  old_param_name='clearsky_ghi',
1620
1629
  new_param_name='ghi_clear',
1621
- removal="0.13.0")
1630
+ removal="0.14.0")
1622
1631
  def clearsky_index(ghi, ghi_clear, max_clearsky_index=2.0):
1623
1632
  """
1624
1633
  Calculate the clearsky index.
@@ -2163,12 +2172,12 @@ def _dirint_bins(times, kt_prime, zenith, w, delta_kt_prime):
2163
2172
  since='0.11.2',
2164
2173
  old_param_name='ghi_clearsky',
2165
2174
  new_param_name='ghi_clear',
2166
- removal="0.13.0")
2175
+ removal="0.14.0")
2167
2176
  @renamed_kwarg_warning(
2168
2177
  since='0.11.2',
2169
2178
  old_param_name='dni_clearsky',
2170
2179
  new_param_name='dni_clear',
2171
- removal="0.13.0")
2180
+ removal="0.14.0")
2172
2181
  def dirindex(ghi, ghi_clear, dni_clear, zenith, times, pressure=101325.,
2173
2182
  use_delta_kt_prime=True, temp_dew=None, min_cos_zenith=0.065,
2174
2183
  max_zenith=87):
@@ -3653,7 +3662,7 @@ def _get_dirint_coeffs():
3653
3662
  since='0.11.2',
3654
3663
  old_param_name='clearsky_dni',
3655
3664
  new_param_name='dni_clear',
3656
- removal="0.13.0")
3665
+ removal="0.14.0")
3657
3666
  def dni(ghi, dhi, zenith, dni_clear=None, clearsky_tolerance=1.1,
3658
3667
  zenith_threshold_for_zero_dni=88.0,
3659
3668
  zenith_threshold_for_clearsky_limit=80.0):
@@ -0,0 +1,20 @@
1
+ """
2
+ The ``sdm`` package contains functions to fit single diode models.
3
+ Function names should follow the pattern "fit_" + name of model + "_" +
4
+ fitting method.
5
+ """
6
+
7
+ from pvlib.ivtools.sdm.cec import ( # noqa: F401
8
+ fit_cec_sam,
9
+ )
10
+
11
+ from pvlib.ivtools.sdm.desoto import ( # noqa: F401
12
+ fit_desoto,
13
+ fit_desoto_sandia
14
+ )
15
+
16
+ from pvlib.ivtools.sdm.pvsyst import ( # noqa: F401
17
+ fit_pvsyst_sandia,
18
+ fit_pvsyst_iec61853_sandia_2025,
19
+ pvsyst_temperature_coeff,
20
+ )