def test_opt_ocr507_irradiance(self):
        """
        Test opt_ocr507_irradiance function.

        Values calculated using data product algorithm in the DPS in an excel spreadsheet
        as available on Alfresco:

        OOI (2014). Data Product Specification for Downwelling Spectral Irradiance.
            Document Control Number 1341-00730. https://alfresco.oceanobservatories.org/
            (See: Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-00730__???.pdf)

        OOI (2014). SPECTIR Unit Test. 1341-00730_SPECTIR Artifact.
            https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >>
            >> REFERENCE >> Data Product Specification Artifacts >> 1341-00730_SPECTIR >>
            SPKIR_SPECTIR_unit_test.xlsx)


        Implemented by Russell Desiderio, March 14, 2014.
        Modified by Russell Desiderio, March 25, 2014. Transposed test array.
                                                       Set known output to be 2D row vector.
        """
#              counts         offset          scale        mrsn     Ed
        test_array = np.transpose(np.array([
            [2148370944, 2148377867.8, 2.09023117662E-07, 1.368, -0.002],
            [2200000000, 2148218092.4, 2.06543624674E-07, 1.410, 15.080],
            [2300000000, 2147607229.7, 2.12484770952E-07, 1.365, 44.200],
            [2400000000, 2147789959.1, 2.07241106309E-07, 1.354, 70.771],
            [2500000000, 2148047456.7, 1.99358530187E-07, 1.372, 96.266],
            [2600000000, 2147335412.8, 2.06033896796E-07, 1.404, 130.943],
            [2700000000, 2146998228.4, 2.14806273478E-07, 1.347, 160.008]
        ]))

        # set inputs
        counts = test_array[0, :]
        offset = test_array[1, :]
        scale = test_array[2, :]
        immersion_factor = test_array[3, :]

        # set known output
        Ed = np.atleast_2d(test_array[-1, :])

        # calculate the downwelling irradiance
        Ed_out = optfunc.opt_ocr507_irradiance(counts, offset, scale, immersion_factor)

        ###########################################################################
        # The (unfinished) DPS specifies a precision of 0.25 uW/cm^2/nm
        np.testing.assert_allclose(Ed_out, Ed, rtol=0.01, atol=0.1)
Exemplo n.º 2
0
    def test_opt_ocr507_irradiance(self):
        """
        Test opt_ocr507_irradiance function.

        Values calculated using data product algorithm in the DPS in an excel spreadsheet
        as available on Alfresco:

        OOI (2014). Data Product Specification for Downwelling Spectral Irradiance.
            Document Control Number 1341-00730. https://alfresco.oceanobservatories.org/
            (See: Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-00730__???.pdf)

        OOI (2014). SPECTIR Unit Test. 1341-00730_SPECTIR Artifact.
            https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >>
            >> REFERENCE >> Data Product Specification Artifacts >> 1341-00730_SPECTIR >>
            SPKIR_SPECTIR_unit_test.xlsx)


        Implemented by Russell Desiderio, March 14, 2014.
        Modified by Russell Desiderio, March 25, 2014.
            Transposed test array.
            Set known output to be 2D row vector.
        Modified by Russell Desiderio, April 09, 2015.
            Added unit tests for multiple data packets and exception checking
            Set known output for 1 data packet case to be 1D array.
        Modified by Russell Desiderio, April 21, 2015.
            Conditioned inputs for 1 data packet case to be 2D row vectors.
            Set known output for 1 data packet case back to 2D row vector.
        """
        #              counts         offset          scale        mrsn     Ed
        test_array = np.transpose(
            np.array([
                [2148370944, 2148377867.8, 2.09023117662E-07, 1.368, -0.00198],
                [2200000000, 2148218092.4, 2.06543624674E-07, 1.410, 15.080],
                [2300000000, 2147607229.7, 2.12484770952E-07, 1.365, 44.200],
                [2400000000, 2147789959.1, 2.07241106309E-07, 1.354, 70.771],
                [2500000000, 2148047456.7, 1.99358530187E-07, 1.372, 96.266],
                [2600000000, 2147335412.8, 2.06033896796E-07, 1.404, 130.943],
                [2700000000, 2146998228.4, 2.14806273478E-07, 1.347, 160.008]
            ]))

        ## one data packet case
        # set inputs
        counts = test_array[[0], :]
        offset = test_array[[1], :]
        scale = test_array[[2], :]
        immersion_factor = test_array[[3], :]

        # set known output to be a 2D row vector
        Ed = test_array[[-1], :]
        #print Ed.shape

        # calculate the downwelling irradiance
        Ed_out = optfunc.opt_ocr507_irradiance(counts, offset, scale,
                                               immersion_factor)

        ###########################################################################
        # The DPS specifies a precision of 0.25 uW/cm^2/nm
        np.testing.assert_allclose(Ed_out, Ed, rtol=0.0, atol=0.1)
        ###########################################################################

        ## multiple data packets case
        ## cal coeffs will also be "time-vectorized" by CI
        # create 10 data packets
        z_value = 10
        zcounts = np.tile(counts, (z_value, 1))
        zoffset = np.tile(offset, (z_value, 1))
        zscale = np.tile(scale, (z_value, 1))
        zimmersion_factor = np.tile(immersion_factor, (z_value, 1))

        # set known output
        zEd = np.tile(Ed, (z_value, 1))
        #print Ed.shape

        # calculate the downwelling irradiance
        zEd_out = optfunc.opt_ocr507_irradiance(zcounts, zoffset, zscale,
                                                zimmersion_factor)

        ###########################################################################
        # The DPS specifies a precision of 0.25 uW/cm^2/nm
        np.testing.assert_allclose(zEd_out, zEd, rtol=0.0, atol=0.1)
        ###########################################################################

        ## test error-checking
        # data array counts does not have 7 elements
        counts_wrongshape = test_array[0, 0:-1]
        np.testing.assert_raises(ValueError, optfunc.opt_ocr507_irradiance,
                                 counts_wrongshape, offset, scale,
                                 immersion_factor)

        # cal coeff scale does not have 7 elements
        scale_wrongshape = test_array[2, 0:-1]
        np.testing.assert_raises(ValueError, optfunc.opt_ocr507_irradiance,
                                 counts, offset, scale_wrongshape,
                                 immersion_factor)
Exemplo n.º 3
0
    def test_opt_ocr507_irradiance(self):
        """
        Test opt_ocr507_irradiance function.

        Values calculated using data product algorithm in the DPS in an excel spreadsheet
        as available on Alfresco:

        OOI (2014). Data Product Specification for Downwelling Spectral Irradiance.
            Document Control Number 1341-00730. https://alfresco.oceanobservatories.org/
            (See: Company Home >> OOI >> Controlled >> 1000 System Level >>
            1341-00730__???.pdf)

        OOI (2014). SPECTIR Unit Test. 1341-00730_SPECTIR Artifact.
            https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >>
            >> REFERENCE >> Data Product Specification Artifacts >> 1341-00730_SPECTIR >>
            SPKIR_SPECTIR_unit_test.xlsx)


        Implemented by Russell Desiderio, March 14, 2014.
        Modified by Russell Desiderio, March 25, 2014.
            Transposed test array.
            Set known output to be 2D row vector.
        Modified by Russell Desiderio, April 09, 2015.
            Added unit tests for multiple data packets and exception checking
            Set known output for 1 data packet case to be 1D array.
        Modified by Russell Desiderio, April 21, 2015.
            Conditioned inputs for 1 data packet case to be 2D row vectors.
            Set known output for 1 data packet case back to 2D row vector.
        """
#              counts         offset          scale        mrsn     Ed
        test_array = np.transpose(np.array([
            [2148370944, 2148377867.8, 2.09023117662E-07, 1.368, -0.00198],
            [2200000000, 2148218092.4, 2.06543624674E-07, 1.410, 15.080],
            [2300000000, 2147607229.7, 2.12484770952E-07, 1.365, 44.200],
            [2400000000, 2147789959.1, 2.07241106309E-07, 1.354, 70.771],
            [2500000000, 2148047456.7, 1.99358530187E-07, 1.372, 96.266],
            [2600000000, 2147335412.8, 2.06033896796E-07, 1.404, 130.943],
            [2700000000, 2146998228.4, 2.14806273478E-07, 1.347, 160.008]
        ]))

        ## one data packet case
        # set inputs
        counts = test_array[[0], :]
        offset = test_array[[1], :]
        scale = test_array[[2], :]
        immersion_factor = test_array[[3], :]

        # set known output to be a 2D row vector
        Ed = test_array[[-1], :]
        #print Ed.shape

        # calculate the downwelling irradiance
        Ed_out = optfunc.opt_ocr507_irradiance(counts, offset, scale, immersion_factor)

        ###########################################################################
        # The DPS specifies a precision of 0.25 uW/cm^2/nm
        np.testing.assert_allclose(Ed_out, Ed, rtol=0.0, atol=0.1)
        ###########################################################################

        ## multiple data packets case
        ## cal coeffs will also be "time-vectorized" by CI
        # create 10 data packets
        z_value = 10
        zcounts = np.tile(counts, (z_value, 1))
        zoffset = np.tile(offset, (z_value, 1))
        zscale = np.tile(scale, (z_value, 1))
        zimmersion_factor = np.tile(immersion_factor, (z_value, 1))

        # set known output
        zEd = np.tile(Ed, (z_value, 1))
        #print Ed.shape

        # calculate the downwelling irradiance
        zEd_out = optfunc.opt_ocr507_irradiance(zcounts, zoffset, zscale, zimmersion_factor)

        ###########################################################################
        # The DPS specifies a precision of 0.25 uW/cm^2/nm
        np.testing.assert_allclose(zEd_out, zEd, rtol=0.0, atol=0.1)
        ###########################################################################

        ## test error-checking
        # data array counts does not have 7 elements
        counts_wrongshape = test_array[0, 0:-1]
        np.testing.assert_raises(ValueError, optfunc.opt_ocr507_irradiance, counts_wrongshape,
                                 offset, scale, immersion_factor)

        # cal coeff scale does not have 7 elements
        scale_wrongshape = test_array[2, 0:-1]
        np.testing.assert_raises(ValueError, optfunc.opt_ocr507_irradiance, counts, offset,
                                 scale_wrongshape, immersion_factor)