diff --git a/data/scan_x_rotated_ll_5_4_good.dump b/data/scan_x_rotated_ll_5_4_good.dump index 66efea3b9..77a4e5d61 100644 --- a/data/scan_x_rotated_ll_5_4_good.dump +++ b/data/scan_x_rotated_ll_5_4_good.dump @@ -1,21 +1,21 @@ Latitude, Longitude, Value - 20.000 24.000 5 - 20.000 23.000 4 - 20.000 22.000 3 - 20.000 21.000 2 - 20.000 20.000 1 - 19.000 24.000 10 - 19.000 23.000 9 - 19.000 22.000 8 - 19.000 21.000 7 - 19.000 20.000 6 - 18.000 24.000 15 - 18.000 23.000 14 - 18.000 22.000 13 - 18.000 21.000 12 - 18.000 20.000 11 - 17.000 24.000 20 - 17.000 23.000 19 - 17.000 22.000 18 - 17.000 21.000 17 - 17.000 20.000 16 + 59.143 131.824 5 + 59.882 132.969 4 + 60.606 134.175 3 + 61.316 135.444 2 + 62.009 136.781 1 + 59.743 130.250 10 + 60.500 131.388 9 + 61.243 132.588 8 + 61.972 133.855 7 + 62.685 135.193 6 + 60.323 128.619 15 + 61.099 129.746 14 + 61.861 130.937 13 + 62.609 132.197 12 + 63.342 133.531 11 + 60.883 126.931 20 + 61.677 128.042 19 + 62.458 129.219 18 + 63.226 130.468 17 + 63.979 131.793 16 diff --git a/data/scan_x_rotated_ll_5_7_good.dump b/data/scan_x_rotated_ll_5_7_good.dump index d34e8db24..54985ef5d 100644 --- a/data/scan_x_rotated_ll_5_7_good.dump +++ b/data/scan_x_rotated_ll_5_7_good.dump @@ -1,36 +1,36 @@ Latitude, Longitude, Value - 20.000 24.000 5 - 20.000 23.000 4 - 20.000 22.000 3 - 20.000 21.000 2 - 20.000 20.000 1 - 19.000 24.000 10 - 19.000 23.000 9 - 19.000 22.000 8 - 19.000 21.000 7 - 19.000 20.000 6 - 18.000 24.000 15 - 18.000 23.000 14 - 18.000 22.000 13 - 18.000 21.000 12 - 18.000 20.000 11 - 17.000 24.000 20 - 17.000 23.000 19 - 17.000 22.000 18 - 17.000 21.000 17 - 17.000 20.000 16 - 16.000 24.000 25 - 16.000 23.000 24 - 16.000 22.000 23 - 16.000 21.000 22 - 16.000 20.000 21 - 15.000 24.000 30 - 15.000 23.000 29 - 15.000 22.000 28 - 15.000 21.000 27 - 15.000 20.000 26 - 14.000 24.000 35 - 14.000 23.000 34 - 14.000 22.000 33 - 14.000 21.000 32 - 14.000 20.000 31 + 59.143 131.824 5 + 59.882 132.969 4 + 60.606 134.175 3 + 61.316 135.444 2 + 62.009 136.781 1 + 59.743 130.250 10 + 60.500 131.388 9 + 61.243 132.588 8 + 61.972 133.855 7 + 62.685 135.193 6 + 60.323 128.619 15 + 61.099 129.746 14 + 61.861 130.937 13 + 62.609 132.197 12 + 63.342 133.531 11 + 60.883 126.931 20 + 61.677 128.042 19 + 62.458 129.219 18 + 63.226 130.468 17 + 63.979 131.793 16 + 61.421 125.183 25 + 62.233 126.274 24 + 63.033 127.433 23 + 63.820 128.665 22 + 64.594 129.976 21 + 61.935 123.376 30 + 62.765 124.441 29 + 63.584 125.575 28 + 64.392 126.785 27 + 65.186 128.076 26 + 62.425 121.508 35 + 63.273 122.542 34 + 64.111 123.647 33 + 64.938 124.828 32 + 65.752 126.092 31 diff --git a/data/scan_x_rotated_ll_8_4_good.dump b/data/scan_x_rotated_ll_8_4_good.dump index bff032c3e..f7ab7ec97 100644 --- a/data/scan_x_rotated_ll_8_4_good.dump +++ b/data/scan_x_rotated_ll_8_4_good.dump @@ -1,33 +1,33 @@ Latitude, Longitude, Value - 20.000 27.000 8 - 20.000 26.000 7 - 20.000 25.000 6 - 20.000 24.000 5 - 20.000 23.000 4 - 20.000 22.000 3 - 20.000 21.000 2 - 20.000 20.000 1 - 19.000 27.000 16 - 19.000 26.000 15 - 19.000 25.000 14 - 19.000 24.000 13 - 19.000 23.000 12 - 19.000 22.000 11 - 19.000 21.000 10 - 19.000 20.000 9 - 18.000 27.000 24 - 18.000 26.000 23 - 18.000 25.000 22 - 18.000 24.000 21 - 18.000 23.000 20 - 18.000 22.000 19 - 18.000 21.000 18 - 18.000 20.000 17 - 17.000 27.000 32 - 17.000 26.000 31 - 17.000 25.000 30 - 17.000 24.000 29 - 17.000 23.000 28 - 17.000 22.000 27 - 17.000 21.000 26 - 17.000 20.000 25 + 56.853 128.720 8 + 57.628 129.702 7 + 58.392 130.736 6 + 59.143 131.824 5 + 59.882 132.969 4 + 60.606 134.175 3 + 61.316 135.444 2 + 62.009 136.781 1 + 57.401 127.178 16 + 58.193 128.149 15 + 58.974 129.171 14 + 59.743 130.250 13 + 60.500 131.388 12 + 61.243 132.588 11 + 61.972 133.855 10 + 62.685 135.193 9 + 57.930 125.591 24 + 58.738 126.546 23 + 59.536 127.554 22 + 60.323 128.619 21 + 61.099 129.746 20 + 61.861 130.937 19 + 62.609 132.197 18 + 63.342 133.531 17 + 58.438 123.957 32 + 59.263 124.893 31 + 60.078 125.883 30 + 60.883 126.931 29 + 61.677 128.042 28 + 62.458 129.219 27 + 63.226 130.468 26 + 63.979 131.793 25 diff --git a/data/scan_x_rotated_ll_8_7_good.dump b/data/scan_x_rotated_ll_8_7_good.dump index c7ebdeec6..661b6c972 100644 --- a/data/scan_x_rotated_ll_8_7_good.dump +++ b/data/scan_x_rotated_ll_8_7_good.dump @@ -1,57 +1,57 @@ Latitude, Longitude, Value - 20.000 27.000 8 - 20.000 26.000 7 - 20.000 25.000 6 - 20.000 24.000 5 - 20.000 23.000 4 - 20.000 22.000 3 - 20.000 21.000 2 - 20.000 20.000 1 - 19.000 27.000 16 - 19.000 26.000 15 - 19.000 25.000 14 - 19.000 24.000 13 - 19.000 23.000 12 - 19.000 22.000 11 - 19.000 21.000 10 - 19.000 20.000 9 - 18.000 27.000 24 - 18.000 26.000 23 - 18.000 25.000 22 - 18.000 24.000 21 - 18.000 23.000 20 - 18.000 22.000 19 - 18.000 21.000 18 - 18.000 20.000 17 - 17.000 27.000 32 - 17.000 26.000 31 - 17.000 25.000 30 - 17.000 24.000 29 - 17.000 23.000 28 - 17.000 22.000 27 - 17.000 21.000 26 - 17.000 20.000 25 - 16.000 27.000 40 - 16.000 26.000 39 - 16.000 25.000 38 - 16.000 24.000 37 - 16.000 23.000 36 - 16.000 22.000 35 - 16.000 21.000 34 - 16.000 20.000 33 - 15.000 27.000 48 - 15.000 26.000 47 - 15.000 25.000 46 - 15.000 24.000 45 - 15.000 23.000 44 - 15.000 22.000 43 - 15.000 21.000 42 - 15.000 20.000 41 - 14.000 27.000 56 - 14.000 26.000 55 - 14.000 25.000 54 - 14.000 24.000 53 - 14.000 23.000 52 - 14.000 22.000 51 - 14.000 21.000 50 - 14.000 20.000 49 + 56.853 128.720 8 + 57.628 129.702 7 + 58.392 130.736 6 + 59.143 131.824 5 + 59.882 132.969 4 + 60.606 134.175 3 + 61.316 135.444 2 + 62.009 136.781 1 + 57.401 127.178 16 + 58.193 128.149 15 + 58.974 129.171 14 + 59.743 130.250 13 + 60.500 131.388 12 + 61.243 132.588 11 + 61.972 133.855 10 + 62.685 135.193 9 + 57.930 125.591 24 + 58.738 126.546 23 + 59.536 127.554 22 + 60.323 128.619 21 + 61.099 129.746 20 + 61.861 130.937 19 + 62.609 132.197 18 + 63.342 133.531 17 + 58.438 123.957 32 + 59.263 124.893 31 + 60.078 125.883 30 + 60.883 126.931 29 + 61.677 128.042 28 + 62.458 129.219 27 + 63.226 130.468 26 + 63.979 131.793 25 + 58.925 122.277 40 + 59.766 123.189 39 + 60.598 124.157 38 + 61.421 125.183 37 + 62.233 126.274 36 + 63.033 127.433 35 + 63.820 128.665 34 + 64.594 129.976 33 + 59.389 120.549 48 + 60.246 121.435 47 + 61.095 122.376 46 + 61.935 123.376 45 + 62.765 124.441 44 + 63.584 125.575 43 + 64.392 126.785 42 + 65.186 128.076 41 + 59.830 118.775 56 + 60.703 119.629 55 + 61.568 120.539 54 + 62.425 121.508 53 + 63.273 122.542 52 + 64.111 123.647 51 + 64.938 124.828 50 + 65.752 126.092 49 diff --git a/data/scan_y_rotated_ll_5_4_good.dump b/data/scan_y_rotated_ll_5_4_good.dump index dcccfb8a3..a1dd2205b 100644 --- a/data/scan_y_rotated_ll_5_4_good.dump +++ b/data/scan_y_rotated_ll_5_4_good.dump @@ -1,21 +1,21 @@ Latitude, Longitude, Value - 17.000 20.000 16 - 17.000 21.000 17 - 17.000 22.000 18 - 17.000 23.000 19 - 17.000 24.000 20 - 18.000 20.000 11 - 18.000 21.000 12 - 18.000 22.000 13 - 18.000 23.000 14 - 18.000 24.000 15 - 19.000 20.000 6 - 19.000 21.000 7 - 19.000 22.000 8 - 19.000 23.000 9 - 19.000 24.000 10 - 20.000 20.000 1 - 20.000 21.000 2 - 20.000 22.000 3 - 20.000 23.000 4 - 20.000 24.000 5 + 63.979 131.793 16 + 63.226 130.468 17 + 62.458 129.219 18 + 61.677 128.042 19 + 60.883 126.931 20 + 63.342 133.531 11 + 62.609 132.197 12 + 61.861 130.937 13 + 61.099 129.746 14 + 60.323 128.619 15 + 62.685 135.193 6 + 61.972 133.855 7 + 61.243 132.588 8 + 60.500 131.388 9 + 59.743 130.250 10 + 62.009 136.781 1 + 61.316 135.444 2 + 60.606 134.175 3 + 59.882 132.969 4 + 59.143 131.824 5 diff --git a/data/scan_y_rotated_ll_5_7_good.dump b/data/scan_y_rotated_ll_5_7_good.dump index 8d5be97b9..7c547d75e 100644 --- a/data/scan_y_rotated_ll_5_7_good.dump +++ b/data/scan_y_rotated_ll_5_7_good.dump @@ -1,36 +1,36 @@ Latitude, Longitude, Value - 14.000 20.000 31 - 14.000 21.000 32 - 14.000 22.000 33 - 14.000 23.000 34 - 14.000 24.000 35 - 15.000 20.000 26 - 15.000 21.000 27 - 15.000 22.000 28 - 15.000 23.000 29 - 15.000 24.000 30 - 16.000 20.000 21 - 16.000 21.000 22 - 16.000 22.000 23 - 16.000 23.000 24 - 16.000 24.000 25 - 17.000 20.000 16 - 17.000 21.000 17 - 17.000 22.000 18 - 17.000 23.000 19 - 17.000 24.000 20 - 18.000 20.000 11 - 18.000 21.000 12 - 18.000 22.000 13 - 18.000 23.000 14 - 18.000 24.000 15 - 19.000 20.000 6 - 19.000 21.000 7 - 19.000 22.000 8 - 19.000 23.000 9 - 19.000 24.000 10 - 20.000 20.000 1 - 20.000 21.000 2 - 20.000 22.000 3 - 20.000 23.000 4 - 20.000 24.000 5 + 65.752 126.092 31 + 64.938 124.828 32 + 64.111 123.647 33 + 63.273 122.542 34 + 62.425 121.508 35 + 65.186 128.076 26 + 64.392 126.785 27 + 63.584 125.575 28 + 62.765 124.441 29 + 61.935 123.376 30 + 64.594 129.976 21 + 63.820 128.665 22 + 63.033 127.433 23 + 62.233 126.274 24 + 61.421 125.183 25 + 63.979 131.793 16 + 63.226 130.468 17 + 62.458 129.219 18 + 61.677 128.042 19 + 60.883 126.931 20 + 63.342 133.531 11 + 62.609 132.197 12 + 61.861 130.937 13 + 61.099 129.746 14 + 60.323 128.619 15 + 62.685 135.193 6 + 61.972 133.855 7 + 61.243 132.588 8 + 60.500 131.388 9 + 59.743 130.250 10 + 62.009 136.781 1 + 61.316 135.444 2 + 60.606 134.175 3 + 59.882 132.969 4 + 59.143 131.824 5 diff --git a/data/scan_y_rotated_ll_8_4_good.dump b/data/scan_y_rotated_ll_8_4_good.dump index 7b2ca02fc..8627db057 100644 --- a/data/scan_y_rotated_ll_8_4_good.dump +++ b/data/scan_y_rotated_ll_8_4_good.dump @@ -1,33 +1,33 @@ Latitude, Longitude, Value - 17.000 20.000 25 - 17.000 21.000 26 - 17.000 22.000 27 - 17.000 23.000 28 - 17.000 24.000 29 - 17.000 25.000 30 - 17.000 26.000 31 - 17.000 27.000 32 - 18.000 20.000 17 - 18.000 21.000 18 - 18.000 22.000 19 - 18.000 23.000 20 - 18.000 24.000 21 - 18.000 25.000 22 - 18.000 26.000 23 - 18.000 27.000 24 - 19.000 20.000 9 - 19.000 21.000 10 - 19.000 22.000 11 - 19.000 23.000 12 - 19.000 24.000 13 - 19.000 25.000 14 - 19.000 26.000 15 - 19.000 27.000 16 - 20.000 20.000 1 - 20.000 21.000 2 - 20.000 22.000 3 - 20.000 23.000 4 - 20.000 24.000 5 - 20.000 25.000 6 - 20.000 26.000 7 - 20.000 27.000 8 + 63.979 131.793 25 + 63.226 130.468 26 + 62.458 129.219 27 + 61.677 128.042 28 + 60.883 126.931 29 + 60.078 125.883 30 + 59.263 124.893 31 + 58.438 123.957 32 + 63.342 133.531 17 + 62.609 132.197 18 + 61.861 130.937 19 + 61.099 129.746 20 + 60.323 128.619 21 + 59.536 127.554 22 + 58.738 126.546 23 + 57.930 125.591 24 + 62.685 135.193 9 + 61.972 133.855 10 + 61.243 132.588 11 + 60.500 131.388 12 + 59.743 130.250 13 + 58.974 129.171 14 + 58.193 128.149 15 + 57.401 127.178 16 + 62.009 136.781 1 + 61.316 135.444 2 + 60.606 134.175 3 + 59.882 132.969 4 + 59.143 131.824 5 + 58.392 130.736 6 + 57.628 129.702 7 + 56.853 128.720 8 diff --git a/data/scan_y_rotated_ll_8_7_good.dump b/data/scan_y_rotated_ll_8_7_good.dump index e225cd92a..cf6cc9412 100644 --- a/data/scan_y_rotated_ll_8_7_good.dump +++ b/data/scan_y_rotated_ll_8_7_good.dump @@ -1,57 +1,57 @@ Latitude, Longitude, Value - 14.000 20.000 49 - 14.000 21.000 50 - 14.000 22.000 51 - 14.000 23.000 52 - 14.000 24.000 53 - 14.000 25.000 54 - 14.000 26.000 55 - 14.000 27.000 56 - 15.000 20.000 41 - 15.000 21.000 42 - 15.000 22.000 43 - 15.000 23.000 44 - 15.000 24.000 45 - 15.000 25.000 46 - 15.000 26.000 47 - 15.000 27.000 48 - 16.000 20.000 33 - 16.000 21.000 34 - 16.000 22.000 35 - 16.000 23.000 36 - 16.000 24.000 37 - 16.000 25.000 38 - 16.000 26.000 39 - 16.000 27.000 40 - 17.000 20.000 25 - 17.000 21.000 26 - 17.000 22.000 27 - 17.000 23.000 28 - 17.000 24.000 29 - 17.000 25.000 30 - 17.000 26.000 31 - 17.000 27.000 32 - 18.000 20.000 17 - 18.000 21.000 18 - 18.000 22.000 19 - 18.000 23.000 20 - 18.000 24.000 21 - 18.000 25.000 22 - 18.000 26.000 23 - 18.000 27.000 24 - 19.000 20.000 9 - 19.000 21.000 10 - 19.000 22.000 11 - 19.000 23.000 12 - 19.000 24.000 13 - 19.000 25.000 14 - 19.000 26.000 15 - 19.000 27.000 16 - 20.000 20.000 1 - 20.000 21.000 2 - 20.000 22.000 3 - 20.000 23.000 4 - 20.000 24.000 5 - 20.000 25.000 6 - 20.000 26.000 7 - 20.000 27.000 8 + 65.752 126.092 49 + 64.938 124.828 50 + 64.111 123.647 51 + 63.273 122.542 52 + 62.425 121.508 53 + 61.568 120.539 54 + 60.703 119.629 55 + 59.830 118.775 56 + 65.186 128.076 41 + 64.392 126.785 42 + 63.584 125.575 43 + 62.765 124.441 44 + 61.935 123.376 45 + 61.095 122.376 46 + 60.246 121.435 47 + 59.389 120.549 48 + 64.594 129.976 33 + 63.820 128.665 34 + 63.033 127.433 35 + 62.233 126.274 36 + 61.421 125.183 37 + 60.598 124.157 38 + 59.766 123.189 39 + 58.925 122.277 40 + 63.979 131.793 25 + 63.226 130.468 26 + 62.458 129.219 27 + 61.677 128.042 28 + 60.883 126.931 29 + 60.078 125.883 30 + 59.263 124.893 31 + 58.438 123.957 32 + 63.342 133.531 17 + 62.609 132.197 18 + 61.861 130.937 19 + 61.099 129.746 20 + 60.323 128.619 21 + 59.536 127.554 22 + 58.738 126.546 23 + 57.930 125.591 24 + 62.685 135.193 9 + 61.972 133.855 10 + 61.243 132.588 11 + 60.500 131.388 12 + 59.743 130.250 13 + 58.974 129.171 14 + 58.193 128.149 15 + 57.401 127.178 16 + 62.009 136.781 1 + 61.316 135.444 2 + 60.606 134.175 3 + 59.882 132.969 4 + 59.143 131.824 5 + 58.392 130.736 6 + 57.628 129.702 7 + 56.853 128.720 8 diff --git a/definitions/grib1/grid_rotation.def b/definitions/grib1/grid_rotation.def index 4d95993b6..8cc995be4 100644 --- a/definitions/grib1/grid_rotation.def +++ b/definitions/grib1/grid_rotation.def @@ -15,4 +15,5 @@ meta geography.longitudeOfSouthernPoleInDegrees scale(longitudeOfSouthernPole ibmfloat geography.angleOfRotationInDegrees : dump; -alias angleOfRotation =angleOfRotationInDegrees; \ No newline at end of file +alias angleOfRotation =angleOfRotationInDegrees; +alias is_rotated_grid = one; diff --git a/definitions/grib1/section.2.def b/definitions/grib1/section.2.def index f908592d0..45414b940 100644 --- a/definitions/grib1/section.2.def +++ b/definitions/grib1/section.2.def @@ -42,6 +42,7 @@ meta gridDefinitionDescription codetable_title(dataRepresentationType); # Grid definition # (according to data representation type - octet 6 above) +alias is_rotated_grid=zero; if (dataRepresentationType < 192) { diff --git a/definitions/grib2/section.3.def b/definitions/grib2/section.3.def index f508d1791..3647f44a6 100644 --- a/definitions/grib2/section.3.def +++ b/definitions/grib2/section.3.def @@ -45,6 +45,7 @@ if(numberOfOctectsForNumberOfPoints == 0){ codetable[2] gridDefinitionTemplateNumber ('3.1.table',masterDir,localDir) =0 : dump,edition_specific; meta gridDefinitionDescription codetable_title(gridDefinitionTemplateNumber); +alias is_rotated_grid=zero; template gridDefinitionSection "grib2/template.3.[gridDefinitionTemplateNumber:l].def"; diff --git a/definitions/grib2/template.3.rotation.def b/definitions/grib2/template.3.rotation.def index d4f616e40..3d07bb2bb 100755 --- a/definitions/grib2/template.3.rotation.def +++ b/definitions/grib2/template.3.rotation.def @@ -25,3 +25,4 @@ alias geography.angleOfRotationInDegrees=angleOfRotation; alias angleOfRotationOfProjection=angleOfRotation; +alias is_rotated_grid=one; diff --git a/src/grib_accessor_class_latitudes.c b/src/grib_accessor_class_latitudes.c index f44781fe5..1ae83d288 100644 --- a/src/grib_accessor_class_latitudes.c +++ b/src/grib_accessor_class_latitudes.c @@ -177,7 +177,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len) grib_accessor_latitudes* self = (grib_accessor_latitudes*)a; int ret = 0; double* v=val; - double dummy=0; + double dummyLon=0, dummyVal=0; size_t size=0; long count=0; grib_iterator* iter=NULL; @@ -215,7 +215,7 @@ static int unpack_double(grib_accessor* a, double* val, size_t *len) return ret; } - while(grib_iterator_next(iter,v++,&dummy,&dummy)) {} + while(grib_iterator_next(iter,v++,&dummyLon,&dummyVal)) {} grib_iterator_delete(iter); *len=size; @@ -258,7 +258,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) { double prev; double *v=NULL; double *v1=NULL; - double dummy; + double dummyLon=0, dummyVal=0; int ret=0; int i; long jScansPositively=0; /*default: north to south*/ @@ -278,7 +278,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) { } *val=v; - while(grib_iterator_next(iter,v++,&dummy,&dummy)) {} + while(grib_iterator_next(iter,v++,&dummyLon,&dummyVal)) {} grib_iterator_delete(iter); v=*val; diff --git a/src/grib_accessor_class_longitudes.c b/src/grib_accessor_class_longitudes.c index e05ae210f..8556b7dd8 100644 --- a/src/grib_accessor_class_longitudes.c +++ b/src/grib_accessor_class_longitudes.c @@ -165,7 +165,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len) grib_accessor_longitudes* self = (grib_accessor_longitudes*)a; int ret = 0; double* v=val; - double dummy=0; + double dummyLat=0, dummyVal=0; size_t size=0; long count=0; grib_iterator* iter=NULL; @@ -204,7 +204,7 @@ static int unpack_double (grib_accessor* a, double* val, size_t *len) return ret; } - while(grib_iterator_next(iter,&dummy,v++,&dummy)) {} + while(grib_iterator_next(iter,&dummyLat,v++,&dummyVal)) {} grib_iterator_delete(iter); *len=size; @@ -246,7 +246,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) { double prev; double *v=NULL; double *v1=NULL; - double dummy; + double dummyLat=0, dummyVal=0; int ret=0; int i; size_t size=*len; @@ -265,7 +265,7 @@ static int get_distinct(grib_accessor* a,double** val,long* len) { } *val=v; - while(grib_iterator_next(iter,&dummy,v++,&dummy)) {} + while(grib_iterator_next(iter,&dummyLat,v++,&dummyVal)) {} grib_iterator_delete(iter); v=*val; diff --git a/src/grib_iterator_class_gaussian.c b/src/grib_iterator_class_gaussian.c index f0d4982a5..745f595fd 100644 --- a/src/grib_iterator_class_gaussian.c +++ b/src/grib_iterator_class_gaussian.c @@ -53,6 +53,10 @@ typedef struct grib_iterator_gaussian{ long nap; long nam; long iScansNegatively; + long isRotated; + double angleOfRotation; + double southPoleLat; + double southPoleLon; /* Members defined in gaussian */ } grib_iterator_gaussian; diff --git a/src/grib_iterator_class_latlon.c b/src/grib_iterator_class_latlon.c index 7fcff9cdc..61f076d3e 100644 --- a/src/grib_iterator_class_latlon.c +++ b/src/grib_iterator_class_latlon.c @@ -8,10 +8,6 @@ * virtue of its status as an intergovernmental organisation nor does it submit to any jurisdiction. */ -/************************************** - * Enrico Fucile - **************************************/ - #include "grib_api_internal.h" /* @@ -20,7 +16,7 @@ START_CLASS_DEF CLASS = iterator SUPER = grib_iterator_class_regular - IMPLEMENTS = init + IMPLEMENTS = init;next END_CLASS_DEF */ @@ -39,6 +35,7 @@ or edit "iterator.class" and rerun ./make_class.pl static void init_class (grib_iterator_class*); static int init (grib_iterator* i,grib_handle*,grib_arguments*); +static int next (grib_iterator* i, double *lat, double *lon, double *val); typedef struct grib_iterator_latlon{ @@ -52,6 +49,10 @@ typedef struct grib_iterator_latlon{ long nap; long nam; long iScansNegatively; + long isRotated; + double angleOfRotation; + double southPoleLat; + double southPoleLon; /* Members defined in latlon */ } grib_iterator_latlon; @@ -65,7 +66,7 @@ static grib_iterator_class _grib_iterator_class_latlon = { &init_class, /* init_class */ &init, /* constructor */ 0, /* destructor */ - 0, /* Next Value */ + &next, /* Next Value */ 0, /* Previous Value */ 0, /* Reset the counter */ 0, /* has next values */ @@ -76,13 +77,98 @@ grib_iterator_class* grib_iterator_class_latlon = &_grib_iterator_class_latlon; static void init_class(grib_iterator_class* c) { - c->next = (*(c->super))->next; c->previous = (*(c->super))->previous; c->reset = (*(c->super))->reset; c->has_next = (*(c->super))->has_next; } /* END_CLASS_IMP */ +static const double degree_to_radian = M_PI/180.0; +static const double radian_to_degree = 180.0 * M_1_PI; + +void unrotate(grib_handle* h, + const double inlat, const double inlon, + const double angleOfRot, const double southPoleLat, const double southPoleLon, + double* outlat, double* outlon) +{ + /* Algorithm taken from ecKit */ + const double lon_x = inlon; + const double lat_y = inlat; + /* First convert the data point from spherical lat lon to (x',y',z') */ + double latr = lat_y * degree_to_radian; + double lonr = lon_x * degree_to_radian; + double xd = cos(lonr)*cos(latr); + double yd = sin(lonr)*cos(latr); + double zd = sin(latr); + + double t = -(90.0 + southPoleLat); + double o = -southPoleLon; + + double sin_t = sin(degree_to_radian * t); + double cos_t = cos(degree_to_radian * t); + double sin_o = sin(degree_to_radian * o); + double cos_o = cos(degree_to_radian * o); + + double x = cos_t*cos_o*xd + sin_o*yd + sin_t*cos_o*zd; + double y = -cos_t*sin_o*xd + cos_o*yd - sin_t*sin_o*zd; + double z = -sin_t*xd + cos_t*zd; + + double ret_lat=0, ret_lon=0; + + /* Then convert back to 'normal' (lat,lon) + * Uses arcsin, to convert back to degrees, put in range -1 to 1 in case of slight rounding error + * avoid error on calculating e.g. asin(1.00000001) */ + if (z > 1.0) z = 1.0; + if (z < -1.0) z = -1.0; + + ret_lat = asin(z) * radian_to_degree; + ret_lon = atan2(y, x) * radian_to_degree; + + /* Still get a very small rounding error, round to 6 decimal places */ + ret_lat = roundf( ret_lat * 1000000.0 )/1000000.0; + ret_lon = roundf( ret_lon * 1000000.0 )/1000000.0; + + ret_lon -= angleOfRot; + + /* Make sure ret_lon is in range*/ + /* + while (ret_lon < lonmin_) ret_lon += 360.0; + while (ret_lon >= lonmax_) ret_lon -= 360.0; + */ + *outlat = ret_lat; + *outlon = ret_lon; +} + +static int next(grib_iterator* i, double *lat, double *lon, double *val) +{ + /* GRIB-238: Support rotated lat/lon grids */ + + double ret_lat, ret_lon, ret_val; + grib_iterator_latlon* self = (grib_iterator_latlon*)i; + + if((long)i->e >= (long)(i->nv-1)) return 0; + + i->e++; + + ret_lat = self->las[(long)floor(i->e/self->nap)]; + ret_lon = self->los[(long)i->e%self->nap]; + ret_val = i->data[i->e]; + + if (self->isRotated) + { + double new_lat = 0, new_lon = 0; + unrotate(i->h, ret_lat, ret_lon, + self->angleOfRotation, self->southPoleLat, self->southPoleLon, + &new_lat, &new_lon); + ret_lat = new_lat; + ret_lon = new_lon; + } + + *lat = ret_lat; + *lon = ret_lon; + *val = ret_val; + return 1; +} static int init(grib_iterator* i,grib_handle* h,grib_arguments* args) { @@ -91,12 +177,22 @@ static int init(grib_iterator* i,grib_handle* h,grib_arguments* args) double jdir; double laf; long jScansPositively; - long lai; const char* latofirst = grib_arguments_get_name(h,args,self->carg++); const char* jdirec = grib_arguments_get_name(h,args,self->carg++); const char* s_jScansPositively = grib_arguments_get_name(h,args,self->carg++); + self->angleOfRotation = 0; + self->isRotated = 0; + self->southPoleLat = 0; + self->southPoleLon = 0; + + if ((ret = grib_get_long(h, "is_rotated_grid", &self->isRotated))) return ret; + if (self->isRotated) { + if ((ret = grib_get_double_internal(h,"angleOfRotation", &self->angleOfRotation))) return ret; + if ((ret = grib_get_double_internal(h,"latitudeOfSouthernPoleInDegrees", &self->southPoleLat))) return ret; + if ((ret = grib_get_double_internal(h,"longitudeOfSouthernPoleInDegrees", &self->southPoleLon))) return ret; + } if((ret = grib_get_double_internal(h,latofirst, &laf))) return ret; if((ret = grib_get_double_internal(h,jdirec, &jdir))) return ret; diff --git a/src/grib_iterator_class_regular.c b/src/grib_iterator_class_regular.c index f263321c1..ecfbbb7a8 100644 --- a/src/grib_iterator_class_regular.c +++ b/src/grib_iterator_class_regular.c @@ -19,11 +19,15 @@ SUPER = grib_iterator_class_gen IMPLEMENTS = previous;next IMPLEMENTS = init;destroy - MEMBERS = double *las - MEMBERS = double *los - MEMBERS = long nap - MEMBERS = long nam - MEMBERS = long iScansNegatively + MEMBERS = double *las + MEMBERS = double *los + MEMBERS = long nap + MEMBERS = long nam + MEMBERS = long iScansNegatively + MEMBERS = long isRotated + MEMBERS = double angleOfRotation + MEMBERS = double southPoleLat + MEMBERS = double southPoleLon END_CLASS_DEF */ @@ -58,6 +62,10 @@ typedef struct grib_iterator_regular{ long nap; long nam; long iScansNegatively; + long isRotated; + double angleOfRotation; + double southPoleLat; + double southPoleLon; } grib_iterator_regular; extern grib_iterator_class* grib_iterator_class_gen;