BHoM / BHoM/LadybugTools_Toolkit

Scrape weather function unhandled error

Open
#240 0 comments 0 reactions 2 assignees Claimed by @tg359 View on GitHub
type:bug
Dominant language
Python
Stars
3
Forks
2
Avg merge
8d 20h
Merged PRs (30d)
2

Description

#### Description:

Using the `scrape_weather()` function from `ladybugtools_toolkit\helpers.py`, an error is received when trying to run the OMRK weather station from 2003 to 2023. Error is pasted at bottom of this issue.

#### Steps to reproduce:

Run the following code:
```
from ladybugtools_toolkit.helpers import scrape_weather

scrape_weather(station_name, start_date, end_date, station_name)

station_name = "OMRK"
start_date = "2003-01-01"
end_date = "2023-12-31"
```

Running this code and it should produce the error message at the bottom.

#### Expected behaviour:

Fix should handle this error.

#### Error message:

```
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
Cell In[2], line 10
7 velocity_threshold = 35
8 percentage_threshold = 70
---> 10 df = scrape_weather(station_name, start_date, end_date, station_name)
12 df["indexes"] = df.index
13 df['datetime_objects'] = pd.to_datetime(df['indexes'], format='%d/%m/%Y %H:%M:%S')

File c:\programdata\bhom\extensions\pythoncode\ladybugtools_toolkit\src\ladybugtools_toolkit\bhom\analytics.py:85, in bhom_analytics..decorator..wrapper(*args, **kwargs)
83 except Exception as exc: # pylint: disable=broad-except
84 exec_metadata["Errors"].extend(sys.exc_info())
---> 85 raise exc
86 finally:
87 ANALYTICS_LOGGER.info(
88 json.dumps(exec_metadata, default=str, indent=None)
89 )

File c:\programdata\bhom\extensions\pythoncode\ladybugtools_toolkit\src\ladybugtools_toolkit\bhom\analytics.py:82, in bhom_analytics..decorator..wrapper(*args, **kwargs)
52 exec_metadata = {
53 "BHoMVersion": BHOM_VERSION,
54 "BHoM_Guid": _id,
(...)
78 "_t": "BH.oM.UI.UsageLogEntry",
79 }
81 try:
---> 82 result = function(*args, **kwargs)
83 except Exception as exc: # pylint: disable=broad-except
84 exec_metadata["Errors"].extend(sys.exc_info())

File c:\programdata\bhom\extensions\pythoncode\ladybugtools_toolkit\src\ladybugtools_toolkit\helpers.py:334, in scrape_weather(station, start_date, end_date, interpolate, resample)
331 vals = []
332 for _, row in df.iterrows():
333 vals.append(
--> 334 estimate_illuminance_from_irradiance(
335 row.solar_altitude * 180 / math.pi,
336 row.global_horizontal_radiation,
337 row.direct_normal_radiation,
338 row.diffuse_horizontal_radiation,
339 row.dew_point_temperature,
340 )
341 )
342 gh_ill, dn_ill, dh_ill, z_lum = list(zip(*vals))
343 df["direct_normal_illuminance"] = dn_ill

File C:\ProgramData\BHoM\Extensions\PythonEnvironments\LadybugTools_Toolkit\lib\site-packages\ladybug\skymodel.py:316, in estimate_illuminance_from_irradiance(altitude, ghi, dni, dhi, dew_point, rel_airmass)
314 e_category = 7
315 else:
--> 316 raise ValueError('Error in sky luminous efficacy calculation\n'
317 'eps: %f altitude: %f' % (eps, altitude))
319 # Perez Table 4: Luminous Efficacy
320 glob_lum_eff_coeff = ((96.63, -0.47, 11.50, -9.16),
321 (107.54, 0.79, 1.79, -1.19),
322 (98.73, 0.70, 4.40, -6.95),
(...)
326 (78.63, 1.47, 4.93, -11.37),
327 (99.65, 1.86, -4.46, -3.15))

ValueError: Error in sky luminous efficacy calculation
eps: -6.351289 altitude: 12.695684
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.