Utility Functions#
The pygeostat.utility module provides utility functions for file management,
logging, and deprecation warnings.
File Management#
mkdir#
rmdir#
rmfile#
get_executable#
- pygeostat.utility.get_executable(source='gslib', access_token=None, clean=False)[source]#
Gets a collection of executable files from a protected repository using an access token. Note that in order to use this function, git needs to be installed on the target computer.
- Parameters:
source (str) – gslib or CCG as the source of software.
access_token (str) – An access token to authorize access to the target private repository for CCG software. Access token is available for CCG members and can be found at CCG knowledge base.
clean (bool) – Option to clean the executable directory prior to upload the files from the target private repository. Note that choosing this option will delete the existing executable files.
Examples
Installing GSLIB executable files
import pygeostat as gs gs.get_executable(source='GSLIB')
Installing CCG software
import pygeostat as gs gs.get_executable(source='CCG', clean=True)
Using the installed software
# Load example data included in pygeostat data_file = gs.ExampleData('cluster') # Initialize the Program object nscore = gs.Program('nscore', getpar=True) # Run normal score transformation parstr = """ Parameters for NSCORE ********************* START OF PARAMETERS: {datafile} - file with data 3 1 2 3 - number of variables and columns 5 - column for weight, 0 if none 0 - column for category, 0 if none 0 - number of records if known, 0 if unknown -1.0e21 1.0e21 - trimming limits 0 -transform using a reference distribution, 1=yes ../histsmth/histsmth.out -file with reference distribution. 1 2 0 - columns for variable, weight, and category 101 -maximum number of quantiles, 0 for all {outfl} -file for output {trnfl} -file for output transformation table """ pars = dict(datafile=data_file.flname, outfl = 'nscore.out', trnfl = 'nscore.trn') nscore.run(parstr=parstr.format(**pars), liveoutput=True)
list_executable#
Logging#
printerr#
- pygeostat.utility.printerr(text, width=80, errtype=None)[source]#
Small utility to print custom errors with proper indentation and text wrapping. The only error types coded are error and warning.
- Parameters:
text (str) – String of text without the preceding error flag that will be formated
width (int) – The maximum length of wrapped lines
errtype (str) – Indicate which type of error to format the string as. The default value of None will only text wrap the string to the specified width.
Code author: pygeostat development team 2015-11-01