module Himawari
encapsulates all the functions pertaining to acquiring images from the himawari8 satellite in near real-time from HIMAWARI_URL
(defined in the Base
Class)
require 'pry'
Constants
- HIMAWARI_URL
Yep, that's the big one. Where we actually download everything from
- LOCAL_MIDNIGHT
Local (JST) midnight happens @14:10 UTC, so we have to use pics in interval of [2.days.ago@14:40 .. 14 at
1.day.ago
:40]- MONITOR_ASPECT
This Aspect Ratio is used to try and download the most appropriate Tiles from
Himawari
, while omitting those that won't be visible. (used by the :focus param)- UPDATE_RATE
int; update the pic once every `UPDATE_RATE` minutes
Public Class Methods
all-in-one method. downloads images, sets backgrounds, crontabs, whatever @param params [Hash] any combination of the acceptable command line args you can throw at it.
Plz see README for the list/description
@return nothing useful
# File lib/himawari.rb, line 16 def self.autorun(params = {}) h = Download.new(params) h.cron_action ? h.crontab : h.update_backgrnd ^ h.start end
downloads 1 picture from himawari website, closest (but in the past of) the `:datetime` provided in the params @param [Hash] any combination of the acceptable command line args + THE REQUIRED `:datetime` additional stamp @return [true, false] on success/failure
# File lib/himawari.rb, line 24 def self.get_pic(params = {}) t = validate(params[:datetime]) Download.new(params).pic(t, OsUtils.tenmin(t.min, t.min)) end
downloads many pictures from himawari website, in the range of [:from, :to] provided in the params @param [Hash] any combination of the acceptable command line args + THE REQUIRED `:from` && `:to` timestamps @return [true, false] on success/failure
# File lib/himawari.rb, line 32 def self.get_pics(params = {}) Download.new(params).pics(validate(params[:from]), validate(params[:to])) end
validates the user-provided timestamps coming from `get_pic` or `get_pics` methods @param stamp [DateTime, String] @return [DateTime] of the stamp, or the most recent round 10-minute mark to Time.now - 10.minutes
# File lib/himawari.rb, line 39 def self.validate(stamp) return stamp if stamp.is_a? Time return Time.parse("#{stamp}+00:00") if stamp.is_a? String t = Time.now.utc - 600 # 600secs == 10.minutes ago Time.new(t.year, t.month, t.day, t.hour, t.min / 10 * 10, 0, '+00:00') end