def test_adcp_ins2earth_orientation(self): """ Test the adcp worker routine adcp_inst2earth when the vertical orientation toggle switch codes for downward-looking (orient = 0). The instrument to earth coordinate transformation was coded in matlab using the January 2010 version of the Teledyne RD Instruments "ADCP Coordinate Transformation" manual. This matlab code was then used to generate the check values for the downward looking case. Implemented by: 2014-07-02: Russell Desiderio. Initial code. """ # input values: these are the output of adcp_beam2inst in test_vadcp_beam # (velocities are in instrument coordinates) u = np.array([[-749.95582864]]) v = np.array([[-739.72251324]]) w = np.array([[-81.67564404]]) heading = np.array([3200]) # units of centidegrees pitch = np.array([300]) # units of centidegrees roll = np.array([400]) # units of centidegrees # check test: upwards looking case orient_1 = np.array([1]) # expected outputs, earth coordinates, upwards case, from test_vadcp_beam which # agrees with the test matlab code values to (much) better than single precision. vle = np.array([[247.015599]]) vln = np.array([[-1027.223026]]) vlu = np.array([[-9.497397]]) xpctd = np.hstack((vle, vln, vlu)) # calculated upwards looking case uu, vv, ww = af.adcp_ins2earth(u, v, w, heading, pitch, roll, orient_1) calc = np.hstack((uu, vv, ww)) # test results np.testing.assert_array_almost_equal(calc, xpctd, 6) # primary test: downwards looking case. orient_0 = np.array([0]) # expected outputs, earth coordinates, downwards case, from matlab test code vle = np.array([[-1029.9328104]]) vln = np.array([[-225.7064203]]) vlu = np.array([[-67.7426771]]) xpctd = np.hstack((vle, vln, vlu)) # calculated downwards looking case uu, vv, ww = af.adcp_ins2earth(u, v, w, heading, pitch, roll, orient_0) calc = np.hstack((uu, vv, ww)) # test results np.testing.assert_array_almost_equal(calc, xpctd, 6)
def test_adcp_earth(self): """ Tests magnetic_correction function for ADCPs set to output data in the Earth Coordinate system. Values were not defined in DPS, were recreated using test values above: OOI (2012). Data Product Specification for Velocity Profile and Echo Intensity. Document Control Number 1341-00750. https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >> Controlled >> 1000 System Level >> 1341-00750_Data_Product_SPEC_VELPROF_OOI.pdf) Implemented by Christopher Wingard, 2014-02-06 """ # set the test data u, v, w, e = af.adcp_beam2ins(self.b1, self.b2, self.b3, self.b4) ### old adcp_ins2earth returned 3 variables uu, vv, ww = af.adcp_ins2earth(u, v, w, self.heading / 100., self.pitch / 100., self.roll / 100., self.orient) # test the magnetic variation correction got_uu_cor = af.adcp_earth_eastward(uu, vv, self.depth, self.lat, self.lon, self.ntp) got_vv_cor = af.adcp_earth_northward(uu, vv, self.depth, self.lat, self.lon, self.ntp) np.testing.assert_array_almost_equal(got_uu_cor, np.atleast_2d(self.uu_cor), 4) np.testing.assert_array_almost_equal(got_vv_cor, np.atleast_2d(self.vv_cor), 4) # reset the test inputs for multiple records uu = np.tile(uu, (24, 1)) vv = np.tile(vv, (24, 1)) depth = np.ones(24) * self.depth lat = np.ones(24) * self.lat lon = np.ones(24) * self.lon ntp = np.ones(24) * self.ntp # reset expected results for multiple records uu_cor = np.tile(self.uu_cor, (24, 1)) vv_cor = np.tile(self.vv_cor, (24, 1)) # compute the results for multiple records got_uu_cor = af.adcp_earth_eastward(uu, vv, depth, lat, lon, ntp) got_vv_cor = af.adcp_earth_northward(uu, vv, depth, lat, lon, ntp) # test the magnetic variation correction np.testing.assert_array_almost_equal(got_uu_cor, uu_cor, 4) np.testing.assert_array_almost_equal(got_vv_cor, vv_cor, 4)
def test_adcp_beam2earth(self): """ Test adcp_beam2ins and adcp_ins2earth functions. Values based on those defined in DPS: OOI (2012). Data Product Specification for Velocity Profile and Echo Intensity. Document Control Number 1341-00750. https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >> Controlled >> 1000 System Level >> 1341-00750_Data_Product_SPEC_VELPROF_OOI.pdf) Implemented by Christopher Wingard, April 2013 """ # set test inputs b1 = np.array([-0.0300, -0.2950, -0.5140, -0.2340, -0.1880, 0.2030, -0.3250, 0.3050]) b2 = np.array([ 0.1800, -0.1320, 0.2130, 0.3090, 0.2910, 0.0490, 0.1880, 0.3730]) b3 = np.array([-0.3980, -0.4360, -0.1310, -0.4730, -0.4430, 0.1880, -0.1680, 0.2910]) b4 = np.array([-0.2160, -0.6050, -0.0920, -0.0580, 0.4840, -0.0050, 0.3380, 0.1750]) heading = 98.4100 pitch = 0.6900 roll = -2.5400 orient = 1 # compute beam to instrument transform u, v, w, e = adcpfunc.adcp_beam2ins(b1, b2, b3, b4) # compute instrument to Earth transform got_uu, got_vv, got_ww = adcpfunc.adcp_ins2earth(u, v, w, heading, pitch, roll, orient) # set expected results uu = np.array([ 0.2175, -0.2814, -0.1002, 0.4831, 1.2380, -0.2455, 0.6218, -0.1807]) vv = np.array([-0.3367, -0.1815, -1.0522, -0.8676, -0.8919, 0.2585, -0.8497, -0.0873]) ww = np.array([ 0.1401, 0.3977, 0.1870, 0.1637, 0.0091, -0.1290, 0.0334, -0.3017]) # test the transform self.assertTrue(np.allclose(got_uu, uu, rtol=1e4, atol=0)) self.assertTrue(np.allclose(got_vv, vv, rtol=1e4, atol=0)) self.assertTrue(np.allclose(got_ww, ww, rtol=1e4, atol=0))
def test_vadcp_beam(self): """ Tests vadcp_beam_eastward, vadcp_beam_northward, vadcp_beam_vertical_est and vadcp_beam_vertical_true functions (which call adcp_beam2ins and adcp_ins2earth) for the specialized 5-beam ADCP. Application of the magnetic correction and conversion from mm/s to m/s is not applied. Values based on those defined in DPS: OOI (2012). Data Product Specification for Turbulent Velocity Profile and Echo Intensity. Document Control Number 1341-00760. https://alfresco.oceanobservatories.org/ (See: Company Home >> OOI >> Controlled >> 1000 System Level >> 1341-00760_Data_Product_SPEC_VELTURB_OOI.pdf) Implemented by: 2014-07-24: Christopher Wingard. Initial code. """ # test inputs b1 = np.ones((10, 10)) * -325 b2 = np.ones((10, 10)) * 188 b3 = np.ones((10, 10)) * 168 b4 = np.ones((10, 10)) * -338 b5 = np.ones((10, 10)) * -70 heading = np.array([30, 30, 30, 30, 30, 32, 32, 32, 32, 32]) pitch = np.array([0, 2, 3, 3, 1, 2, 2, 3, 3, 1]) roll = np.array([0, 4, 3, 4, 3, 3, 4, 3, 4, 3]) orient = np.ones(10) # expected outputs vle = np.array([279.6195, 282.6881, 281.8311, 282.7147, 282.1188, 246.2155, 246.9874, 246.1226, 247.0156, 246.4276]).reshape(-1, 1) vle = np.reshape(np.tile(vle, 10), (10, 10)) vln = np.array([-1015.5964, -1018.0226, -1018.2595, -1017.9765, -1017.7612, -1027.3264, -1027.2681, -1027.4749, -1027.2230, -1026.9870]).reshape(-1, 1) vln = np.reshape(np.tile(vln, 10), (10, 10)) vlu = np.array([81.6756, 3.3916, 3.5950, -9.4974, 29.4154, 16.5077, 3.3916, 3.5950, -9.4974, 29.4154]).reshape(-1, 1) vlu = np.reshape(np.tile(vlu, 10), (10, 10)) evl = np.array([34.1128, 34.1128, 34.1128, 34.1128, 34.1128, 34.1128, 34.1128, 34.1128, 34.1128, 34.1128]).reshape(-1, 1) evl = np.reshape(np.tile(evl, 10), (10, 10)) w5 = np.array([70.0000, -8.2485, -8.0487, -21.1287, 17.7575, 4.8552, -8.2485, -8.0487, -21.1287, 17.7575]).reshape(-1, 1) w5 = np.reshape(np.tile(w5, 10), (10, 10)) # test the transformations u, v, w_est, e = af.adcp_beam2ins(b1, b2, b3, b4) uu, vv, ww_est = af.adcp_ins2earth(u, v, w_est, heading, pitch, roll, orient) _, _, ww_true = af.adcp_ins2earth(u, v, b5, heading, pitch, roll, orient) # compare the results np.testing.assert_array_almost_equal(uu, vle, 4) np.testing.assert_array_almost_equal(vv, vln, 4) np.testing.assert_array_almost_equal(ww_est, vlu, 4) np.testing.assert_array_almost_equal(e, evl, 4) np.testing.assert_array_almost_equal(ww_true, w5, 4)