def test_Altitude_Covariate(self): altitude_element = GeographyBasedElement(self.altitude_datafile, 'lat', 'lon', 'dem', 1.0) altitude_element.load() numpy.testing.assert_array_equal(-89.875, altitude_element.latitude[0, 0]) numpy.testing.assert_array_equal(-84.875, altitude_element.latitude[20, 0]) numpy.testing.assert_array_equal(-89.875, altitude_element.latitude[0, 10]) numpy.testing.assert_array_equal(-84.875, altitude_element.latitude[20, 10]) numpy.testing.assert_array_equal(-179.875, altitude_element.longitude[0, 0]) numpy.testing.assert_array_equal(-179.875, altitude_element.longitude[20, 0]) numpy.testing.assert_array_equal(-177.375, altitude_element.longitude[0, 10]) numpy.testing.assert_array_equal(-177.375, altitude_element.longitude[20, 10]) numpy.testing.assert_array_equal(2779, altitude_element.covariate[0, 0]) numpy.testing.assert_array_equal(2861, altitude_element.covariate[1, 1]) design = altitude_element.element_design( TestRealCovariate.SimulatedObservationStructureAltitude()) altitude_design = design.design_matrix() numpy.testing.assert_almost_equal( numpy.array([2779, 2861, 2820, 2860.344]).reshape(-1, 1), altitude_design.todense())
def test_element_design(self): geography = GeographyBasedElement(self.covariate_file.name, 'lat', 'lon', 'covariate', 1.0) geography.load() design = geography.element_design(SimulatedObservationStructure()) self.assertTrue(isinstance(design, GeographyBasedElementDesign)) self.assertTrue( isinstance(design.function_class, GeographyBasedCovariateFunction)) for original_array, file_array, name in zip( [self.latitude, self.longitude, self.covariate], [ design.function_class.latitude, design.function_class.longitude, design.function_class.covariate ], ['latitude', 'longitude', 'covariate']): numpy.testing.assert_array_equal(original_array, file_array, err_msg="Testing vaues of " + name + " array") self.assertEqual(design.design_number_of_state_parameters(), GeographyBasedElement.NUMBER_OF_STATE_PARAMETERS)
def test_CoastalInfluence_Covariate(self): coastalinfluence_element = GeographyBasedElement( self.coastal_influence_datafile, 'lat', 'lon', 'coastal_influence', 1.0) coastalinfluence_element.load() numpy.testing.assert_array_equal( -89.875, coastalinfluence_element.latitude[0, 0]) numpy.testing.assert_array_equal( -84.875, coastalinfluence_element.latitude[20, 0]) numpy.testing.assert_array_equal( -89.875, coastalinfluence_element.latitude[0, 10]) numpy.testing.assert_array_equal( -84.875, coastalinfluence_element.latitude[20, 10]) numpy.testing.assert_array_equal( -179.875, coastalinfluence_element.longitude[0, 0]) numpy.testing.assert_array_equal( -179.875, coastalinfluence_element.longitude[20, 0]) numpy.testing.assert_array_equal( -177.375, coastalinfluence_element.longitude[0, 10]) numpy.testing.assert_array_equal( -177.375, coastalinfluence_element.longitude[20, 10]) numpy.testing.assert_array_almost_equal( 2.6666667, coastalinfluence_element.covariate[19, 82]) numpy.testing.assert_array_almost_equal( 100.0, coastalinfluence_element.covariate[20, 83]) design = coastalinfluence_element.element_design( TestRealCovariate.SimulatedObservationStructureCoastalInfluence()) coastalinfluence_design = design.design_matrix() numpy.testing.assert_almost_equal( numpy.array([2.6666667, 14.9382706, 100.0, 55.604321]).reshape(-1, 1), coastalinfluence_design.todense())