overwrite_files = False
recording_backend = "memory"

import nest
nest.ResetKernel()
nest.SetKernelStatus({
    "overwrite_files": overwrite_files,
    "data_path": './Debug-Log',
    "data_prefix": 'DEBUG-SPIKE-REC',
})
noise_device = nest.Create(
    "poisson_generator",
    params={'start': 0.,'rate' : 100.}
)
Input_SD = nest.Create("spike_detector",1, params={
    "to_file": True,
    "label": "Input_spike_recorder"
})
nest.Connect(noise_device,Input_SD)

nest.Simulate(100.)
# do something here

# When using recording backend "ascii" with overwrite_files set to True,
# you have to move files away here, otherwise they get overwritten and
# you only get to see the results from the next run.
# If you set overwrite_fiules to False, you will get an error here, as
# the file to be created already exists.
# When using the recording backend "memory" with, overwrite_files is
# not considered, as that does not actually write files.
# Data from the recording backend "memory" just accumulates and needs to
# be explicitly deleted from memory using "Input_SD.n_events = 0"

nest.Simulate(100.)

#if recording_backend == "memory":
#    for x in Input_SD.events["times"]:
#        print(f"{x:.2f}")

#  ascii           memory

#  first file      one array
#       3.400      3.40 
#       6.000      6.00 
#       8.200      8.20 
#       22.000     22.00
#       30.900     30.90
#       51.000     51.00
#       81.200     81.20
#       83.800     83.80
#       98.100     98.10

#  second file
#       108.200    108.20
#       132.800    132.80
#       133.100    133.10
#       147.000    147.00
#       148.100    148.10
#       149.500    149.50
#       153.600    153.60
#       161.700    161.70
#       175.100    175.10

