Documentation
¶
Index ¶
- Constants
- Variables
- func IsForest(b hmz2ter.Biome) bool
- func RenderPreview(g hmz2ele.Grid, hexes []HexJSON, rivers []hmz2riv.EdgeJSON, scale int) (*image.RGBA, error)
- func Validate(hexes []HexJSON) error
- func Version() semver.Version
- type Climate
- type Document
- type HexJSON
- type Map
- type MethodInfo
- type Rules
- func (r Rules) Arid(t float64) float64
- func (r Rules) Biome(c Climate, landform hmz2ter.Landform) hmz2ter.Biome
- func (r Rules) Latitude(y float64, height int) float64
- func (r Rules) Moisture(profile []float64) (moisture, lift float64)
- func (r Rules) Surface(c Climate, biome hmz2ter.Biome, h *hmz2ter.HexJSON) hmz2ter.Surface
- func (r Rules) Validate() error
- func (r Rules) Wet(h *hmz2ter.HexJSON) bool
- func (r Rules) Wind(lat float64) (trades, westerlies, weight float64)
- type Stats
- type Table
- type TerrainInfo
Constants ¶
const ( GlacialIce hmz2ter.Surface = "glacial-ice" Marshes hmz2ter.Surface = "marshes" Swamps hmz2ter.Surface = "swamps" Bogs hmz2ter.Surface = "bogs" Mangroves hmz2ter.Surface = "mangroves" SaltFlats hmz2ter.Surface = "salt-flats" )
Surfaces beyond hmz2ter's clear.
const ( Tundra hmz2ter.Biome = "tundra" Alpine hmz2ter.Biome = "alpine" Desert hmz2ter.Biome = "desert" Scrubland hmz2ter.Biome = "scrubland" Grassland hmz2ter.Biome = "grassland" Steppe hmz2ter.Biome = "steppe" Savanna hmz2ter.Biome = "savanna" BorealForest hmz2ter.Biome = "boreal-forest" TemperateForest hmz2ter.Biome = "temperate-forest" TemperateRainforest hmz2ter.Biome = "temperate-rainforest" TropicalDryForest hmz2ter.Biome = "tropical-dry-forest" TropicalRainforest hmz2ter.Biome = "tropical-rainforest" CloudForest hmz2ter.Biome = "cloud-forest" )
Biomes beyond hmz2ter's clear.
const HexKm = 10
HexKm is a campaign hex's flat-to-flat height in campaign kilometers.
Variables ¶
var ( Surfaces = []hmz2ter.Surface{hmz2ter.SurfaceClear, GlacialIce, Marshes, Swamps, Bogs, Mangroves, SaltFlats} Biomes = []hmz2ter.Biome{hmz2ter.BiomeClear, Tundra, Alpine, Desert, Scrubland, Grassland, Steppe, Savanna, BorealForest, TemperateForest, TemperateRainforest, TropicalDryForest, TropicalRainforest, CloudForest} )
Surfaces and Biomes list every value in the terrain model, in order.
var Method = MethodInfo{
Latitude: "interpolated linearly from top_lat_deg at the raster's top edge to bottom_lat_deg at its bottom edge, at the hex center's y",
Temperature: "sea_level_temp_c at the latitude, less lapse_rate_c_per_km per km of median elevation; warmest and coldest months are the mean ± (annual_range_base_c + annual_range_per_deg_c × |latitude|) / 2",
Precipitation: "windward_precip_mm × (convective_share + (1 − convective_share) × moisture × (1 + lift_gain_per_km × lift_m / 1000)); moisture starts at 1 over the sea (salt water, cliffs, badlands, or off the map) and each step_km upwind keeps exp(−step_km/rainout_km − rise/orographic_m); lift is the median elevation above the lowest point within lift_window_km upwind; the trades and westerlies are traced separately and blended by latitude; distances are campaign km, elevations real m",
Biome: "warmest month below ice → clear (glacial ice); below the tree line → tundra if the sea-level warmest month is also below it, else alpine; precipitation below arid_per_deg_mm × T + arid_base_mm → desert (under desert_share of it), scrubland (hot), or steppe; cooler than montane_below_c → cloud forest on hills, mountains, plateaus, and volcanic highlands where the sea-level coldest month is at least cloud_forest_coldest_min_c, lift at least cloud_forest_lift_m, and precipitation at least cloud_forest_min_mm, else temperate forest in the tropics (sea-level coldest month ≥ tropics_coldest_min_c); hot → tropical rainforest, tropical dry forest, or savanna by precipitation; otherwise boreal forest, temperate rainforest, grassland, or temperate forest",
Surface: "glacial ice with the biome; otherwise only flats and plains that are flat-surface with a median of at most flat_surface_max_m, or flats on a coast or river with a median of at most lowland_max_m, get a surface: salt flats if dry (below the aridity limit), mangroves on the coast if the coldest month is at least mangrove_coldest_min_c, bogs if cooler than bogs_below_c, swamps in a forest biome, marshes otherwise; the rest are clear",
}
Method is the model's description, as written to JSON.
Functions ¶
func RenderPreview ¶
func RenderPreview(g hmz2ele.Grid, hexes []HexJSON, rivers []hmz2riv.EdgeJSON, scale int) (*image.RGBA, error)
RenderPreview draws the hmz2ele preview, then fills each hex with its color (see hexColor), keeping the hex outlines. Rivers are drawn along hex edges.
func Validate ¶
Validate checks every hex against the terrain model's valid combinations and returns the problems found, or nil. Once the climate step has run, an unset surface or biome is an error.
The flat-surface flag is allowed on land although the model doesn't list it: it is hmz2ter's hint to this step, carried through for reference.
Types ¶
type Climate ¶
type Climate struct {
// Latitude of the hex's center, in degrees, north positive.
Latitude float64 `json:"latitude_deg"`
// Temperature is the mean annual temperature, and Warmest and Coldest
// the means of the warmest and coldest months, in °C.
Temperature float64 `json:"temperature_c"`
Warmest float64 `json:"warmest_c"`
Coldest float64 `json:"coldest_c"`
// Precipitation is the annual precipitation in mm.
Precipitation float64 `json:"precipitation_mm"`
// Moisture is the share of the sea air's moisture left when the
// prevailing wind reaches the hex, and Lift the height in meters the
// wind climbs onto the hex (see Rules).
Moisture float64 `json:"moisture"`
Lift float64 `json:"lift_m"`
}
Climate is a land hex's climate. Values are rounded as written to JSON, and the biome and surface are chosen from the rounded values, so they can be checked from the output alone.
type Document ¶
type Document struct {
Hmz2bioVersion string `json:"hmz2bio_version"`
TerrainFile TerrainInfo `json:"terrain"`
hmz2ter.Terrain
ClimateRules Rules `json:"climate_rules"`
ClimateMethod MethodInfo `json:"climate_method"`
ClimateStats Stats `json:"climate_stats"`
Hexes []HexJSON `json:"hexes"`
}
Document is the climate output: every field of hmz2ter's terrain, plus the climate step's own. Hexes replaces the terrain's hexes with ones that carry their climate.
type HexJSON ¶
HexJSON is one hex: hmz2ter's hex, with its surface and biome set, plus the climate of a land hex.
type Map ¶
type Map struct {
Grid hmz2ele.Grid
Hexes []hmz2ter.HexJSON
// contains filtered or unexported fields
}
Map looks up hexes by column and row.
func (*Map) At ¶
At returns the hex of the pixel containing the raster point, or nil if the point is outside the raster or its hex isn't in the grid. A pixel belongs to the hex containing its center, as in hmz2ter; going through the pixel keeps points that fall exactly on a hex boundary (the trace often steps along one) from depending on floating-point noise.
func (*Map) Climate ¶
Climate returns a land hex's climate. Everything uses the latitude rounded as written to JSON.
type MethodInfo ¶
type MethodInfo struct {
Latitude string `json:"latitude"`
Temperature string `json:"temperature"`
Precipitation string `json:"precipitation"`
Biome string `json:"biome"`
Surface string `json:"surface"`
}
MethodInfo describes the parts of the model that Rules doesn't hold.
type Rules ¶
type Rules struct {
// TopLat and BottomLat are the latitudes of the raster's top and bottom
// edges, in degrees, north positive. A hex's latitude is interpolated
// from its center's y.
TopLat float64 `json:"top_lat_deg"`
BottomLat float64 `json:"bottom_lat_deg"`
// SeaLevelTemp is the mean annual temperature at sea level by latitude.
// LapseRate cools it with the hex's median elevation.
SeaLevelTemp Table `json:"sea_level_temp_c"`
LapseRate float64 `json:"lapse_rate_c_per_km"`
// The annual range, warmest month minus coldest, is RangeBase +
// RangePerDeg × |latitude|, split evenly about the mean.
RangeBase float64 `json:"annual_range_base_c"`
RangePerDeg float64 `json:"annual_range_per_deg_c"`
// WindwardPrecip is the annual precipitation on a windward coast at
// sea level, by latitude. ConvectiveShare is the part of it that falls
// regardless of the wind (the tropical wet season's storms); the rest
// depends on the moisture the wind brings.
WindwardPrecip Table `json:"windward_precip_mm"`
// The prevailing wind blows from TradesFrom (a bearing, clockwise from
// north) at latitudes up to TradesMaxLat and from WesterliesFrom beyond
// WesterliesMinLat, blended linearly in between.
TradesFrom float64 `json:"trades_from_deg"`
WesterliesFrom float64 `json:"westerlies_from_deg"`
TradesMaxLat float64 `json:"trades_max_lat_deg"`
WesterliesMinLat float64 `json:"westerlies_min_lat_deg"`
// Moisture: air leaves the sea saturated (1) and is traced upwind in
// steps of StepKm, for at most ReachKm. Each step keeps
// exp(−StepKm/RainoutKm − rise/OrographicM) of its moisture, where rise
// is the height gained, so mountains wring the air dry and leave a rain
// shadow behind them.
StepKm float64 `json:"step_km"`
ReachKm float64 `json:"reach_km"`
RainoutKm float64 `json:"rainout_km"`
OrographicM float64 `json:"orographic_m"`
// Lift is the hex's height above the lowest point within LiftWindowKm
// upwind. Rain on the hex is multiplied by 1 + LiftGain × lift / 1000.
LiftWindowKm float64 `json:"lift_window_km"`
LiftGain float64 `json:"lift_gain_per_km"`
// A hex whose warmest month is below IceBelow is glacial ice, and below
// TreeLineBelow is above the tree line: tundra if the warmest month
// would be below TreeLineBelow at sea level at that latitude, and
// alpine if not.
IceBelow float64 `json:"ice_warmest_below_c"`
TreeLineBelow float64 `json:"tree_line_warmest_below_c"`
// Aridity (Köppen): a hex is dry if its precipitation is below
// AridPerDeg × T + AridBase, where T is its mean temperature, and a
// desert below DesertShare of that. A dry hex at least HotMin is
// scrubland, and steppe if cooler.
AridPerDeg float64 `json:"arid_per_deg_mm"`
AridBase float64 `json:"arid_base_mm"`
HotMin float64 `json:"hot_min_c"`
// A humid hex cooler than MontaneBelow is montane. It is cloud forest
// where the coldest month at sea level is at least
// CloudForestColdestMin (the tropics and subtropics), on hills,
// mountains, plateaus, or volcanic highlands, on a windward slope (lift
// of at least CloudForestLift) with at least CloudForestMin. Otherwise,
// in the tropics, where the coldest month at sea level is at least
// TropicsColdestMin, it is temperate forest.
MontaneBelow float64 `json:"montane_below_c"`
CloudForestColdestMin float64 `json:"cloud_forest_coldest_min_c"`
CloudForestLift float64 `json:"cloud_forest_lift_m"`
CloudForestMin float64 `json:"cloud_forest_min_mm"`
TropicsColdestMin float64 `json:"tropics_coldest_min_c"`
// A humid hex at least HotMin, tropical or not, is tropical rainforest
// with at least RainforestMin, tropical dry forest with at least
// DryForestMin, and savanna with less.
RainforestMin float64 `json:"rainforest_min_mm"`
DryForestMin float64 `json:"dry_forest_min_mm"`
// A humid hex cooler than HotMin outside the tropics is boreal forest
// below BorealBelow, temperate rainforest with at least RainforestMin,
// grassland below GrasslandAridity × the aridity limit, and temperate
// forest otherwise.
BorealBelow float64 `json:"boreal_below_c"`
GrasslandAridity float64 `json:"grassland_aridity"`
// Wetland surfaces (wetlands, mangroves, and salt flats) go only on
// flats and plains that hmz2ter marked flat-surface with a median
// elevation of at most FlatSurfaceMax, or on flats with the coast or
// river flag and a median of at most LowlandMax.
FlatSurfaceMax int `json:"flat_surface_max_m"`
LowlandMax int `json:"lowland_max_m"`
// Such a hex is salt flats if it is dry (see AridBase), mangroves on
// the coast if its coldest month is at least MangroveColdestMin, bogs
// below BogsBelow, swamps in a forest biome, and marshes otherwise.
MangroveColdestMin float64 `json:"mangrove_coldest_min_c"`
BogsBelow float64 `json:"bogs_below_c"`
}
Rules holds the climate model's settings and the thresholds that choose biomes and surfaces. Temperatures are in °C and precipitation in mm per year. Elevations are real meters, as in the source. Distances along the wind are campaign kilometers: the air crosses the campaign world, which is about 3.4 times the real one, while lift depends only on height gained.
func (Rules) Latitude ¶
Latitude returns the latitude at raster row y of a raster that is height pixels tall.
func (Rules) Moisture ¶
Moisture returns the moisture left at the end of the profile, and the lift onto its last point.
type Stats ¶
type Stats struct {
LandHexes int `json:"land_hexes"`
Biomes map[hmz2ter.Biome]int `json:"biomes"`
Surfaces map[hmz2ter.Surface]int `json:"surfaces"`
}
Stats counts land hexes by biome and surface.
type Table ¶
type Table [][2]float64
Table is a piecewise-linear function of latitude: each entry is [degrees from the equator, value], in increasing latitude. Values are interpolated between entries and held flat beyond the ends.
type TerrainInfo ¶
type TerrainInfo struct {
FileName string `json:"file_name"`
}
TerrainInfo identifies the hmz2ter file the climate was built from.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
hmz2bio
command
Command hmz2bio gives every land hex of an hmz2ter terrain file a climate, a biome, and a surface, and writes the result as JSON, with an optional PNG preview.
|
Command hmz2bio gives every land hex of an hmz2ter terrain file a climate, a biome, and a surface, and writes the result as JSON, with an optional PNG preview. |