Skip to content
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

The preprocessor extract_trajectory doesn't create coordinate bounds, and confuses lat/lon coordinates #1137

Open
ledm opened this issue May 19, 2021 · 4 comments
Assignees

Comments

@ledm
Copy link
Contributor

ledm commented May 19, 2021

The preprocessor extract_trajectory is built to interpolate the model data between two points at a prescribed number of points.

This means that it creates a new set of coordinates between those two points. However, the new coordinates do not include the coordinate attribute, bounds.

ie:

The preprocessor

  prep_transect:
    extract_trajectory:
      latitudes: [0., 0. ]
      longitudes: [-5.,  5.]
      number_points: 25

Produces the follow latitude

print(cube.cooord('latitude')
AuxCoord(masked_array(data=[-5.1491704 , -4.4021463 , -4.044439  , -3.6941166 ,
                   -3.3493495 , -3.0086572 , -2.3350284 , -2.0004609 ,
                   -1.6666366 , -1.3331935 , -0.9999002 , -0.33332792,
                    0.        ,  0.33332792,  0.9999002 ,  1.3331935 ,
                    1.6666366 ,  2.0004609 ,  2.3350284 ,  3.0086572 ,
                    3.3493495 ,  3.6941166 ,  4.044439  ,  4.4021463 ,
                    5.1491704 ],
             mask=False,
       fill_value=1e+20,
            dtype=float32)

However, you'll also notice that it actually switches latitudes and longitudes:

https://docs.esmvaltool.org/projects/esmvalcore/en/latest/_modules/esmvalcore/preprocessor/_volume.html#extract_trajectory

        longitudes = np.linspace(minlat, maxlat, num=number_points)
        latitudes = np.linspace(minlon, maxlon, num=number_points)

should be:

        longitudes = np.linspace(minlon, maxlon, num=number_points)
        latitudes = np.linspace(minlat, maxlat, num=number_points)

Whoops!

(This was first an issue on ESMValTool, instead of ESMValCore: ESMValGroup/ESMValTool#2174)

@ledm
Copy link
Contributor Author

ledm commented Jun 11, 2021

Note that PR #1174 doesn't address the issue with the missing boundaries.

@valeriupredoi
Copy link
Contributor

would you be willing to fix this (well, just the bounds bit) @ledm pls 🍺

@ledm
Copy link
Contributor Author

ledm commented Jul 2, 2021

I came up with a workaround at the diagnostic level, but sure it would work in the preprocessor...

@zklaus
Copy link

zklaus commented Jul 5, 2021

I am not sure there should be bounds here. In the example, the points happen to lie on the same latitude, so on the face of it, bounds seem to have a clear interpretation, but what if the trajectory is not aligned like this. Does it really make sense to build rectangular cells around the points in that case? Should those touch at corners, or would you want to add parameters to the preprocessor to define something like a halo size in all involved directions?

@zklaus zklaus removed their assignment Feb 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants