Tuesday, 23 February 2016

What is new in GCDkit 4.1 (Chlopskie jadlo)?

On 10 February has been released a new version of GCDkit. Apart from numerous bug fixes, and a great deal of editing to enable running the GCDkit scripts in a batch mode, it brings several new features. Arguably the most interesting include: 
  
Switching between datasets
  • Datasets can be stored using the function pokeDataset. Or it is done automatically, like for data freshly loaded into the system using the functions loadData and accessVar. Technically they always become components of a list WRCube.
  • Later, the previous datasets can be restored by functions peekDataset or selectDataset.
  • The WRCube can be cleared anytime using the function purgeDatasets; only the most recent copy of the current dataset survives this operation.
  • Function selectAll has been completely rewritten using the dataset switching, i.e. backup copy of data  stored in the WRCube. Variables WR.bak,WRanh.bak,milli.bak and labels.bak are thus not needed anymore.
  • New function figOverplot allows overplotting a reference dataset onto any Figaro-compatible binary plots, ternary plots, or spiderplots. The reference dataset, stored in an arbitrary global variable, can contain either real-world data or a numeric matrix  spanning from petrogenetic modelling.
Futher important changes
  • figCex, plateCex accept now the value NA (no quotes) that means no plotting  of symbols (most useful on spiderplots if only lines are desired).
  • figAddReservoirs checked and reprogrammed; it newly does work for ternary plots,  and is Figaro-compatible for binaries, ternaries and spiders. It also includes a lot of new arguments, mainly plotting parameters.
  • New functions oxide2ppm and ppm2oxide to recast wt.% of the given oxide to ppm of cations
  • Platform-independent functions tk_winDialog and tk_winDialogString written in Tcl/Tk.
  • calcCore does not require global variables anymore, but can use also those from the parental environment.
  • accessVar does not utilize Windows clipboard to transfer data into variables WR and labels anymore

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

Good luck, Vojtech

Monday, 9 November 2015

GCDkit 4.0 (Great October Revolution) just released!

We are pleased to announce that the new stable version of GCDkit has been just released!
Primarily, it is aimed to accompany our freshly published book (see the previous post). Of course, this brought about numerous small changes to the code, especially in the batch mode.

