dankelley / oce

R package for oceanographic processing
http://dankelley.github.io/oce/
GNU General Public License v3.0
143 stars 42 forks source link

plotTS() can fail on a check for frozen water #2079

Closed dankelley closed 1 year ago

dankelley commented 1 year ago

I won't bother explaining, since this is just a reminder for me to take a look at the code. I won't make a reprex because (1) it always fails for me lately (no idea why) and (2) the dataset is 27 megs. It's a csv file for years of data in Passamaquoddy Bay from https://open.canada.ca/data/en/dataset/12184962-7879-4214-aef0-b31162f04a27. Don't ask me about those crazy-high temperatures and salinities ... I guess the data have not been QCd.

Screenshot 2023-04-20 at 3 29 47 PM
dankelley commented 1 year ago

Oh, I see. The GSW freezing-temperature code returns NaN values, as you can see from the below (things I typed after putting a browser() call in trimIsopycnalLine(). I don't want to mess with what gsw is doing because that package aims to wrap gsw C code, not to interpose a new view of it.

Note: the x is salinity, and it is indeed negative in this funky dataset. The min salinity is -2.7888, actually. Oh, and the max is 99 so that is likely a missing-value code. (As for the other crazy-high salinities and crazy-high temperatures you can see on the plot, I will just ignore them. I'm not going to use this dataset. I'll just add some tests so plotTS() does not freak out on crazy data and then close this issue.)

Browse[1]> swTFreeze(x, 0, eos="unesco")
 [1]  0.01653356 -0.05107607 -0.12983216 -0.18070370 -0.20772327 -0.28617108 -0.36310516
 [8] -0.37335210 -0.44149659 -0.51908500 -0.56513073 -0.59686128 -0.67604055 -0.75417901
[15] -0.75730032 -0.83634490 -0.91836120 -0.95057581 -1.00407375
Browse[1]> swTFreeze(x, 0, eos=eos, longitude=longitude, latitude=latitude)
 [1]         NaN -0.05144995 -0.12998181 -0.18056688 -0.20742731 -0.28544504 -0.36204782
 [8] -0.37225872 -0.44021321 -0.51768579 -0.56370858 -0.59544101 -0.67467925 -0.75293728
[15] -0.75606438 -0.83527508 -0.91749129 -0.94978832 -1.00342423
dankelley commented 1 year ago

commit c1dbe79ed0b14faae328a79125fc57abd4db5629 Author: dankelley kelley.dan@gmail.com Date: Thu Apr 20 15:56:31 2023 -0300

plotTS() isopycnals can handle S<0 (issue 2079)
dankelley commented 1 year ago

Done in "develop" commit c1dbe79ed0b14faae328a79125fc57abd4db5629