Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions commonutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
from neuron import h
from pathlib import Path
from typing import List
from typing import List, Literal

def mkdir_p(path):
try:
Expand Down Expand Up @@ -169,15 +169,20 @@ def setup_nrnbbcore_register_mapping(rings):

def write_report_config(output_file, report_name, target_name, report_type, report_variable,
unit, report_format, target_type, dt, start_time, end_time, gids,
buffer_size=8):
buffer_size=8, scaling: Literal["none", "area"] = "area"):
"""
Writes the configuration for a report to a file. Check the docs here:

https://sonata-extension.readthedocs.io/en/latest/sonata_simulation.html#reports
"""
import struct
num_gids = len(gids)
report_conf = Path(output_file)
report_conf.parent.mkdir(parents=True, exist_ok=True)
with report_conf.open("wb") as fp:
# Write the formatted string to the file
fp.write(b"1\n")
fp.write(("%s %s %s %s %s %s %d %lf %lf %lf %d %d\n" % (
fp.write(("%s %s %s %s %s %s %d %lf %lf %lf %d %d %s\n" % (
report_name,
target_name,
report_type,
Expand All @@ -189,7 +194,8 @@ def write_report_config(output_file, report_name, target_name, report_type, repo
start_time,
end_time,
num_gids,
buffer_size
buffer_size,
scaling
)).encode())
# Write the array of integers to the file in binary format
fp.write(struct.pack(f'{num_gids}i', *gids))
Expand Down