-
Notifications
You must be signed in to change notification settings - Fork 25
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
Weird behavior with wet_mask #85
Comments
Hi Takaya (@roxyboy)! Glad to hear you're using the package. It took me a little while to track down what was going on here, but I think I've figured it out. Several of the "required grid args" that you passed to the filter constructor included NaNs. These values are accessed & used during the Laplacian step, which produces NaNs internally. When this gets passed back in as input for another Laplacian step, we set all NaNs to 0. So values near the land boundaries were getting set to 0, and these values were then getting diffused into the interior. Whether the explanation is completely correct or not, I was able to produce something that looks a lot better. Next I added a bunch of lines like this Finally, and I don't understand this one, the way that you were using
and now it looks like it's working. |
Hi @iangrooms , thank you for the support. Your solution fixed the issue so I'm going to close this :) It was helpful to know that the area shouldn't include 0s. |
@roxyboy, thanks for posting the issue! If I understand correctly, 0s or NaNs in |
@NoraLoose I progressively changed my code back prior to Ian's solution and it seems to originate from a combination of NaNs in the |
Thanks a lot Takaya for reporting a useful issue and helping us iron out the package. I think the best solution here is not necessarily to change the gcm-filters code but to clearly document this possible pitfalll in the documentation. |
Feeling encouraged with the success with NEMO, I've been trying to apply the The I thought that the grids being irregular may be causing the issue so I then tried the
|
The second error you mentioned is easy to correct:
to this
it fixes the error. The noise output is the result of roundoff errors. Per the gcm-filters docs, you can improve this by using double precision. Your dataset uses float32 (single precision), so if you just promote using Almost. The filtered sst field still has some noise. The original filter used 56 steps. One quick way to try to reduce noise is to manually reduce the number of filter steps. I tried the following
and it worked quite well. (At least the plots didn't appear to have noise.) You might play around with finding a value for [edit:typo] |
This is definitely counterintuitive to users. I hit the same problem when I was demoing gcm-filters the other day. I have opened #88 to track this specifically. Takaya, I'm curious whether you had read the documentation on numerical instability before posting this. If so, is there some way we can make that section more prominent or more clear?
I think we should keep thinking about this. I have also hit the same noise problems quite often when playing around with gcm-filters recently. Perhaps our defaults need to be adjusted so this is less common? Or maybe providing a series of "recipes" known to work for common models? |
Thanks @iangrooms for the detailed feedback. Your solutions worked like a charm :)
And my apologies for having missed the section on numerical instability. Perhaps having the package raise a warning with a link to the documentation when the input data is single precision could help the user in debugging the noise. |
Shall I start a PR? |
I'm closing this issue because the numerical instability issues is fixed as per version v0.3. |
Firstly, I'd like to thank the developers for this awesome package and documentation!
I am currently playing around with a submesoscale permitting simulation but I am getting some weird behavior where at the boundaries, although I pad zeros to the
wet_mask
, the filter seems to ignore the 0 values in the mask and uses the data there to apply the filtering. I've attached a screenshot below where the values of the filtered field tend to go to zero towards the boundary.I have a reproducible example here: https://github.com/roxyboy/Cal1_SWOT-AdAC/blob/master/Filter.ipynb
Could you let me know what I'm doing wrong?
The text was updated successfully, but these errors were encountered: