pyprecag.kriging_ops

class pyprecag.kriging_ops.VesperControl(*args, **kwargs)[source]

A dictionary used to manage vesper control keys and values.

The list of keys is confined to those in __defaults, values are checked against the default and must be the same type.

__defaults = values to use as defaults. Defaults are set for type as well ie 0.00 = float
key_order = This doubles as the list of allowed keys and the order required when writing

to file with the exception of epsg.

__init__(*args, **kwargs)[source]

x.__init__(…) initializes x; see help(type(x)) for signature

key_order = ['ivers', 'title', 'datfil', 'outdir', 'repfil', 'outfil', 'parfil', 'igrids', 'gridfile', 'jigraph', 'jimap', 'numcol', 'icol_x', 'icol_y', 'icol_z', 'valmis', 'jpntkrg', 'xside', 'yside', 'nest', 'dstinc', 'jsetint', 'xlint', 'xhint', 'ylint', 'yhint', 'jsetrad', 'radius', 'minpts', 'maxpts', 'sigsqr', 'lognorm', 'itrend', 'iconvex', 'jlockrg', 'jcomvar', 'nlag', 'tolag', 'hmax', 'iwei', 'modtyp', 'CO', 'C1', 'A1', 'C2', 'A2', 'Alfa', 'jordkrg', 'isomod', 'isearch', 'igeos', 'icircs', 'phi', 'psin', 'pcos']
updated_keys()[source]
write_to_file(output_file)[source]
pyprecag.kriging_ops.prepare_for_vesper_krige(in_dataframe, krig_column, grid_filename, out_folder, control_textfile='', coord_columns=[], epsg=0, display_graphics=False, control_options={'A1': 10.0, 'A2': 1.0, 'Alfa': 1.0, 'C1': 1.0, 'C2': 1.0, 'CO': 0.0, 'datfil': 'vesperdata.csv', 'dstinc': 1, 'epsg': 0, 'gridfile': 'vespergrid.txt', 'hmax': 0, 'icircs': 0, 'icol_x': 1, 'icol_y': 2, 'icol_z': 3, 'iconvex': 0, 'igeos': 0, 'igrids': 1, 'isearch': 0, 'isomod': 1, 'itrend': 0, 'ivers': 16121, 'iwei': 1, 'jcomvar': 1, 'jigraph': 0, 'jimap': 0, 'jlockrg': 1, 'jordkrg': 1, 'jpntkrg': 0, 'jsetint': 0, 'jsetrad': 0, 'lognorm': 0, 'maxpts': 100, 'minpts': 90, 'modtyp': 2, 'nest': 10, 'nlag': 20, 'numcol': 4, 'outdir': '', 'outfil': 'kriged.txt', 'parfil': 'parameter.txt', 'pcos': 0, 'phi': 0, 'psin': 0, 'radius': 100, 'repfil': 'report.txt', 'sigsqr': 0, 'title': 'kriging of control.txt configured by pyprecag epsg=', 'tolag': 10, 'valmis': -9999, 'xhint': 0, 'xlint': 0, 'xside': 10, 'yhint': 0, 'ylint': 0, 'yside': 10}, block_size=10, vesper_exe='C:\\Program Files (x86)\\Vesper\\Vesper1.6.exe')[source]

Prepare data for vesper kriging and create a windows batch file to run outside the python/pyprecag environment.

The input arguments will be used to update the control_options.

A description of the keys and their options can be found in the VESPER user manual at https://sydney.edu.au/agriculture/pal/documents/Vesper_1.6_User_Manual.pdf

block_size will be replaced by the xside and yside keys in the VesperControl Object.

Outputs: The following files will be added to the vesper sub-folder in the output folder.

_control_.txt - The vesper control file _vesperdata_.csv - The subset of data to krige. All non-required columns are deleted. Do_Vesper.bat - A windows batch file to launch vesper kriging for all control files

Any files matching the derived kriged output names will be deleted to ensure that the files in the folder belong to the newly create control file. If old version are to be kept, manually rename first.

DEPENDANCY: Vesper must already be installed on the PC and the install directory added to the config.json file.

Parameters:
  • in_dataframe (geopandas.geodataframe.GeoDataFrame, pandas.core.frame.DataFrame) –
  • krig_column (str) – The column containing the data to krige.
  • grid_filename (str) – The vesper grid file.
  • control_textfile (str) – The name of the control text file without the path
  • out_folder (str) – The folder to add outputs too. A ‘Vesper’ sub directory will be created
  • block_size (int) – The size to apply for block Kriging. Units are from the coordinate system.
  • coord_columns (List) – The columns representing the X and Y coordinates.
  • epsg (int) – The epsg_number number for the data. If 0 the en_epsg or enepsg column (if exists) will be used.
  • display_graphics (bool) – Option to display graphics while running vesper kriging.
  • vesper_exe (str) – The path for the location of the Vesper executable
  • control_options (pyprecag.kriging_ops.VesperControl) – Vesper control settings parameters
Returns:

The paths to the generated batch file and control file.

Return type:

vesper_batfile, vesper_ctrlfile

pyprecag.kriging_ops.run_vesper(ctrl_file, bMinimiseWindow=True, vesper_exe='C:\\Program Files (x86)\\Vesper\\Vesper1.6.exe')[source]

Run VESPER for selected control file.

By default the current working directory will be set to the folder containing the control file.

By default processing will wait for the current VESPER control file to complete. :param ctrl_file: the control file to run as VESPER argument. :type ctrl_file: str :param bMinimiseWindow: Option to automatically minimise the VESPER window on launch. :type bMinimiseWindow: bool :param vesper_exe: The path for the location of the Vesper executable :type vesper_exe: str

pyprecag.kriging_ops.test_for_windows()[source]
pyprecag.kriging_ops.vesper_text_to_raster(control_textfile, krig_epsg=0, nodata_value=-9999)[source]

Convert an vesper kriged text file output to a prediction and a standard error (SE) tif raster, and create a confidence interval (CI) metadata file. If the output files already exists, they will be overwritten.

Kriging using Vesper creates 3 new files:
_kriged_.txt, _report_.txt, _parameter_.txt.

There is a 100 character file path limitation set within vesper for the kriged and report files. By using the control filename as the input, the truncated files can be renamed to their correct names and is used as a base for derived tiff and metadata

The _kriged_.txt file contains the data to create the desired outputs.

Parameters:
  • control_textfile (str) – The control file for the associated vesper krige raster (see note above) to convert.
  • krig_epsg (int) – The EPSG number to assign to the output raster
  • nodata_value (int) – The value to assign to nodata pixels.
Outputs:
_CI_.txt The confidence interval (CI) metadata file. _PRED_.tif The kriged column prediction tif _SE_.tif The kriged column standard error (SE) tif