himago

package module
v0.0.0-...-776e0f8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2019 License: MIT Imports: 14 Imported by: 0

README

himago

GoDoc Go Report Card Build Status

Download high-resolution images taken by the Himawari 8 satellite. A command line tool written in Go.

Overview

Images of the Asia-Pacific region taken by Himawari 8 can be viewed online at http://himawari8.nict.go.jp/. Each image of the Earth is composed of a grid of Tiles, allowing the user to freely pan and zoom. Himago downloads all images and stitches them together.

Examples

Install

go get github.com/tscott0/himago

Build

$ git clone https://github.com/tscott0/himago.git
$ cd himago/cmd/himago/
$ go build

Usage

usage: himago [--help] [-z zoom] [-b band] [-o output_file]
              [-y year] [-m month] [-d day] [-h hour] [-m minute] [-s second]

  -b, --band value
    	Electromagnetic band. Accepts integers between 1 and 16 inclusive
    	If a band is not specified a full-colour image will be produced.
  -B, --bg value
    	The background colour in hex format (default #000000,)
  -d, --day int
    	The day of the month the image was taken e.g. 30 (default 29)
  -F, --fg value
    	The foreground colour in hex format (default #ffffff,)
  -h, --hour int
    	The hour the image was taken in 24-hour format e.g. 16 means 4pm (default 15)
  -i, --minute int
    	The minute the image was taken.
    	Reverts to last 10min multiple e.g. 15 becomes 10 (default 45)
  -m, --month int
    	The month of the year the image was taken e.g. 5 means May (default 4)
  -o, --output string
    	The name of the file to write to (default "output.png")
  -y, --year int
    	The year the image was taken e.g. 2016 (default 2017)
  -z, --zoom value
    	Zoom level 1-5 (default 2)

Zoom

Changing the zoom level will alter the resolution of the image created. By default zoom level will be set to 2, producing 1100x1100 pixel image. Turning it up to 5 will produce a 8800x8800 pixel image or 77.4 megapixels.

The JMA have made generously made these images freely available. While this tool might be useful for wallpapers, please don't abuse it by downloading hi-resolution images regularly.

Zoom  Grid   Resolution
1     1x1    550  x 550
2     2x2    1100 x 1100
3     4x4    2200 x 2200
4     8x8    4400 x 4400
5     16x16  8800 x 8800

Acknowledgements

Known issues

  • Unrealistic colours: According to Wikipedia, the images returned are true-colour. Looking at the colour of Australia, in particular, the colours don't look accurate. Correcting the colour to make it appear more natural looks complicated.
  • Occasionally will get 404 errors. Himago doesn't handle these automatically so it would require the user to specify a different date or time.

TODO

  • Pass number of rollback attempts on the command line. Maximum?
  • JPEG output format (inferred from filename -o)
  • Percentage completion in-line?
  • Download speed in-line
  • Summarise output image: location, file size, dimensions, format, cropping?
  • Cropping functionality
    • Just crop image before writing
  • Option to save intermediate Tile images
    • Improve by skipping downloads for images that aren't needed.
  • --version
  • 404 should fail but be handled better
  • Consider using https://github.com/pkg/errors
  • Measure performance

License

MIT.

Documentation

Overview

Package himago provides functions to download images ultimately coming from the Himawari 8 satellite. Multiple smaller images, Tiles, are downloaded and stitched together to produce a single large image.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DrawTiles

func DrawTiles(band Band, tiles [][]Tile, outImg draw.Image, fileName string, bg Color, fg Color) error

DrawTiles takes a collection of Tiles and writes them to file.

func GetTiles

func GetTiles(band Band, zoom Zoom, imageTime SatTime) ([][]Tile, error)

GetTiles retrieves the individual tiles to construct an image at the required zoom level.

Types

type Band

type Band int

Band is an int representing the electromagnetic frequency that an image was taken.

Band  Frequency  Description
1     00.47µm    BLUE
2     00.51µm    GREEN
3     00.64µm    RED
4     00.86µm    Near-IR
5     01.60µm    Near-IR
6     02.30µm    Near-IR
7     03.90µm    Short-IR
8     06.20µm    Mid-IR
9     06.90µm    Mid-IR
10    07.30µm    Mid-IR
11    08.60µm    Far-IR
12    09.60µm    Far-IR
13    10.40µm    Far-IR
14    11.20µm    Far-IR
15    12.40µm    Far-IR
16    13.30µm    Far-IR

0 represents the default band which is a full-colour version combining the visible light bands (RGB)

func (*Band) Set

func (b *Band) Set(flag string) error

Set will take the flag passed as a string and attempt to convert it to an int. That int is used the set the value of the Band.

func (*Band) String

func (b *Band) String() string

String returns the Band int as a string. Nothing to see here.

func (*Band) URL

func (b *Band) URL() string

URL will build a URL string for the band The URL will be in Sprintf format e.g. a band of "3" will set the value to be:

"http://himawari8-dl.nict.go.jp/himawari8/img/FULL_24H/B03/%vd/550/%02d/%02d/%02d/%02d%02d00_%v_%v.png"

type Color

type Color struct {
	color.NRGBA
}

Color wraps a color.NRGBA for passing as a command-line flag.

func (*Color) Set

func (c *Color) Set(value string) error

Set accepts a string of digits making a hex number. Must be prefixed with a # eg. #FFFFFF or #ab12ab

func (*Color) String

func (c *Color) String() string

String returns the color as a string

type SatTime

type SatTime struct {
	time.Time
}

SatTime is a defines time to minute precision. Just wraps time.Time

func (*SatTime) Rollback

func (t *SatTime) Rollback()

Rollback 10 minutes. Assumes that the time was previously a multiple of 10 minutes, which calling Round() guarantees.

func (*SatTime) Round

func (t *SatTime) Round()

Round down do the nearest 10 minute multiple and update the Minute value. e.g. at 13:34 would become 13:30 Existing multiples of 10 minutes will not be affected.

type Tile

type Tile struct {
	image.Image
}

Tile wraps an image.Image and provides helper functions to detect "no image" images.

Tiles are always the same size: 550x550 pixels

func (*Tile) IsNoImage

func (t *Tile) IsNoImage() bool

IsNoImage returns true if the md5sum of the image matches the "No Image" hash.

type Xy

type Xy struct {
	X int
	Y int
}

Xy represents coordinates or dimensions of an image. X and Y should always be positive integers.

func (*Xy) Set

func (c *Xy) Set(value string) error

Set accepts two integers separated by an "x" e.g. 100x40 It then sets the values of X and Y. Implements the flag.Value interface.

func (*Xy) String

func (c *Xy) String() string

Outputs Xy as two integers separated by an "x" e.g. 100x40 This is the same format that Set accepts as input.

type Zoom

type Zoom int

Zoom is an int restricted to numbers 1-5 inclusive. A higher zoom produces a larger image but requires many more Tiles to be downloaded.

Zoom  Grid   Tiles  Resolution
1     1x1    1      550  x 550
2     2x2    4      1100 x 1100
3     4x4    16     2200 x 2200
4     8x8    64     4400 x 4400
5     16x16  256    8800 x 8800

func (*Zoom) GridWidth

func (z *Zoom) GridWidth() int

GridWidth returns the number of Tiles the image is square.

func (*Zoom) Set

func (z *Zoom) Set(zoomString string) error

Set will check the value of the zoom and error if invalid Zoom can only be 1-5 inclusive.

func (*Zoom) String

func (z *Zoom) String() string

String returns Zoom as a string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL