-
-
Save darothen/c7560d8d19ffca90024c1f2df4927599 to your computer and use it in GitHub Desktop.
Thanks!
Hi, Dan. I was plotting some model data where longitudes are at varying intervals [-279.515801, -278.547384, -277.578912, . . . , -100.484199, -99.515801, -98.547384, . . . , 77.578912, 78.547384, 79.515801]. Applying 'add_cyclic_point' I am getting "ValueError: The coordinate must be equally spaced". Can you please help me out?
@Sumit-Mukherjee, you can see in the underlying implementation of add_cyclic_point()
that there is an explicit check that the values are equally spaced. It's not obvious to me that the rest of the code wouldn't work if the values weren't equally spaced, so you could try copy/pasting that function into your code, removing the exception, and see if that works.
It worked! One more way I found is to set the tolerance (rtol) in numpy.allclose used in the function add_cyclic_point() according to my coordinate values. Thank you for the suggestion.
Hello!
I am having a similar issue but my lat and lon are 2 dimensional and not equally spaced (it's in a polar projection). add_cyclic_point() seem to only work with 1 dimensional longitudes. Is there an equivalent way to make it work in this case?
Thank you!
@Sumit-Mukherjee Please share the code
@Wamashudu Inside the function add_cyclic_point, modify the following snippet setting atol (default value 1e-5) according to your data values (for my case it is 0.1).
if not np.allclose(delta_coord, delta_coord[0], atol=0.1):
raise ValueError('The coordinate must be equally spaced.')
Commenting out these two lines will also work.
@sevfour I also encounter the same problem, have you found out a way to solve this? Thanks in advance if you can share your experience.
Thanks Dan! Just came across this problem myself and Google led me here. Worked like a charm.