import numpy as np import struct import xml.etree.ElementTree as ET from xml.dom import minidom def main(): pretime = 500 * 10 ** -6 uptime = 50 * 10 ** -6 posttime = 60 * 10 ** -6 sample_freq = 2 pulse_number = 1 #add = (pulse_width * pulse_number * sample_freq * (10**6) * 2) counter = 0 n_pre = round(pretime * sample_freq * (10 ** 6)) n_up = round(uptime * sample_freq * (10 ** 6)) n_post = round(posttime * sample_freq * (10 ** 6)) size_1 =(n_pre + n_post + n_up) * 2 print(f'rf array size_1 = {size_1}') size_2 = np.int32(size_1) * np.int32(pulse_number) print(f'rf array size_2 = {size_2}') rf_array = np.zeros(size_2, dtype=np.int8) for _ in range(0, pulse_number, 1): for _ in range(0, n_pre, 1): rf_array[counter] = np.int8(0) rf_array[counter + 1] = np.int8(0) counter += 2 for _ in range(0, n_up, 1): rf_array[counter] = np.int8(127) rf_array[counter + 1] = np.int8(0) counter += 2 for _ in range(0, n_up, 1): rf_array[counter] = np.int8(0) rf_array[counter + 1] = np.int8(0) counter += 2 print(rf_array) f = open(f'test3_22_08_25.bin', 'wb') # открываем файл на чтение for elem in rf_array: # берём каждую строчку из файла f f.write(struct.pack('