Just a note for anyone who’s using the Hymod or HBV rainfall-runoff models. The previous versions were very specific to the paper I was doing, and thus not as useful or general as they could have been. Several people requested cleaned-up versions, so they’re now hosted separately on Github: Hymod and HBV. I removed the previous repo (titled “rainfall-runoff-models”) to avoid confusion.
Let me know if you have questions about running these, or feel free to submit a pull request!
Continuing the series of “animations you may find useful”, this is part of a homework assignment for my Transport & Mixing class. The general idea is this: you have an instantaneous point source in the middle of a two-dimensional box with unit length and height. It spreads via diffusion until it hits the walls of the box, which are no-flux boundaries. Since these are parallel reflective boundaries, the solution for C(x,y,t) is given by an infinite superposition of image sources.
Here’s what concentration looks like as a function of time. It follows a symmetric 2D Gaussian distribution until it hits the walls of the box. Then it spreads out until the concentration is approximately uniform.
And if we zoom out a bit, we can also look at the image sources. (There are technically an infinite number of them, but we can only see a handful over this particular timescale). The image sources are plotted as circles with a radius equal to three standard deviations of the plume.
Here’s the code for the second animation (which also contains the first animation). If you want to actually run it, you’ll also need the function C(x,y,t) which is given here. Finally, the function “circle” was just copied from this discussion. Thanks for reading, let me know if you have questions.
One of our projects involves running the VIC model over the globe at 1-degree cell resolution. We’ve been doing all the post-processing and plotting in Python. Here are some examples that you might be able to use.
First, we want to plot our data on a flat map projection. There’s a nice plugin for Matplotlib called Basemap (just Google it), which is akin to Matlab’s mapping toolbox. Here’s an example of the nice output you can get using Basemap’s “shaded relief” function. You may want to click the image to view it in a new tab to get the full effect.
Here’s a gist with the code for this example. You’ll have to use your own data, obviously, but you should be able to pull the important Basemap functions. Note this figure was combined in Illustrator; the four panels were generated separately.
Ok, that’s all well and good, but it’s so … static. Just for kicks, let’s make a globe that spins around! (Here’s the gist). You can see the main loop that changes the point of focus on the globe, which gradually creates the effect of seeing it spin around.
It’s not quite as easy as just making an animation. You have to save separate image files, and then stitch them together with ImageMagick on the command line. This could be something like:
convert -delay 7 -loop 0 globeframes/*.png globe_error_new.gif
But I realized I had too many frames, and I wanted to choose just every other frame to combine into a gif. There might be better ways of doing this, but I came upon an awk one-liner:
convert -delay 7 -loop 0 `find globeframes/ -type f | awk 'NR % 2 == 0'` globe_error_new.gif
And voila! (Click the figure below to watch the animation–it’s too big to put inline).