OpenDrift / opendrift

Open source framework for ocean trajectory modelling
https://opendrift.github.io
GNU General Public License v2.0
231 stars 113 forks source link

small change to mask values #1290

Closed kthyng closed 2 months ago

kthyng commented 2 months ago

small change to mask values in get_lonlats(self) for values of 9.969209968386869e+36

I am not sure why these values occur but they happen when coastline_action is set to "stranding" and seafloor_action to "deactivate" and then I can't plot the results. I couldn't find a way to avoid the values in the first place instead.

I'm not sure is this is a universal problem or solution. What do you think @knutfrode?

gauteh commented 2 months ago

It almost seems like we incorrectly convert Nan to float somewhere. Do you have a test simulation where this happens regularly?

knutfrode commented 2 months ago

OpenDrift has until now not masked NaN-values in output netCDF-file, as instead the status variable had to be used manually for masking. However, FillValue of NaN (or -999 for integers) are now applied: https://github.com/OpenDrift/opendrift/pull/1291/files The Nan-values should correspond to elements deactivated, or not yet seeded. Otherwise status shall be 0 for active particles, and a positive integer for deactivated elements (though the final properties at time of deactication are not repeated until the end of the netCDF-file, for historical and performance reasons)

Can you update and see if this solves your problem? If not, it would be great if you could make a minimalistic example to reproduce your problem.

kthyng commented 2 months ago

@knutfrode I updated and yes your new changes fix my problem. Thank you!