Thursday, January 30, 2014

Physicists do it all the time

Physicists do it all the time, and so should geologists and engineers.

I'm talking about dimensional analysis. As a student in a physics department (which I was, for my undergrad degree in geophysics), it is required as part of "showing your work" but it also helps you figure out which formulas and equations to use if you're stuck.

Dimensional analysis is a tool to keep track of the units when you are doing calculations with physical properties. If you have an equation that involves measured values, the units on both sides of the equation must add up.  If you manipulating an equation in any way, such as substituting in other equations, or rearranging it to solve for an important variable, you should do the dimensional analysis before you start plugging in your numbers.

If you are working with Darcy's Law, or Newton's Law of Universal Gravitation, or any other number of equations that involve measurements of physical parameters, the first step to making sure your work is correct should always be dimensional analysis.  Do this on a piece of paper, before you start plugging things in to a spreadsheet or script/code.

Here's an example using Newton's Law of Universal Gravitation, for calculating the gravitational force between two bodies:

1. Create a "legend" of the variables in your equation, defining them and the units they are measured in:
  • Fg is the gravitational force (in Newtons)
  • m1 and m2 are masses of the two bodies (in kilograms)
  • d is the distance between the two bodies (in meters)
  • and G is the gravitational constant: 

2. Plug the units into the equation instead of the variables:

3. We can rearrange this a little bit, and cancel things out, leaving Newtons on both sides of the equation:

As long as the values you have are input in Newtons, kilograms, and meters, you will correctly calculate the gravitational force, in Newtons, between two objects.

Notice that there are no values in the dimensional analysis (steps 2-3). Dimensional analysis should never include values. 

Last semester, my students had to do two labs where they made some lab measurements and then did some calculations using those measurements in Excel. They struggled with this concept a lot in the first one.  A few weeks later, when it was time for the second lab like this, I included teaching them to do dimensional analysis before plugging things into Excel. It made a world of a difference in how well they did with the rest of the lab.

Monday, December 2, 2013

Plotting Geologic Time in R

I'm going to be plotting some data in R, with geologic age along the y-axis, so I thought it would be nice to have a version of the timescale to go with it.  In order to plot everything with the same y-axis, I need the Cenozoic timescale as a stacked bar chart R.

The first step was creating a table with the information I needed. I created a comma-separated file that I loaded into R. My file had four columns: Time (a text column where I listed the Epochs), AgeStart (the beginning of each epoch), AgeEnd (the end of each epoch) and Duration (the length of each epoch).

In R, I'm using the ggplot2 library (and for what it's worth, I use RStudio). To begin with:
# Script created by Tannis McCartney
# Read in time scale file (Ages from 2013 International Time Scale)
Cenozoic <- read.csv(file='Cenozoic.csv')
The next step was to calculate the midpoint of each epoch.
midpoint <- Cenozoic$Age.End + Cenozoic$Duration/2
I also needed to tell R which order to put my epochs in. For a larger dataset, I would probably create a sequential numerical column, but with only seven epochs in the Cenozoic, I could spell it out:
Cenozoic$Time <- factor(Cenozoic$Time, levels = c("Holocene", "Pleistocene", "Pliocene", "Miocene", "Oligocene", "Eocene", "Paleocene"))
With ggplot2, the plot is generated by a series of commands added together:
ggplot(data = Cenozoic, aes(x= "Epoch", y = Duration, fill = Time)) + ylab("Ma") + xlab(NULL) + geom_bar(stat="identity") + geom_text(label = Cenozoic$Time, aes(y=midpoint, ymax=65.5)) + theme(legend.position="none")  + scale_fill_manual(values=c("#FEF2E0", "#FFF2AE", "#FFFF99", "#FFFF00", "#FDC07A", "#F3B46C", "#FDA75F"))
Let me break that down a bit:

