MightyBOBcnc / nixis

A python program for procedurally generating planet-scale maps for Earth-like, spherical worlds.
MIT License
8 stars 0 forks source link

calc_daily_insolation_2 appears to make NaN values in some instances #2

Closed MightyBOBcnc closed 3 years ago

MightyBOBcnc commented 3 years ago

Steps to Reproduce:

  1. In the climate section of nixis.py, set the following parameters:
        axial_tilt = 8.0
        current_tilt = calculate_seasonal_tilt(axial_tilt, 90)
  2. Run Nixis with default arguments, most importantly divisions is 320 for the distribution of vertices (optional: set seed to 1337)

Observed Result: A gray ring of vertices appears around both poles when visualized in PyVista.

Expected Result: All vertices are assigned a color from the color scale.

Additional Notes: The gray vertices suggests that NaN values are being placed in the array used for color mapping. PyVista will assign no color if it encounters a NaN. The calc_daily_insolation_2 function has a lerp operation that uses division and that is the first place I would investigate; dividing by a certain value could possibly produce NaNs.

MightyBOBcnc commented 3 years ago

Further investigation: Probably an "invalid" Z coordinate being passed to xyz2latlon.

It looks like due to floating point precision sometimes a value of 1.0000000000000002 or -1.0000000000000002 is being passed for the Z coordinate which is just enough outside of the allowable range for arcsin to fail and return a NaN.

MightyBOBcnc commented 3 years ago

Fixed by https://github.com/MightyBOBcnc/nixis/commit/a0f3ab0bd5583d98c8a6fba404ff0d0cb16b9619