But there also further important improvements, even though many are hiding behind the bonnet.

  •  At last, the package has got its NAMESPACE, which means that it became available for R 3.2 and higher.
  •  Hopefully fixed were the notorious problems with installation pointed out by several users even on this forum. They were apparently occurring when there has been a personal library folder created during the R installation process.  
  • Improved was the help system, which includes a number of illustrative figures now.  
  • Semitransparency of plotting symbols (that can be set through function setTransparency) or fields (e.g., in spiderByGroupFields).Use preferably PDF export to preserve it.
  • New possibility of assigning colours according to values of a variable (assignColVar). 
  • Table of molecular weights from the CIAAW official web site (http://www.ciaaw.org) has replaced the existing one.  
  • New diagrams:
    • New geotectonic diagrams of Müller et al. (1992) for potassic igneous rocks
    • New Nb/Yb–Th/Yb and Nb/Yb–TiO2 /Yb plots of Pearce (2008) 
  • New plugin:
    • Rutile saturation algorithms of Ryerson & Watson (1987) and Hayden & Watson (2007)
  • File input/output:
    • improved import from GeoRoc, references in the end saved into file, references.txt and shown in a separate window upon load,
    • reading ROC, PEG, CSV files even on 64bit systems,
    • improved merging of files,
    • fixed problems with comments in data files.
  •  Legends:
    • improved appearance of legends, esp. for single colour and/or single plotting symbol,
    • corrected were problems with legends in spider.contour and spiderByGroupFields,
    • fixed were legends in figMulti, in addition their backgrounds became semitransparent.
  •  Calculations:
    • addResults replaces any already existing variables of the given name,
    • printSamples got a new parameter, print=FALSE, that allows to use the function just for calculations, i.e. skipping the printing,
    • millications can be newly calculated from any matrix/vector ,
    • the function groupsByLabel assigns a value (Undefined) to analyses for which the grouping information is missing,
    • calcCore did not work correctly for fractions. For instance, Nb/Ta ratios were Inf for Ta contents that were not determined. This affected scaling of plots etc.,
    • summaryRangesByGroup and strip work correctly even for subsets.
 
  •  Plotting:
    • new function plateLabelSlots to annotate individual slots by letters, numbers or Roman numerals,
    • binary and plotWithLimits allow linear fits also when some (or both) of the axes is/are logarithmic.
    • contourGroups is more robust now - and works better on datasets with missing values.

 Enjoy!
Vojtech

Tuesday, 27 October 2015

Book on geochemical modelling of magmatic processes in R/GCDkit

We break the two years of our silence with some news potentially interesting to anyone involved in interpretation of whole-rock geochemical data from igneous rocks. We are pleased to announce that, after two years of intense writing, we have finally published a book:

Janoušek, V., Moyen, J. F., Martin, H., Erban, V. & Farrow, C. M. (2016). Geochemical Modelling of Igneous Processes – Principles and Recipes in R Language. Bringing the Power of R to a Geochemical Community. Springer-Verlag, Berlin, Heidelberg, 346 pp. 


 Abstract from the publisher:
"The aim of this book is to unlock the power of the freeware R language to advanced university students and researchers dealing with whole-rock geochemistry of (meta-) igneous rocks. The first part covers data input/output, calculation of commonly used indexes and plotting in R. The core of the book then focuses on the presentation and practical implementations of modelling techniques used for fingerprinting processes such as partial melting, fractional crystallization, binary mixing or AFC using major-, trace-element and radiogenic isotope data. The reader will be given a firm theoretical basis for forward/reverse modelling, followed by exercises dealing with typical problems likely to be encountered in real life, and their solutions using R. The concluding sections GCDkit for interpretation of whole-rock geochemical data from igneous and metamorphic rocks."
demonstrate, using practical examples, how a researcher can proceed in developing a realistic model simulating natural systems. The appendices outline the fundamentals of the R language and provide a quick introduction to the open-source R-package
In more simple words, this book:
  • Provides basics of R language and its application to geochemical problems,
  • Gives the first comprehensive introduction to the GCDkit system,
  • Explains fundamentals of numerical modelling of igneous processes,
  • Shows not only formulae, but also the successful modelling strategies,
  • Includes numerous worked examples how geochemical modelling helps us to understand geological problems.
And its contents are in the nutshell:

Part I: R/GCDkit at work

  • Loading and Manipulating Data
  • Linking Whole-Rock Chemistry with Mineral Stoichiometry
  • Statistics
  • Classification and Grouping
  • Classical Plots
    (binary, Harker, ternary, spider)
  • Specialized Plots
    (log–log, specialized spiderplots, contour plots, anomaly plots…)
  • Radiogenic Isotopes
    (initial ratios, epsilon values, model ages, isochrons…)

Parts II–IV: Majors, traces, radiogenic isotopes

  • Core of the book; explains fundamentals of each direct and reverse modelling, including the relevant formulae
  • Introduces the numerical solution and its implementation in the R language
  • Includes a number of real numerical problems
  • Each is presented as a numerical receipt with solution in R  (± GCDkit )

Part V: Practical Modelling

  • Choosing an Appropriate Model
    (evidence for crystallization, partial melting, magma mixing and assimilation…)
  • Semi-Quantitative Approach
    (assessing the trace-element compatibility, process identification, mixing test…)
  • Constraining a Model
    (using appropriate strategy, obtaining input parameters for the model, partition coefficients, dealing with accessories…)
  • Numerical Tips and Tricks
    (reducing system, colinearity, breaking minerals to end-members, coupling majors and traces…)
  • Common Sense in Action
    (thermodynamic, rheological  constraints, scale and speed of processes, how well can we distinguish between models, dangerous projections…)

Part VI: Worked Examples

  • Differentiation of a Calc-Alkaline Series: Atacazo-Ninahuilca volcanoes, Ecuador
  • Progressive Melting of a Metasedimentary Sequence: the Saint-Malo Migmatitic Complex, France
  • Appendix A: R Syntax in a Nutshell
  • Appendix B: Introduction to GCDkit
  • Appendix C: Solving Systems of Linear Algebraic Equations in R
Courtesy of the publisher, the Appendices explaining the R syntax and the workings of the GCDkit system, are freely available here.

Sunday, 21 July 2013

Installing GCDkit


Two important point to note – the source of a great many complains :

1) You must install R before installing GCDkit. I repeat – you must install R before GCDkit.

You must install R before GCDkit.

(if you don’t, GCDkit will not start properly and complain about not finding the R Gui file etc.)

(in fact it is possible, but you then need to manually load GCDkit with library(GCDkit), but most regular users will not want to go that route).



2) With the current version of GCDkit (GCDkit 3.0), you must use R2.13.1. Again : you must use R 2.13.1

If you don’t, it’s very likely that GCDkit will not work. Also, note that the current version of R is 2.15.1 at the time of writing; so if you want version 2.13, you will need to look for it on CRAN website.

Sometimes, the simplest information is the most overlooked...


Wednesday, 10 July 2013

GCDkit workshop in India, January 2013

In the June issue of the Journal  of the Geological Society of India just appeared a short article by Sita Bora and Quazi A. Rasool on our workshop 'Geochemical Modelling in Igneous Petrogenesis: An Introduction to GCDkit' which was hosted by the National Geophysical Research Institute, Hyderabad on January12–15, 2013.  It brings nice memories of a very lively meeting and spotless organization by a team led by dr. Vysetti Balaram (Hyderabad) and prof. Santosh Kumar (Nainital).


The workshop, led by Jean-Francois Moyen and myself, focussed initially on basic usage of the GCDkit system, then fundamentals of the R language and principles of geochemical modelling of the main processes in  igneous petrogenesis, such as fractional crystallization, partial melting and binary mixing, using the whole-rock major- and trace-element data and radiogenic isotopic compositions. The enjoyable and enlightening part of the meeting represented invited lectures by several leading  Indian specialists. See the original article for more details. Big thanks are due to all who made this great event to happen, as well as to participants for their eagerness and hard work!


Previous invited workshops on GCDkit (and often on geochemical modelling in the R language)

  • Czech Geological Survey, Prague (11.6. 2004),
  • TU Bergakademie Freiberg, Germany (16. 10. 2005),
  • CGS/EOST, Université Louis Pasteur Strasbourg, France (23.–24. 10 2008),
  • University of Tromso, Norway (16.–17. 6. 2010),
  • Université Jean Monnet, Saint-Etienne, France (9.–11. 5. 2011),
  • University of Helsinki, Finland (7.–11.11. 2011),
  • University of Stelenbosch, South Africa (19–23 3. 2012)

Tuesday, 25 June 2013

Making (kind of) good-looking data tables

Unavoidable task in writing up any scientific paper is to prepare a data table, or rather several of them.  You will probably agree that it quite easy to waste a lot of time trying to format such a table so that it complies with in-house rules of the given Journal or just (often worse) our own needs/wishes. Most commonly, we would like to arrange the analyses according to some key, for instance grouping together the analyses coming from the same intrusion or locality. Moreover, we may want to order the analyses within each of the groups according to an additional criterion, say the increasing silica contents. Lastly, the page width is finite and thus there is likely to be a limit on number of analyses we can fit across a page.
Fortunately the new GCDkit comes with a function which makes this ask easier. In fact, it is currently not attached to the menu system and this is exactly the moment when it is good to be a power user, i.e. not afraid to type in a few lines of code. ;-)

The function in question is called HTMLtableOrdered and outputs the data stored in the numeric matrix specified by parameter 'what'. Optional argument 'which' gives the list of sample names (rows) in the matrix to be saved. The data are first sorted based on 'key2', which typically gives a grouping information (name of a column in 'labs'). Within each of the groups, the data are further sorted based on the numeric variable 'key1'. And the number of analyses across a page is indicated by the parameter 'split.by'. For example, we can produce a table of Large Ion Lithophile Elements (LILE) from our sample datafile, sazava.data:
# Read in the sample data
data(sazava)
accessVar("sazava")
HTMLtableOrdered(WR[,LILE],digits=1,key1="SiO2",key2="Intrusion",
title="LILE (ppm)",split.by=7)
 
There are some other parameters which can be included, for instance the table can have samples in rows, as we are used to from the GCDkit system, and the analyses summed up:

HTMLtableOrdered(WR[,major],digits=2,key1="SiO2",key2="Intrusion",
title="Major-element data (wt. %)",split.by=14,rotate=FALSE,sum.up=TRUE)
 
 
And here is the last example, generating the table from results, here of the CIPW norm calculation.
results<-CIPW(WR)
HTMLtableOrdered(results,digits=2,key1="SiO2",key2="Intrusion",
title="CIPW norm",split.by=5)
 

I just hope you have found the today's tip useful and that it will save you some time to do something more sensible than formatting tables.......

Friday, 21 June 2013

First patch for GCDkit 3.00 released on 5 June 2013

A patch for the GCDkit 3.00 number 130605 is available, addressing following bugs:
  • Redrawing plates in plateCexLab()
  • Verma() was not working correctly for datasets with only total iron determined
  • crashing gcdOptions() (missing were some underlying TclTk functions)
  • multipleMjr() and multipleTrc() did not work at all from the command line

The newest patch installation file can be downloaded here.

Read more about GCDkit patches