Archive for August, 2009
Munk, Pelagic Plastic, Leaving CCHDO, and Burritos
0My summer in San Diego is over, I fly to Hawaii tomorrow (Monday). Much has happened this past week.
Starting with the big oceanographic news, the research cruise to the north pacific gyre and the garbage patch that resides there. The cruise was called SEAPLEX and was one of the first research cruises to the area. Last Thursday, the researchers had a press conference where they discussed their results. I was lucky enough to attend and listen to the researchers talk about what they found. Very interesting stuff, particulary about the discussion of another gyre in the Southern Pacific that is four times larger than the well known one in the north. Attending the conference was famous physical oceanographer Walter Munk, student of the even more famous (in oceanography) Harald Sverdup. I introduced myself to him, but there was little time for talk before the conference started.
Friday was my last day working at SIO for the summer. During my time there I worked with an incredible group of people, especially undergraduate students like myself.
From left to right: Dr. James Swift (Jim) the PI of the group I worked for, Carolina Berys a former student now full time employee, Jessicah Morison a very talented data forensics analyst, Andrew Barna (me), Matthew Shen a skilled programer and cellist, Roxanne Lee a talented graphic design artist. Matthew, the programer cellist, would occasionally come over to the place I was living and we would play music, him on cello, me on piano.
On Friday, I finally asked for a tour of the lab I had been working above for the last few months. Jim, after expressing surprise that he hadn’t given me one earlier, was more than happy to lead the tour. In the labs I saw all sorts of instrumentation and calibration equipment. 
Above is the nutrient auto analyzer. Which uses a color based method for determining the concentration of various nutrients in the water.


The first images shows the sample rosette with niskin bottles mounted on them, these are also referred to as CTDs though no instrumentation was mounted to them at the time of the photograph. The lower photo is of Jim holding what all HPU marine science students will learn about, an actual niskin bottle.
I board the plane and depart San Diego tomorrow, before I go, I’ll be getting one last burrito…
-Andrew
CCHDO Downsizing
0CCHDO (CLIVAR (Climate Variability and Predictability) and Carbon Hydrographic Data Office), yes that is double parenthesis, is the data office I’ve been working in for the past three or so months. I’m in the student office that houses four of the roughly 10 employees. Soon three of us will be leaving, one has reached the limit of how long they may be employed. Another is going to travel the world then join the peace corps. And finally, I will be returning to HPU in a week. Friday we had our departing party to honor those who will be leaving. Many good times were had.
Conversations with those who have been in the oceanographic field for a long time can be extremely enlightening. Jim Swift, the head of CCHDO (though there might be an oversight committee), is one such person who has been in the field for a long time. The dinner party conversation included his reminisces of his graduate school experience. From a rough start in graduate school, he is now well respected in the field and even taught a graduate student who would become an HPU professor, they will remain unnamed. When I asked about how I might get the opportunity to go to sea, Jim suggested that I might look at the Hawaii Ocean Time-series (HOT) cruises that happen once a month or so. It would be an honor for the opportunity to participate in collecting the data that I see come into the CCHDO.
I have lots to do my last week at the CCHDO and hopefully I’ll be able to post the final product of what I have been working on all summer soon.
I’m apparently NOT an intern but something else… (“we don’t know what you are” -Jim)
Hawaii in 10 days.
-Andrew
Tree Crawling Results
0Last weeks post might have been a bit puzzling to most people so I figured I could show what it actually does. Just the end product (in its current state). When that code is interpreted (ruby is not a compiled language), it outputs HTML stable for display in any (modern) web browser. The particular bit of code, produces a navigation menu to make finding the videos easy. I can’t link to the live page yet as it is not complete, but I can show a screen shot of what it looks like.
The to make the embedding of the video itself convenient I wrote a custom tag class that is then interpreted to make an embedded video. All I need to put in the page file is the following line: {video: "Rosette/Rosette_Recovery_Day_Rough.m4v"} where the “Rosette/Rosette_Recovery_Day_Rough.m4v” is simply the path to the desired video inside the video folder. The custom video tag class then figures out how deep the resulting page is in the tree and constructs the video embed path accordingly so it always is the correct path. So far everyone (especially myself) is happy with the results. The graphic designer is currently working on what we are calling an “exploding ship,” if you is familiar with the book series Incredible Cross-Sections it will be something like that. So the exploding ship will be included to give a location of where the video was shot on the ship.
Finished product due in 2 weeks…
-Andrew
Due to a disaster, the screenshot will probably be lost forever
Tree Crawling Problem
0My opportunities to work on coding problems occur rarely in the office I work in. So when I was asked to figure out a menu generation problem, I was more than happy to accept. All of the content I’m working on will eventually be included on the DVD which will come included as supplemental material for a new edition of an oceanographic textbook titled Descriptive Physical Oceanography. What this means is all files included will be unchanging, static, little to no dynamic content. It is also desirable to have any materials included with the book be as self contained as possible due to the seafaring nature of oceanographic work, internet at sea may be unavailable or, when available, very expensive and slow.
To allow the easy construction of static, self contained websites while utilizing templates and generators that use the state of the dynamic content at the time of “compile”, we use a ruby gem called webgen. This gem allows easy creation of static websites using templates, markup languages, and a rather nifty programing language called ruby.
Webgen has a rather nice menu generation method which crawls a tree generated from the files and directories in a special folder of the webgen project. When the webgen command is run in the project directory, it crawls this folder looking for changes and updates the tree accordingly. As convenient as this was, it did not function in a way that would suit our needs based on what the very talented graphic designer had produced. The built in behavior was to create a nested unordered list. What we needed it to do was only use the unordered list tag for the first level of the tree. Subsequent branches, if any, needed to be in the html div tag and not be nested within the unordered list, as this both makes applying styling difficult, but also appears to be unsupported by the spec. To accomplish these changes, I needed to extend the functionality of webgen. Luckily, there was a framework in place to allow this and, thanks to the object oriented nature of ruby, I could easily inherent the functionally of built in menu generation class and simply override the methods I needed to. Just my luck, only one method need to be overridden. Bellow is the almost finished product.
Code:
module Webgen
module Tag
include Webgen::Tag::Base
class CustomMenu < Webgen::Tag::Menu
def create_output_nested(context, tree, level = 1)
### output variable initialization ###
out = ""
out_div = ""
out = "<ul>" if level == 1
out_div = "<div class='sub_nav#{level}'>" if level > 1
### Loop through the tree and all the children to generate the menu ###
tree.children.each do |child|
menu = child.children.length > 0 ? create_output_nested(context, child, level + 1) : ''
style, link = menu_item_details(context.dest_node, child.node, context.content_node.lang, level)
out << "<li #{style}>#{link}" if level == 1
### Only the first level should be encapsulated in a <ul> tag ###
if level > 1 then
out_div << "<div class='directory'>" if child.node.is_directory?
out_div << "<div class='item#{" current node" if context.node == child.node}'>" if !child.node.is_directory?
### Getting the Image path, this should act the same as the relocatable: tag ###
image_path = ""
depth = context.node.level - 1
depth.times do
image_path << "../"
end
image_path << "images/"
image_path << child.node['thumb'] if child.node['thumb']
### Done ###
out_div << "<img src=#{image_path}>" if child.node['thumb']
out_div << link
out_div << "<br />#{child.node['blerb']}" if child.node['blerb']
out_div << "</div>"
end
out_div << menu
out << "</li>" if level == 1
end
### Closing the approprate tags to keep things tidy ###
out_div << "</div>" if level > 1
out << "</ul>"
### Add the output of the div enclosed items to the *END* of the output containing the ul ###
out << out_div
out
end
end
end
end
Webgen::WebsiteAccess.website.config['contentprocessor.tags.map']['custommenu'] = 'Webgen::Tag::CustomMenu'
You may be noticing that it uses a lot of if statements to check what level of the tree the loop is on. Granted this may not be the best practice and would probably have been better to separate all the level one stuff from the greater than level one stuff by putting them in separate methods. However, if you were able to spot it, you may have noticed that there is recursion occurring in the method. Since it can be tricky to visualize the result of using recursive methods, I opted to just check to see what level of the tree the loop was on, and the construct the appropriate output accordingly. I even managed to throw in a connivence method by resolving the depth of the page in the website, and constructing an appropriate link to the images on the page. Bottom line, all the images work.
In all this took about two days to sort out. Most of the first one spent learning the ins and outs of the API and most of the second day moulding the output to what I wanted.
Finished product due in 3 weeks.
-Andrew