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

Add a cyclic point to POP model output #48

Closed
wants to merge 1 commit into from

Conversation

andersy005
Copy link
Contributor

As it's been pointed out before, the longitudes in POP grid are not monotonic, and as a result matplotlib/cartopy don't work properly when plotting POP output. This PR adds the original workaround developed by @matt-long for addressing this plotting issue.

@dcherian
Copy link
Contributor

I think we should rewrite a lot of this to use Dataset.pad. It'll be a lot easier to read and maintain.

For example, what is happening here? Is there a possible subset of a global grid that would break it?

   if ni == 320:
        lon[367:-3, 0] = lon[367:-3, 0] + 360.0
    lon = lon - 360.0

    lon = np.hstack((lon, lon[:, 0:1] + 360.0))
    if ni == 320:
        lon[367:, -1] = lon[367:, -1] - 360.0

The painful bit will be working around pydata/xarray#3868 but I can help with that.

@matt-long
Copy link
Collaborator

This routine is not purely adding a cyclic point; it also re-orders by longitude. The name of the original routine is a bit misleading in that regard. @dcherian, you point to a section that is dealing with curvature of the seam, if I recall, specific to the gx1vN grids. This should not be necessary, unless the subsetted domain is in that specific region. Fred Castruccio wrote part of this original routine and has modified my version to work with a subsetted domain, I believe.

@dcherian
Copy link
Contributor

Thanks for clarifying @matt-long

if I recall, specific to the gx1vN grids. This should not be necessary, unless the subsetted domain is in that specific region

Is this function more appropriate at the "clean dataset & grid" stage then? Or should we have grid metadata as an input variable? Or is there a better condition than ni == 320

@andersy005 andersy005 marked this pull request as draft April 13, 2020 14:28
@matt-long
Copy link
Collaborator

I like the idea of an API-based mechanism for determining the grid, removing the ni == 320 condition in favor of something the user provides.

This routine yields a dataset with an extra column in the arrays, so its purpose is really restricted to plotting. In that sense, it should not be part of a general "clean dataset & grid" stage, but called en route to a plotting command.

We may want a DataArray version.

@fredc
Copy link

fredc commented Apr 13, 2020

I agree that the name if confusing and should be changed.

The main usage of this function is to make the longitude monotonically increasing.
In that regard, the gut is the following line:

tlon = np.where(np.greater_equal(tlon, min(tlon[:,0])), tlon-360., tlon)

Subset don't typically require work around to plot unless the subset is striding the discontinuity in the longitude coordinate, and in that case it can be dealt with easily.

I also agree that a version that can handle both Dataset and DataArray is desirable.

@andersy005
Copy link
Contributor Author

I'm closing this because it has gone stale :(

@andersy005 andersy005 closed this Sep 26, 2021
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

Successfully merging this pull request may close these issues.

4 participants