Beispiel #1
0
def depth_to_pressure_test():
    '''
    check behavior of depth_to_pressure for different input shapes.
    '''

    lat = 30.0
    depth = 10000
    truePressure = 10302423165

    #two single value arrays
    assert np.round(1e6*outils.depth_to_pressure( np.array([depth]), np.array([lat]) )) == truePressure, 'failed to match expectation for 2 single-valued arrays'

    #single lat, array of depths
    p = outils.depth_to_pressure( np.array([depth, depth, depth]), np.array([lat]) )
    for i in range(len(p)):
        assert np.round(1e6*p[i]) == truePressure, 'failed to match expectation when given multiple depths and a single latitude.'

    #single depth, array of latitudes
    p = outils.depth_to_pressure( np.array([depth]), np.array([lat, lat, lat]) )
    for i in range(len(p)):
        assert np.round(1e6*p[i]) == truePressure, 'failed to match expectation when given multiple latitudes and a single depth.'

    #array of depths, array of latitudes
    p = outils.depth_to_pressure( np.array([depth, depth, depth]), np.array([lat, lat, lat]) )
    for i in range(len(p)):
        assert np.round(1e6*p[i]) == truePressure, 'failed to match expectation when given arrays of both latitude depth.'
Beispiel #2
0
def depth_to_pressure_test():
    """
    check behavior of depth_to_pressure for different input shapes.
    """

    lat = 30.0
    depth = 10000
    truePressure = 10300977189

    # two single value arrays
    assert (
        np.round(1e6 * outils.depth_to_pressure(np.array([depth]), np.array([lat]))) == truePressure
    ), "failed to match expectation for 2 single-valued arrays"

    # single lat, array of depths
    p = outils.depth_to_pressure(np.array([depth, depth, depth]), np.array([lat]))
    for i in range(len(p)):
        assert (
            np.round(1e6 * p[i]) == truePressure
        ), "failed to match expectation when given multiple depths and a single latitude."

    # single depth, array of latitudes
    p = outils.depth_to_pressure(np.array([depth]), np.array([lat, lat, lat]))
    for i in range(len(p)):
        assert (
            np.round(1e6 * p[i]) == truePressure
        ), "failed to match expectation when given multiple latitudes and a single depth."

    # array of depths, array of latitudes
    p = outils.depth_to_pressure(np.array([depth, depth, depth]), np.array([lat, lat, lat]))
    for i in range(len(p)):
        assert (
            np.round(1e6 * p[i]) == truePressure
        ), "failed to match expectation when given arrays of both latitude depth."
Beispiel #3
0
def test(p, parameters):
    """
    Runs the quality control check on profile p and returns a numpy array
    of quality control decisions with False where the data value has
    passed the check and True where it failed.
    """

    # Get temperature values from the profile.
    t = p.t()
    # Get depth values (m) from the profile.
    z = obs_utils.depth_to_pressure(p.z(), p.latitude())

    assert len(t.data) == len(z.data), 'Number of temperature measurements does not equal number of depth measurements.'

    # initialize qc as a bunch of falses;
    # implies all measurements pass when a gradient can't be calculated, such as at edges & gaps in data:
    qc = numpy.zeros(len(t.data), dtype=bool)

    # check for gaps in data
    isTemperature = (t.mask==False)
    isPressure = (z.mask==False)
    isData = isTemperature & isPressure

    for i in range(1,len(t.data)-1):
        if isData[i] & isTemperature[i-1] & isTemperature[i+1]:

          isSlope = numpy.abs(t.data[i] - (t.data[i-1] + t.data[i+1])/2)

          if z.data[i] < 500:
              qc[i] = isSlope > 9.0
          else:
              qc[i] = isSlope > 3.0

    return qc
Beispiel #4
0
def test(p, parameters):
    """ 
    Runs the quality control check on profile p and returns a numpy array 
    of quality control decisions with False where the data value has 
    passed the check and True where it failed. 
    """

    # Get temperature and pressure values from the profile.
    t = p.t()
    z = obs_utils.depth_to_pressure(p.z(), p.latitude())

    # Make the quality control decisions. This should
    # return true if the temperature is outside -2.5 deg C
    # and 40 deg C or pressure is less than -5.
    qct = (t.mask == False) & ((t.data < -2.5) | (t.data > 40.0))
    qcp = (z.mask == False) & (z.data < -5)
    qc = qct | qcp

    return qc
def test(p, parameters):
    """ 
    Runs the quality control check on profile p and returns a numpy array 
    of quality control decisions with False where the data value has 
    passed the check and True where it failed. 
    """

    # Get temperature and pressure values from the profile.
    t = p.t()
    z = obs_utils.depth_to_pressure(p.z(), p.latitude())

    # Make the quality control decisions. This should
    # return true if the temperature is outside -2.5 deg C
    # and 40 deg C or pressure is less than -5.
    qct = (t.mask == False) & ((t.data < -2.5) | (t.data > 40.0))
    qcp = (z.mask == False) & (z.data < -5)
    qc  = qct | qcp
    
    return qc
Beispiel #6
0
def test(p):
    """ 
    Runs the quality control check on profile p and returns a numpy array 
    of quality control decisions with False where the data value has 
    passed the check and True where it failed. 
    """

    # Get vertical coordinate values from the profile.
    z = obs_utils.depth_to_pressure(p.z(), p.latitude())

    # Make the quality control decisions. This should
    # return true where z decreases or stays the same.
    qc = np.ndarray(p.n_levels(), dtype=bool)
    qc[:] = False
    iRef = -1
    for i in range(0, p.n_levels()):
         # Check if the data value is missing.
         if z.mask[i] == True: 
             continue
         
         # The first level with a z value is saved to use as a reference
         # to compare to the next level.
         if iRef == -1:
             iRef     = i
             zRef     = z[iRef]
             continue
         
         # Check for non-increasing z. If z increases, update the reference.
         if z[i] == zRef:
             qc[i]    = True
         elif z[i] < zRef:
             qc[iRef] = True
             qc[i]    = True
         else:
             iRef     = i
             zRef     = z[iRef]

    return qc
Beispiel #7
0
def test(p, parameters):
    """ 
    Runs the quality control check on profile p and returns a numpy array 
    of quality control decisions with False where the data value has 
    passed the check and True where it failed. 
    """

    # Get vertical coordinate values from the profile.
    z = obs_utils.depth_to_pressure(p.z(), p.latitude())

    # Make the quality control decisions. This should
    # return true where z decreases or stays the same.
    qc = numpy.ndarray(p.n_levels(), dtype=bool)
    qc[:] = False
    iRef = -1
    for i in range(0, p.n_levels()):
         # Check if the data value is missing.
         if z.mask[i] == True: 
             continue
         
         # The first level with a z value is saved to use as a reference
         # to compare to the next level.
         if iRef == -1:
             iRef     = i
             zRef     = z[iRef]
             continue
         
         # Check for non-increasing z. If z increases, update the reference.
         if z[i] == zRef:
             qc[i]    = True
         elif z[i] < zRef:
             qc[iRef] = True
             qc[i]    = True
         else:
             iRef     = i
             zRef     = z[iRef]

    return qc