Skip to content

Commit 2989adb

Browse files
authored
Merge pull request #10401 from gem/timezone
Import `timezonefinder` at runtime as it was before
2 parents a7d28cb + f5b94c3 commit 2989adb

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

openquake/hazardlib/shakemap/parsers.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
import pandas as pd
3737
from datetime import datetime
3838
from zoneinfo import ZoneInfo
39-
from timezonefinder import TimezoneFinder
4039
from shapely.geometry import Polygon
4140
import numpy
4241

@@ -243,6 +242,16 @@ def utc_to_local_time(utc_timestamp, lon, lat):
243242
"""
244243
Convert a timestamp '%Y-%m-%dT%H:%M:%S.%fZ' into a datetime object
245244
"""
245+
try:
246+
# NOTE: mandatory dependency for ARISTOTLE
247+
from timezonefinder import TimezoneFinder
248+
except ImportError:
249+
raise ImportError(
250+
'The python package "timezonefinder" is not installed. It is'
251+
' required in order to convert the UTC time to the local time of'
252+
' the event. You can install it from'
253+
' https://wheelhouse.openquake.org/v3/linux/ choosing the one'
254+
' corresponding to the installed python version.')
246255
tf = TimezoneFinder()
247256
timezone_str = tf.timezone_at(lng=lon, lat=lat)
248257
if timezone_str is None:

0 commit comments

Comments
 (0)