#NEWLINE# @ staticmethod #NEWLINE# def _calculate( world , seed , elevation , mountain_level ) : #NEWLINE# #INDENT# width = world . width #NEWLINE# height = world . height #NEWLINE# rng = numpy . random . RandomState ( seed ) #NEWLINE# base = rng . randint ( 0 , 4096 ) #NEWLINE# temp = numpy . zeros ( ( height , width ) , dtype = float ) #NEWLINE# '\n        Set up variables to take care of some orbital parameters:\n         distance_to_sun: -Earth-like planet = 1.0\n                          -valid range between ~0.7 and ~1.3\n                                see https://en.wikipedia.org/wiki/Circumstellar_habitable_zone\n                          -random value chosen via Gaussian distribution\n                                see https://en.wikipedia.org/wiki/Gaussian_function\n                          -width of distribution around 1.0 is determined by HWHM (half width at half maximum)\n                          -HWHM is used to calculate the second parameter passed to random.gauss():\n                                sigma = HWHM / sqrt(2*ln(2))\n                          -*only HWHM* should be considered a parameter here\n                          -most likely outcomes can be estimated:\n                                HWHM * sqrt(2*ln(10)) / sqrt(2*ln(2)) = HWHM * 1.822615728;\n                                e.g. for HWHM = 0.12: 0.78 < distance_to_sun < 1.22\n         axial_tilt:      -the world/planet may move around its star at an angle\n                                see https://en.wikipedia.org/wiki/Axial_tilt\n                          -a value of 0.5 here would refer to an angle of 90 degrees, Uranus-style\n                                see https://en.wikipedia.org/wiki/Uranus\n                          -this value should usually be in the range -0.15 < axial_tilt < 0.15 for a habitable planet\n        ' #NEWLINE# distance_to_sun_hwhm = 0.12 #NEWLINE# axial_tilt_hwhm = 0.07 #NEWLINE# distance_to_sun = rng . normal ( loc = 1.0 , scale = ( distance_to_sun_hwhm / 1.177410023 ) ) #NEWLINE# distance_to_sun = max ( 0.1 , distance_to_sun ) #NEWLINE# distance_to_sun *= distance_to_sun #NEWLINE# axial_tilt = rng . normal ( scale = ( axial_tilt_hwhm / 1.177410023 ) ) #NEWLINE# axial_tilt = min ( max ( ( - 0.5 ) , axial_tilt ) , 0.5 ) #NEWLINE# border = ( width / 4 ) #NEWLINE# octaves = 8 #NEWLINE# freq = ( 16.0 * octaves ) #NEWLINE# n_scale = ( 1024 / float ( height ) ) #NEWLINE# for y in range ( 0 , height ) : #NEWLINE# #INDENT# y_scaled = ( ( float ( y ) / height ) - 0.5 ) #NEWLINE# latitude_factor = numpy . interp ( y_scaled , [ ( axial_tilt - 0.5 ) , t , ( axial_tilt + 0.5 ) ] , [ 0.0 , 1.0 , 0.0 ] , left = 0.0 , right = 0.0 ) #NEWLINE# for x in range ( 0 , width ) : #NEWLINE# #INDENT# n = snoise2 ( ( ( x * n_scale ) / freq ) , ( ( y * n_scale ) / freq ) , octaves , base = base ) #NEWLINE# if ( x <= border ) : #NEWLINE# #INDENT# n = ( ( ( snoise2 ( ( ( x * n_scale ) / freq ) , ( ( y * n_scale ) / freq ) , octaves , base = base ) * x ) / border ) + ( ( snoise2 ( ( ( ( x * n_scale ) + width ) / freq ) , ( ( y * n_scale ) / freq ) , octaves , base = base ) * ( border - x ) ) / border ) ) #NEWLINE# #UNINDENT# t = ( ( ( ( latitude_factor * 12 ) + ( n * 1 ) ) / 13.0 ) / distance_to_sun ) #NEWLINE# if ( elevation [ ( y , x ) ] > mountain_level ) : #NEWLINE# #INDENT# if ( elevation [ ( y , x ) ] > ( mountain_level + 29 ) ) : #NEWLINE# #INDENT# altitude_factor = 0.033 #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# altitude_factor = ( 1.0 - ( float ( ( elevation [ ( y , x ) ] - mountain_level ) ) / 30 ) ) #NEWLINE# #UNINDENT# t *= altitude_factor #NEWLINE# #UNINDENT# temp [ ( y , x ) ] = t #NEWLINE# #UNINDENT# #UNINDENT# return temp