Skip to content

Commit 656a44a

Browse files
committed
Fixed BBP 22.4.0 compatibility issues with Python 3.13 and gcc 13
1 parent 8781ecb commit 656a44a

File tree

17 files changed

+140
-117
lines changed

17 files changed

+140
-117
lines changed

.github/scripts/bbp-build-ci.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ echo "===================FFTW=================="
6161
mkdir -p ${FFTW_BUILD_DIR}
6262
OLD_DIR=`pwd`
6363
cd ${FFTW_BUILD_DIR}
64-
download_untar https://g-c662a6.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/fftw-3.3.8.tar.gz
64+
download_untar https://g-3a9041.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/fftw-3.3.8.tar.gz
6565
cd fftw-3.3.8
6666
./configure --prefix=${FFTW_INSTALL_DIR}
6767
make
@@ -92,14 +92,14 @@ echo
9292
# Install LABasin500 (CI) region and NR validation packages
9393
echo "==> Installing LA Basin CI region..."
9494
cd ${BASEDIR}/bbp_gf
95-
download_untar https://g-c662a6.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/labasin500ci-velocity-model-${VERSION}.tar.gz
95+
download_untar https://g-3a9041.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/labasin500ci-velocity-model-${VERSION}.tar.gz
9696
echo
9797
ls ${BASEDIR}/bbp_gf
9898
echo
9999

100100
echo "==> Installing NR validation package..."
101101
cd ${BASEDIR}/bbp_val
102-
download_untar https://g-c662a6.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/nr-validation-${VERSION}.tar.gz
102+
download_untar https://g-3a9041.a78b8.36fe.data.globus.org/bbp/releases/${VERSION}/nr-validation-${VERSION}.tar.gz
103103
echo
104104
ls ${BASEDIR}/bbp_val
105105
echo

.github/workflows/bbp-ci.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,27 @@
11
name: bbp-ci
22

3-
on: push
3+
on:
4+
push:
5+
pull_request:
46

57
jobs:
68
bbp-build-linux:
7-
runs-on: ubuntu-20.04
9+
runs-on: ubuntu-latest
810
strategy:
911
matrix:
10-
python-version: [ "3.7", "3.8", "3.9", "3.10" ]
12+
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
1113
steps:
1214
- name: set BBP_DIR
1315
run: echo "BBP_BASE_DIR=$RUNNER_WORKSPACE/bbp" >> $GITHUB_ENV
1416
- name: Setup Python ${{ matrix.python-version }}
15-
uses: actions/setup-python@v3
17+
uses: actions/setup-python@v4
1618
with:
1719
python-version: ${{ matrix.python-version }}
1820
- name: configure Python
1921
run: |
2022
sudo apt-get update
21-
sudo apt-get install g++-8 -y
22-
sudo apt-get install gfortran-8 -y
23+
sudo apt-get install g++ -y
24+
sudo apt-get install gfortran -y
2325
pip install numpy
2426
pip install scipy
2527
pip install matplotlib

bbp/comps/PySeismoSoil/PySeismoSoil/class_site_factors.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import os
44
import itertools
55
import numpy as np
6-
import pkg_resources
6+
import importlib.resources
77
from scipy.interpolate import griddata
88

99
from .class_frequency_spectrum import Frequency_Spectrum
@@ -41,11 +41,9 @@ class Site_Factors():
4141
#%%------------------------------------------------------------------------
4242
def __init__(self, Vs30_in_meter_per_sec, z1_in_m, PGA_in_g,
4343
lenient=False):
44-
self.dir_amplif = pkg_resources.resource_filename('PySeismoSoil',
45-
'data/amplification/')
46-
self.dir_phase = pkg_resources.resource_filename('PySeismoSoil',
47-
'data/phase/')
48-
44+
base_pkg_dir = importlib.resources.files("PySeismoSoil")
45+
self.dir_amplif = os.path.join(base_pkg_dir, 'data', 'amplification')
46+
self.dir_phase = os.path.join(base_pkg_dir, 'data', 'phase')
4947
status = Site_Factors._range_check(Vs30_in_meter_per_sec, z1_in_m,
5048
PGA_in_g)
5149
if 'Vs30 out of range' in status:

