Open filefolder opened 9 months ago
Hi @filefolder , from inspecting the code you posted above my guess is that this can only happen if self.cy_iax_isperiodic[iax]
is True
; otherwise, it would either have returned early in the first if
test (as out of bounds) or it would not have entered the else
branch in the second.
And if it is periodic (and out of bounds), the assigment to ii[iax][0]
should probably be wrapped into bounds, i.e.,
ii[iax][0] = <Py_ssize_t>idx[iax] % self.npts[iax]
Only guesswork from my side.
Thank you... that's interesting. I am not quite sure why that parameter would be periodic necessarily, but the model is type pykonal.fields.ScalarField3D(coord_sys='spherical')
so perhaps that is the default?
In practice, despite the spherical coordinate system I am dealing only with local areas, so I would never want any wrap-around.
Been a while since I thought about this issue. I tend to think my hack is probably not very sound, but I can say that I haven't had any issues since, for whatever that's worth.
For a spherical model the periodicity would be on the angle (e.g., 181° = -179°).
Ah, a NZ model I was building could be affected then. Perhaps that was the issue?
I could try removing my hack and replacing
ii[iax][0] = <Py_ssize_t>idx[iax]
with
ii[iax][0] = <Py_ssize_t>idx[iax] % self.npts[iax]
as you suggest
at some point (but not any time soon unfortunately)
I'm not familiar enough with this code to say for sure, maybe @malcolmw ? A sanity check on the result might be to transform all input coordinates by 180° and compare, if that is an option.
After re-reading your comment, I was mistaken: If your area is local, there should be no periodicity. Sorry for adding confusion here.
Hi Malcom,
I had been experiencing this issue for quite some time, I suspect caused by an edge effect somewhere as it mostly happens with shallower models.
adding the last bit within the else clause in fields.pyx around line 500 seems to be a valid workaround... FWIW to anyone else and curious if this is a thing you've ran into yourself or might have a better way to address.