Thursday, 22 August 2019

GCDkit 6.0 has been unleashed. What is new?

On August 16, 2019 has been released a new version of GCDkit 6.0. It was developed in R 3.6.0 and code-named Il padrino sono io. This is the first truly platform independent version that could run on all systems, including Mac OS X and Linux from both command line and graphical user interface (GUI). The most important changes are summarised below.

Platform-independent GUI
  • Optional platform-independent Tcl/Tk graphical user interface (GUI)
  • In both command-line/batch mode and from graphical user interface (GUI), the GCDkit should run also operation systems other than Windows, notably Linux or Mac OSX. To start GUI on non-Windows systems, type menuet()
Performance improvements
  • Quicker response of the menu for geotectonic plots that is newly being built only once, upon the system startup 
  • Quicker and improved routine enabling overplotting datasets, especially values after Debon and Le Fort.
  • Some norms (most notably CIPW) were speeded up considerably.


User-defined plots

  •  Help pages to user-defined plots are added automatically to the html help system.
Bug fixes
  • Correct function on the Chinese (and perhaps other non-European) locales.
New plugins
  • New plugin for ternary projection from biotite (Moyen et al. 2017).
New geotectonic/general purpose diagrams
  • B vs. Mg/(Fe + Mg), Q vs. B, K/(Na+K) vs. B and BQF ternary diagram of Debon and Le Fort (1983, 1988) 
  • Diagrams for classification of feldspathic igneous rocks of Frost and Frost (2008)
  • Diagram of Laurent et al. (2014) to decipher possible source of granitic magmas
  • New function phasePropPlot() that plots barplot of mineral proportions
  • Mesonormative Q'-ANOR diagram of Streckeisen and Le Maitre (1976) was added to the Classification plots and can be indeed used for this purpose now. If necessary, a matrix of mesonormative values can be provided upon call; otherwise these are to be calculated anew. 
The new version of GCDkit has been unveiled at the Goldschmidt Conference in Barcelona on 21 August. Follow this link for the PDF version of the poster. 

Sunday, 3 March 2019

GCDkit not starting on Chinese locales?

Several users from China have reported problems with running GCDkit 5.0.

The troublemaker is the newly introduced Eartchem module, as already mentioned here: http://blog.gcdkit.org/2018/04/version-50-has-been-just-released.html#comments 

The problem is clearly with multibyte encoding of Chinese characters. But the bug may be also affecting the users on other locales/systems, including Mac.

The fix is relatively simple, though. Please, in the line 216 of the EarthChemFUN.r file, replace the text by:

if(.Platform$OS.type=="windows") zzz[zzz==intToUtf8(0x00c2)]<-NA

and restart GCDkit.

Please accept my apologies. The next version of GCDkit (6.0), now at the stage of beta testing, will have this problem solved.

Vojtech

PS
Special thanks go to Jiacheng Tian and Shi-Chao Li for their helpful bug reports and patience.



Plotting TAS diagram of Le Bas et al. (1986)

By far the most common bug report that we are getting concerns the implementation of the total alkali-silica (TAS) diagram of Le Bas et al. (1986) in GCDkit. But in reality, it is  not a bug, but a feature. One should be aware of the fact that the analyses plotted have been recalculated on 100% anhydrous (volatile-free) basis.  This is in accordance with the recommendation of the IUGS  Subcommission on the Systematics of Igneous Rocks (Le Bas et al. 1986; Le Maitre ed. 2002).

On the other hand, such a recalculation is not carried out for subsequent modifications of the TAS diagram (Cox et al. 2002; Middlemost 1994), where rough data are plotted.

In any case, using analyses with too high volatile contents is to be avoided, as they are suspicious from being affected by alteration and attendant mobility of alkalis.   


Cox KG, Bell JD & Pankhurst (1979) The Interpretation of Igneous Rocks.
Allen & Unwin, London

Le Bas MJ, Le Maitre RW, Streckeisen A & Zanettin B (1986)
A chemical classification of volcanic rocks based on the total alkali-silica
diagram. J Petrology 27: 745-750

Le Maitre RW (ed) (2002) Igneous rocks: a classification and glossary of terms: recommendations
of the International Union of Geological Sciences, Subcommission on the Systematics of
Igneous Rocks, 2nd edition. Cambridge University Press


Middlemost EAK (1994) Naming materials in the magma/igneous rock system.
Earth Sci Rev 37: 215-224

Wednesday, 18 April 2018

How to use GCDkit in a batch mode II


In one of the earlier blogs, Jeff has presented my exercise showing effective use of batch mode borrowed from our joint workshop at University of Catania.  

