{"id":137,"date":"2013-08-02T12:25:41","date_gmt":"2013-08-02T10:25:41","guid":{"rendered":"https:\/\/www.benscoat.eu\/?p=137"},"modified":"2020-11-27T12:26:32","modified_gmt":"2020-11-27T11:26:32","slug":"clam-starter","status":"publish","type":"post","link":"https:\/\/www.benscoat.eu\/index.php\/2013\/08\/02\/clam-starter\/","title":{"rendered":"Clam Starter"},"content":{"rendered":"\n<p>Clam is one my favorite piece of software. Designed by Maarten Blaauw, it allows to draw age-depth model of stratigraphic cores, using the software R. It uses a csv file containing your radiocarbon dates&#8217; results, stored in a specific folder. To avoid mistake and save time, I wrote an AppleScript to use with Alfred (my favorite Mac app!).<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>In Alfred window, I type the command clam (or whatever you choose) followed by the name of the new core for which I want to draw age-depth model. Alfred passes the core name to my script, which then does several things:<\/p>\n\n\n\n<p>It creates a folder named by the core name, in the folder &#8230;\/clam\/Cores (as clam requires); It creates a csv file ready to fill in with the 14C results; And it creates a R script including the commands necessary for a basic age-depth model. Here is the AppleScript:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"applescript\" class=\"language-applescript\">-- Create folder\n\ntell application \"Finder\"\n    set CoresPath to \"Macintosh HD:Users:--your:path:here--:clam:Cores\"\n    make new folder at CoresPath with properties {name:q}\nend tell\n\n-- Create .csv file\n-- Credit goes to member regular6633 (http:\/\/macscripter.net\/viewtopic.php?pid=143425#p143425)\n\nset filePath to \"Macintosh HD:Users:--your:path:here--:clam:Cores:\" &amp; q &amp; \":\" &amp; q &amp; \".csv\"\nset theString to \"ID,C14_age,cal_BP,error,reservoir,depth\nsurface,,,1,,0\"\n\nset theResult to writeTo(filePath, theString, text, false)\nif not theResult then display dialog \"There was an error writing the data!\"\n\non writeTo(targetFile, theData, dataType, apendData)\n    -- targetFile is the path to the file you want to write\n    -- theData is the data you want in the file.\n    -- dataType is the data type of theData and it can be text, list, record etc.\n    -- apendData is true to append theData to the end of the current contents of the file or false to overwrite it\n    try\n        set targetFile to targetFile as text\n        set openFile to open for access file targetFile with write permission\n        if apendData is false then set eof of openFile to 0\n        write theData to openFile starting at eof as dataType\n        close access openFile\n        return true\n    on error\n        try\n            close access file targetFile\n        end try\n        return false\n    end try\nend writeTo\n\n-- Create R script\n\nset filePath to \"Macintosh HD:Users:--your:path:here--:clam:Cores:\" &amp; q &amp; \":\" &amp; q &amp; \".R\"\nset theString to \"# This script is designed to generate an age-depth model of the core \" &amp; q &amp; \" thanks to clam R software. For any help on clam, see documentation provided by author Maarten Blaauw, or original publication (Blaauw, M., 2010. Methods and code for \\\"classical\\\"age-modelling of radiocarbon sequences. Quaternary Geochronology, 5(5), pp.512\u2013518.)\n\n# Author: Benjamin Dietre, benjamin.dietre [at] uibk.ac.at\n\n# Load workspace and source code\n\nsetwd(\\\"\/Users\/your\/path\/here\/clam\\\") # On Macs\nsetwd(\\\"C:\/your\/path\/her'\/clam\\\") # On PCs\nsource(\\\"clam.R\\\")\n\n# Age-depth models\n\nclam(\\\"\" &amp; q &amp; \"\\\")\n\n# You might like some more options, e.g., clam(\\\"\" &amp; q &amp; \"\\\", yrlab=\\\"Age (years cal. BP)\\\", hiatus=123, outlier=123, yrmin=0, yrmax=12000, dmin=0, dmax=200)\"\n\nset fRef to (open for access file filePath with write permission)\ntry\n    set eof of file filePath to 0\n    write theString to fRef\n    do shell script \"afplay \/System\/Library\/Sounds\/Glass.aiff\"\nend try\nclose access fRef<\/code><\/pre>\n\n\n\n<p>You can download the Alfred workflow here. When you don&#8217;t want to use Alfred (although I definitely recommend), you can modify this script to use a prompt dialog, for instance.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Clam is one my favorite piece of software. Designed by Maarten Blaauw, it allows to draw age-depth model of stratigraphic cores, using the software R. It uses a csv file containing your radiocarbon dates&#8217; results, stored in a specific folder. To avoid mistake and save time, I wrote an AppleScript to use with Alfred (myContinue reading &rarr;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5],"tags":[],"_links":{"self":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/137"}],"collection":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/comments?post=137"}],"version-history":[{"count":1,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/137\/revisions"}],"predecessor-version":[{"id":138,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/posts\/137\/revisions\/138"}],"wp:attachment":[{"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/media?parent=137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/categories?post=137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benscoat.eu\/index.php\/wp-json\/wp\/v2\/tags?post=137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}