Beispiel #1
0
    def test06_prepareForVesperKrig(self):
        csv_desc = CsvDescribe(fileTrimmed)
        df_csv = csv_desc.open_pandas_dataframe()

        global file_control
        sub_file = os.path.splitext(os.path.basename(file_csv))[0]
        file_control = sub_file + '_control_' + data_col + '.txt'

        vc = VesperControl()
        vc.update(xside=30, yside=30)

        if not os.path.exists(file_control):
            bat_file, file_control = prepare_for_vesper_krige(df_csv, data_col, file_block_txt,
                                                              TmpDir,
                                                              control_textfile=file_control,
                                                              coord_columns=[], epsg=epsg,
                                                              control_options=vc)

            self.assertTrue(os.path.exists(bat_file))
            self.assertTrue(os.path.exists(file_control))

        self.assertTrue(os.path.exists(os.path.join(TmpDir, r'Vesper',
                                                    sub_file + '_vesperdata_' + data_col + '.csv')))
        df_csv = pd.read_csv(os.path.join(TmpDir, r'Vesper',
                                          sub_file + '_vesperdata_' + data_col + '.csv'))

        x_column, y_column = predictCoordinateColumnNames(df_csv.columns)
        self.assertEqual(x_column.upper(), 'EASTING')
        self.assertEqual(y_column.upper(), 'NORTHING')

        print('Running Vesper, Please wait....')
        run_vesper(file_control)
    def test4_RunVesper(self):
        if platform.system() != 'Windows':
            print('Skipping test4_RunVesper - VESPER only present on Windows')
        else:

            # for this to work this file needs updating first
            # these are requirements so check first
            self.assertTrue(os.path.exists(g_ctrl_file))

            vesper_exe = kriging_ops.vesper_exe

            os.path.join(TEMPDIR, 'Vesper', 'high_kriged.tif')
            try:
                print('Running Vesper, Please wait....')
                run_vesper(g_ctrl_file)
            except IOError as msg:
                self.assertIn(
                    'does not exist. Please install and configure for kriging to occur',
                    str(msg))
Beispiel #3
0
    def test2_vesperTextToRaster(self):
        file_ctrl = os.path.join(
            TmpDir, r'Vesper',
            os.path.basename(fileSubName) + '_control.txt')

        # these are requirements so check first
        self.assertTrue(os.path.exists(file_ctrl))
        self.assertTrue(os.path.exists(block_tif))

        vesper_exe = kriging_ops.vesper_exe
        self.assertTrue(os.path.exists(vesper_exe))
        os.path.join(TmpDir, r'Vesper',
                     os.path.basename(fileSubName) + '_kriged.tif')
        if not os.path.exists(
                os.path.join(TmpDir, r'Vesper',
                             os.path.basename(fileSubName) + '_kriged.tif')):
            print('Running Vesper, Please wait....')
            run_vesper(file_ctrl)

        out_PredTif, out_SETif, out_CITxt = vesper_text_to_raster(
            file_ctrl, 28354)
        for eaFile in [out_PredTif, out_SETif, out_CITxt]:
            self.assertTrue(os.path.exists(eaFile))

        with rasterio.open(os.path.normpath(out_PredTif)) as dataset:
            self.assertEqual(dataset.count, 1)
            self.assertEqual(dataset.width, 47)
            self.assertEqual(dataset.height, 25)
            self.assertEqual(dataset.nodatavals, (-9999.0, ))
            self.assertEqual(dataset.dtypes, ('float32', ))
            self.assertEqual(dataset.crs, rasterio.crs.CRS.from_epsg(28354))

        with rasterio.open(os.path.normpath(out_SETif)) as dataset:
            self.assertEqual(dataset.count, 1)
            self.assertEqual(dataset.width, 47)
            self.assertEqual(dataset.height, 25)
            self.assertEqual(dataset.nodatavals, (-9999.0, ))
            self.assertEqual(dataset.dtypes, ('float32', ))

            self.assertEqual(dataset.crs, rasterio.crs.CRS.from_epsg(28354))