cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
Neo
Neo
Level VI

How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

Hi,

I have bunch of scripts which I use to analyse the product test data in JMP.

The scripts generally call multiple columns in the test data file.

Each test run is tagged by an ID and only this ID changes for pulling the new test run data into JMP - the scripts used for data analysis remain same.

 

For sharing my analysis I (currently) manually create a PPT slide pack with the charts and analysis data (such as median & std-dev etc.).

I would like to move to JMP journal.

 

I was wondering if it is possible to have a script which would (either by running my other analysis scripts automatically or without) send the charts and analysis data to a JMP journal? If this is possible, could I please get some help with example script to put together such a journal?

 

Thanks.

When it's too good to be true, it's neither
9 REPLIES 9
ih
Super User (Alumni) ih
Super User (Alumni)

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

A web search for 'scripting a JMP journal' will give you more examples, but this might get you pointed in the right direction:

 

Names default to here(1);

dt = Open("$SAMPLE_DATA\Big Class.jmp");

// New Journal with a couple headings
nw = New Window("My Journal", <<Journal,
    obHist = Outline Box("Histograms"),
    obXY = Outline Box("Scatterplots")
);

// Save graphs to the journal
obHist << Append(
	dt << Distribution(
		Nominal Distribution( Column( :name ) ),
		Nominal Distribution( Column( :age ) ),
		Nominal Distribution( Column( :sex ) ),
		Continuous Distribution( Column( :height ) ),
		Continuous Distribution( Column( :weight ) ),
		Histograms Only
	)
);

obXY << Append(
	dt << Graph Builder(
		Size( 867, 280 ),
		Show Control Panel( 0 ),
		Variables( X( :height ), Y( :weight ), Group X( :age ) ),
		Elements( Points( X, Y, Legend( 5 ) ) )
	)
);
Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

Thanks. Yes, this does point me to an approach I could follow.

However, I note that the data file loading script and the graph plotting/analysis scripts etc need to be written in within the script for generating the journal.

In my case, I already have separate scripts which loads the data, plots the necessary graphs and generates the necessary analysis. 

 

I there a way to reference existing scripts from within the journal script without writing them again inside the journal script?

When it's too good to be true, it's neither
ian_jmp
Staff

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

If you don't want to modify your existing scripts, you could try this kind of approach. If the scripts are not saved in the table, look at the JSL 'Include()' function:

NamesDefaultToHere(1);

// Returns a list containing the names of all the currently open windows in a session
namesOfOpenWindows = 
Function({}, {DefaultLocal},
	openWindows = Window();
	openWindowNames = {};
	For(w=1, w<=NItems(openWindows), w++, InsertInto(OpenWindowNames, OpenWindows[w] << GetWindowTitle));
	openWindowNames;
);

// Which windows are open now?
preWindowList = namesOfOpenWindows();

// Open a table
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Find out what scripts are in the table
dts = dt << GetTableScriptNames;

// Run every script
for (s=1, s<=NItems(dts), s++, dt << runScript(dts[s]));

// Which windows are open now?
postWindowList = namesOfOpenWindows();

// Journal the contents of each 'new' window
for(w=1, w<=NItems(postWindowList), w++,
	thisWindow = postWindowList[w];
	if (!Contains(preWindowList, thisWindow), Window(thisWindow) << Journal);
	);

 

Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

Thanks @ian_jmp .

 

Your script looks extremely useful, especially as I am relatively new to JMP (coming from MATLAB)..

However, I do not understand you comment on "if the scripts are not saved in the table".

My scripts are saved and do not change for analysis of new test data (as mentioned in my OP).

 

Also, I only need specific charts from each script and only some calculated analysis data (such as median and std-dev for example, not other parameters which JMP also calculates) to go to the journal. How to achieve this in JSL?

 

When it's too good to be true, it's neither
txnelson
Super User

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

The selecting of specific reports from your output is fairly simple, but quite specific.  I suggest that you take the time to read the Scripting Guide to get started.  Then your specific questions about how to get the precise reports will either be answered by the documentation, or you will be able to provide a more detailed question for the community to answer.

Jim
Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

@ian_jmp . I am trying to use your script in the following way.

I have written a script which loads the data file and plots various charts.

 

 

partID = "part012"; // specifies part ID
DataTable = getDataTable4WfrID2(partID,partID);  // loads test data table corresponding to the partID and names it the same as partID
include ("allGraphPlotter.jsl"); //plots all necessary charts

The above script works as expected.

 

Then (on fourth line above), I tried to include your script as below (note the commented lines) for sending the charts to journal but is not working.

Where am I going wrong (perhaps my include statement or the function call e.g. output = namesOfOpenWindows())? 

NamesDefaultToHere(1);

// Returns a list containing the names of all the currently open windows in a session
namesOfOpenWindows = 
Function({}, {DefaultLocal},
	openWindows = Window();
	openWindowNames = {};
	For(w=1, w<=NItems(openWindows), w++, InsertInto(OpenWindowNames, OpenWindows[w] << GetWindowTitle));
	openWindowNames;
);

// Which windows are open now?
preWindowList = namesOfOpenWindows();

// Open a table
//dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Find out what scripts are in the table
//dts = dt << GetTableScriptNames;

// Run every script
//for (s=1, s<=NItems(dts), s++, dt << runScript(dts[s]));

// Which windows are open now?
postWindowList = namesOfOpenWindows();

// Journal the contents of each 'new' window
for(w=1, w<=NItems(postWindowList), w++,
	thisWindow = postWindowList[w];
	if (!Contains(preWindowList, thisWindow), Window(thisWindow) << Journal);
	);

 

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

@ian_jmp . I have now done some more tests. This part of your script is not working.

for(w=1, w<=NItems(postWindowList), w++,
	thisWindow = postWindowList[w];
	if (!Contains(preWindowList, thisWindow), Window(thisWindow) << Journal);
	);

Everything above this in your script gives expected results, but only if I comment the above for loop block.

Also, I do not get the charts into the journal, so only the code above the for looks seems to work as expected unless I am doing something wrong.

 

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

@ian_jmp , If I try the following way I do not get a list of open chart windows (in log) unless I comment the for loop (at the end).

Also, no journal file gets generated. Where am I making the mistake?

 

I define a function (called getOpenWindowNames.jsl) and execute it

Names Default To Here(1);

// Returns a list containing the names of all the currently open windows in a session
namesOfOpenWindows = 
Function({}, {DefaultLocal},
	openWindows = Window();
	openWindowNames = {};
	For(w=1, w<=NItems(openWindows), w++, InsertInto(OpenWindowNames, OpenWindows[w] << GetWindowTitle));
	openWindowNames;
);

Then call the above function in another script  as

Names Default To Here(1);
//Clear Symbols();
include ("getOpenWindowNames.jsl");

// Which windows are open now?
preWindowList = namesOfOpenWindows();

// Open a table
dt = Open("$SAMPLE_DATA/Big Class.jmp");

// Find out what scripts are in the table
dts = dt << GetTableScriptNames;

// Run every script
for (s=1, s<=NItems(dts), s++, dt << runScript(dts[s]));

// Which windows are open now?
postWindowList = namesOfOpenWindows();

//// Journal the contents of each 'new' window
for(w=1, w<=NItems(postWindowList), w++,
	thisWindow = postWindowList[w];
	if (!Contains(preWindowList, thisWindow), Window(thisWindow) << Journal);
	);

 

 

When it's too good to be true, it's neither
Neo
Neo
Level VI

Re: How do I script for sending charts and analysis data to the journal without manually running existing scripts for charts/analysis?

@ian_jmp  -  I broke down your suggested code to track down what is not working. It appears that the issue is in the line in the for loop

thisWindow = postWindowList[w];

which in my case reports in the log (when a simple script is run to plot a chart)

"part012 - Graph Builder"

for the first chart item not in 

preWindowList 

Then just running 

Window(thisWindow) << Journal

does not put the window called

"part012 - Graph Builder"

into a journal file. Is there an issue with the name "part012 - Graph Builder" itself due to which this chart does not get send to a journal?

When it's too good to be true, it's neither