Documentation
¶
Overview ¶
Package slider provides functionality for downloading and animating weather satellite imagery.
Index ¶
- Constants
- Variables
- func AnimateGIF(images []image.Image, delay int, style LoopStyle) (*gif.GIF, error)
- func AnimatePNG(images []image.Image, delay int, style LoopStyle) (*apng.APNG, error)
- func AvailableDates(satellite *Satellite, sector *Sector, product *Product) ([]int, error)
- func CreateLoop(opts *LoopOptions) error
- func DownloadImage(uri string) (image.Image, error)
- func DownloadProductsJS() ([]byte, error)
- func ImageTileURL(request *TileImageRequest) string
- func LatestTimes(satellite *Satellite, sector *Sector, product *Product, count int) ([]int, error)
- func SaveGIF(output string, img *gif.GIF) (string, error)
- func SavePNG(output string, img *apng.APNG) (string, error)
- func SelectTimestamps(times []int, opts *LoopOptions) ([]time.Time, error)
- func URLToFilePath(urlString string) (string, error)
- type CropSettings
- type FileFormat
- type ImageCache
- type LoopOptions
- type LoopStyle
- type Product
- type ProductDefaults
- type ProductInventory
- type ProductNavigation
- type ProductNavigationDirection
- type Satellite
- type Sector
- type TileImageRequest
- type Zoom
Constants ¶
const ProductsJSURL = "https://rammb-slider.cira.colostate.edu/js/define-products---rammb-slider.js"
ProductsJSURL is the address to download the latest product data from.
const TileImageURI = "https://rammb-slider.cira.colostate.edu/data/imagery/%s/%s---%s/%s/%s/%02d/%03d_%03d.png"
TileImageURI is the request address for images. It contains the following fields:
- Date
- Satellite
- Sector
- Product
- Image Timestamp
- Zoom Level
- Tile Y-Position
- Tile X-Position
Variables ¶
var AvailableDatesURI = "https://rammb-slider.cira.colostate.edu/data/json/%s/%s/%s/available_dates.json"
AvailableDatesURI is the address for retrieving the latest dates for available images.
- Satellite
- Sector
- Product
var BackupProductsJS []byte
BackupProductsJS is a copy of the define-products.js for use in the event the file can't be retrieved from the SLIDER server.
var LatestTimes5760URI = "https://rammb-slider.cira.colostate.edu/data/json/%s/%s/%s/latest_times_5760.json"
LatestTimes5760URI is the same as LatestTimesURI but with more times.
var LatestTimesURI = "https://rammb-slider.cira.colostate.edu/data/json/%s/%s/%s/latest_times.json"
LatestTimesURI is the address for retrieving the latest times for available images.
- Satellite
- Sector
- Product
var NoProductDownload = false
NoProductDownload will disable downloading the latest products from SLIDER.
var SectorCropTable = map[string]map[string]*CropSettings{
"goes-16": {
"conus": {RatioX: 1, RatioY: 0.6},
},
"goes-17": {
"conus": {RatioX: 1, RatioY: 0.6},
},
}
SectorCropTable includes the builtin crop settings for satellites and sectors.
Functions ¶
func AnimateGIF ¶ added in v0.3.0
AnimateGIF animates the supplied images into a GIF image. This will convert RGB images to a 256-color palette due to the GIF color limit of 256. This will likely result in some down-sampling of your image colors.
func AnimatePNG ¶ added in v0.5.0
AnimatePNG animates the supplied images into a PNG image.
func AvailableDates ¶
AvailableDates returns the list of dates that SLIDER has available data for as ints in the form of YYYYMMDD.
func CreateLoop ¶
func CreateLoop(opts *LoopOptions) error
CreateLoop creates a new loop with the options specified in the provided LoopOptions.
func DownloadImage ¶
DownloadImage downloads an individual image file.
func DownloadProductsJS ¶ added in v0.5.0
DownloadProductsJS will download and return the bytes for the define-products.js file.
func ImageTileURL ¶ added in v0.5.0
func ImageTileURL(request *TileImageRequest) string
ImageTileURL returns the full request URL for an image tile.
func LatestTimes ¶
LatestTimes returns the list of timestamps that SLIDER has available data for as ints in the form of YYYYMMDDhhmmss.
func SaveGIF ¶
SaveGIF encodes the GIF data into a .gif file. The .gif extension will be added automatically. If a file with the same name exists an incrementing number will be appended to the end of the file name.
func SavePNG ¶ added in v0.5.0
SavePNG encodes the PNG data into a .png file. The .png extension will be added automatically. If a file with the same name exists an incrementing number will be appended to the end of the file name.
func SelectTimestamps ¶
func SelectTimestamps(times []int, opts *LoopOptions) ([]time.Time, error)
SelectTimestamps selects the desired timestamps from the list of int timestamps returned by SLIDER. Timestamps are returned in sorted chronological order.
func URLToFilePath ¶ added in v0.5.0
URLToFilePath converts a URL to a file system path by removing the URL scheme (e.g. https://) and converting the URL path to a file system directory path. For example 'https://example.com/a/b/c/d' will return 'example.com/a/b/c/d'
Types ¶
type CropSettings ¶ added in v0.5.0
CropSettings contains the crop ratio settings for a single satellite sector.
func GetCropSettings ¶ added in v0.5.0
func GetCropSettings(satelliteID, sectorID string) *CropSettings
GetCropSettings will return the crop settings for the specified satellite and sector if they exist, otherwise nil.
type FileFormat ¶ added in v0.5.0
type FileFormat int
FileFormat is an output file format type.
const ( // GIF is the .gif file format. GIF FileFormat = iota // PNG is the .png file format. PNG )
type ImageCache ¶ added in v0.5.0
type ImageCache struct {
// Dir is the directory to store the cache in.
Dir string
}
ImageCache is a file system cache for image files.
func (*ImageCache) Delete ¶ added in v0.5.0
func (c *ImageCache) Delete(filePath string) error
Delete will delete the image in Dir at filePath. No error will be returned if the file doesn't exist.
type LoopOptions ¶
type LoopOptions struct {
// AllowStaleImages allows imagery that is over one year old to be included in animations. Disallowing this old
// imagery by default helps to prevent old images from being accidentally included in loops.
AllowStaleImages bool
// Angle is the number of degrees to rotate the image.
Angle float64
// BeginTime is the desired capture time of the first image in the loop.
BeginTime time.Time
// CacheDirectory is the directory to cache downloaded images in. Caching will only happen if a directory is
// supplied here.
CacheDirectory string
// Crop is the area to crop the animation to.
Crop *image.Rectangle
// EndTime is the desired capture time of the last image in the loop.
EndTime time.Time
// FileFormat is the output file format of the animation.
FileFormat FileFormat
// LoopStyle is the animation style of the output animation.
Loop LoopStyle
// NumberOfImages is the number of frames in the output animation.
NumberOfImages int
// OutputDirectory is the directory to save output animations in.
OutputDirectory string
// Product is the product to request imagery for.
Product *Product
// Satellite is the satellite to request imagery from.
Satellite *Satellite
// Sector is the sector to request imagery for.
Sector *Sector
// Speed is the interval between frames. A higher number increases the delay between frames.
Speed int
// TimeStep is the interval between image capture times in minutes.
TimeStep int
// ZoomLevel is the zoom level to request imagery for. Increasing ZoomLevel increases the output animation
// resolution and therefore filesize.
ZoomLevel int
// contains filtered or unexported fields
}
LoopOptions are the config options used to create a new loop.
func LoopOptsFromURL ¶ added in v0.3.0
func LoopOptsFromURL(uri string) (*LoopOptions, error)
LoopOptsFromURL creates a new set of loop options from a SLIDER URL starting with https://rammb-slider.cira.colostate.edu/?...
type LoopStyle ¶
type LoopStyle int
LoopStyle is the animation direction of the images, for example forward or backward.
const ( // ForwardLoop animates loops with images in chronological order. ForwardLoop LoopStyle = iota // ReverseLoop animates loops in reverse order from ForwardLoop ReverseLoop // RockLoop animates the loop forward first then in reverse. Note that using the RockLoop style will cause // animation file sizes to be nearly twice the size has a forward and reverse loops due there being twice the // number of frames. RockLoop )
type Product ¶
type Product struct {
// ColorTableName is the name of the color table legend
ColorTableName string `json:"color_table_name"`
// ProductTitle is the friendly human-readable name for this product
ProductTitle string `json:"product_title"`
// ProductDescription is a long description of this product
ProductDescription string `json:"product_description"`
// Resolution is the minimum resolution for imagery for this product.
Resolution string `json:"resolution"`
// Value is the string sent to SLIDER for this product when requesting images
Value string
// ZoomLevelAdjust is the number of zoom levels to remove from available zoom levels for this product.
ZoomLevelAdjust int `json:"zoom_level_adjust"`
}
Product contains all of the information for a single product captured by a weather satellite.
type ProductDefaults ¶ added in v0.5.0
type ProductDefaults struct {
StartingOpacity float64 `json:"starting_opacity"`
ZoomLevelAdjust int `json:"zoom_level_adjust"`
MaxZoomLevel int `json:"max_zoom_level"`
MinutesBetweenImages float64 `json:"minutes_between_images"`
Colors map[string]string `json:"colors"`
Maps map[string]string `json:"maps"`
}
ProductDefaults contains the default settings for satellites, sectors, and products.
type ProductInventory ¶ added in v0.5.0
type ProductInventory struct {
NumberOfImagesOptions []int `json:"number_of_images_options"`
TimeStepOptions []int `json:"time_step_options"`
DefaultSatellite string `json:"default_satellite"`
Defaults *ProductDefaults `json:"defaults"`
Colors map[string]string `json:"colors"`
UniqueColors map[string]string `json:"unique_colors"`
IgnoreWhiteMapsOnly []string `json:"ignore_white_maps_only"`
Satellites map[string]*Satellite `json:"satellites"`
}
ProductInventory contains all of the product information for SLIDER.
func GetProductInventory ¶ added in v0.5.0
func GetProductInventory() (*ProductInventory, error)
GetProductInventory will download the latest products from SLIDER or return the builtin fail-safe product inventory if the latest products cannot be downloaded.
func ParseProductsJS ¶ added in v0.5.0
func ParseProductsJS(data []byte) (*ProductInventory, error)
ParseProductsJS will parse the define-products.js file which is available on the SLIDER server. ParseProductsJS can also parse the BackupProductsJS data in the event that the file cannot be retrieved from the SLIDER server.
type ProductNavigation ¶ added in v0.5.0
type ProductNavigation struct {
}
ProductNavigation contains details for navigating between products in the SLIDER UI.
type ProductNavigationDirection ¶ added in v0.5.0
type ProductNavigationDirection struct {
}
ProductNavigationDirection contains details for navigating between products in the SLIDER UI.
type Satellite ¶
type Satellite struct {
// Defaults contains default settings for products on this satellite
Defaults *ProductDefaults `json:"defaults"`
// DefaultSector is the default sector selected by SLIDER
DefaultSector string `json:"default_sector"`
// ImageryResolutions is the list of imagery resolutions used by SLIDER. Using ZoomLevels() is preferred to
// to using ImageryResolutions.
ImageryResolutions map[string]string `json:"imagery_resolutions"`
// Products contains a list of available products for this satellite keyed by ID.
Products map[string]*Product
// SatelliteTitle is the friendly human-readable name for this satellite
SatelliteTitle string `json:"satellite_title"`
// Sectors contains a list of available sectors for this Satellite keyed by ID.
Sectors map[string]*Sector
// Value is the string sent to SLIDER for this satellite when requesting images
Value string
}
Satellite contains all of the information for a single weather satellite and all of it's sectors and products.
func (*Satellite) ValidProduct ¶ added in v0.3.0
ValidProduct returns true if the provided product is available for this satellite.
func (*Satellite) ValidSector ¶
ValidSector returns true if the provided sector is available for this satellite.
func (*Satellite) ValidSectorProduct ¶
ValidSectorProduct returns true if the provided sector and products are available for this satellite AND the product is not included in the sector's MissingProducts list. Generally this is the method that should be used to validate that sectors and products are available for the satellite.
func (*Satellite) ZoomLevels ¶ added in v0.3.0
ZoomLevels is the list of available zoom levels or resolutions for this satellite
type Sector ¶
type Sector struct {
// CropRatioX is the amount to crop the image on the X-axis from 0 to 1
CropRatioX float32
// CropRatioY is the amount to crop the image on the X-axis from 0 to 1
CropRatioY float32
// Defaults contains the default products settings for this sector
Defaults *ProductDefaults `json:"defaults"`
// DefaultProduct is the default product selected by SLIDER for this sector.
DefaultProduct string `json:"default_product"`
// MaxZoomLevel is the max zoom level or resolution that this is available for this sector.
MaxZoomLevel int `json:"max_zoom_level"`
// MissingProducts is a list of satellite products that are unavailable for this sector (typically due to the lack
// of data availability).
MissingProducts []string `json:"missing_products"`
Navigation *ProductNavigation `json:"navigation"`
// SectorTitle is a longer string with a human-readable name for the sector
SectorTitle string `json:"sector_title"`
// TileSize is the size of each tile in pixels
TileSize int `json:"tile_size"`
// Value is the string for this sector sent to SLIDER when requesting images
Value string
}
Sector contains all of the information for a single sector captured by a weather satellite.
func (*Sector) ProductMissing ¶ added in v0.3.0
ProductMissing returns true if the provided product is present in the MissingProducts list.
type TileImageRequest ¶ added in v0.5.0
type TileImageRequest struct {
Date string
Satellite string
Sector string
Product string
ImageTimestamp string
ZoomLevel int
TileXPosition int
TileYPosition int
}
TileImageRequest contains the parameters required to request an individual image tile from SLIDER.