Here I would like to carry on and show the new capabilities of GCDkit to use multiple datasets and to overplot them on a single diagram (or plate thereof).

Binary plot

# Loading and storing the 1st dataset
data(atacazo)
accessVar("atacazo")
assign1col("gray")
pokeDataset("atacazo",overwrite.warn=FALSE)

Loading and storing the 2nd dataset
data(sazava)
accessVar("sazava")

Switching back to the atacazo dataset
peekDataset("atacazo")
# Overplotting classification diagram
plotDiagram("TAS",F,F)
overplotDataset("sazava",pch="*",col="red",cex=2)

Spiderplot

# Overplotting on spiderplot
peekDataset("atacazo")

# Atacazo as grey field
spider(WR,"Boynton",0.1,1000,field=TRUE,fill.col=TRUE,
  shaded.col="khaki")
overplotDataset("sazava")


A plate (Harker plots)

# blatna dataset
data(blatna)
accessVar("blatna")
multiple("SiO2","MgO,CaO,Na2O,K2O")
plateXLim(c(53,70)) # Common x axis scaling
plate0YLim() # All y axes start from 0

plateCex(1.5)
plateCexLab(1.5)
plateCol("gray")

# Overplot sazava on top of it
overplotDataset("sazava",cex=2)



# Getting rid of the datasets other than the current (blatna)
purgeDatasets()

User-defined diagrams in GCDkit 5.0


Due to a popular demand, the new version of our program comes with a straightforward possibility of adding (Figaro-compatible) templates for both stand-alone binary/ternary diagrams and plates. If done correctly, they integrate seamlessly into the GCDkit system, namely into the menu 'Plots|User defined...' .

There are still some limitations, though. So far, the user-defined diagrams cannot be used for classification purposes (and hence for defining subsets, groups…).  We cannot offer language versions other than English, either.

Principle

All *.r or *.R files stored in the directory Diagrams/User , except for those whose name starts with underscore ("_"), are sourced every time the menu item 'Plots|User defined...' is invoked. Hence the list of available diagrams is always built on fly, using the function .userlist().

The ordering information and name under which it appears in the menu are integral parts of the template. For stand-alone, single Figaro plots, the crucial information is:
  • Name of function defining a diagram
  • Name of the plot: sheet$demo$template$GCDkit$plot.name
  • Sequence number of the plot in the menu: sheet$demo$template$GCDkit$plot.position

For a plate of Figaro templates:
  • Name of function defining a plate
  • Name of the whole plate: plate$plot.name
  • Sequence number of the plot in the menu: plate$plot.position 

In both cases, the file should define a single function of a name identical to (the root of) the filename.
 'Sequence number' above is any positive real number (i.e., it does not have to be an integer).

Documentation

The HTML documentation is linked to the help system automatically. However, this is only done when the *.htm file, named exactly like the function, resides in Diagrams/User/doc subdirectory.

An example

Here is an example of the Al2O3/SiO2 vs MgO/SiO2 binary plot of Paulick et al. (2006). This is done using the function Paulick provided in the file Paulick.r  of  the current GCDkit distribution.


#####################################################################
#                  Al2O3/SiO2 vs MgO/SiO2 binary plot               #
#                   Fig. 3 in Paulick et al. (2006)                 #
#  Paulick, H., Bach, W., Godard, M., De Hoog, J.C.M., Suhr, G.,    #
#  Harvey, J., 2006. Geochemistry of abyssal peridotites (Mid-      #
#  Atlantic Ridge, 15o20'N, ODP Leg 209): implications for fluid/   #
#  rock interaction in slow spreading environments. Chemical Geo-   #
#  logy, 234: 179-210.                                              #
##################################################################### 
Paulick<-function(){
    x.data<<-WR[,"Al2O3"]/WR[,"SiO2"]
    y.data<<-WR[,"MgO"]/WR[,"SiO2"]

    temp<-list(
lines1=list("lines",x=c(0,0.1),y=c(1.1,0.842),
col="darkgray", lwd=10),
GCDkit=list(
"NULL",
plot.type="binary",
plot.position=12,
plot.name="Al2O3/SiO2 - MgO/SiO2 (Paulick et al. 2006)"
)
)

temp2<-list(
text1=list("text",x=0.095,y=1.008,
text="Terrestrial Array\n(melting trend)",
col="black",adj=c(1,0.5),srt=-10),
            text2=list("text",x=0.002,y=1.15,text="Depleted",
col=plt.col[2],adj=c(0,0.5)),
text3=list("text",x=0.099,y=0.83,text="Enriched",
col=plt.col[2],adj=c(1,1))
      )

if(getOption("gcd.plot.text")) temp<-c(temp,temp2) # Text on?

sheet<<-list(
  demo=list(
fun="plot",
call=list(
xlim=c(0,0.1),ylim=c(0,1.4),
main=annotate("Al2O3/SiO2 - MgO/SiO2 plot
  (Paulick et al. 2006)"
),
col="green",bg="transparent",fg="black",
xlab=annotate("Al2O3/SiO2"),
ylab=annotate("MgO/SiO2")),
template=temp
  )
)
}  

Saturday, 14 April 2018

Version 5.0 has been just released!



On March 28, 2018 has been released a new version of GCDkit 5.0. It was developed in R 3.4.3 and code-named El Chupacabra. The most important changes are summarised below.



Towards a platform-independent version
  • It is well-known that the GCDkit has been originally designed as a Windows-only package. From the current version it is possible to install  and run it also on operation systems other than Windows,  most notably Linux or Mac OSX.  
  • So far, this concerns command-line/batch mode only. 
  • The platform-independent graphical user interface (menus, dialogue boxes...) written in Tcl/Tk language  is ready and just being tested. If you are feeling unadventurous, and work on Linux and/or Mac, please do get in touch and you can become one of the beta testers. 

New Windows installer
  • As we hope, we have fixed the long-standing problems with the installation of GCDkit on Windows 10, and people without administrative rights.
  • The new GUI installer, based on the Tcl/Tk  language,  is started by simply dragging the file @INSTALL.r from the temporary installation directory onto the R Console window. 
  • his file can be also located manually and loaded using the  File|Source R code...'  menu. See the download page for more details. 
  • Please note that this installer relies on a live Internet connection to download the missing packages required by the GCDkit. 


User-defined templates
  • User-defined templates for stand-alone Figaro plots or their plates. They can be uploaded into the  directory Diagrams/User and then employed for standard plotting (i.e. not classification)  purposes. This mechanism allows easy and fully automatic expansion of the plotting capabilities  of the GCDkit system. For further info, see the file @README.txt in the directory in question.
  • There are five examples of user-defined templates provided: three binary plots for discrimination of lavas from destructive plate boundaries (Pearce 1982), ternary plot for classification of A-type granites (Grebennikov 2014) and binary plot of Paulick et al. (2006) to portray the mantle peridotite fertility.  

Overplotting two or more datasets on a single diagram (or plate)
  • Functions allowing overplotting new datapoints onto standard single binary plots, ternary plots,
    spiderplots or multiple plots, including the diagram templates (overplotDataset, underplotDataset) linked to the menu system. 
  • In addition, there are functions figOverplot and figOverplotDiagram but these are meant mostly for internal use. 
  • For plotting serves a reference dataset, either real-world data (say compiled from literature) or a numeric  matrix spanning, for instance, from petrogenetic modelling.
  • See the example of overplotting the atacazo over sazava dataset on De la Roche et al. (1980) plot.
  • Very attractive feature should be the new possibility of obtaining dataset by online search of the EarthChem.org database. The search can be performed directly from the menu GCDkit|Online search EarthChem.org.  It invokes a graphical front-end, written By Oscar Laurent (ETH, Zurich) that allows to enter the desired search criteria. On Windows, it also includes a primitive, and still rather slow, possibility of selecting a polygon of interest from a map of the World. 




Further new features/important changes
  • New plugin 'disclosure' for log-transformation of compositional data.
  • New geotectonic/general purpose diagrams
    • La/Yb vs. Nb/La and La/Yb vs. Th/Nb of Hollocher et al. (2012)
    • La/10-Y/15-Nb/8 of Cabanis and Lecolle (1989)
    • Zr/Y-Th/Yb of Ross and Bedard (2009)
    • YbN vs. LaN/YbN of Martin (1986) to distinguish adakites and TTGs
    • F-M-W diagram (Ohta and Arai 2007) for chemical weathering of igneous rocks
  • calcAnomaly, a function for calculating a magnitude of any anomaly on any spiderplot, based on concentrations of selected neighbouring (not necessarily adjacent) elements.
  • Spanish translation of the classification plots (courtesy of Tomas Grijalva,  Geology Department of UNAM, Mexico).
  • New zircon saturation model of Boehnke et al. (2013).
  • New training dataset atacazo.data giving the whole-rock major- and trace-element contents,   together with Sr and Nd isotopic compositions of lavas from two volcanic complexes in Ecuador: the Atacazo and the Ninahuilca (Hidalgo 2006; Hidalgo et al. 2008).   This dataset, kindly provided by Silvana Hidalgo, is used in a worked example (chapter 25) of Janousek et al.’s book (2016).
  • Another new training dataset blatna.data from the Central Bohemian Plutonic Complex, Czech Republic  (Janousek et al. 2000, 2010). It could be, together with sazava.data already present, used to test dataset switching etc.
  • New function figFixLim() extends the scales of both axes of a binary plot automatically  if necessary to accommodate all the data points.
  • new training dataset blatna.data from the Central Bohemian Plutonic Complex, Czech Republic (Janousek et al. 2000, 2010). It could be, together with sazava.data already present, used to test   dataset switching etc.
  •  New function figFixLim()extends the scales of both axes of a binary plot automatically  if necessary to accommodate all the data points.
  • New normalization scheme of Anders and Grevesse (1989) for chondrite-normalized REE spiderplots.
  • Better behaviour of many functions in batch mode (in RTerm, Jupyter, on Linux/Mac etc.)......

  • We trust that you will find this new release useful and reasonably stable.

    Good luck, Vojtech

