Skip to content
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

Patch the check values for geo_strf_dyn_height. #36

Merged
merged 2 commits into from
Jul 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions README-developer
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,15 @@ gsw_data_v3_0.nc -- A redundant and hopefully current version of
using the supplied utilities
make_check_data.py and make_saar_data.py.
make_check_data.py -- Utility to generate gsw_check_data.c from
gsw_data_v3_0.nc.
gsw_data_v3_0.nc. **Do not use**
make_saar_data.py -- Utility to generate gsw_saar_data.c from
gsw_data_v3_0.nc.
gsw_data_v3_0.nc. **Do not use**
make_data_from_mat.py -- Utility to generate check data and SAAR data from
gsw_matlab_v3_06_11/library/gsw_data_v3_0.mat.
You need to edit the file to supply the correct
path. The geostrophic streamfunction values are
patched in from geo_strf_dyn_height.npy to match
the pchip-based version being used here.
libgswteos-10.spec.proto
-- template used to create libgswteos-10.spec,
the configuration file for rpmbuild on RedHat
Expand Down
Binary file added geo_strf_dyn_height.npy
Binary file not shown.
64 changes: 32 additions & 32 deletions gsw_check_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -8037,38 +8037,38 @@ static UNUSED double p_mid_ipvfn2[132] = {
#define p_mid_ipvfn2_ca 2.3000211513135582e-08

static UNUSED double geo_strf_dyn_height[135] = {
0, -0.5911014524388053, -1.1806398617861791, -1.7684589368979684,
-2.3548968003730293, -2.9393665644521696, -4.4149088286046956,
-5.703020180914999, -6.8270913892724403, -7.7750715828207309,
-8.5636698587683409, -9.2665791654007492, -10.360344599572446,
-11.253191057523505, -12.019129579678603, -12.718788340058289,
-13.946651135335799, -15.047365323465835, -16.0596439906443,
-16.998798896370396, -17.87605154845906, -18.696280163100138,
-19.463019978532266, -20.188181080160465, -20.863696840572679,
-21.508216576820903, -22.114082959734201, -23.53061414517639,
-24.823823088348504, -26.028981372034469, -27.17891597265416,
-28.28544924408752, -29.366313788480497, -30.422095192019146,
-31.462359830017093, -32.487014896760684, -33.511038652516021,
-34.529689567166365, -35.555027921425626, -36.573906318756428,
-37.593500993923932, -38.606434231914122, -39.623586644577813,
-40.633324069347744, -41.643055177185161, 0, -0.56387538523857716,
-1.1263520379601282, -1.6870470660146004, -2.2460964538045625,
-2.8016411639655034, -4.1377289349942732, -5.1863028333006378,
-6.0323368769899579, -6.7081683122409999, -7.2506491641315103,
-7.7279669056432558, -8.5153068358952542, -9.2441136687128047,
-9.9237167123223795, -10.590166437456576, -11.834927388967513,
-12.98127281990466, -14.031202688069268, -14.99838656946315,
-15.901926840500785, -16.745530821743799, -17.539744819321957,
-18.301944743788759, -19.015989216219499, -19.696034938801628,
-20.329244419381265, -21.79907152137115, -23.121488382340036,
-24.348537002643624, -25.525399970061162, -26.654074805979818,
-27.751535859958974, -28.811425788955798, -29.846461733591301,
-30.850112055738883, -31.825502257098361, -32.767981346556965,
-33.703124647569936, -34.630592045043507, -35.556248332104708,
-36.473426483579303, -37.391842233880084, -38.300665160936035,
-39.207089035143667, 0, -2.2402449033712917, -4.4577608581959831,
-6.6463200389705914, -8.8096161026171416, -10.953441082703741,
-16.35264749473339, -21.259667424050036, 8.9999999999999998e+90,
0, -0.5911034214399562, -1.1806439252923104, -1.7684650558066393,
-2.3548997511286331, -2.9393942266795459, -4.4138270084285578,
-5.7018667114771873, -6.825843630860307, -7.7737386924288545,
-8.5620081330599902, -9.2649033039875412, -10.357335048987016,
-11.250119836788921, -12.016231963659491, -12.715930646903955,
-13.943864423418352, -15.044587936807645, -16.056873329014806,
-16.996028543635198, -17.873281378970585, -18.693510206060999,
-19.460250176762429, -20.185412265311655, -20.860929617236724,
-21.505451055703716, -22.111319118724985, -23.527859871514927,
-24.82108334317542, -26.026248073802101, -27.176187051736772,
-28.282722344749779, -29.363588391482011, -30.419369529182685,
-31.459644431300564, -32.484343768028609, -33.508281057865567,
-34.52693323914032, -35.552275191175184, -36.571153388299429,
-37.590750654709275, -38.603684773173413, -39.62083726879311,
-40.630574901488529, -41.640306011084235, 0, -0.56388024349693844,
-1.1263582708638318, -1.6870554286444268, -2.2459829397179143,
-2.8011431433414105, -4.1361171927311657, -5.1849893683086163,
-6.0307202892794081, -6.7062244619059515, -7.2486271811689198,
-7.7260658198352283, -8.5135541886778725, -9.2424374097706199,
-9.9220035629064078, -10.588451128192085, -11.833205945890063,
-12.979545706352814, -14.029392142096063, -14.996568803684102,
-15.900132936306356, -16.743751939768106, -17.537981327641248,
-18.300181288930556, -19.014225699263072, -19.694271464352596,
-20.327486255636575, -21.797345218333088, -23.119815844578753,
-24.346875943486168, -25.523745939043785, -26.652421858053859,
-27.749884631022507, -28.809775304847655, -29.844810972649622,
-30.848462604134571, -31.82385380907607, -32.766349502753371,
-33.701321254756671, -34.628788494098842, -35.554446634605746,
-36.471627832272112, -37.390043822500665, -38.298866724272003,
-39.205290532788347, 0, -2.240330849582127, -4.457828737459038,
-6.646391799711564, -8.8097004120596001, -10.953485694137456,
-16.352438808384978, -21.259503743654498, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
8.9999999999999998e+90, 8.9999999999999998e+90, 8.9999999999999998e+90,
Expand Down
14 changes: 11 additions & 3 deletions make_data_from_mat.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@

One function, geo_strf_dyn_height, is in a state of flux; until it is
completely rewritten to match the matlab v3_06_12 version, and this file
is rerun with the corresponding matfile, the test will fail. Using the
pchip-based version here, the error is:
is rerun with the corresponding matfile, the test needs to be patched.
Using the pchip-based version here, the difference is:

Max difference = 0.0030712207345846565, limit = 4.5372335222282345e-07
Max diff (rel) = 0.027299449064902257, limit = 4.0330535034756395e-06
Expand All @@ -19,12 +19,15 @@
Max difference = 0.014465517624415725, limit = 4.5372335222282345e-07
Max diff (rel) = 0.088538110572418685, limit = 2.7770736845661537e-06

To avoid the failing test, the pchip result is now substituted for the
version from gsw_data_3_0.mat


This is a developer utility and not a part of the public distribution, but its
end-product is.

"""
import math, os, sys
import math, os
import textwrap
import numpy as np
from scipy.io import loadmat
Expand All @@ -49,6 +52,8 @@
# ca = var.computation_accuracy
# return dh, ca

def get_strf_dyn_height_from_npy():
return np.load("geo_strf_dyn_height.npy")

def write_variable_ca(out, var_name, val):
if math.isnan(val):
Expand Down Expand Up @@ -326,6 +331,9 @@ def write_variable(out, var_name, v):
cv = dict()
for name in mat['gsw_cv'].dtype.names:
cv[name] = mat['gsw_cv'][name].item()
if name == "geo_strf_dyn_height":
geo_strf = get_strf_dyn_height_from_npy()
cv[name] = geo_strf
# if name == 'geo_strf_dyn_height':
# geo_strf, geo_strf_ca = get_strf_dyn_height_from_nc()
# print("replacing ", name, cv[name].shape, geo_strf.shape)
Expand Down