Skip to content

Commit bd1301c

Browse files
committed
push func to get logmean and logstddev
1 parent ab898da commit bd1301c

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed

GUI/fragility_vulnerability_base.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,20 @@ def calculate_vul_curve_edps_to_loss(imls,edps,consequence_model,damage_threshol
158158

159159
return vul_curve_array
160160
#%%
161-
161+
def residual_lognormal_dist(coeffs, imls, fractions):
162+
163+
mu = coeffs[0]
164+
sigma = coeffs[1]
165+
residual = abs(np.array(fractions) - stats.lognorm.cdf(imls, sigma, scale = math.exp(mu)))
166+
167+
return residual
168+
169+
def get_logmean_logstddev(imls_array,poes_loss_ratio_array):
170+
171+
x_vec=imls_array
172+
y_vec=poes_loss_ratio_array
173+
solution, _ = optimize.leastsq(residual_lognormal_dist,[0.1, 0.6],args=(x_vec, y_vec))
174+
logmean=solution[0]
175+
logstddev=solution[1]
176+
177+
return logmean, logstddev

demand/CSM_implementation/csm_python_implementation.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ def get_target_spectrum(knownPer,selectionParams,indPer,rup):
7373
#% =2 for Japan
7474
#% =3 for China or Turkey
7575
#% =4 for Italy
76-
#% .z1 : basin depth (km); depth from ground surface to the 1km/s shear-wave horizon, =999 if unknown
77-
#% .Vs30 : average shear wave velocity in the top 30m of the soil (m/s)
76+
#% .z1 :
77+
#% .Vs30 : average shear wave velocity in the top 30m of the soil (m/s)basin depth (km); depth from ground surface to the 1km/s shear-wave horizon, =999 if unknown
7878
#%
7979
#%
8080
#% Outputs (these could be replaced by user-specified matrices if desired

fragility_vulnerability/fragility_vulnerability_base.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,20 @@ def calculate_vul_curve_edps_to_loss(imls,edps,consequence_model,damage_threshol
158158

159159
return vul_curve_array
160160
#%%
161-
161+
def residual_lognormal_dist(coeffs, imls, fractions):
162+
163+
mu = coeffs[0]
164+
sigma = coeffs[1]
165+
residual = abs(np.array(fractions) - stats.lognorm.cdf(imls, sigma, scale = math.exp(mu)))
166+
167+
return residual
168+
169+
def get_logmean_logstddev(imls_array,poes_loss_ratio_array):
170+
171+
x_vec=imls_array
172+
y_vec=poes_loss_ratio_array
173+
solution, _ = optimize.leastsq(residual_lognormal_dist,[0.1, 0.6],args=(x_vec, y_vec))
174+
logmean=solution[0]
175+
logstddev=solution[1]
176+
177+
return logmean, logstddev

0 commit comments

Comments
 (0)