FairShip
Loading...
Searching...
No Matches
add_noise_to_field Namespace Reference

Functions

None plot_my_hist (datum)
None generate_file (input_fileName, output, xSpace=73, ySpace=128, zSpace=1214, step=2.5, *, argparse.Namespace args)

Variables

 parser = argparse.ArgumentParser(description="Process field.")
 default
 type
 str
 action
 False
 float
 int
 args = parser.parse_args()
 first_line = f.readline().strip().split()
 xSpace
 ySpace
 zSpace
 step

Function Documentation

◆ generate_file()

None add_noise_to_field.generate_file ( input_fileName,
output,
xSpace = 73,
ySpace = 128,
zSpace = 1214,
step = 2.5,
* ,
argparse.Namespace args )

Definition at line 22 of file add_noise_to_field.py.

24) -> None:
25 # (min, max, max/stepSize + 1) in case of Z: (0, nSteps*2.5 - 2.5, nSteps)
26 field = pd.read_csv(input_fileName, skiprows=1, sep=r"\s+", names=["x", "y", "z", "bx", "by", "bz"])
27
28 field_mask = field.copy()
29 field_mask[["bx", "by", "bz"]] = field_mask[["bx", "by", "bz"]] != 0
30
31 field_new = field.copy()
32
33 if args.sidesOnly:
34 temp_by = np.array(field_new["by"]).reshape([xSpace, ySpace, zSpace])
35 temp_by = gaussian_filter(temp_by, sigma=args.sigma)
36 field_new["by"] = temp_by.reshape(-1)
37 field_new["by"] = field_new["by"] * field_mask["by"]
38 rezult = field_new
39 else:
40 field_new[["bx", "by", "bz"]] = 0
41 index_range = np.random.choice(field_new.index, size=args.nCores)
42 # Draw an independent value per noise core so --peak sets the amplitude;
43 # a single scalar (assigned to every core) was cancelled by the
44 # self-normalisation below, leaving --peak with no effect but its sign.
45 field_new.loc[index_range, "by"] = np.random.uniform(-args.peak, args.peak, size=args.nCores)
46 temp_by = np.array(field_new["by"]).reshape([xSpace, ySpace, zSpace])
47 temp_by = gaussian_filter(temp_by, sigma=args.sigma)
48 field_new["by"] = temp_by.reshape(-1)
49 field_new["by"] = field_new["by"] * field_mask["by"]
50 rezult = field.copy()
51 rezult["by"] = rezult["by"] + rezult["by"] * field_new["by"] * args.fraction
52
53 # plot_my_hist(field_mask)
54 # plot_my_hist(field)
55 # plot_my_hist(field_new)
56 # plot_my_hist(rezult)
57 rezult.to_csv(output, sep="\t", header=False, index=False)
58
59

◆ plot_my_hist()

None add_noise_to_field.plot_my_hist ( datum)

Definition at line 13 of file add_noise_to_field.py.

13def plot_my_hist(datum) -> None:
14 plotData = datum[datum["y"] == 0]
15 H, _xedges, _yedges = np.histogram2d(plotData["x"], plotData["z"], bins=[50, 500], weights=plotData["by"])
16 plt.figure(figsize=[20, 10])
17 plt.imshow(H, interpolation="nearest", origin="lower")
18 # plt.colorbar()
19 plt.show()
20
21

Variable Documentation

◆ action

add_noise_to_field.action

Definition at line 62 of file add_noise_to_field.py.

◆ args

add_noise_to_field.args = parser.parse_args()

Definition at line 71 of file add_noise_to_field.py.

◆ default

add_noise_to_field.default

Definition at line 62 of file add_noise_to_field.py.

◆ False

add_noise_to_field.False

Definition at line 66 of file add_noise_to_field.py.

◆ first_line

add_noise_to_field.first_line = f.readline().strip().split()

Definition at line 74 of file add_noise_to_field.py.

◆ float

add_noise_to_field.float

Definition at line 67 of file add_noise_to_field.py.

◆ int

add_noise_to_field.int

Definition at line 68 of file add_noise_to_field.py.

◆ parser

add_noise_to_field.parser = argparse.ArgumentParser(description="Process field.")

Definition at line 61 of file add_noise_to_field.py.

◆ step

add_noise_to_field.step

Definition at line 82 of file add_noise_to_field.py.

◆ str

add_noise_to_field.str

Definition at line 62 of file add_noise_to_field.py.

◆ type

add_noise_to_field.type

Definition at line 62 of file add_noise_to_field.py.

◆ xSpace

add_noise_to_field.xSpace

Definition at line 79 of file add_noise_to_field.py.

◆ ySpace

add_noise_to_field.ySpace

Definition at line 80 of file add_noise_to_field.py.

◆ zSpace

add_noise_to_field.zSpace

Definition at line 81 of file add_noise_to_field.py.