Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scrape weather function unhandled error #240

Open
SamuelButterworth opened this issue Aug 27, 2024 · 0 comments
Open

Scrape weather function unhandled error #240

SamuelButterworth opened this issue Aug 27, 2024 · 0 comments
Assignees
Labels
type:bug Error or unexpected behaviour

Comments

@SamuelButterworth
Copy link

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.<locals>.decorator.<locals>.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.<locals>.decorator.<locals>.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
@SamuelButterworth SamuelButterworth added the type:bug Error or unexpected behaviour label Aug 27, 2024
@github-staff github-staff deleted a comment from YeGop0218 Oct 28, 2024
@github-staff github-staff deleted a comment from YeGop0218 Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug Error or unexpected behaviour
Projects
None yet
Development

No branches or pull requests

3 participants