ground- water, geo- statistics, environmental- engineering, earth- science

Archive for 2015

automation: getting papers into papersapp from OmniFocus tasks

without comments

I am using OmniFocus to organize my life and in an attempt to get a few things done. My academic live also involves staying on top of publications. I rely on papers as my reference manager. In the last little while, I used OmniFocus to keep track of the papers that I found and that I wanted to get and / or read. This has been a quite reliable workflow, but involved quite some manual clicking.

OF papers

This post describes how I improved it with a little applescript to go more directly from OmniFocus to papers:

  • whenever I see a paper that interests me, I capture it into OmniFocus;
    • the title of the task is the title of the paper or whatever else helps me to identify the paper;
    • the note contains the URL to the pdf of the paper, and nothing else;
    • the task gets assigned one particular project, whose sole purpose is to collect papers I want to get / download;
    • the capturing works mostly via Omni’s “clipotron“, the share sheet extension in iOS, or from within Reeder;
  • regularly, I check that project (on its review date) and get the papers. Until very recently, this involved a few steps for each paper: open the note in OF, click on the link, the relevant page would open in Safari, and I would klick on the bookmark tool that I had setup such that this webpage would open in papers. I replaced this with a very simple applescript (see code listing below)
    • make sure that I am connected to the University’s network to ensure that most papers are accessible;
    • select the perspective that focusses on the project that contains the papers I want to get;
    • select the papers that I want to get, hit a keyboard shortcut associated to the applescript in Keyboard Maestro;
    • tada! papers opens the links, tries to retrieve the pdf (which works in most of the cases) and the bibliographic information. All is left for me is to add some meta-data and read;

Below you can find a listing of the applescript code. It is fairly simple and contains only a few lines. I can see a few areas where it could be expanded (parse URL from note if it contains more stuff than just the URL; what if pdf and / or bibliographic information can not be retrieved by papers). But for most of my use cases it works remarkably well. Hence, I would well agree to John D. Cook’s line of thought that yes, it’s a bit about time being saved, and it’s also about not being derailed. It’s also about accuracy (as followed up by Dr. Drang), and about knowledge transfer and improved processes, as Mike Croucher points out.

Here’s the code snippet:

tell application "OmniFocus"
    -- Target the content of the front window
    tell content of front window

    -- get selected entries
    set theTasks to value of every selected tree

    -- loop over each selected task
    repeat with aTask in theTasks

        tell aTask
            -- extract the task name and the note
            -- note contains URL
            set theTaskName to name
            set theNote to note

            display dialog theNote

            -- open in papers; it automatically retrieves the pdf and 
            ---    the bibliographic information (mostly)
            tell application "Papers"
                open location theNote
            end tell
        end tell

    end repeat
end tell

end tell

Relevant links regarding applescript with the two main software packages used:

Written by Claus

December 30th, 2015 at 10:39 am

Posted in

Mindstorms: Playing and Learning from Mistakes

without comments

Seymour Papert lays down the foundations of his philosophy about programming and about learning in his book Mindstorms: Children, Computers, and Powerful Ideas was heavily involved with the creation of the programming language “Logo” (downloadable here). The main use of this programming language is education in general and learning to program as a side effect. It seems like no coincidence that the name of “Lego Mindstorms” is related to Papert’s book’s title, given that the ancestor of the Lego kit was programmed in Logo.

“Logo” in Python

There is a python module called “turtle” in python, that mimics the capabilities of Logo. This is what I used to create the figure below. There are many more examples online, f.ex. here. The point of turtle and Logo is to provide an interface that is easy to grasp, but that allows to build stepwise more and more complex things. I’ve seen an implementation of Tetris using turtle.

“Das Haus vom Nikolaus ” drawn with turtle in python.

Learning and Playing

One of the first points of Papert is that the modern car was not created based on an analysis of the bad things of horse-powered coaches. Rather it happened because some people played around, “experimented” is probably a nicer word. Directly related to playing is the fact that you make mistakes. Which according to him is nothing bad as long as the mistakes are recognized and fixed. Unfortunately, some people are afraid of making mistakes. Papert calls this “Mathophobie”.

In that sense, Papert argues that it is a good thing if a (young) learner is following epistemology, following two approaches

  1. take “the novel”, the things to be learned, and provide a context with something already known
  2. take “the novel”, embrace it and adopt it, and make based on it something new.

The computer, and the turtle, or any programming language offer a valuable tool for playing, because it is very easy to fix mistakes! Hence, computers and programming can take away the fear of making mistakes! This sounds like such an awesome thing, but then, debugging can be quite painful! 😉

Mistakes in Hydro-Geo-Logy

Unfortunately, I am aware of only a very limited number of reported failures in hydro-geo-logy. “The Court of Miracles of Hydrology: can failure stories contribute to hydrological science? is one example. They build on Popper instead of Papert, but go along a similar vein. And in that issue of the journal there is a list of papers that deal with hydro-geo-logical mistakes. One example are models that are “right for the wrong reasons”.


Keeping all this in mind will hopefully make me a better teacher in the coming term, but also hopefully keeps me constantly reminded to try out things, if nowhere else than in the code editors! When using Computers, I look a lot at data, process data, and analyze the results. Sometimes, it is quite astounding, it almost seems magic to me, that this entire process works. Inevitably, errors occur, and they need to be found and fixed.

Written by Claus

September 24th, 2015 at 9:51 am

Posted in

Presenting at Heterogeneity Conference in Valencia (MADE site)

without comments

I will be presenting at the AGU Chapman Conference “The MADE Challenge for Groundwater Transport in Highly Heterogeneous Aquifers: Insights from 30 Years of Modeling and Characterization at the Field Scale and Promising Future Directions” website.

Details my talk at the Chapman Conference
date Monday, October 5, 2015
time 04:00 PM – 07:00 PM
location Blue Auditorium at the Research Park, located on the campus of the Universitat Politècnica de València
title of talk “Modelling Non-Linear Spatial Dependence with Applications to MADE Hydraulic Conductivity Data”
authors Claus Haslauer, Geoff Bohling

The MADE site is one of three sites world wide, where very detailed measurements of aquifer properties and solute transport movement within these aquifers were taken. The other two sites are in Borden, Canada and Cape Cod, Massachusetts. The detail of monitoring was very fine for hydrogeologic applications, e.g. via test well installations used to sample aqueous geochemical parameters, that some people argue that those wells influence the properties of the aquifer (see Figure below).

MADESite1995 blog
The MADE site in 1995; Image by Geoff Bohling

A review of the first 25 years at the MADE site is given by

C. Zheng, M. Bianchi, and S. M. Gorelick, “Lessons Learned From 25 Years of Research at the MADE Site.,” Ground Water, vol. 49, no. 5, pp. 649–662, Sep. 2011. URL

Written by Claus

September 9th, 2015 at 10:17 am

Posted in

10 Minutes of Yoga (or Programming) Per Day

without comments

I knew it through experience. I knew it from Malcolm Gladwell’s 10,000 hour rule, stating that you need about that number of hours of practice to excel in anything. It is tough. I feel like I had a lot of those hours spent in front of the piano, and I feel like i am not much further then when I started.

In my daily work, I do a lot of programming. By now, I would say I feel mostly comfortable in python. But, I am no computer scientist, and not a developer of a programming language. I once had a roommate who wrote an operating system for a term project. So at least I feel like I can gauge the work involved. What I try to get to is this this recent tweet from one of the key ipython developers. How awesome is this?

One year of constant commits to github
One year of constant commits to GitHub by minrk.

Also interesting is that not everything is dark green. It can not be. 10 minutes of Yoga per day are better than 30 minutes once per week!


So my goal is to program from now on at least 30 minutes per working day.

I played around with various tools to help me keep track of things. I feel like I can’t commit to one repository I have some stuff on repos that I host myself on a server, some on github, some on bitbucket. “I done this” looked very promising, but then my notes sit somewhere and can’t easily access or process them. I settled for now on a simple list in OmniOutliner, which exports to OPML, and which syncs between my smartphone and my computer. I will keep you posted on how I progress!

update 2015-Sep-08:

Michael Tsai just posted on a similar issue

Written by Claus

August 21st, 2015 at 3:31 pm

Posted in

Automatically Prepare Email (Mail, OS X): Sender, Recipient, GPG Encryption Checked

without comments

Sometimes, I enjoy doing something that does not belong to my core area of expertise, at first glance. Still it is fun to figure out how something works 😉

Here is the “problem” I decided to address: – frequently, I send emails to “recipient_x_”. – The content of these messages should be encoded via pgp. I use gpg tools, which I like because their seamless integration into apple mail. Depsite this seamlessness, I have to click on a button to tell mail to encrypt the message, every time I want to send an email. Granted, I could encrypt by default, but among my typical recipients, the ones that use pgp are in the minority. And yes, I am still using apple mail, despite some interesting new kids on the block (MailMate at the forefront). I do use the add-ons mail tags and mail act on though. – I want to send this email from a particular email account

These tasks seems to be ideal for automation, I must have captured the macpowerusers bug. Typically I do most of my scripting with python. I dislike solutions that are bound to something specific like a given operating system. Despite recent discussions about the state of the mac, I don’t foresee myself to be using anything else in the near future. Hence, I started looking into automator, which has a few mail related tasks available, such as selecting the account. However, it has no way to automate gpg.

The next step was to look into applescript. I’ve looked a bit into it in the past, when I created latex based pdfs as notes for omni outliner. Generally, an applescript can be associated with a keyboard shortcut. Keyboard maestro, which I own since a little while, offers similar functionality, with improved user-friendliness. So now, when I am in mail, I just have to type cmd - opt - E, the script is executed, and I get a window as shown below. The three areas highlighted by red rectangles are adapted according to variables in the script.

Template of an email draft generated with the applescript. Fields marked with a red rectangle are filled by executing the script.

Feel free to check out my script on github.

Written by Claus

January 11th, 2015 at 6:35 pm

Posted in