ggplot(data = Cenozoic, aes(x= "Epoch", y = Duration, fill = Time))
This plots the data in the Cenozoic table with "Epoch" on the x-axis, Duration on the y-axis, and using Time to fill the bars with different colours. Epoch is not something I had in the input table - to create a single stacked bar chart you want only one x value and it has to be assigned a value/string. I called it Epoch. By using Duration along the y-axis, it creates the stacked bars of the appropriate widths, and it fills the colours according to the Time column.

ylab("Ma") + xlab(NULL)
This sets the labels for the x- and y- axes. I didn't need an x-axis label since the tick will be labeled with Epoch based on my inputs above.

This tells R to create bars with heights that represent specific values (in this case, the duration of the epoch).

geom_text(label = Cenozoic$Time, aes(y=midpoint, ymax=65.5))
This puts the epoch labels in the center of each bar. The midpoint values calculated earlier are used here.

This turns off the legend, since the labels have been applied to the bars directly.

scale_fill_manual(values=c("#FEF2E0", "#FFF2AE", "#FFFF99", "#FFFF00", "#FDC07A", "#F3B46C", "#FDA75F"))
This sets the hex colour values for each bar. I decided to go all out here - I used the "official" colours for the International Time Scale. I got the RGB values for each epoch from this handy resource at Purdue. I'm not sure if R can handle RGB values, but I know it can take hex colours, so I converted the RGB values for the epochs to hex using an online converter. There may be a more efficient way to do this, and if I was working with more than seven rows of data, I would have spent a bit of time finding it. However, this works for the Cenozoic epochs. This command creates a column that assigns the colours to the bars in the same order they are plotted.

Since my plan is to tile this with other data I'm plotting, I'm leaving off the title for now. Eventually I will make this narrower too. Once I have everything else scripted in R, I'll decide whether or not to flip the y-axis or rotate the whole plot, but for now I'm pretty pleased with the results:

Monday, November 11, 2013

Sedimentary Petrology

I was doing really well with my 30 minutes of blogging per day, right up until the class I TA started the 4-week section on sedimentary petrology.  Prior to teaching these labs, I hadn't looked at a thin section since the nineties, and even then I was terrible at it.  So I've had to devote a huge chunk of my time to re-learning how to use an optical microscope and the fundamentals of sedimentary petrology. Not that this is a bad thing to review-- I've always been very self-conscious about my level of comfort with a thin section.

I've kept these labs very basic, because about 2/3 of my students haven't even taken mineralogy yet. No measuring angles of extinction, no interference color charts, just visual differentiation between a few key minerals, sedimentary textures, provenance, and diagenesis.

Rather than dig out the department camera that goes with the microscope (it was getting a lot of use in October as people prepared for GSA), I used my smartphone camera to get photos of some of the slides we were using in lab. It's tricky, and the photos aren't high quality, but they are good enough for learning and for reviewing the slides with the students. Here are a few of my favorite thin section photos from the last month or so of teaching. Most of these are at 4x magnification. A few are at 10x magnification.

Glauconite under XPL
Glauconite under PPL

Precambrian impactite? Great examples of feldspar twinning here.

Tahitian black beach sand (mostly olivine)
Silicified oolite under XPL, with calcite exhibiting twinning.

The same silicifed oolite under PPL.
The calcite is showing beautiful rhombohedral cleavage.

Dolostone under PPL
The same dolostone under XPL
Oolitic Limestone under PPL
I don't remember which sample this photo is from (I think it's a carbonate).
I assume this is some sort of recrystallization. Please feel free to comment if you know otherwise.

Monday, October 14, 2013

Seashells, and not at the ocean

I was inspired to write this entry by an xkcd comic:

If you haven't seen this one, the mouseover text is what really made me laugh:  
"This is roughly equivalent to 'number of times I've picked up a seashell at the ocean' / 'number of times I've picked up a seashell,' which in my case is pretty close to one and gets closer if we're considering only times I didn't put it to my ear."
I collected a few seashells in Turkana, in the dry lagas (riverbeds). I was nowhere near the ocean, and I was several kilometers away from the modern lake. But once upon a time...

