Skip to content

Instantly share code, notes, and snippets.

@rthbound
Last active August 29, 2015 13:57
Show Gist options
  • Save rthbound/7c16483b13eaac87a3c5 to your computer and use it in GitHub Desktop.
Save rthbound/7c16483b13eaac87a3c5 to your computer and use it in GitHub Desktop.
Make a gif of the Moon as seen from Earth for one lunar year, starting now - http://gfycat.com/SilverPositiveBluet
require "usno/imagery"
require "open-uri"
require "RMagick"
include Magick
def animate(n,f)
i=0
time = Time.now
1.upto(n).to_a.map {|t| time + (t * f * 60 * 60) }.map {|x| USNO::Imagery::Moon.new(time: x).call.data }.each do |url|
i += 1
open(i.to_s + "_image.png", 'wb') do |file|
file << open(url).read
end
end
ImageList.new(*1.upto(n).to_a.map(&:to_s).map {|x| "#{x}_image.png" }).write("animated_moon.gif")
end
# A "Lunar year" is about 355 days, we want 1 image per day
animate(355, 24)
@rthbound
Copy link
Author

Our moon
Our moon

Mars seen from earth
Mars seen from earth

Other options - https://github.com/rthbound/usno-imagery#usage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment