Author Topic: Customizing Surfer Scripts  (Read 14197 times)

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Customizing Surfer Scripts
« on: August 07, 2014, 04:01:57 AM »
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?
« Last Edit: August 13, 2014, 10:30:48 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Malcolm Roberts

  • Professor
  • ****
  • Posts: 134
Re: Customizing Surfer Scripts
« Reply #1 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?

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Customizing Surfer Scripts
« Reply #2 on: August 10, 2014, 05:19:52 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
The only stupid question is the one not asked!

Probeman

  • Emeritus
  • *****
  • Posts: 2856
  • Never sleeps...
    • John Donovan
Re: Customizing Surfer Scripts
« Reply #3 on: August 10, 2014, 08:23:53 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
The only stupid question is the one not asked!

Malcolm Roberts

  • Professor
  • ****
  • Posts: 134
Re: Customizing Surfer Scripts
« Reply #4 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?

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Customizing Surfer Scripts
« Reply #5 on: August 11, 2014, 06:49:10 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
« Last Edit: August 11, 2014, 07:10:29 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Malcolm Roberts

  • Professor
  • ****
  • Posts: 134
Re: Customizing Surfer Scripts
« Reply #6 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.

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Customizing Surfer Scripts
« Reply #7 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:



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...
« Last Edit: August 13, 2014, 12:06:11 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: Customizing Surfer Scripts
« Reply #8 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.
« Last Edit: August 13, 2014, 12:06:46 PM by John Donovan »
The only stupid question is the one not asked!

Malcolm Roberts

  • Professor
  • ****
  • Posts: 134
Re: Customizing Surfer Scripts
« Reply #9 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.

John Donovan

  • Administrator
  • Emeritus
  • *****
  • Posts: 3304
  • Other duties as assigned...
    • Probe Software
Re: Customizing Surfer Scripts
« Reply #10 on: August 13, 2014, 06:01:03 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
« Last Edit: August 13, 2014, 06:04:49 PM 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: Customizing Surfer Scripts
« Reply #11 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

« Last Edit: August 14, 2014, 12:01:08 PM by John Donovan »
John J. Donovan, Pres. 
(541) 343-3400

"Not Absolutely Certain, Yet Reliable"

Ben Buse

  • Professor
  • ****
  • Posts: 498
Re: Customizing Surfer Scripts
« Reply #12 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

Ben Buse

  • Professor
  • ****
  • Posts: 498
Re: Customizing Surfer Scripts
« Reply #13 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

Code: [Select]
'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

« Last Edit: July 04, 2017, 06:29:58 AM by Ben Buse »

Ben Buse

  • Professor
  • ****
  • Posts: 498
Re: Customizing Surfer Scripts
« Reply #14 on: July 04, 2017, 05:34:44 AM »
Improved turn of ticks and labels, not hide axes - otherwise no map frame

Code: [Select]
'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-

Move scale bar

Code: [Select]
'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



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

Code: [Select]
'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



Map frame line width is given by
 
Code: [Select]
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

Code: [Select]
' ScaleBar.LabelRotation = 45
Files attached
Custom 1 = micron scale
Custom 2 = micron scale with 45 degree rotation on scale bar
Custom 3 = mm scale

« Last Edit: April 14, 2020, 11:49:09 AM by John Donovan »