Skip to content

Add FunctionFromDatafile() function to be used in input scripts#343

Merged
JonathanMaes merged 3 commits into3.11from
feature/functionfromfile
Oct 23, 2024
Merged

Add FunctionFromDatafile() function to be used in input scripts#343
JonathanMaes merged 3 commits into3.11from
feature/functionfromfile

Conversation

@JonathanMaes
Copy link
Copy Markdown
Contributor

Several years ago, @JeroenMulkers created the FunctionFromDatafile function. This can be used to read a CSV file and create a function that maps any column to another column. I now added a test for this, and the feature can be merged.

The function is used as FunctionFromDatafile(filename, xColumnIdx, yColumnIdx, interpolation), where the available interpolation methods are the self-explanatory "linear", "nearest" or "step". Example usage:

f = FunctionFromDatafile("data.csv", 0, 1, "step")
B_ext = Vector(0, 0, f(t))

where the first column of data.csv (i.e. column index 0) in this example contains the timestamps, and the second column (index 1) contains the field magnitudes. Lines in data.csv starting with # are ignored, so can be used for e.g. a header row.

@JonathanMaes JonathanMaes merged commit b8df3f7 into 3.11 Oct 23, 2024
@JonathanMaes JonathanMaes deleted the feature/functionfromfile branch October 23, 2024 12:01
@JonathanMaes JonathanMaes mentioned this pull request Oct 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants