Author Topic: Surfer Scripting for CalcImage  (Read 13426 times)

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Surfer Scripting for CalcImage
« on: September 11, 2013, 01:01:07 PM »
As many of you know, we utilize Golden Software's Surfer plotting and presentation package for creating most of the output seen in this forum. Usually this output is performed automatically simply by clicking one of the Project | Export menus in CalcImage.

However, it is also possible to customize your output scripts since they are saved automatically. For example, the default is to output 4 plots per page in the normal export mode, but by simply editing one line you can also get 1 full plot per page or 9 plots per page.

To edit your script, run the Surfer Scripter app from the Golden Software menu (note that for editing Grapher scripts you must run the Grapher Scripter app instead).

Then open your script by browsing to it, or simply pick it off the recently opened file list, it will usually be the top entry in the file list.

To change the number of plots per page, go to this line highlighted here in red:

ZLabel$(10) = "Ti Wt%"
ZLabel$(11) = "Oxygen (Stoic) Wt%"
ZLabel$(12) = "Total Wt%"

' Specify number of plots per page (must be 1, 4, or 9 images per page)
PlotsPerPage% = 4

' Call output routine
Call OutputAll(PlotsPerPage%, XInvert%, YInvert%, Directory$, FileArray$(), Sample$, MaxCol%, XLabel$, YLabel$, ZLabel$())

End Sub

 
and change the 4 to a 9, then save and re-run your script by clicking the "play" button in Scripter. You will now get this output which is automatically saved with different file names so your original documents are not overwritten. See attached example.  Remember that one needs to be logged in to see attachments!
« Last Edit: September 21, 2013, 11:29:39 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Gareth D Hatton

  • Professor
  • ****
  • Posts: 51
Re: Surfer Scripting for CalcImage
« Reply #1 on: September 16, 2013, 02:05:02 AM »
I like to change the titles as well so they look neater:

simply change the
Sample$="PI_Testing_MAN_09-09-2013_MSH4-1_00652__Quant"

to something a little shorter as this also appears as the title in your images, saves time later.

eg.  Sample$="MSH4-1_00652"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Surfer Scripting for CalcImage
« Reply #2 on: December 06, 2013, 02:13:29 PM »
Let's run through some CalcImage output and and easy Surfer plot modifications for, say publication quality with some tall-thin plots.

After starting CalcImage and re-opening our quant project file from the Project menu, the raw intensity data is loaded as seen here:



After a horizontal re-tiling from the Window menu we obtain this somewhat improved display:



Since this was a trace element quant map we have off-peak images displayed also, but by simply clicking the File | Close Off Peak Images menu we can close all the off-peak intensity maps and see this somewhat further improved display:



Now let's select the log weight percent output using the Project | Export the Project Grid Files For Presentation Output | Output Log Weight Percent Maps to Surfer menu. We are then asked if we would like to run the Surfer script that was created and we click yes and obtain the following output:



Which, depending on the purpose, might or might not be sufficient.

Let's "clean-up" the plots a little for publication by locating the automatically saved .SRF file for this output and opening it in the Surfer app proper. By simply unchecking the Show Labels checkboxs as seen in the Surfer app Plot Property Manager for each displayed axis,



we now obtain a much cleaner plot as seen here:



Now a final tweak using the mouse to move the plot labels so they are more centered over the plot gives us this:



Not too bad for a few mouse clicks!

Remember all plot elements are automatically saved to the Surfer .SRF file for further modification and output to a large variety of export formats as seen here:

John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Surfer Scripting for CalcImage
« Reply #3 on: January 21, 2014, 12:55:33 PM »
Golden Software has just announced Surfer version 12.

Though I haven't tried it myself they do have a new option to "flip" the X and Y axes which is really good news for JEOL stage mapping.  Previously we were forced to use Cartesian coordinate systems and only Cameca is Cartesian.

Now we won't have to multiply by negative one to get the JEOL map displays correct!

http://www.goldensoftware.com/blog/surfer-12-released

The only stupid question is the one not asked!

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Surfer Scripting for CalcImage
« Reply #4 on: September 16, 2014, 01:21:49 PM »
Note also that Golden Software has an extensive forum area for users of their Grapher and Surfer products that might very well be very useful:

http://www.goldensoftware.com/forum/
The only stupid question is the one not asked!

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Surfer Scripting for CalcImage
« Reply #5 on: November 17, 2014, 11:00:52 PM »
The CalcImage scripting output for polygon 3 plots per page is now working.



The best way to utilize this feature is to output the plots using the default plots per page value (usually 8 plots per page). Then open the script using the Surfer Scripter application and edit the plot per page line to 3 (or 1) plot(s) per page as seen here:

Option Explicit

Sub Main
' This polygon extraction routine is created by CalcImage

Dim XLabel As String
Dim YLabel As String

Dim XInvert As Integer
Dim YInvert As Integer

Dim Directory As String
Directory$ = "C:\UserData\SurferData\Monazite\"
'Directory$ = CurDir$() & "\"
If Command$() <> "" Then Directory$ = Command$()    ' see if script path was passed as a command line argument

BLANKINGVALUE! = 1.70141E+38

Dim SampleName As String
SampleName$ = "Monazite, U, Th, Pb, Y and La_10-28-2013_Monazite-4_00693__Quant_Polygon"
Dim SampleTitle As String
SampleTitle$ = "Monazite, U, Th, Pb, Y and La Chem Age, Elemental Wt.%"

' Specify number of plots per page (must be 1, 3, or 8 images per page)
PlotsPerPage% = 3

Dim iMax As Integer
iMax% = 7

XInvert% = 0
YInvert% = 0


Then optionally save the script and then re-run it (using the play button) to output the new plots.

Another example (wt% U, Pb, Y, Pb) is attached below.
« Last Edit: November 17, 2014, 11:22:48 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Surfer Scripting for CalcImage
« Reply #6 on: December 14, 2014, 08:55:30 AM »
Here's another example of the 3 polygon area quant plots output. I've attached (below) the other automatically generated 3 pages of images for this garnet sample for you all to examine (please login to see attachments).

Remember, you can also easily output 1 polygon per page or 9 polygon plots per page and the full quant for each pixel and averages are output to a .dat file for further optional processing/analysis.

« Last Edit: December 14, 2014, 02:24:41 PM by John Donovan »
The only stupid question is the one not asked!

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Surfer Scripting for CalcImage
« Reply #7 on: February 10, 2015, 07:21:47 PM »
Malcolm Roberts asks: "How can I change the default plots per page so I don't have to edit the Surfer script for each project?"

Easy. Simply open the Probewin.ini file in the Probe for EPMA application folder (usually C:\Probe Software\Probe for EPMA), and find these two entries in the [software] section:

SurferPlotsPerPage=4   ; must be 1, 4 or 9
SurferPlotsPerPagePolygon=8   ; must be 1, 3 or 8

and edit them for your preferences.

Note that any text after the semi-colon is a comment and is ignored.

I should just add, that if you do not want to permanently change the default PlotsPerPage parameter you can simply edit the entry in the Surfer script generated by CalcImage. To edit only for a specific CalcImage project output, simply open your project in CalcImage from the Project menu, then select the output type you prefer and create the script.

Click OK to message box and then click No when asked "Would you want like to run the BAS script in Surfer right now?"

Then run the Scripter app from the Windows All Programs | Surfer menu (do not run the Scripter app in the Windows All Programs | Grapher menu) and open the script you created from CalcImage.

Then look for the PlotsPerPage keyword and edit it for the number of plots per page you want. Remember: all output formats must be 1, 4 or 9 plots per page, except for the polygon output formats which must be 1, 3 or 8 plots per page.
« Last Edit: February 11, 2015, 04:08:54 AM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Surfer Scripting for CalcImage
« Reply #8 on: February 20, 2015, 10:11:01 AM »
I did a bad thing.  I broke the CalcImage customized output scripts because I added a parameter for the page delay in seconds, for a particular user.

I am updating the customizable scripts and they will be available in the next version of PFE (it will be v. 10.7.3).

If you haven't personally edited any of the customizable scripts, you are OK, but you should follow the directions below for updating them. Basically just delete them and the next update will replace them with the new already modified scripts.

There is no need to replace the default scripts (without the word "Custom" in the file name) because it is automatically replaced with each PFE update.

If you have edited the customizable scripts, first, my apologies. Second, you'll need to add the new PageSecondsDelay% parameter to your already customized scripts. Again I'll provide instructions below.

Instructions:
If you haven't edited any of the customizable scripts, simply delete them and then simply run the ProbeForEPMA.msi update again and they will be automatically replaced.

The scripts you need to delete before updating PFE again (to v. 10.7.3) are as follows and are found in the Probe For EPMA application folder (usually C:\Probe Software\Probe For EPMA):

gridxy_Custom1.bas
gridxy_Custom2.bas
gridxy_Custom3.bas
gridxy_Custom4.bas

If you *have* edited the customizable scripts (after all, that is what they are there for!), you will have to further edit the scripts as follows if you want to keep your modifications:

The following changes applies only to the normal presentation output scripts.  The poly, slice and strip scripts do not require any changes.

Change the first line in each of scripts you modified from :

Sub OutputAll(PlotsPerPage%, XInvert%, YInvert%, Directory$, FileArray$(), Sample$, SampleTitle$, iMax%, XLabel$, YLabel$, ZLabel$())

to

Sub OutputAll(PlotsPerPage%, PageSecondsDelay%, XInvert%, YInvert%, Directory$, FileArray$(), Sample$, SampleTitle$, iMax%, XLabel$, YLabel$, ZLabel$())

Next change the line (line 142 actually) from:

Call GridOutput(OutputType$, SurferPlot, SurferDoc)

to

Call GridOutput(OutputType$, PageSecondsDelay%, SurferPlot, SurferDoc)


Finally change the lines (near the end) in the GridOutput routine from:

Sub GridOutput(OutputType$, SurferPlot, SurferDoc)

and

Wait(8)

to

Sub GridOutput(OutputType$, PageSecondsDelay%, SurferPlot, SurferDoc)

and

Wait(PageSecondsDelay%)

Sorry again for any  inconvenience!
john
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Surfer Scripting for CalcImage
« Reply #9 on: July 13, 2015, 03:18:44 PM »
Sabrina Pearson at Golden Software reports that Microsoft broke some Windows GDI calls in a recent security update:

The May 2015 Windows update contains two updates (KB3045171 and KB3057110) that affect drawing symbols in Golden Software programs. If you receive a GSDraw error (1): generic error when creating a graph/map that uses symbols, you are experiencing this issue.

Microsoft has issued a Windows update KB3065979 that fixes the bug they introduced in KB3045171. Please update your version of Windows again to include this update. You will need to reboot the computer after the update is installed.


I can confirm this as I ran into it myself!  Here is the Knowledge Base link you will need to fix this on your Windows computer:

https://support.microsoft.com/en-us/kb/3065979
The only stupid question is the one not asked!