Skip to content

Commit

Permalink
Fixes fill value
Browse files Browse the repository at this point in the history
  • Loading branch information
lukecampbell committed Jun 18, 2013
1 parent 9c20b62 commit aec5fdb
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 19 deletions.
3 changes: 3 additions & 0 deletions ion_functions/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@
#from data.vel_functions import nobska_mag_corr_east, nobska_mag_corr_north, nobska_mag_corr_up, vel_mag_correction

from data.generic_functions import extract_parameter, magnetic_declination, ntp_to_unix_time


fill_value = -9999999.
3 changes: 2 additions & 1 deletion ion_functions/data/co2_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import numpy as np
import numexpr as ne
from ion_functions import fill_value


# wrapper functions to extract parameters from SAMI-II CO2 instruments (PCO2W)
Expand Down Expand Up @@ -88,7 +89,7 @@ def pco2_pco2wat(mtype, light, therm, ea434, eb434, ea620, eb620,
pco2 = pco2_calc_pco2(light, therm, ea434, eb434, ea620, eb620,
calt, cala, calb, calc, a434blnk, a620blnk)
else:
pco2 = -99999999.
pco2 = fill_value

return pco2

Expand Down
7 changes: 4 additions & 3 deletions ion_functions/data/perf/test_co2_performance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from ion_functions.data.perf.test_performance import PerformanceTestCase
from ion_functions.data.co2_functions import pco2_thermistor, pco2_abs434_blank, pco2_abs620_blank, pco2_pco2wat
import numpy as np
from ion_functions import fill_value

class TestCO2Performance(PerformanceTestCase):
def setUp(self):
Expand All @@ -15,14 +16,14 @@ def setUp(self):
self.cala = 0.0459
self.calb = 0.6257
self.calc = -1.5406
self.a434blnk = -99999999.
self.a620blnk = -99999999.
self.a434blnk = fill_value
self.a620blnk = fill_value

# expected outputs
self.therm = np.array([18.8526, 18.8765, 18.9245, 18.9485,
18.9485, 18.9485, 18.8765, 19.0686,
19.0686, 19.0446, 18.9725])
self.pco2 = np.array([-99999999., 294.1720, 311.3361, 319.0101,
self.pco2 = np.array([fill_value, 294.1720, 311.3361, 319.0101,
319.8925, 319.8950, 305.8104, 317.9661,
284.3676, 280.2324, 280.0354
])
Expand Down
5 changes: 3 additions & 2 deletions ion_functions/data/sfl_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@author Christopher Wingard
@brief Module containing Seafloor Properties related data-calculations.
"""

from ion_functions import fill_value
def sfl_trhph_vfltemp(V_s, V_c, a, b, c, d, e):
"""
Description:
Expand Down Expand Up @@ -147,6 +147,7 @@ def sfl_trhph_chloride(V_R1, V_R2, V_R3, T):

# reset NaN values generated in interpolation functions above to system
# default of -99999999
Cl[np.isnan(Cl)] = -99999999.
Cl[np.isnan(Cl)] = fill_value

return Cl

7 changes: 4 additions & 3 deletions ion_functions/data/test/test_co2_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import numpy as np
from ion_functions.data import co2_functions as co2func
from ion_functions import fill_value

@attr('UNIT', group='func')
class Testpco2FunctionsUnit(BaseUnitTestCase):
Expand Down Expand Up @@ -53,14 +54,14 @@ def test_co2_pco2wat(self):
cala = 0.0459
calb = 0.6257
calc = -1.5406
a434blnk = -99999999.
a620blnk = -99999999.
a434blnk = fill_value
a620blnk = fill_value

# expected outputs
therm = np.array([18.8526, 18.8765, 18.9245, 18.9485,
18.9485, 18.9485, 18.8765, 19.0686,
19.0686, 19.0446, 18.9725])
pco2 = np.array([-99999999., 294.1720, 311.3361, 319.0101,
pco2 = np.array([fill_value, 294.1720, 311.3361, 319.0101,
319.8925, 319.8950, 305.8104, 317.9661,
284.3676, 280.2324, 280.0354
])
Expand Down
17 changes: 9 additions & 8 deletions ion_functions/data/test/test_sfl_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import numpy as np
from ion_functions.data import sfl_functions as sflfunc
from ion_functions import fill_value

@attr('UNIT', group='func')
class TestSFLFunctionsUnit(BaseUnitTestCase):
Expand Down Expand Up @@ -84,14 +85,14 @@ def test_sfl_trhph_chloride(self):
Implemented by Christopher Wingard, April 2013
"""
test_array = np.array([
[0.906, 4.095, 4.095, 11.8, 4.530, 0.2208, -99999999., -99999999.],
[0.890, 4.095, 4.095, 15.9, 4.450, 0.2247, -99999999., -99999999.],
[0.891, 4.095, 4.095, 3.2, 4.455, 0.2245, -99999999., -99999999.],
[0.184, 0.915, 4.064, 67.7, 0.915, 1.0929, -99999999., -99999999.],
[0.198, 1.002, 4.095, 75.8, 1.002, 0.9980, -99999999., -99999999.],
[0.172, 0.857, 4.082, 97.5, 0.857, 1.1669, -99999999., -99999999.],
[0.183, 0.926, 4.076, 95.0, 0.926, 1.0799, -99999999., -99999999.],
[0.233, 1.182, 4.072, 96.2, 1.182, 0.8460, -99999999., -99999999.],
[0.906, 4.095, 4.095, 11.8, 4.530, 0.2208, fill_value, fill_value],
[0.890, 4.095, 4.095, 15.9, 4.450, 0.2247, fill_value, fill_value],
[0.891, 4.095, 4.095, 3.2, 4.455, 0.2245, fill_value, fill_value],
[0.184, 0.915, 4.064, 67.7, 0.915, 1.0929, fill_value, fill_value],
[0.198, 1.002, 4.095, 75.8, 1.002, 0.9980, fill_value, fill_value],
[0.172, 0.857, 4.082, 97.5, 0.857, 1.1669, fill_value, fill_value],
[0.183, 0.926, 4.076, 95.0, 0.926, 1.0799, fill_value, fill_value],
[0.233, 1.182, 4.072, 96.2, 1.182, 0.8460, fill_value, fill_value],
[0.146, 0.747, 3.634, 116.8, 0.727, 1.3759, 0.19507, 195],
[0.134, 0.681, 3.405, 272.8, 0.681, 1.4684, 0.10893, 109],
[0.131, 0.673, 3.293, 325.8, 0.659, 1.5184, 0.12813, 128],
Expand Down
4 changes: 2 additions & 2 deletions ion_functions/qc/qc_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import numpy as np
import numexpr as ne
from scipy.interpolate import LinearNDInterpolator
from ion_functions import utils
from ion_functions import utils, fill_value

# try to load the OOI logging module, using default Python logging module if
# unavailable
Expand All @@ -23,7 +23,7 @@
log = logging.getLogger('ion-functions')

def is_fill(arr):
return np.atleast_1d(arr)[-1] == -9999
return np.atleast_1d(arr)[-1] == fill_value
def is_none(arr):
return arr is None or (np.atleast_1d(arr)[-1] == None)

Expand Down

0 comments on commit aec5fdb

Please sign in to comment.