0
$\begingroup$

I have a Mathematica module im_solver.m that I wish to iterate through Python or a bash script. The module runs a bunch o' other modules. At the end im_solver.m executes a diagnostic.m that collects all the data and exports to an existing file match_data.csv.

When I run << im_solver.m in a Mathematica notebook everything behaves as expected. When I try and execute im_solver.m through the command line–either through Python or just the regular ol' terminal–the csv is populated with a bunch of nonsense. I'm not sure where the difference comes from. The Mathematica modules are pretty intense and I think at best I can make minimal alterations. I included an example below. Please help =)

Example (Good) Here is a sample of the good output

Lq (mm) KE (keV)
0.695 7.

Example (Messed Up)

Lq (mm) KE (keV)
1.A~\227 10 Max[0. -2.5858 A~\227 10 gradscale

One note: when opening the CSV file I'm hit with a warning that I have 1258 columns, this is the number of sample points in an array that I use to perform some numerical procedures. So it would appear that this array is being saved to the CSV for whatever reason. As I said, this does not happen when running the module through a notebook. Additionally, in the second column there is "gradscale" which is a variable used to scale the gradient array of size 1258.

For reference:

  • Mathematica Version 13.2
  • WolframScript 1.9.0 for Mac OS X x86 (64-bit)
  • MacOS Ventura 13.3.1
$\endgroup$
2
  • 1
    $\begingroup$ Welcome to the Mathematica Stack Exchange. In the absence of a concrete example, it is not possible to offer good advice. Could you please share a minimal example? $\endgroup$ Commented Apr 26, 2023 at 13:07
  • $\begingroup$ It is very hard to guess with so few details. But keep in mind that some code requires the frontend to run and will fail when run without it. It might be that you need to use UsingFrontEnd wrap all or part of your code. $\endgroup$ Commented Apr 26, 2023 at 19:01

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.