bbp/comps/anderson_gof.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -51,6 +51,16 @@
5151
from scipy import signal, stats
5252
from scipy.signal import butter, filtfilt
5353

54+
# Compatible with SciPy 1.4
55+
try:
56+
cumulative_trapezoid = integrate.cumulative_trapezoid
57+
except AttributeError:
58+
cumulative_trapezoid = integrate.cumtrapz
59+
try:
60+
simpson = integrate.simpson
61+
except AttributeError:
62+
simpson = integrate.simps
63+
5464
# Import BBP modules
5565
import bband_utils
5666
import plot_config
@@ -135,15 +145,15 @@ def eval_func2(p1, p2):
135145

136146
@staticmethod
137147
def integral(x, idt):
138-
return integrate.simps(x, x=None, dx=idt)
148+
return simpson(x, x=None, dx=idt)
139149

140150
@staticmethod
141151
def integral2(x, idt):
142-
return integrate.simps(x * x, x=None, dx=idt)
152+
return simpson(x * x, x=None, dx=idt)
143153

144154
@staticmethod
145155
def integ(array_in, idt):
146-
return integrate.cumtrapz(array_in, dx=idt)
156+
return cumulative_trapezoid(array_in, dx=idt)
147157

148158
@staticmethod
149159
def shift_bit_length(x):