Lake Turkana is a saltwater lake, and it used to be much larger than it is now.  The photo below is of a rock I picked up en route to our drilling site in northern Turkana. We were stopped for at least an hour because the truck carrying our equipment got stuck. There wasn't anything I could add to the effort to get it out so I had a bit of time to explore the piles of rocks that were carried downstream when water flooded the laga. Because it was found in the riverbed, I don't know very much about it, except that it originated upstream from where I was in ancient deposits.

Seashells that are not from the sea
If you look on the bottom left corner of the rock, there is a darker piece. That's a fish bone.

Saturday, October 12, 2013


My personal 30 minute blog challenge, in which I spend 30 minutes a day writing blog posts, failed yesterday. I'm not beating myself up for this - I had a research deadline yesterday, and by the time I finished with that I was exhausted and couldn't keep my eyes open for 30 more minutes. 

Today, I'm asking you to take 30 minutes to catch up on what made my twitter feed explode in the last day: censorship used to silence a woman who called out someone for completely inappropriate behavior. 

Begin here, with an account of what happened (including the original post that has since been removed from its home):

Then these posts which call out Scientific American for their appalling action (hopefully the ones hosted by Scientific American won't also be censored):

And finally, here, for a call to everyone to join in and "raise our voices":

Thursday, October 10, 2013

Look up!

I've posted before about the importance of looking up and around when you're out in the field. In 2012, on a field trip that crisscrossed a remote corner of Dinosaur Provincial Park and some of the private land surrounding it, I took the following two photos.

The red arrow in the top photo is pointing to my scale card, which has 1 cm markers on the right side.  This scale card is as high up the exposure as I could reach.  The blue arrow is pointing to some eroded but still cool cross-bedding.  And above that is the really cool reason to look up.  A dinosaur bone.
High up in the badlands. The scale card at the bottom is in the highest nook I could reach.
The bone is still there because this is a remote area that you need permits and permission to access. It's possible it has only recently been exposed, and I overheard field trip participants talking about how they could climb up to get it down to take home. Fortunately, they were ushered on before they could carry out their plan.  Because of the nature of the southern Alberta badlands, they wouldn't be able to find it again if they went back on their own either. 

A closer look at the dinosaur bone. 

Wednesday, October 9, 2013

Hillshades of New York State

I've always been fascinated with maps. At some point in my teenage life I thought it would be amazing to be a cartographer.  I do make a lot of maps for my research, and it's one of my favourite things to work on. I've been spending a lot of time lately working with DEMs (digital elevation models) and using them to create hillshades, like the one below. 

New York State is a great place to study glacial morphology, and this hillshade, which shows a bit of Lake Ontario at the top, all of Seneca Lake (bottom center) and some of Cayuga Lake (bottom right), is a great example of why. 

Just south of Lake Ontario there are many tiny hills. These are drumlins, remnants of the last glacial period in the area. The Finger Lakes (of which Seneca and Cayuga Lakes are the largest) are deeply carved valleys that filled with water when they were dammed by terminal moraines of the Pleistocene Glaciation.  At the far southern end of the map, the terrain becomes more rugged. This is the northern extent of the Allegheny Plateau.

For more posts about drumlins, check out Evelyn's Geology Word of the Week, where she writes about Drumlins and posts links to other posts.

The other thing that is great about studying in New York State is the availability of geospatial data for the state. Cornell University, through its CUGIR site, offers "open and free access to geospatial data and metadata for New York State."  This was immensely helpful for the geomorphology project I wrote about yesterday, and for preparing resources for the sed/strat field trips I've been TAing this semester.

Hillshade of the Seneca Lake region in central New York State

* This post is part of a personal challenge I've made to spend 30 minutes a day on my blog. For this week, I'm trying to get out short posts every day.