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")
23 input_fileName, output, xSpace=73, ySpace=128, zSpace=1214, step=2.5, *, args: argparse.Namespace
26 field = pd.read_csv(input_fileName, skiprows=1, sep=
r"\s+", names=[
"x",
"y",
"z",
"bx",
"by",
"bz"])
28 field_mask = field.copy()
29 field_mask[[
"bx",
"by",
"bz"]] = field_mask[[
"bx",
"by",
"bz"]] != 0
31 field_new = field.copy()
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"]
40 field_new[[
"bx",
"by",
"bz"]] = 0
41 index_range = np.random.choice(field_new.index, size=args.nCores)
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"]
51 rezult[
"by"] = rezult[
"by"] + rezult[
"by"] * field_new[
"by"] * args.fraction
57 rezult.to_csv(output, sep=
"\t", header=
False, index=
False)
67 parser.add_argument(
"--sigma", default=30, type=float, action=
"store")
68 parser.add_argument(
"--nCores", default=1000, type=int, action=
"store")
69 parser.add_argument(
"--peak", default=500, type=float, action=
"store")
70 parser.add_argument(
"--fraction", default=0.4, type=float, action=
"store")
None generate_file(input_fileName, output, xSpace=73, ySpace=128, zSpace=1214, step=2.5, *, argparse.Namespace args)