Skip to content

Commit

Permalink
reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Feb 22, 2024
1 parent d2675f1 commit d2c927b
Show file tree
Hide file tree
Showing 2 changed files with 381 additions and 355 deletions.
44 changes: 27 additions & 17 deletions src/py2dmat/solver/lib_make_convolution.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,50 @@
import numpy as np
import sys
import copy


def calc(RC_data_org, number_of_beams, number_of_glancing_angles, omega, verbose_mode):

sigma = 0.5 * omega / (np.sqrt(2.0*np.log(2.0)))
sigma = 0.5 * omega / (np.sqrt(2.0 * np.log(2.0)))

def g(x):
g = (1.0 / (sigma*np.sqrt(2.0*np.pi))) * np.exp(-0.5 * x ** 2.0 / sigma ** 2.0)
g = (1.0 / (sigma * np.sqrt(2.0 * np.pi))) * np.exp(
-0.5 * x**2.0 / sigma**2.0
)

return g

RC_data_cnv = np.zeros((number_of_glancing_angles, number_of_beams+1))
#copy glancing angle
RC_data_cnv[:,0] = copy.deepcopy(RC_data_org[:,0])
RC_data_cnv = np.zeros((number_of_glancing_angles, number_of_beams + 1))
# copy glancing angle
RC_data_cnv[:, 0] = copy.deepcopy(RC_data_org[:, 0])

if verbose_mode:
print("RC_data_org =\n",RC_data_org)
print("RC_data_cnv =\n",RC_data_cnv)
print('angle_interval=', angle_interval)
print("RC_data_org =\n", RC_data_org)
print("RC_data_cnv =\n", RC_data_cnv)

for beam_index in range(number_of_beams):
for index in range(number_of_glancing_angles):
integral = 0.0
angle_interval = 0.0
for index2 in range(number_of_glancing_angles):
if index2 == number_of_glancing_angles - 1 :
pass
else :
angle_interval = RC_data_org[index2+1,0] - RC_data_org[index2,0]
integral += RC_data_org[index2,beam_index+1] * g(RC_data_org[index,0] - RC_data_org[index2,0]) * angle_interval
if index2 < number_of_glancing_angles - 1:
angle_interval = RC_data_org[index2 + 1, 0] - RC_data_org[index2, 0]
integral += (
RC_data_org[index2, beam_index + 1]
* g(RC_data_org[index, 0] - RC_data_org[index2, 0])
* angle_interval
)
if verbose_mode:
print("beam_index, index, index2, g(RC_data_org[index,0] - RC_data_org[index2,0]) =",beam_index, index, index2, g(RC_data_org[index,0] - RC_data_org[index2,0]))
RC_data_cnv[index, beam_index+1]=integral
print(
"beam_index, index, index2, g(RC_data_org[index,0] - RC_data_org[index2,0]) =",
beam_index,
index,
index2,
g(RC_data_org[index, 0] - RC_data_org[index2, 0]),
)
RC_data_cnv[index, beam_index + 1] = integral

if verbose_mode:
print("RC_data_cnv =\n",RC_data_cnv)
print("RC_data_cnv =\n", RC_data_cnv)

return RC_data_cnv

Loading

0 comments on commit d2c927b

Please sign in to comment.