Skip to content

Commit

Permalink
Updating syntax for flake8 protocol.
Browse files Browse the repository at this point in the history
  • Loading branch information
ryan.haagenson@pnnl.gov committed Nov 27, 2024
1 parent 38b94a4 commit 750bc66
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
4 changes: 2 additions & 2 deletions SOSAT/stress_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,8 @@ def plot_posterior(self,
self.evaluate_posterior()

# Convert data format to bin-centered eval of PDF for plotting
dsig = self.shmax_grid[0][1]-self.shmax_grid[0][0]
posterior_PDF = self.posterior/dsig**2.0
dsig = self.shmax_grid[0][1] - self.shmax_grid[0][0]
posterior_PDF = self.posterior / dsig**2.0

fig = plt.figure(figsize=(figwidth, figheight))
ax = fig.add_subplot(111)
Expand Down
70 changes: 35 additions & 35 deletions tests/test_PDF_plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,49 +8,49 @@

def test_PDF_plotting():

# depth in meters
depth = 1228.3
# density in kg/m^3
avg_overburden_density = 2580.0
# pore pressure gradient in MPa/km
pore_pressure_grad = 9.955
# depth in meters
depth = 1228.3
# density in kg/m^3
avg_overburden_density = 2580.0
# pore pressure gradient in MPa/km
pore_pressure_grad = 9.955

pore_pressure = pore_pressure_grad * (1.0 / 1000) * depth
pore_pressure = pore_pressure_grad * (1.0 / 1000) * depth

# Create two StessState objects that differ only for nbins
ss_50 = StressState(depth=depth,
avg_overburden_density=avg_overburden_density,
pore_pressure=pore_pressure,nbins=50)
# Create two StessState objects that differ only for nbins
ss_50 = StressState(depth=depth,
avg_overburden_density=avg_overburden_density,
pore_pressure=pore_pressure, nbins=50)

ss_5000 = StressState(depth=depth,
avg_overburden_density=avg_overburden_density,
pore_pressure=pore_pressure,nbins=5000)
ss_5000 = StressState(depth=depth,
avg_overburden_density=avg_overburden_density,
pore_pressure=pore_pressure, nbins=5000)

fc = FaultConstraint()
fc = FaultConstraint()

ss_50.add_constraint(fc)
ss_5000.add_constraint(fc)
ss_50.add_constraint(fc)
ss_5000.add_constraint(fc)

ss_50.evaluate_posterior()
ss_5000.evaluate_posterior()
ss_50.evaluate_posterior()
ss_5000.evaluate_posterior()

# These lines are repeated in StressState.plot_posterior()
# Convert data format to bin-centered eval of PDF for plotting
dsig_50 = ss_50.shmax_grid[0][1]-ss_50.shmax_grid[0][0]
posterior_PDF_50 = ss_50.posterior/dsig_50**2.0
# These lines are repeated in StressState.plot_posterior()
# Convert data format to bin-centered eval of PDF for plotting
dsig_50 = ss_50.shmax_grid[0][1] - ss_50.shmax_grid[0][0]
posterior_PDF_50 = ss_50.posterior / dsig_50**2.0

dsig_5000 = ss_5000.shmax_grid[0][1]-ss_5000.shmax_grid[0][0]
posterior_PDF_5000 = ss_5000.posterior/dsig_5000**2.0
dsig_5000 = ss_5000.shmax_grid[0][1] - ss_5000.shmax_grid[0][0]
posterior_PDF_5000 = ss_5000.posterior / dsig_5000**2.0

# Test if maximum value of posterior is approximately equal
# Small err is expected due to different discretizations of sigma-space
tol = 5.0e-2
rel_err = (np.nanmax(posterior_PDF_50) - np.nanmax(posterior_PDF_5000)) \
/ np.nanmax(posterior_PDF_50)
assert rel_err <= tol
# Test if maximum value of posterior is approximately equal
# Small err is expected due to different discretizations of sigma-space
tol = 5.0e-2
rel_err = (np.nanmax(posterior_PDF_50) - np.nanmax(posterior_PDF_5000)) \
/ np.nanmax(posterior_PDF_50)
assert rel_err <= tol

fig_50 = ss_50.plot_posterior()
fig_5000 = ss_5000.plot_posterior()
fig_50 = ss_50.plot_posterior()
fig_5000 = ss_5000.plot_posterior()

fig_50.savefig("50_bin_posterior_PDF.png")
fig_5000.savefig("5000_bin_posterior_PDF.png")
fig_50.savefig("50_bin_posterior_PDF.png")
fig_5000.savefig("5000_bin_posterior_PDF.png")

0 comments on commit 750bc66

Please sign in to comment.