bbp/comps/arias_duration.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
#!/usr/bin/env python3
12
"""
23
BSD 3-Clause License
34
4-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
56
All rights reserved.
67
78
Redistribution and use in source and binary forms, with or without
@@ -40,6 +41,12 @@
4041
import math
4142
import scipy.integrate
4243

44+
# Compatible with SciPy 1.4
45+
try:
46+
cumulative_trapezoid = scipy.integrate.cumulative_trapezoid
47+
except AttributeError:
48+
cumulative_trapezoid = scipy.integrate.cumtrapz
49+
4350
# Converting to cm units. Use approximation to g
4451
G_TO_CMS = 981.0 # %(cm/s)
4552

@@ -97,9 +104,9 @@ def ad_from_acc(a_in_peer_file, a_out_ad):
97104
# Integrate and calculate vel and disp arrays
98105
#
99106
acc_cms = [value * G_TO_CMS for value in acc]
100-
velo = list(dt * scipy.integrate.cumtrapz(acc_cms))
107+
velo = list(dt * cumulative_trapezoid(acc_cms))
101108
velo.insert(0, 0)
102-
disp = list(dt * scipy.integrate.cumtrapz(velo))
109+
disp = list(dt * cumulative_trapezoid(velo))
103110
disp.insert(0, 0)
104111

105112
#
@@ -138,7 +145,7 @@ def ad_from_acc(a_in_peer_file, a_out_ad):
138145
# Arias Intensities
139146
# Using the trapezoidal integration
140147
arias_intensity = [pow((value * G_TO_CMS), 2) for value in acc]
141-
tsum = list(scipy.integrate.cumtrapz(arias_intensity) * dt)
148+
tsum = list(cumulative_trapezoid(arias_intensity) * dt)
142149
tsum.insert(0, 0)
143150

144151
arias_intensity = [num * math.pi / (2 * G_TO_CMS) for num in tsum]

bbp/comps/fas.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -491,7 +491,7 @@ def plot_fas_comparison(station, sim_file, data_file, label1, label2,
491491
pylab.ylabel("Fourier Amplitude")
492492
pylab.axis([0.01, 100, 0.001, 1000])
493493
pylab.grid(True)
494-
pylab.grid(b=True, which='major', linestyle='-', color='lightgray')
494+
pylab.grid(which='major', linestyle='-', color='lightgray')
495495
#pylab.grid(b=True, which='minor', linewidth=0.5, color='gray')
496496
if lfreq is not None:
497497
pylab.vlines(lfreq, 0.001, 1000,
@@ -514,7 +514,7 @@ def plot_fas_comparison(station, sim_file, data_file, label1, label2,
514514
pylab.ylabel("Fourier Amplitude")
515515
pylab.axis([0.01, 100, 0.001, 1000])
516516
pylab.grid(True)
517-
pylab.grid(b=True, which='major', linestyle='-', color='lightgray')
517+
pylab.grid(which='major', linestyle='-', color='lightgray')
518518
if lfreq is not None:
519519
pylab.vlines(lfreq, 0.001, 1000,
520520
color='violet', linestyles='--')
@@ -536,7 +536,7 @@ def plot_fas_comparison(station, sim_file, data_file, label1, label2,
536536
pylab.ylabel("Fourier Amplitude")
537537
pylab.axis([0.01, 100, 0.001, 1000])
538538
pylab.grid(True)
539-
pylab.grid(b=True, which='major', linestyle='-', color='lightgray')
539+
pylab.grid(which='major', linestyle='-', color='lightgray')
540540
if lfreq is not None:
541541
pylab.vlines(lfreq, 0.001, 1000,
542542
color='violet', linestyles='--')
@@ -574,8 +574,8 @@ def plot_fas(freqs, ns_data, ew_data, eas_smoothed_data,
574574
pylab.xlabel('Frequency (Hz)')
575575
pylab.axis([0.01, 100, 0.001, 1000])
576576
pylab.grid(True)
577-
pylab.grid(b=True, which='major', linestyle='-', color='lightgray')
578-
pylab.grid(b=True, which='minor', linewidth=0.5, color='gray')
577+
pylab.grid(which='major', linestyle='-', color='lightgray')
578+
pylab.grid(which='minor', linewidth=0.5, color='gray')
579579

580580
# Save plot
581581
pylab.savefig(fas_plot, format="png",

bbp/comps/geobb_srf.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -376,7 +376,7 @@ def write_xyz_srf(self, srf_file, xyz_srf_file, T3M):
376376
lon = float(tokens[0])
377377
lat = float(tokens[1])
378378
[x_cart, y_cart] = self.geo2cart(lon, lat, self.min_lon, self.min_lat)
379-
tmp = T3M * np.mat([x_cart, y_cart, 0, 1]).transpose()
379+
tmp = T3M * np.asmatrix([x_cart, y_cart, 0, 1]).transpose()
380380
tokens[0] = str(float(tmp[0]))
381381
tokens[1] = str(float(tmp[1]))
382382
outfile.write(" %s\n" % " ".join(tokens))
@@ -411,7 +411,7 @@ def write_xyz_srf(self, srf_file, xyz_srf_file, T3M):
411411
lat = float(tokens[1])
412412
[x_cart, y_cart] = self.geo2cart(lon, lat,
413413
self.min_lon, self.min_lat)
414-
tmp = T3M * np.mat([x_cart, y_cart, 0, 1]).transpose()
414+
tmp = T3M * np.asmatrix([x_cart, y_cart, 0, 1]).transpose()
415415
tokens[0] = str(float(tmp[0]))
416416
tokens[1] = str(float(tmp[1]))
417417
outfile.write(" %s\n" % " ".join(tokens))
@@ -540,9 +540,9 @@ def run(self, slo, coord_out_file, fault_out_file,
540540

541541
# % matrix to translate to new minimum values (minimum is [0 0])
542542
T3 = self.translation_matrix([-x_min, -y_min, 0])
543-
T3M = np.mat(T3)
543+
T3M = np.asmatrix(T3)
544544
# % shift opposite corner in x-y
545-
tmp = T3M * np.mat([x_max, y_max, 0, 1]).transpose()
545+
tmp = T3M * np.asmatrix([x_max, y_max, 0, 1]).transpose()
546546
bbextent = [float(tmp[0]), float(tmp[1])]
547547

548548
# Write station coord_out file
@@ -551,13 +551,13 @@ def run(self, slo, coord_out_file, fault_out_file,
551551

552552
sfile = open(coord_out_file, 'w')
553553
for i in range(0, n_stat):
554-
tmp = T3M * np.mat([x_stat[i], y_stat[i], 0, 1]).transpose()
554+
tmp = T3M * np.asmatrix([x_stat[i], y_stat[i], 0, 1]).transpose()
555555
BBx_stat.append(float(tmp[0]))
556556
BBy_stat.append(float(tmp[1]))
557557
sfile.write("%8.4f\t%8.4f\n" % (BBx_stat[i], BBy_stat[i]))
558558
sfile.close()
559559

560-
tmp = T3M * np.mat([hypo_x_cart, hypo_y_cart, 0, 1]).transpose()
560+
tmp = T3M * np.asmatrix([hypo_x_cart, hypo_y_cart, 0, 1]).transpose()
561561
BBx_hypo = float(tmp[0])
562562
BBy_hypo = float(tmp[1])
563563

@@ -574,14 +574,14 @@ def run(self, slo, coord_out_file, fault_out_file,
574574

575575
# < put the 'where' point at the axis origin >
576576
T1 = self.translation_matrix([-corn_x, -corn_y, 0])
577-
T1M = np.mat(T1)
577+
T1M = np.asmatrix(T1)
578578

579579
# < align the fault plane to the north axis >
580580
c = np.cos(np.pi / 180 * self.f_strike[0])
581581
s = np.sin(np.pi / 180 * self.f_strike[0])
582582
T2 = np.array([[c, -s, 0, 0], [s, c, 0, 0],
583583
[0, 0, 1, 0], [0, 0, 0, 1]])
584-
T2M = np.mat(T2)
584+
T2M = np.asmatrix(T2)
585585

586586
# inverse matrixes for inverse transform
587587
T1M_inv = np.linalg.inv(T1M)
@@ -608,7 +608,7 @@ def run(self, slo, coord_out_file, fault_out_file,
608608
math.sin(math.radians(self.f_dip[plane])) +
609609
j * math.sin(math.radians(self.f_dip[plane])))
610610
tmp = (T1M_inv * T2M_inv *
611-
np.mat([x_term, y_term, 0, 1]).transpose())
611+
np.asmatrix([x_term, y_term, 0, 1]).transpose())
612612
sub_coord[j].append([float(tmp[0]),
613613
float(tmp[1]),
614614
z_term])

bbp/comps/pynga/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ def NGA08(model_name, Mw, Rjb, Vs30, period, epislon=0, NGAs=None,
249249
# compute median, std directly for the existing period in the
250250
# period list of the NGA model
251251
values = mapfunc(ngaM, Mw, Rjb, Vs30, period, rake, **kwds)
252-
values = np.array(values)
252+
values = np.array(values, dtype=object)
253253

254254
if itmp == 0:
255255
# do the interpolation for periods that is not in the period

bbp/comps/rzz2015.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -45,6 +45,12 @@
4545
mpl.use('Agg') # Disable use of Tk/X11
4646
import pylab
4747

48+
# Compatible with SciPy 1.4
49+
try:
50+
cumulative_trapezoid = integrate.cumulative_trapezoid
51+
except AttributeError:
52+
cumulative_trapezoid = integrate.cumtrapz
53+
4854
# Import BBP modules
4955
import bband_utils
5056
import plot_config
@@ -106,7 +112,7 @@ def arias(self, F, dt, percent):
106112
n = len(F)
107113

108114
a_i = [pow(value, 2) for value in F]
109-
I = integrate.cumtrapz(a_i) * dt
115+
I = cumulative_trapezoid(a_i) * dt
110116
# Arias Intensity
111117
Ia = (F[0]**2) * dt / 2.0 + I[n-2] + (F[n-1]**2) * dt / 2.0
112118
It = (percent / 100.0) * Ia

bbp/comps/sdsu_mogof.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
#!/usr/bin/env python
1+
#!/usr/bin/env python3
22
"""
33
BSD 3-Clause License
44
5-
Copyright (c) 2021, University of Southern California
5+
Copyright (c) 2026, University of Southern California
66
All rights reserved.
77
88
Redistribution and use in source and binary forms, with or without
@@ -479,7 +479,7 @@ def summarize_results(self, gof_results, summ_results):
479479
self.config.cfggof["file"]["pga"])
480480
PGA_val = np.array(self.get_gof_metric(fname, start_col=0))
481481
self.site_fit = (self.site_fit +
482-
(PGA_val * np.float(self.config.cfggof["weights"]["pga"])))
482+
(PGA_val * float(self.config.cfggof["weights"]["pga"])))
483483
self.metric_count += 1
484484
if self.format == 'A':
485485
self.plotOverlays(self.input_set_1, self.input_set_2, PGA_val)

0 commit comments

Comments
 (0)