Tuesday, 23 May 2017

Batch / Console mode

One of the nice features in the recent versions of GCkit is that it can be ran without any graphical user interface, just by typing commands in the console.

What good is it, will you say ? Well:
  • It saves time. After a while it gets a bit annoying to have to go to "plot", "binary", select X variable, select Y variable "ok", "ok"... Isn't it easier, and faster, to just type binary("SiO2","Rb/Sr") ? I think so.
  • It is reproducible. You can copy a string of commands to a file, and re-run the file every time you need it, perhaps because you've updated the dataset, or you're doing the same thing with all of your data anyway.
  • Since it does not rely on the GUI, it is platform-independent (ha-ha !).  So this allows to use GCDkit on platforms other than windows.

All the commands that are found in the menus can be used from the command line (and, in fact, even more or at least with more flexibility). So you may, for instance, run the following scripts (borrowed from the latest workshop in Catania).
In all examples, you may either copy the commands to a text file, that you save as "something.r", and then drag and drop the r-file to your console; or type each command in succession into the console.
Also, we assume in each example that you have the relevant data files, stored in a directory that happens to be, in this case, C:\\Users\\admin\\Documents\\R code\\.The datafiles are from the book.

Example 1 (loading and grouping data; simple calculations)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("sazava.data",sep="\t")
print(WR[,"A/CNK"])

     Sa-1      Sa-2      Sa-3      Sa-4      Sa-7     SaD-1     Gbs-1    Gbs-20     Gbs-2     Gbs-3
0.8355344 0.7618697 0.8078703 0.7193632 0.9617544 0.8418038 0.4370269 0.5549208 0.7506752 0.8598510
     Po-1      Po-3      Po-4      Po-5
0.9716144 1.0248678 1.0129914 1.169989

groupsByLabel("Intrusion")
summaryByGroup(LILE,show.boxplot=TRUE)
print(results)
results<-CIPW(WR)
spider(WR,"Boynton",plot=FALSE) # Calculation only
print(results)

Example 2 (simple diagrams)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

# Binary plot

binary(x="SiO2",y="Y",ymin=0,ymax=50,main="My Binary plot")

figCex(1.8)

# A single classification diagram, zoom in

plotDiagram("LarochePlut",F,F)

figXlim(c(1000,2700))

figYlim(c(1000,2500))

figRemove()

# Harker plot (a simple plate)

multipleMjr("SiO2")

plateCex(1.7)

plateCexLab(1.2)

plateXLim(c(45,60))

plateBW()

Example 3 (Custom plates)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

# Custom plate

multiplePerPage(4,nrow=2,ncol=2,dummy=F,title="Geotectonic")

plotDiagram("Meschede",F,F,main=" ")

plateExtract("Wood",3,main=" ")

plotDiagram("PearceNbThYb",F,F,main=" ")

plotDiagram("PearceNbTiYb",F,F,main=" ")

plateLabelSlots(text=letters,cex=1.5,pos="topleft")

plateCex(1.7)

plateCexLab(1.2)





(this example involves still a lot of clicking in dialogs, so it is not too likely to work in non-windows environments)

Example 4 (spiderplots)

setwd("C:\\Users\\admin\\Documents\\R code\\")
loadData("dolerites_test.data",sep="\t")

groupsByLabel("region")

# REE spider

spider(WR,"Boynton",1,100,pch="*",col="blue",cex=2)

spider.contour("Boynton","MgO","jet.colors",ymin=1,ymax=100,
 
pch=15)


# NMORB Sun and McDonough

spider(WR,"^NMORB..Sun",0.1,500,offset=TRUE)

figMulti(shaded.col="khaki",plot.symb=FALSE,nrow=2,ncol=2)

plateLabelSlots(text=letters,cex=1.5,pos="bottomright")

plateCex(2)

plateCexLab(2)

plateBW()