-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create biome lookup #23
Comments
Made some good progress tonight; should have an elevation-adjusted temperature map soon ... |
Some precipitation+temperature-based approaches for biome/ecoregion/climate zone calculations: While not strictly biomes or ecoregions, these approaches lend themselves to algorithmic definitions that can act as proxies. |
Working on several biome possibilities in the following spreadsheet: |
Okay, so after days of exploring the possibility of using roaring bitmaps, B-trees, R-trees, etc., and weighing the size of the biome lookup data as well as the fairly expensive operations that will be done at the same time (reading two images, pixel at a time), here's what I think I'm going to do:
|
I've generated a few biome images, and it's not coming out as planned ... then I took a closer look at the temp ranges I had set up, and those aren't going to work at all ... temperature will need to be reworked :-/ |
Here's a current, buggy biome map: Possible issues with temp that need to be investigated/addressed:
Possible issues with precip that may need to be investigated/addressed, also:
|
To solve the issue around the buggy
This has been done, and it seems that one of the problems is that the map image that is index by Gimp using a 42-color palette (the temperature map) actually has 47 colors in it. This was discovered by reading the file and its pixels from Clojure-wrapped Java and stuffing all the color values into a set. Currently looking at the possibility of generating a palette from the 47-color image, and just using that ... |
Setup for checking colors: (def ref-hex-vals (->> (scales/temperature-colors)
(map util/color-map->hex)
(into #{})))
(def im (biome-tmp/read-adjusted-temperature))
(def rgb-vals (into #{} (map-io/all-pixels im)))
(def hex-vals (->> rgb-vals
(mapv util/rgb-pixel->hex)
(into #{}))) (set/difference hex-vals ref-hex-vals) #{"0x00b1dd"
"0x00d6b9"
"0x0c38e0"
"0x0ed6a6"
"0x155cdc"
"0x1f4edc"
"0x2c9aca"
"0x3000df"
"0x8900e4"
"0x94d662"
"0x9953dc"
"0xd9a300"} (set/difference ref-hex-vals hex-vals) #{"0x00b0dd" "0x00d6b8" "0x165cdc" "0x1b37e0" "0x7700e2" "0x8a00e5" "0xdaa200"} So, in both sets, we have colors that are not in the other ... time to re-index the image, I think ... Update: that didn't work; going to try using the colors found in the actual image as the basis for the palette instead. |
I've been working on creating new temperature scales to experiment with; after a significant refactor that will make that easier, I've started tweaking the temperature scales, color ranges, etc., as I do trial-regenerations of the biomes. The temperature work is flexible enough to experiment with nicely, so will work on doing the same with precipitation. |
Precipitation has now been brought into the new abstraction, so I will now be able to create an exponential scale for precipitation ... fingers crossed, that will fix many of the biome-generation issues. |
As a result of the problems with biome generation, I've created a new biome reporting namespace that reads temp and precip data from images and prints out stats on these; it also uses the same function that the biome-image-generator uses, but just the data and there's a function that prints that out too. From the output of the temp and precip stats, we can see that those look good (data/stats as expected): But when the biome stats are gathered, we see the same issue as is in the image: As we can see, all of the expected temperatures are represented, but the precipitation seems not only low but actually wrong: while the stats show zero precip (for everything!), there is no occurrence of zero precip in the actual data; the lowest precip in our data is 250 mm/yr. There's a chance that some or all of our problems here are related to a bad munging of biome precip data ... |
Huh: (set (for [x (range (map-io/width precip-im))
y (range (map-io/height precip-im))]
(scales/coord->precipitation biome/ps precip-im x y))) #{0} All lookups result in zero. Yet the reporting functionality does get proper, non-zero lookups (see the output above). Ah, the report uses a different function for lookups: (scales/precipitation-amount biome/ps (:color-map datum)) Getting closer ... |
Excerpt from running the above So, it's getting a color map, but it's not able to get a precipitation from it ... (def precip-stats (reporter/get-precip-stats precip-im))
(def colors (map :color-map (:freqs precip-stats)))
(sort-by :blue colors) ({:blue 27 :green 95 :red 2}
{:blue 32 :green 106 :red 0}
{:blue 40 :green 119 :red 0}
{:blue 46 :green 126 :red 0}
{:blue 52 :green 132 :red 6}
{:blue 56 :green 136 :red 18}
{:blue 63 :green 145 :red 33}
{:blue 71 :green 152 :red 44}
{:blue 77 :green 159 :red 52}
{:blue 77 :green 167 :red 64}
{:blue 84 :green 173 :red 79}
{:blue 90 :green 180 :red 89}
{:blue 97 :green 187 :red 97}
{:blue 105 :green 195 :red 113}
{:blue 112 :green 207 :red 136}
{:blue 135 :green 216 :red 157}
{:blue 159 :green 224 :red 177}
{:blue 170 :green 228 :red 187}
{:blue 180 :green 230 :red 195}
{:blue 182 :green 231 :red 203}
{:blue 184 :green 231 :red 211}
{:blue 186 :green 232 :red 219}
{:blue 189 :green 232 :red 227}
{:blue 190 :green 232 :red 234}
{:blue 193 :green 232 :red 242}
{:blue 205 :green 237 :red 252}
{:blue 214 :green 240 :red 253}
{:blue 223 :green 242 :red 254}
{:blue 232 :green 247 :red 251}
{:blue 242 :green 251 :red 253}
{:blue 251 :green 255 :red 252}) (count colors) 31 (def generated (map util/rgb-pixel->color-map
(set (for [x (range (map-io/width precip-im))
y (range (map-io/height precip-im))]
(map-io/rgb precip-im x y)))))) (clojure.set/difference (set colors) generated) #{} And looking at the log output, we can see that these colors are present in the maps above. Hrm. Curiouser and curiouser ... |
Ah, but the colors are in there! Seems that the lookup isn't working due to the sometimes differing order of the map k/v pairs! |
Nope, that was a red-herring. Using sorted maps didn't change anything ... manual checks still failed. Let's use some data that failed a lookup in the logged output: (def x 239)
(def y 152)
(def rgb -3938636)
(def cm (sorted-map :blue 180 :green 230 :red 195)) Do checks against our data: [(= rgb (map-io/rgb precip-im x y)) (= cm (util/rgb-pixel->color-map rgb))] [true true] Confirm that it fails: (scales/coord->precipitation biome/ps precip-im x y)
Yet direct lookups are fine: (scales/precipitation-amount biome/ps cm)
And the same logic that fails in (scales/precipitation-amount biome/ps (util/rgb-pixel->color-map -3938636))
Ah-HA!!! The threading macro ... that changed between temp and precip; setting the precip code to use the same threading macro Now we're back to the rain-saturated biome map, and can experiment with the scales. |
Horray! Just applied some fixes to the exponential precipitation scales, and have generated some biome images that are starting to look pretty good: That biome looks like the following, once oceans and altitude shading are overlaid: This still isn't quite right, since with the amount of rainfall hitting that large, oceanic island, there should be a lot of rainforest there. This leads me to believe the current combinations of temperature and precipitation scales still need tweaking. |
Okay, I think I've got something I can be happy with: With the oceans, that gives this: This biome iteration used the following: (def ts (scales/new-scale :temperature :gaussian 0.4 -0.1))
(def ps (scales/new-scale :precipitation :exponential 5)) After a lot of trial and error, the Gaussian normal really shone for the temperature maps. The first parameter is sigma2, and the second parameter is mu. Legends for the above: |
The text was updated successfully, but these errors were encountered: