10 plotData = datum[datum[
'y'] == 0]
11 H, xedges, yedges = np.histogram2d(plotData[
'x'], plotData[
'z'], bins=[50, 500], weights=plotData[
'by'])
12 plt.figure(figsize=[20, 10])
13 plt.imshow(H, interpolation=
'nearest', origin=
'low')
17def generate_file(input_fileName, output, xSpace=73, ySpace=128, zSpace=1214, step=2.5, args=None):
19 field = pd.read_csv(input_fileName, skiprows=1, sep =
'\s+', names=[
'x',
'y',
'z',
'bx',
'by',
'bz'])
21 field_mask = field.copy()
22 field_mask[[
'bx',
'by',
'bz']] = field_mask[[
'bx',
'by',
'bz']] != 0
24 field_new = field.copy()
27 temp_by = np.array(field_new[
'by']).reshape([xSpace, ySpace, zSpace])
28 temp_by = gaussian_filter(temp_by, sigma=args.sigma)
29 field_new[
'by'] = temp_by.reshape(-1)
30 field_new[
'by'] = field_new[
'by'] * field_mask[
'by']
33 field_new[[
'bx',
'by',
'bz']] = 0
34 index_range = np.random.choice(field_new.index, size=args.nCores)
35 field_new.loc[index_range,
'by'] = random.uniform(-args.peak, args.peak)
36 temp_by = np.array(field_new[
'by']).reshape([xSpace, ySpace, zSpace])
37 temp_by = gaussian_filter(temp_by, sigma=args.sigma)
38 field_new[
'by'] = temp_by.reshape(-1)
39 field_new[
'by'] = field_new[
'by'] / (field_new[
'by'].abs().max())
40 field_new[
'by'] = field_new[
'by'] * field_mask[
'by']
42 rezult[
'by'] = rezult[
'by'] + rezult[
'by'] * field_new[
'by'] * args.fraction
48 rezult.to_csv(output, sep=
'\t', header=
None, index=
None)
56 parser.add_argument(
'--sigma', default=30, type=float, action=
'store')
57 parser.add_argument(
'--nCores', default=1000, type=int, action=
'store')
58 parser.add_argument(
'--peak', default=500, type=float, action=
'store')
59 parser.add_argument(
'--fraction', default=0.4, type=float, action=
'store')