NCAR / icar

The Intermediate Complexity Atmospheric Research model (ICAR)
MIT License
73 stars 53 forks source link

Rotate Wind Field Fix #84

Closed scrasmussen closed 3 years ago

scrasmussen commented 3 years ago

TYPE: Bug Fix

SOURCE: Soren Rasmussen, NCAR

DESCRIPTION OF CHANGES: Possible fix of the wind field issue. Comparing the previous algorithm with the one from Wikipedia's rotation matrix page shows that an addition was happening when there should have been a subtraction.

TESTS CONDUCTED: Comparing the results of zoomed in wind fields of the two methods show a small difference:

prefix postfix

It is difficult to tell simply by looking if the wind field is corrected. To understand more, here is a unit circle, created by an initial vector of length one (x=1,y=0) and then rotating it at 5 degree increments. This uses the rotation matrix algorithm based on the Wikipedia page.

color_unit_circle

Here is the same plot but estimating the error from the other algorithm. At each point of the previous unit circle, the old algorithm is used to rotate the vector a further 360 degrees, at 5 degree increments. The output is graphed using the starting vector's color to demonstrate the error from the old rotational algorithm can lead to widely differing results based on the starting vectors position.

color_unit_circle_w_error

NOTES: This still hasn't "proven" that the winds are being shifted correctly though. It might be worth it to create a forcing wind field with all the same values and then graph the forcing wind field and ICAR's rotated wind field to see if the input and outputs match what is expected.