Probe Software Users Forum

Software => CalcImage => Topic started by: John Donovan on August 07, 2014, 04:01:57 AM

Title: Customizing Surfer Scripts
Post by: John Donovan on August 07, 2014, 04:01:57 AM
Quote from: Malcolm Roberts on August 06, 2014, 08:50:32 PM
Hi John
Yes... I can do that in surfer but it means I have to do it for every plot. I want to modify the script output produced by calcimage so I can save time in surfer, or at least specify those parameters I want at that point...... At the moment, I open the script and then make some changes there (plots per page, font and size plus cut down on the 8 secs waiting time), then make the rest of the changes in surfer......

I see.

Maybe the best thing would be for me to add an INI option where one can specify using a "custom" script for output instead of the default script?
Title: Re: Customizing Surfer Scripts
Post by: Malcolm Roberts on August 10, 2014, 05:11:12 PM
That would be a good idea. You could have a range of options - the current one and two or three others? Maybe I should send you a copy of my preferred format? The other thing would be to make the script fully customizable via a GUI?
Title: Re: Customizing Surfer Scripts
Post by: Probeman on August 10, 2014, 05:19:52 PM
Quote from: Malcolm Roberts on August 10, 2014, 05:11:12 PM
That would be a good idea. You could have a range of options - the current one and two or three others? Maybe I should send you a copy of my preferred format? The other thing would be to make the script fully customizable via a GUI?

Hi Malcolm,
I'll try the single custom script first and see how that goes.

As for a GUI for editing the scripts, that is called Scripter and you already have it.
john
Title: Re: Customizing Surfer Scripts
Post by: Probeman on August 10, 2014, 08:23:53 PM
Quote from: Malcolm Roberts on August 10, 2014, 05:11:12 PM
That would be a good idea. You could have a range of options - the current one and two or three others?

You will be able to modify the filename of the customized script in the probewin.ini file.

Just as easily you can write a short batch file to automatically rename your customized scripts to the one specified in the ini file for switching between them.
john
Title: Re: Customizing Surfer Scripts
Post by: Malcolm Roberts on August 11, 2014, 06:30:22 PM
Forgive me for being dumb, but I am not sure that what I am talking about is getting across. I am not interested particularly in renaming files. I am seeking to customise the output. At the moment, when calcimage generates the script, the output design by default has 4 plots per A4 page, X and Y axes marked and displayed, a colour scale up the RHS, the plot title above the plot and the element or species of interest beneath that. Font is times new roman by default at default sizes as given in the script. The script can be modified via scripter and this is not a GUI. Currently, I can use scripter to change plots per page, change font style and size plus change the 8 second delay (???) to 1 second and speed up the process. However, I would like to change the defaults for the output script from calcimage FOR GOOD so I do not have to keep constantly making modifications in scripter, followed by further changes in Surfer - here I move the "species" title and in some cases add a scale bar. This is what I would like to see available to me......... Do I currently have this function in calcimage?
Title: Re: Customizing Surfer Scripts
Post by: John Donovan on August 11, 2014, 06:49:10 PM
Quote from: Malcolm Roberts on August 11, 2014, 06:30:22 PM
Forgive me for being dumb, but I am not sure that what I am talking about is getting across. I am not interested particularly in renaming files. I am seeking to customise the output. At the moment, when calcimage generates the script, the output design by default has 4 plots per A4 page, X and Y axes marked and displayed, a colour scale up the RHS, the plot title above the plot and the element or species of interest beneath that. Font is times new roman by default at default sizes as given in the script. The script can be modified via scripter and this is not a GUI. Currently, I can use scripter to change plots per page, change font style and size plus change the 8 second delay (???) to 1 second and speed up the process. However, I would like to change the defaults for the output script from calcimage FOR GOOD so I do not have to keep constantly making modifications in scripter, followed by further changes in Surfer - here I move the "species" title and in some cases add a scale bar. This is what I would like to see available to me......... Do I currently have this function in calcimage?

Hi Malc,
You are clear I think. Yes, that is what I am speaking of.

Not sure what a 'species" title is. The output title can be edited in CalcImage now.

This weekend I will implement this and you won't have to rename anything, just enter the modified script name in the INI file the first time only.

I will also add an option to append the data type to the title. Maybe that is want you mean by "species title"?
john
Title: Re: Customizing Surfer Scripts
Post by: Malcolm Roberts on August 11, 2014, 07:38:37 PM
Hi John
By species I was trying to cover all bases including elements.......e.g., sulphides, oxides etc.......
Cheers,
malc.
Title: Re: Customizing Surfer Scripts
Post by: John Donovan on August 12, 2014, 05:46:10 PM
Hi Malc,
I've got something for you to try that I think will make running with your user customized scripts much easier.

