Last active
March 17, 2022 22:13
-
-
Save d-chambers/5cd99ecbac18425fd0265bda9d44b626 to your computer and use it in GitHub Desktop.
Reading RSF (Madagascar) files into numpy arrays.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example modified from here: https://github.com/ahay/src/issues/130 | |
from subprocess import run | |
import m8r | |
import numpy as np | |
# create example data | |
run('sfspike n1=5 n2=5 k1=3 > spike.rsf', shell=True) | |
# Read rsf file | |
rsf = m8r.Input('spike.rsf') | |
# Init output array of appropriate size | |
output = np.zeros(rsf.shape(), dtype='float32') | |
# Populate output array with contents of rsf file | |
rsf.read(output) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Actually, I just noticed
m8r.Input
has a read method, so this can be simplified: