Beispiel #1
0
    def test_biophysical_aoi(self):
        """WaveEnergy: testing Biophysical component with an AOI."""
        from natcap.invest.wave_energy import wave_energy

        args = WaveEnergyRegressionTests.generate_base_args(self.workspace_dir)

        args['aoi_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy', 'input',
                                       'AOI_WCVI.shp')

        wave_energy.execute(args)

        raster_results = [
            'wp_rc.tif', 'wp_kw.tif', 'capwe_rc.tif', 'capwe_mwh.tif'
        ]

        for raster_path in raster_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_rasters_equal(
                os.path.join(args['workspace_dir'], 'output', raster_path),
                os.path.join(REGRESSION_DATA, 'aoi', raster_path), 1e-9)

        table_results = ['capwe_rc.csv', 'wp_rc.csv']

        for table_path in table_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_csv_equal(
                os.path.join(args['workspace_dir'], 'output', table_path),
                os.path.join(REGRESSION_DATA, 'aoi', table_path), 1e-9)
Beispiel #2
0
    def test_removing_filenames(self):
        """WaveEnergy: testing file paths which already exist are removed."""
        from natcap.invest.wave_energy import wave_energy

        workspace_dir = 'test_removing_filenames'
        args = WaveEnergyRegressionTests.generate_base_args(
            workspace_dir)  #self.workspace_dir)

        args['aoi_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy', 'input',
                                       'AOI_WCVI.shp')
        args['valuation_container'] = True
        args['land_gridPts_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy',
                                                'input',
                                                'LandGridPts_WCVI.csv')
        args['machine_econ_uri'] = os.path.join(
            SAMPLE_DATA, 'WaveEnergy', 'input', 'Machine_Pelamis_Economic.csv')
        args['number_of_machines'] = 28

        wave_energy.execute(args)
        # Run through the model again, which should mean deleting
        # shapefiles that have already been made, but which need
        # to be created again.
        wave_energy.execute(args)

        raster_results = [
            'wp_rc.tif', 'wp_kw.tif', 'capwe_rc.tif', 'capwe_mwh.tif',
            'npv_rc.tif', 'npv_usd.tif'
        ]

        for raster_path in raster_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_rasters_equal(
                os.path.join(args['workspace_dir'], 'output', raster_path),
                os.path.join(REGRESSION_DATA, 'valuation', raster_path), 1e-9)

        vector_results = ['GridPts_prj.shp', 'LandPts_prj.shp']

        for vector_path in vector_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_vectors_equal(
                os.path.join(args['workspace_dir'], 'output', vector_path),
                os.path.join(REGRESSION_DATA, 'valuation', vector_path))

        table_results = ['capwe_rc.csv', 'wp_rc.csv', 'npv_rc.csv']

        for table_path in table_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_csv_equal(
                os.path.join(args['workspace_dir'], 'output', table_path),
                os.path.join(REGRESSION_DATA, 'valuation', table_path))
Beispiel #3
0
    def test_valuation_suffix_underscore(self):
        """WaveEnergy: testing suffix with an underscore through Valuation."""
        from natcap.invest.wave_energy import wave_energy

        args = WaveEnergyRegressionTests.generate_base_args(self.workspace_dir)

        args['aoi_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy', 'input',
                                       'AOI_WCVI.shp')
        args['valuation_container'] = True
        args['land_gridPts_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy',
                                                'input',
                                                'LandGridPts_WCVI.csv')
        args['machine_econ_uri'] = os.path.join(
            SAMPLE_DATA, 'WaveEnergy', 'input', 'Machine_Pelamis_Economic.csv')
        args['number_of_machines'] = 28
        args['suffix'] = '_val'

        wave_energy.execute(args)

        raster_results = [
            'wp_rc_val.tif', 'wp_kw_val.tif', 'capwe_rc_val.tif',
            'capwe_mwh_val.tif', 'npv_rc_val.tif', 'npv_usd_val.tif'
        ]

        for raster_path in raster_results:
            self.assertTrue(
                os.path.exists(
                    os.path.join(args['workspace_dir'], 'output',
                                 raster_path)))

        vector_results = ['GridPts_prj_val.shp', 'LandPts_prj_val.shp']

        for vector_path in vector_results:
            self.assertTrue(
                os.path.exists(
                    os.path.join(args['workspace_dir'], 'output',
                                 vector_path)))

        table_results = ['capwe_rc_val.csv', 'wp_rc_val.csv', 'npv_rc_val.csv']

        for table_path in table_results:
            self.assertTrue(
                os.path.exists(
                    os.path.join(args['workspace_dir'], 'output', table_path)))
Beispiel #4
0
    def test_valuation(self):
        """WaveEnergy: testing valuation component."""
        from natcap.invest.wave_energy import wave_energy

        args = WaveEnergyRegressionTests.generate_base_args(self.workspace_dir)

        args['aoi_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy', 'input',
                                       'AOI_WCVI.shp')
        args['valuation_container'] = True
        args['land_gridPts_uri'] = os.path.join(SAMPLE_DATA, 'WaveEnergy',
                                                'input',
                                                'LandGridPts_WCVI.csv')
        args['machine_econ_uri'] = os.path.join(
            SAMPLE_DATA, 'WaveEnergy', 'input', 'Machine_Pelamis_Economic.csv')
        args['number_of_machines'] = 28

        wave_energy.execute(args)

        raster_results = [
            'wp_rc.tif', 'wp_kw.tif', 'capwe_rc.tif', 'capwe_mwh.tif',
            'npv_rc.tif', 'npv_usd.tif'
        ]

        for raster_path in raster_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_rasters_equal(
                os.path.join(args['workspace_dir'], 'output', raster_path),
                os.path.join(REGRESSION_DATA, 'valuation', raster_path), 1e-9)

        vector_results = ['GridPts_prj.shp', 'LandPts_prj.shp']

        for vector_path in vector_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_vectors_equal(
                os.path.join(args['workspace_dir'], 'output', vector_path),
                os.path.join(REGRESSION_DATA, 'valuation', vector_path))

        table_results = ['capwe_rc.csv', 'wp_rc.csv', 'npv_rc.csv']

        for table_path in table_results:
            natcap.invest.pygeoprocessing_0_3_3.testing.assert_csv_equal(
                os.path.join(args['workspace_dir'], 'output', table_path),
                os.path.join(REGRESSION_DATA, 'valuation', table_path))