Simply rename your scripts to these "custom" file names as seen in the next post (gridxy_Custom1.bas for example), and copy them to the PFE application folder:

(https://smf.probesoftware.com/oldpics/i60.tinypic.com/5b1pib.jpg)

Alternatively simply edit the existing scripts already provided with the next Probe for EPMA .msi file and you are ready to go.

These custom scripts will be installed the first time if they are not already present, but then will never be overwritten by the installer during subsequent updates and upgrades.

Once your modified scripts are renamed or edited you simply select them from the Surfer Templates menu as desired...
Title: Re: Customizing Surfer Scripts
Post by: Probeman on August 13, 2014, 12:03:22 PM
Here's some more details on utilizing the "custom script" feature in CalcImage.

Beginning in v 10.4.4 of the ProbeForEPMA.msi file (not the quick .ZIP update), the installer will update the following "partial" Surfer script files which are used as the "template" for presentation output of quant, slice, polygon and strip data extraction operations.

Why "partial"? Because these scripts do not contain specimen specific information, only the plot layout. This specimen specific information is appended to these "partial" scripts to create a fully functional script to run in the Surfer Scripter application (or automatically from CalcImage):

GRIDXY.BAS                  Default quant presentation output script (will be overwritten on updates, so do not edit normally)
gridxy_Custom1.bas       User customizable script for quantitative and raw data presentation output (will not be overwritten)
gridxy_Custom2.bas       User customizable script for quantitative and raw data presentation output (will not be overwritten)
gridxy_Custom3.bas       User customizable script for quantitative and raw data presentation output (will not be overwritten)
gridxy_Custom4.bas       User customizable script for quantitative and raw data presentation output (will not be overwritten)

SLICEXY.BAS                  Default slice presentation output script (will be overwritten on updates, so do not edit normally)
slicexy_Custom1.bas       User customizable script for slice and profile data presentation output (will not be overwritten)
slicexy_Custom2.bas       User customizable script for slice and profile data presentation output (will not be overwritten)

POLYXY.BAS                  Default polygon presentation output script (will be overwritten on updates, so do not edit normally)
polyxy_Custom1.bas       User customizable script for polygon extraction data presentation output (will not be overwritten)
polyxy_Custom2.bas       User customizable script for polygon extraction data presentation output (will not be overwritten)

STRIPXY1.BAS                  Default equant strip presentation output script (will be overwritten on updates, so do not edit)
STRIPXY2.BAS                  Default tall strip presentation output script (will be overwritten on updates, so do not edit)
STRIPXY3.BAS                  Default wide strip presentation output script (will be overwritten on updates, so do not edit)
stripxy1_Custom1.bas       User customizable script for equant plot strip data presentation output (will not be overwritten)
stripxy1_Custom2.bas       User customizable script for equant plot strip data presentation output (will not be overwritten)
stripxy2_Custom1.bas       User customizable script for tall plot strip data presentation output (will not be overwritten)
stripxy2_Custom2.bas       User customizable script for tall plot strip data presentation output (will not be overwritten)
stripxy3_Custom1.bas       User customizable script for wide plot strip data presentation output (will not be overwritten)
stripxy3_Custom2.bas       User customizable script for wide plot strip data presentation output (will not be overwritten)

Therefore, if you want to customize or overwrite these _Custom1, _Custom2, etc scripts with your own optimized scripts, they will not be overwritten and one can simply select them from the Surfer Templates menu and seen in the previous post.
Title: Re: Customizing Surfer Scripts
Post by: Malcolm Roberts on August 13, 2014, 05:46:56 PM
Ok... so let's get this straight as I have been getting horribly confused by all of this. I can go into these custom scripts using scripter and change them to (something approximating) what I want. This will then be appended to the output script from CI? As I see it, if I rename my CI output script to the custom name in PFE folder, I will simply get my file with a new name and this will be of little use to man nor beast.
Title: Re: Customizing Surfer Scripts
Post by: John Donovan on August 13, 2014, 06:01:03 PM
Quote from: Malcolm Roberts on August 13, 2014, 05:46:56 PM
Ok... so let's get this straight as I have been getting horribly confused by all of this. I can go into these custom scripts using scripter and change them to (something approximating) what I want. This will then be appended to the output script from CI? As I see it, if I rename my CI output script to the custom name in PFE folder, I will simply get my file with a new name and this will be of little use to man nor beast.

Hi Malcolm,
I truly don't understand the confusion!

No, do not rename the custom script that was just output, just edit the supplied partial script that gets appended to the new specimen information before all *subsequent* output operations. That way the new output will utilize the new formats you edited from your edited or renamed "partial" script....

In other words just take the scripts named *_Custom*.bas and edit them to get the output you want.  Then copy them to the PFE folder.  Then select the template you want to use for output from the Surfer Templates menu. Then output the presentation output you want and it should utilize the edited "partial" script you made or modified.

What am I missing...?
john
Title: Re: Customizing Surfer Scripts
Post by: John Donovan on August 13, 2014, 06:18:59 PM
Ok, let's take a simple example and see if that makes it clearer.

Suppose you like the default presentation output script but you would like to have a different color scale as opposed to the default Rainbow2.clr color file...

There's no point in editing the GRIDXY.BAS "partial" template file since it will just get overwritten once the software is next updated. Instead we simply edit the gridxy_Custom1.bas "partial" template, and change the lines:

' Load color spectrum depending on version number
If Val(Left$(SurferApp.Version, 2)) <= Val("8.") Then
   SurferColorMap.LoadFile(SurferApp.Path & "\Samples\Rainbow2.clr")
Else
    SurferColorMap.LoadFile(SurferApp.Path & "\ColorScales\Rainbow2.clr")
End If

from rainbow2.clr to redhot.clr, save the gridxy_Custom1.bas file to the PFE app folder and the next time our data is output, we simply select the Surfer Templates | Gridxy_Custom1.bas menu in CalcImage, and the application will automatically utilize the new "redhot" color scale!

' Load color spectrum depending on version number
If Val(Left$(SurferApp.Version, 2)) <= Val("8.") Then
   SurferColorMap.LoadFile(SurferApp.Path & "\Samples\Redhot.clr")
Else
    SurferColorMap.LoadFile(SurferApp.Path & "\ColorScales\Redhot.clr")
End If

(https://smf.probesoftware.com/oldpics/i59.tinypic.com/o7lliw.jpg)
Title: Re: Customizing Surfer Scripts
Post by: Ben Buse on July 04, 2017, 04:03:08 AM
Hi,

Has anyone made a custom script to plot a scale bar instead of axes for the maps, and express scale in microns not millimetres?

Thanks

Ben
Title: Re: Customizing Surfer Scripts
Post by: Ben Buse on July 04, 2017, 05:05:04 AM
Right so I can add a scale bar and hide axes by adding the following in SubGridText

'Declares ScaleBars as an object
Dim ScaleBars As Object

'Assigns the ScaleBars collection to the variable named "ScaleBars"
Set ScaleBars = SurferMapFrame.ScaleBars

'Declares ScaleBar as an object
Dim ScaleBar As Object

'Creates a scale bar and assigns it to the variable named "ScaleBar"
Set ScaleBar = ScaleBars.Add

'Hide axis
Dim BottomAxis As Object
Set BottomAxis = SurferAxes("Bottom axis")
BottomAxis.Visible=False
Dim TopAxis As Object
Set TopAxis = SurferAxes("Top axis")
TopAxis.Visible=False
Dim LeftAxis As Object
Set LeftAxis = SurferAxes("Left axis")
LeftAxis.Visible=False
Dim RightAxis As Object
Set RightAxis = SurferAxes("Right axis")
RightAxis.Visible=False




Ben

Title: Re: Customizing Surfer Scripts
Post by: Ben Buse on July 04, 2017, 05:34:44 AM
Improved turn of ticks and labels, not hide axes - otherwise no map frame

'Turn labels and ticks off
Dim Axes, Axis As Object
Set Axes = SurferMapFrame.Axes

    For Each Axis In Axes
        Axis.ShowLabels = False
        Axis.MajorTickType = srfTickNone
        Axis.MinorTickType = srfTickNone
    Next Axis


Adapted from
https://support.goldensoftware.com/hc/en-us/articles/226473167-How-can-I-change-the-axes-settings-in-Surfer-via-automation- (https://support.goldensoftware.com/hc/en-us/articles/226473167-How-can-I-change-the-axes-settings-in-Surfer-via-automation-)

Move scale bar

'Move scale bar
ScaleBar.Left = SurferMapFrame.Left + 0.5
'+ SurferMapFrame.Width + SurferMapFrame.Width * 0.05
ScaleBar.Top =SurferMapFrame.Top - SurferMapFrame.Height + 0.1
'* 0.05

'Add units to scale bar
If PlotsPerPage% = 4 Then
title_xpos! = ScaleBar.Left + ScaleBar.Width + 0.05
title_ypos! = SurferMapFrame.Top - SurferMapFrame.Height - 0.01
Set SurferText = SurferShapes.AddText(title_xpos!, title_ypos!, "mm")
SurferText.Font.Face = FileFont$
SurferText.Font.Size = 10
End If


(https://smf.probesoftware.com/gallery/453_04_07_17_6_20_13.jpeg)

So there is an easy solution to get it into microns - just change the scale bar as follows

'Sets the amount to incremenbt each label by. Usually the Label Increment value is equal to the Cycle Spacing value
ScaleBar.LabelIncrement = ScaleBar.LabelIncrement*1000


(https://smf.probesoftware.com/gallery/453_04_07_17_7_55_46.jpeg)

Map frame line width is given by
For Each Axis In Axes
        Axis.ShowLabels = False
        Axis.MajorTickType = srfTickNone
        Axis.MinorTickType = srfTickNone
        Axis.AxisLine.Width = 0.01
    Next Axis


Does anyone know the command for colorscale line width - I can't find it.

It works well, except for large millimetre maps were the digits overlap - can rotate numbers if necessary but in this case would use mm scale

' ScaleBar.LabelRotation = 45

Files attached
Custom 1 = micron scale
Custom 2 = micron scale with 45 degree rotation on scale bar
Custom 3 = mm scale

Title: Re: Customizing Surfer Scripts (JEOL stage axes orientation)
Post by: Probeman on July 05, 2017, 02:06:29 PM
As you may know, for display of JEOL x-ray maps and images in Surfer, I have to invert the x and y axes because Surfer GRD files always expect a Cartesian coordinate system. That is why the axes labels have the notation (* - 1).

However, I believe starting in version 13 of Surfer, Golden Software added a new flag in the scripting automation API that allows one to display (anti-Cartesian) images. The syntax for this axis property is :

axis.[itemname].reverse = true

I haven't implemented this yet in my Surfer output code, but I thought it might be useful to share.
john
Title: Re: Customizing Surfer Scripts (JEOL stage axes orientation)
Post by: John Donovan on December 01, 2018, 09:12:21 AM
Quote from: Probeman on July 05, 2017, 02:06:29 PM
As you may know, for display of JEOL x-ray maps and images in Surfer, I have to invert the x and y axes because Surfer GRD files always expect a Cartesian coordinate system. That is why the axes labels have the notation (* - 1).

However, I believe starting in version 13 of Surfer, Golden Software added a new flag in the scripting automation API that allows one to display (anti-Cartesian) images. The syntax for this axis property is :

axis.[itemname].reverse = true

I haven't implemented this yet in my Surfer output code, but I thought it might be useful to share.
john

The Surfer reverse axis syntax for JEOL anti-cartesian stage axes display was implemented in the CalcImage Surfer generated scripts some time ago and works well.  Remember you will need to edit any customized scripts yourself to utilize this feature.
Title: Re: Customizing Surfer Scripts
Post by: John Donovan on December 01, 2018, 09:46:25 AM
Karsten Goemann recently noticed that if one performs a slice script operation from CalcImage in the Surfer Scripter app, on a polygon (free shape) defined x-ray map acquisition, and the user digitizes slice points that lie outside the actual map acquisition region, the script will create Z values of -8888 or -9999 for those areas outside the map area. 

This was because Julie Chouinard's original Surfer slice scripts had this line of code:

SurferApp.GridSlice(InGrid:=FileGridMap$,BlankFile:=FileBoundaryLine$,OutDataFile:=FileDataOutput$, OutsideVal:=-8888, BlankVal:=-9999)

The -8888 value is returned if the position is outside the map extents, and it returns -9999 if the position is a blanked value. Which is basically the same thing for our purposes.

I think Julie was planning on utilizing these values as "special" values for some other operations, but in the meantime these negative values just caused problems if someone accidentally digitized slice points outside the actual map area.  So I edited the line like this:

SurferApp.GridSlice(InGrid:=FileGridMap$,BlankFile:=FileBoundaryLine$,OutDataFile:=FileDataOutput$, OutsideVal:=0, BlankVal:=0)

So now if one "slices" outside the actual mapped area, the script returns zero values rather than -9999 values, as seen here:

(https://smf.probesoftware.com/gallery/1_01_12_18_9_36_44.jpeg)

So if you update to the latest Probe for EPMA v. 12.5.3, you will be updated for this new script code. 

And finally, if you have customized slice scripts that you have edited for your own purposes, you will need to edit them yourself as I did above.  However, if you haven't customized your "custom" scripts, you can just grab them below where I have attached them for download. 

Remember, the installer will not overwrite custom scripts because it doesn't know if you edited them or not, so one needs to copy the attached scripts to the ProgramData folder manually if desired.  Of course if you never utilize the customized slice scripts in CalcImage, it's a "don't care".