aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/transivent/io.py16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/transivent/io.py b/src/transivent/io.py
index b7ad1c5..07484e6 100644
--- a/src/transivent/io.py
+++ b/src/transivent/io.py
@@ -255,9 +255,19 @@ def rd(
fp = os.path.join(data_path, filename)
else:
fp = filename
- params = get_waveform_params(
- os.path.basename(fp), data_path, sidecar=sidecar
- )
+
+ # If we have a data_path, use it with just the basename
+ # Otherwise use the directory of the file
+ if data_path is not None:
+ params = get_waveform_params(
+ os.path.basename(fp), data_path, sidecar=sidecar
+ )
+ else:
+ # Use the directory containing the file as data_path
+ file_dir = os.path.dirname(fp) or "."
+ params = get_waveform_params(
+ os.path.basename(fp), file_dir, sidecar=sidecar
+ )
# Use sampling_interval from XML if available, else argument, else raise error
si = params["sampling_interval"]
if si is None: