Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Oct 23, 2024

Conversation

JonathanMaes
Copy link
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
2 tasks
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