Utility Routines¶
General mathematical toolbox routines
The routines that follow are part of my general mathematical “toolbox”. Some of them are taken (with reference) from book(s) but most, I have developed on my own. They are modular in construction so that they may be improved, as needed.
-
jldesmear.jl_api.toolbox.
AskDouble
(question, answer)[source]¶ request a double from the command line
Parameters: - question (str) – string to pose
- answer (double) – default answer
Returns: final answer
Return type: double
-
jldesmear.jl_api.toolbox.
AskInt
(question, answer)[source]¶ request an integer from the command line
Parameters: - question (str) – string to pose
- answer (int) – default answer
Returns: final answer
Return type: int
-
jldesmear.jl_api.toolbox.
AskQuestion
(question, answer)[source]¶ request a string, float, or int from the command line
Parameters: - question (str) – string to pose
- answer (string | float | int) – default answer
Returns: final answer
Return type: str | float | int
-
jldesmear.jl_api.toolbox.
AskString
(question, answer)[source]¶ request a string from the command line
Parameters: - question (str) – string to pose
- answer (str) – default answer
Returns: final answer
Return type: str
-
jldesmear.jl_api.toolbox.
AskYesOrNo
(question, answer)[source]¶ one of two choices seems simple
Parameters: - question (str) – string to pose
- answer (str) – default answer
Returns: y | n
Return type: str
-
jldesmear.jl_api.toolbox.
GetDat
(infile)[source]¶ read three-column data from a wss (white-space-separated) file
Data appear as Q I dI with one data point per line. A “#” may be used to comment out any line.
Parameters: infile (string) – name of input data file Returns: x, y, dy Return type: (numpy.ndarray, numpy.ndarray, numpy.ndarray)
-
jldesmear.jl_api.toolbox.
GetTest1DataFilename
(ext='.smr')[source]¶ find the test1 data in the package
-
jldesmear.jl_api.toolbox.
SavDat
(outfile, x, y, dy)[source]¶ save three column ASCII data in tab-separated file
Parameters: - outfile (str) – name of output file
- x (numpy.ndarray) – column 1 data array
- y (numpy.ndarray) – column 2 data array
- dy (numpy.ndarray) – column 3 data array
-
jldesmear.jl_api.toolbox.
Spinner
(i, quiet=False)[source]¶ Spins a stick to indicate program is still working. Call this routine frequently during long operations to show progress.
Parameters: - i (int) – selector (increment this in the calling routine)
- quiet (bool) – optional switch to turn off the spinner
-
jldesmear.jl_api.toolbox.
find_first_index
(x, target)[source]¶ find i such that x[i] >= target and x[i-1] < target
Parameters: - x (ndarray) – array to search
- target (float) – value to bracket
Returns: index of array x or None
Return type: int