repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
3 values
summary
stringlengths
4
350
radjkarl/imgProcessor
imgProcessor/physics/emissivity_vs_angle.py
TG_glass
def TG_glass(): ''' reflected temperature for 250DEG Glass published in IEC 62446-3 TS: Photovoltaic (PV) systems - Requirements for testing, documentation and maintenance - Part 3: Outdoor infrared thermography of photovoltaic modules and plants p Page 12 ''' vals = np.arra...
python
def TG_glass(): ''' reflected temperature for 250DEG Glass published in IEC 62446-3 TS: Photovoltaic (PV) systems - Requirements for testing, documentation and maintenance - Part 3: Outdoor infrared thermography of photovoltaic modules and plants p Page 12 ''' vals = np.arra...
[ "def", "TG_glass", "(", ")", ":", "vals", "=", "np", ".", "array", "(", "[", "(", "80", ",", "0.88", ")", ",", "(", "75", ",", "0.88", ")", ",", "(", "70", ",", "0.88", ")", ",", "(", "65", ",", "0.88", ")", ",", "(", "60", ",", "0.88", ...
reflected temperature for 250DEG Glass published in IEC 62446-3 TS: Photovoltaic (PV) systems - Requirements for testing, documentation and maintenance - Part 3: Outdoor infrared thermography of photovoltaic modules and plants p Page 12
[ "reflected", "temperature", "for", "250DEG", "Glass", "published", "in", "IEC", "62446", "-", "3", "TS", ":", "Photovoltaic", "(", "PV", ")", "systems", "-", "Requirements", "for", "testing", "documentation", "and", "maintenance", "-", "Part", "3", ":", "Out...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/physics/emissivity_vs_angle.py#L45-L72
train
A version of the TG Glass related code.
radjkarl/imgProcessor
imgProcessor/camera/flatField/sensitivity.py
sensitivity
def sensitivity(imgs, bg=None): ''' Extract pixel sensitivity from a set of homogeneously illuminated images This method is detailed in Section 5 of: --- K.Bedrich, M.Bokalic et al.: ELECTROLUMINESCENCE IMAGING OF PV DEVICES: ADVANCED FLAT FIELD CALIBRATION,2017 --- ''' ...
python
def sensitivity(imgs, bg=None): ''' Extract pixel sensitivity from a set of homogeneously illuminated images This method is detailed in Section 5 of: --- K.Bedrich, M.Bokalic et al.: ELECTROLUMINESCENCE IMAGING OF PV DEVICES: ADVANCED FLAT FIELD CALIBRATION,2017 --- ''' ...
[ "def", "sensitivity", "(", "imgs", ",", "bg", "=", "None", ")", ":", "bg", "=", "getBackground", "(", "bg", ")", "for", "n", ",", "i", "in", "enumerate", "(", "imgs", ")", ":", "i", "=", "imread", "(", "i", ",", "dtype", "=", "float", ")", "i",...
Extract pixel sensitivity from a set of homogeneously illuminated images This method is detailed in Section 5 of: --- K.Bedrich, M.Bokalic et al.: ELECTROLUMINESCENCE IMAGING OF PV DEVICES: ADVANCED FLAT FIELD CALIBRATION,2017 ---
[ "Extract", "pixel", "sensitivity", "from", "a", "set", "of", "homogeneously", "illuminated", "images", "This", "method", "is", "detailed", "in", "Section", "5", "of", ":", "---", "K", ".", "Bedrich", "M", ".", "Bokalic", "et", "al", ".", ":", "ELECTROLUMIN...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/sensitivity.py#L7-L30
train
Returns the sensitivity of the homogeneously illuminated images.
radjkarl/imgProcessor
imgProcessor/simulate/navierStokes.py
navierStokes2d
def navierStokes2d(u, v, p, dt, nt, rho, nu, boundaryConditionUV, boundardConditionP, nit=100): ''' solves the Navier-Stokes equation for incompressible flow one a regular 2d grid u,v,p --> initial velocity(u,v) and pressure(p) maps dt --> time s...
python
def navierStokes2d(u, v, p, dt, nt, rho, nu, boundaryConditionUV, boundardConditionP, nit=100): ''' solves the Navier-Stokes equation for incompressible flow one a regular 2d grid u,v,p --> initial velocity(u,v) and pressure(p) maps dt --> time s...
[ "def", "navierStokes2d", "(", "u", ",", "v", ",", "p", ",", "dt", ",", "nt", ",", "rho", ",", "nu", ",", "boundaryConditionUV", ",", "boundardConditionP", ",", "nit", "=", "100", ")", ":", "#next u, v, p maps:\r", "un", "=", "np", ".", "empty_like", "(...
solves the Navier-Stokes equation for incompressible flow one a regular 2d grid u,v,p --> initial velocity(u,v) and pressure(p) maps dt --> time step nt --> number of time steps to caluclate rho, nu --> material constants nit --> number of iteration to solve the pre...
[ "solves", "the", "Navier", "-", "Stokes", "equation", "for", "incompressible", "flow", "one", "a", "regular", "2d", "grid", "u", "v", "p", "--", ">", "initial", "velocity", "(", "u", "v", ")", "and", "pressure", "(", "p", ")", "maps", "dt", "--", ">"...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L8-L49
train
Returns a new 2d grid with the same initial velocity and pressure.
radjkarl/imgProcessor
imgProcessor/simulate/navierStokes.py
shiftImage
def shiftImage(u, v, t, img, interpolation=cv2.INTER_LANCZOS4): ''' remap an image using velocity field ''' ny,nx = u.shape sy, sx = np.mgrid[:float(ny):1,:float(nx):1] sx += u*t sy += v*t return cv2.remap(img.astype(np.float32), (sx).astype(np.float32), ...
python
def shiftImage(u, v, t, img, interpolation=cv2.INTER_LANCZOS4): ''' remap an image using velocity field ''' ny,nx = u.shape sy, sx = np.mgrid[:float(ny):1,:float(nx):1] sx += u*t sy += v*t return cv2.remap(img.astype(np.float32), (sx).astype(np.float32), ...
[ "def", "shiftImage", "(", "u", ",", "v", ",", "t", ",", "img", ",", "interpolation", "=", "cv2", ".", "INTER_LANCZOS4", ")", ":", "ny", ",", "nx", "=", "u", ".", "shape", "sy", ",", "sx", "=", "np", ".", "mgrid", "[", ":", "float", "(", "ny", ...
remap an image using velocity field
[ "remap", "an", "image", "using", "velocity", "field" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/simulate/navierStokes.py#L52-L62
train
remap an image using velocity field remap an image using velocity field
radjkarl/imgProcessor
imgProcessor/filters/addNoise.py
addNoise
def addNoise(img, snr=25, rShot=0.5): ''' adds Gaussian (thermal) and shot noise to [img] [img] is assumed to be noise free [rShot] - shot noise ratio relative to all noise ''' s0, s1 = img.shape[:2] m = img.mean() if np.isnan(m): m = np.nanmean(img) assert m...
python
def addNoise(img, snr=25, rShot=0.5): ''' adds Gaussian (thermal) and shot noise to [img] [img] is assumed to be noise free [rShot] - shot noise ratio relative to all noise ''' s0, s1 = img.shape[:2] m = img.mean() if np.isnan(m): m = np.nanmean(img) assert m...
[ "def", "addNoise", "(", "img", ",", "snr", "=", "25", ",", "rShot", "=", "0.5", ")", ":", "s0", ",", "s1", "=", "img", ".", "shape", "[", ":", "2", "]", "m", "=", "img", ".", "mean", "(", ")", "if", "np", ".", "isnan", "(", "m", ")", ":",...
adds Gaussian (thermal) and shot noise to [img] [img] is assumed to be noise free [rShot] - shot noise ratio relative to all noise
[ "adds", "Gaussian", "(", "thermal", ")", "and", "shot", "noise", "to", "[", "img", "]", "[", "img", "]", "is", "assumed", "to", "be", "noise", "free", "[", "rShot", "]", "-", "shot", "noise", "ratio", "relative", "to", "all", "noise" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/addNoise.py#L4-L25
train
Add noise to the image and return the new image
radjkarl/imgProcessor
imgProcessor/filters/coarseMaximum.py
coarseMaximum
def coarseMaximum(arr, shape): ''' return an array of [shape] where every cell equals the localised maximum of the given array [arr] at the same (scalled) position ''' ss0, ss1 = shape s0, s1 = arr.shape pos0 = linspace2(0, s0, ss0, dtype=int) pos1 = linspace2(0, s1, ss1, ...
python
def coarseMaximum(arr, shape): ''' return an array of [shape] where every cell equals the localised maximum of the given array [arr] at the same (scalled) position ''' ss0, ss1 = shape s0, s1 = arr.shape pos0 = linspace2(0, s0, ss0, dtype=int) pos1 = linspace2(0, s1, ss1, ...
[ "def", "coarseMaximum", "(", "arr", ",", "shape", ")", ":", "ss0", ",", "ss1", "=", "shape", "s0", ",", "s1", "=", "arr", ".", "shape", "pos0", "=", "linspace2", "(", "0", ",", "s0", ",", "ss0", ",", "dtype", "=", "int", ")", "pos1", "=", "lins...
return an array of [shape] where every cell equals the localised maximum of the given array [arr] at the same (scalled) position
[ "return", "an", "array", "of", "[", "shape", "]", "where", "every", "cell", "equals", "the", "localised", "maximum", "of", "the", "given", "array", "[", "arr", "]", "at", "the", "same", "(", "scalled", ")", "position" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/coarseMaximum.py#L8-L25
train
Returns an array of the given shape coarse - maximum of the given array.
radjkarl/imgProcessor
imgProcessor/equations/angleOfView.py
angleOfView
def angleOfView(XY, shape=None, a=None, f=None, D=None, center=None): ''' Another vignetting equation from: M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control" 2009 f --> Focal length D --> Diameter of the aper...
python
def angleOfView(XY, shape=None, a=None, f=None, D=None, center=None): ''' Another vignetting equation from: M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control" 2009 f --> Focal length D --> Diameter of the aper...
[ "def", "angleOfView", "(", "XY", ",", "shape", "=", "None", ",", "a", "=", "None", ",", "f", "=", "None", ",", "D", "=", "None", ",", "center", "=", "None", ")", ":", "if", "a", "is", "None", ":", "assert", "f", "is", "not", "None", "and", "D...
Another vignetting equation from: M. Koentges, M. Siebert, and D. Hinken, "Quantitative analysis of PV-modules by electroluminescence images for quality control" 2009 f --> Focal length D --> Diameter of the aperture BOTH, D AND f NEED TO HAVE SAME UNIT [PX, mm ...] a --> Angular a...
[ "Another", "vignetting", "equation", "from", ":", "M", ".", "Koentges", "M", ".", "Siebert", "and", "D", ".", "Hinken", "Quantitative", "analysis", "of", "PV", "-", "modules", "by", "electroluminescence", "images", "for", "quality", "control", "2009", "f", "...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L12-L40
train
Returns the angle of view of the aperture given the specified parameters
radjkarl/imgProcessor
imgProcessor/equations/angleOfView.py
angleOfView2
def angleOfView2(x,y, b, x0=None,y0=None): ''' Corrected AngleOfView equation by Koentges (via mail from 14/02/2017) b --> distance between the camera and the module in m x0 --> viewable with in the module plane of the camera in m y0 --> viewable height in the module plane of the camera in m ...
python
def angleOfView2(x,y, b, x0=None,y0=None): ''' Corrected AngleOfView equation by Koentges (via mail from 14/02/2017) b --> distance between the camera and the module in m x0 --> viewable with in the module plane of the camera in m y0 --> viewable height in the module plane of the camera in m ...
[ "def", "angleOfView2", "(", "x", ",", "y", ",", "b", ",", "x0", "=", "None", ",", "y0", "=", "None", ")", ":", "if", "x0", "is", "None", ":", "x0", "=", "x", "[", "-", "1", ",", "-", "1", "]", "if", "y0", "is", "None", ":", "y0", "=", "...
Corrected AngleOfView equation by Koentges (via mail from 14/02/2017) b --> distance between the camera and the module in m x0 --> viewable with in the module plane of the camera in m y0 --> viewable height in the module plane of the camera in m x,y --> pixel position [m] from top left
[ "Corrected", "AngleOfView", "equation", "by", "Koentges", "(", "via", "mail", "from", "14", "/", "02", "/", "2017", ")", "b", "--", ">", "distance", "between", "the", "camera", "and", "the", "module", "in", "m", "x0", "--", ">", "viewable", "with", "in...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/angleOfView.py#L43-L56
train
Returns the angle of view between two camera modules.
radjkarl/imgProcessor
imgProcessor/utils/gridLinesFromVertices.py
gridLinesFromVertices
def gridLinesFromVertices(edges, nCells, subgrid=None, dtype=float): """ ###TODO REDO TXT OPTIONAL: subgrid = ([x],[y]) --> relative positions e.g. subgrid = ( (0.3,0.7), () ) --> two subgrid lines in x - nothing in y Returns: horiz,vert -> arrays of (x,y) ...
python
def gridLinesFromVertices(edges, nCells, subgrid=None, dtype=float): """ ###TODO REDO TXT OPTIONAL: subgrid = ([x],[y]) --> relative positions e.g. subgrid = ( (0.3,0.7), () ) --> two subgrid lines in x - nothing in y Returns: horiz,vert -> arrays of (x,y) ...
[ "def", "gridLinesFromVertices", "(", "edges", ",", "nCells", ",", "subgrid", "=", "None", ",", "dtype", "=", "float", ")", ":", "nx", ",", "ny", "=", "nCells", "y", ",", "x", "=", "np", ".", "mgrid", "[", "0.", ":", "ny", "+", "1", ",", "0.", "...
###TODO REDO TXT OPTIONAL: subgrid = ([x],[y]) --> relative positions e.g. subgrid = ( (0.3,0.7), () ) --> two subgrid lines in x - nothing in y Returns: horiz,vert -> arrays of (x,y) poly-lines if subgrid != None, Returns: horiz,vert, subhoriz,...
[ "###TODO", "REDO", "TXT", "OPTIONAL", ":", "subgrid", "=", "(", "[", "x", "]", "[", "y", "]", ")", "--", ">", "relative", "positions", "e", ".", "g", ".", "subgrid", "=", "(", "(", "0", ".", "3", "0", ".", "7", ")", "()", ")", "--", ">", "t...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/gridLinesFromVertices.py#L39-L107
train
Returns a 2d grid of nCells lines from a list of edges.
radjkarl/imgProcessor
imgProcessor/measure/sharpness/_base.py
SharpnessBase.MTF50
def MTF50(self, MTFx,MTFy): ''' return object resolution as [line pairs/mm] where MTF=50% see http://www.imatest.com/docs/sharpness/ ''' if self.mtf_x is None: self.MTF() f = UnivariateSpline(self.mtf_x, self.mtf_y-0.5) r...
python
def MTF50(self, MTFx,MTFy): ''' return object resolution as [line pairs/mm] where MTF=50% see http://www.imatest.com/docs/sharpness/ ''' if self.mtf_x is None: self.MTF() f = UnivariateSpline(self.mtf_x, self.mtf_y-0.5) r...
[ "def", "MTF50", "(", "self", ",", "MTFx", ",", "MTFy", ")", ":", "if", "self", ".", "mtf_x", "is", "None", ":", "self", ".", "MTF", "(", ")", "f", "=", "UnivariateSpline", "(", "self", ".", "mtf_x", ",", "self", ".", "mtf_y", "-", "0.5", ")", "...
return object resolution as [line pairs/mm] where MTF=50% see http://www.imatest.com/docs/sharpness/
[ "return", "object", "resolution", "as", "[", "line", "pairs", "/", "mm", "]", "where", "MTF", "=", "50%", "see", "http", ":", "//", "www", ".", "imatest", ".", "com", "/", "docs", "/", "sharpness", "/" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L21-L30
train
Returns the most recent object resolution as [ line pairs / mm ] where MTF = 50% of the given time frame.
radjkarl/imgProcessor
imgProcessor/measure/sharpness/_base.py
SharpnessBase.MTF
def MTF(self, px_per_mm): ''' px_per_mm = cam_resolution / image_size ''' res = 100 #numeric resolution r = 4 #range +-r*std #size of 1 px: px_size = 1 / px_per_mm #standard deviation of the point-spread-function (PSF) as normal...
python
def MTF(self, px_per_mm): ''' px_per_mm = cam_resolution / image_size ''' res = 100 #numeric resolution r = 4 #range +-r*std #size of 1 px: px_size = 1 / px_per_mm #standard deviation of the point-spread-function (PSF) as normal...
[ "def", "MTF", "(", "self", ",", "px_per_mm", ")", ":", "res", "=", "100", "#numeric resolution\r", "r", "=", "4", "#range +-r*std\r", "#size of 1 px:\r", "px_size", "=", "1", "/", "px_per_mm", "#standard deviation of the point-spread-function (PSF) as normal distributed:\...
px_per_mm = cam_resolution / image_size
[ "px_per_mm", "=", "cam_resolution", "/", "image_size" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L33-L62
train
Returns the MTF and the MTF_y values for the most recent image.
radjkarl/imgProcessor
imgProcessor/measure/sharpness/_base.py
SharpnessBase.uncertaintyMap
def uncertaintyMap(self, psf, method='convolve', fitParams=None): ''' return the intensity based uncertainty due to the unsharpness of the image as standard deviation method = ['convolve' , 'unsupervised_wiener'] latter one also returns the reconstructe...
python
def uncertaintyMap(self, psf, method='convolve', fitParams=None): ''' return the intensity based uncertainty due to the unsharpness of the image as standard deviation method = ['convolve' , 'unsupervised_wiener'] latter one also returns the reconstructe...
[ "def", "uncertaintyMap", "(", "self", ",", "psf", ",", "method", "=", "'convolve'", ",", "fitParams", "=", "None", ")", ":", "#ignore background:\r", "#img[img<0]=0\r", "###noise should not influence sharpness uncertainty:\r", "##img = median_filter(img, 3)\r", "# decrease no...
return the intensity based uncertainty due to the unsharpness of the image as standard deviation method = ['convolve' , 'unsupervised_wiener'] latter one also returns the reconstructed image (deconvolution)
[ "return", "the", "intensity", "based", "uncertainty", "due", "to", "the", "unsharpness", "of", "the", "image", "as", "standard", "deviation", "method", "=", "[", "convolve", "unsupervised_wiener", "]", "latter", "one", "also", "returns", "the", "reconstructed", ...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L66-L100
train
Returns the intensity based uncertainty due to the unsharpness of the image as standard deviation
radjkarl/imgProcessor
imgProcessor/measure/sharpness/_base.py
SharpnessBase.stdDev
def stdDev(self): ''' get the standard deviation from the PSF is evaluated as 2d Gaussian ''' if self._corrPsf is None: self.psf() p = self._corrPsf.copy() mn = p.min() p[p<0.05*p.max()] = mn p-=mn p/=p.sum() ...
python
def stdDev(self): ''' get the standard deviation from the PSF is evaluated as 2d Gaussian ''' if self._corrPsf is None: self.psf() p = self._corrPsf.copy() mn = p.min() p[p<0.05*p.max()] = mn p-=mn p/=p.sum() ...
[ "def", "stdDev", "(", "self", ")", ":", "if", "self", ".", "_corrPsf", "is", "None", ":", "self", ".", "psf", "(", ")", "p", "=", "self", ".", "_corrPsf", ".", "copy", "(", ")", "mn", "=", "p", ".", "min", "(", ")", "p", "[", "p", "<", "0.0...
get the standard deviation from the PSF is evaluated as 2d Gaussian
[ "get", "the", "standard", "deviation", "from", "the", "PSF", "is", "evaluated", "as", "2d", "Gaussian" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/_base.py#L160-L185
train
get the standard deviation of the current time - domain entry from the PSF is evaluated as 2d Gaussian self. _corrPsf is None
radjkarl/imgProcessor
imgProcessor/interpolate/interpolate2dStructuredIDW.py
interpolate2dStructuredIDW
def interpolate2dStructuredIDW(grid, mask, kernel=15, power=2, fx=1, fy=1): ''' replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px+-kernel [power] -> distance weighting factor: 1/distance**[power] ''' weights = ...
python
def interpolate2dStructuredIDW(grid, mask, kernel=15, power=2, fx=1, fy=1): ''' replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px+-kernel [power] -> distance weighting factor: 1/distance**[power] ''' weights = ...
[ "def", "interpolate2dStructuredIDW", "(", "grid", ",", "mask", ",", "kernel", "=", "15", ",", "power", "=", "2", ",", "fx", "=", "1", ",", "fy", "=", "1", ")", ":", "weights", "=", "np", ".", "empty", "(", "shape", "=", "(", "(", "2", "*", "ker...
replace all values in [grid] indicated by [mask] with the inverse distance weighted interpolation of all values within px+-kernel [power] -> distance weighting factor: 1/distance**[power]
[ "replace", "all", "values", "in", "[", "grid", "]", "indicated", "by", "[", "mask", "]", "with", "the", "inverse", "distance", "weighted", "interpolation", "of", "all", "values", "within", "px", "+", "-", "kernel", "[", "power", "]", "-", ">", "distance"...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/interpolate/interpolate2dStructuredIDW.py#L8-L23
train
interpolate all values in a 2D structured IDW grid with inverse distance weighted interpolation of all values in a 2D structured IDW grid
radjkarl/imgProcessor
imgProcessor/uncertainty/temporalSignalStability.py
temporalSignalStability
def temporalSignalStability(imgs, times, down_scale_factor=1): ''' (Electroluminescence) signal is not stable over time especially next to cracks. This function takes a set of images and returns parameters, needed to transform uncertainty to other exposure times using [adjustUncer...
python
def temporalSignalStability(imgs, times, down_scale_factor=1): ''' (Electroluminescence) signal is not stable over time especially next to cracks. This function takes a set of images and returns parameters, needed to transform uncertainty to other exposure times using [adjustUncer...
[ "def", "temporalSignalStability", "(", "imgs", ",", "times", ",", "down_scale_factor", "=", "1", ")", ":", "imgs", "=", "np", ".", "asarray", "(", "imgs", ")", "s0", ",", "s1", ",", "s2", "=", "imgs", ".", "shape", "#down scale imgs to speed up process:\r", ...
(Electroluminescence) signal is not stable over time especially next to cracks. This function takes a set of images and returns parameters, needed to transform uncertainty to other exposure times using [adjustUncertToExposureTime] return [signal uncertainty] obtained from l...
[ "(", "Electroluminescence", ")", "signal", "is", "not", "stable", "over", "time", "especially", "next", "to", "cracks", ".", "This", "function", "takes", "a", "set", "of", "images", "and", "returns", "parameters", "needed", "to", "transform", "uncertainty", "t...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/temporalSignalStability.py#L12-L80
train
This function takes a set of images and returns a set of time - dependent Electrouminescence signal parameters needed to transform the uncertainty of each image to other exposure times using adjustUncertToExposureTime.
radjkarl/imgProcessor
imgProcessor/camera/flatField/vignettingFromSpotAverage.py
vignettingFromSpotAverage
def vignettingFromSpotAverage( images, bgImages=None, averageSpot=True, thresh=None): ''' [images] --> list of images containing small bright spots generated by the same device images at different positions within image plane depending on the calibrat...
python
def vignettingFromSpotAverage( images, bgImages=None, averageSpot=True, thresh=None): ''' [images] --> list of images containing small bright spots generated by the same device images at different positions within image plane depending on the calibrat...
[ "def", "vignettingFromSpotAverage", "(", "images", ",", "bgImages", "=", "None", ",", "averageSpot", "=", "True", ",", "thresh", "=", "None", ")", ":", "fitimg", ",", "mask", "=", "None", ",", "None", "mx", "=", "0", "for", "c", ",", "img", "in", "en...
[images] --> list of images containing small bright spots generated by the same device images at different positions within image plane depending on the calibrated waveband the device can be a LCD display or PV 1-cell mini module This method is refe...
[ "[", "images", "]", "--", ">", "list", "of", "images", "containing", "small", "bright", "spots", "generated", "by", "the", "same", "device", "images", "at", "different", "positions", "within", "image", "plane", "depending", "on", "the", "calibrated", "waveband...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/vignettingFromSpotAverage.py#L15-L85
train
Returns a new image mask containing the small bright spots generated by the same AttributeNames image mask containing valid positions and background images that are at different positions within the same AttributeNames image mask containing valid positions.
radjkarl/imgProcessor
imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py
simulateSytematicError
def simulateSytematicError(N_SAMPLES=5, N_IMAGES=10, SHOW_DETECTED_PATTERN=True, # GRAYSCALE=False, HEIGHT=500, PLOT_RESULTS=True, PLOT_ERROR_ARRAY=True, CAMERA_PARAM=None, PERSPECTIVE=True, ROTATION=True, R...
python
def simulateSytematicError(N_SAMPLES=5, N_IMAGES=10, SHOW_DETECTED_PATTERN=True, # GRAYSCALE=False, HEIGHT=500, PLOT_RESULTS=True, PLOT_ERROR_ARRAY=True, CAMERA_PARAM=None, PERSPECTIVE=True, ROTATION=True, R...
[ "def", "simulateSytematicError", "(", "N_SAMPLES", "=", "5", ",", "N_IMAGES", "=", "10", ",", "SHOW_DETECTED_PATTERN", "=", "True", ",", "# GRAYSCALE=False,\r", "HEIGHT", "=", "500", ",", "PLOT_RESULTS", "=", "True", ",", "PLOT_ERROR_ARRAY", "=", "True", ",", ...
Simulates a lens calibration using synthetic images * images are rendered under the given HEIGHT resolution * noise and smoothing is applied * perspective and position errors are applied * images are deformed using the given CAMERA_PARAM * the detected camera parameters are used to calculate ...
[ "Simulates", "a", "lens", "calibration", "using", "synthetic", "images", "*", "images", "are", "rendered", "under", "the", "given", "HEIGHT", "resolution", "*", "noise", "and", "smoothing", "is", "applied", "*", "perspective", "and", "position", "errors", "are",...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/lens/estimateSystematicErrorLensCorrection.py#L24-L384
train
Simulates a synthetic image using the given parameters and returns a new list of synthetic images.
radjkarl/imgProcessor
imgProcessor/scripts/_FitHistogramPeaks.py
plotSet
def plotSet(imgDir, posExTime, outDir, show_legend, show_plots, save_to_file, ftype): ''' creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram from all images within [imgDir] posExTime - position range of the exposure time in the image name e.g.: img_30...
python
def plotSet(imgDir, posExTime, outDir, show_legend, show_plots, save_to_file, ftype): ''' creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram from all images within [imgDir] posExTime - position range of the exposure time in the image name e.g.: img_30...
[ "def", "plotSet", "(", "imgDir", ",", "posExTime", ",", "outDir", ",", "show_legend", ",", "show_plots", ",", "save_to_file", ",", "ftype", ")", ":", "xvals", "=", "[", "]", "hist", "=", "[", "]", "peaks", "=", "[", "]", "exTimes", "=", "[", "]", "...
creates plots showing both found GAUSSIAN peaks, the histogram, a smoothed histogram from all images within [imgDir] posExTime - position range of the exposure time in the image name e.g.: img_30s.jpg -> (4,5) outDir - dirname to save the output images show_legend - True/False show_plots - di...
[ "creates", "plots", "showing", "both", "found", "GAUSSIAN", "peaks", "the", "histogram", "a", "smoothed", "histogram", "from", "all", "images", "within", "[", "imgDir", "]", "posExTime", "-", "position", "range", "of", "the", "exposure", "time", "in", "the", ...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/scripts/_FitHistogramPeaks.py#L47-L126
train
Plots a set of GAUSSIAN peaks and a smoothed histogram of all images within the image dir.
radjkarl/imgProcessor
imgProcessor/camera/flatField/flatFieldFromCloseDistance.py
flatFieldFromCloseDistance
def flatFieldFromCloseDistance(imgs, bg_imgs=None): ''' Average multiple images of a homogeneous device imaged directly in front the camera lens. if [bg_imgs] are not given, background level is extracted from 1% of the cumulative intensity distribution of the averaged [imgs] ...
python
def flatFieldFromCloseDistance(imgs, bg_imgs=None): ''' Average multiple images of a homogeneous device imaged directly in front the camera lens. if [bg_imgs] are not given, background level is extracted from 1% of the cumulative intensity distribution of the averaged [imgs] ...
[ "def", "flatFieldFromCloseDistance", "(", "imgs", ",", "bg_imgs", "=", "None", ")", ":", "img", "=", "imgAverage", "(", "imgs", ")", "bg", "=", "getBackground2", "(", "bg_imgs", ",", "img", ")", "img", "-=", "bg", "img", "=", "toGray", "(", "img", ")",...
Average multiple images of a homogeneous device imaged directly in front the camera lens. if [bg_imgs] are not given, background level is extracted from 1% of the cumulative intensity distribution of the averaged [imgs] This measurement method is referred as 'Method A' in --- ...
[ "Average", "multiple", "images", "of", "a", "homogeneous", "device", "imaged", "directly", "in", "front", "the", "camera", "lens", ".", "if", "[", "bg_imgs", "]", "are", "not", "given", "background", "level", "is", "extracted", "from", "1%", "of", "the", "...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/flatFieldFromCloseDistance.py#L16-L38
train
This function calculates the flat field from the close distance of the images given by images and background levels.
radjkarl/imgProcessor
imgProcessor/camera/flatField/flatFieldFromCloseDistance.py
flatFieldFromCloseDistance2
def flatFieldFromCloseDistance2(images, bgImages=None, calcStd=False, nlf=None, nstd=6): ''' Same as [flatFieldFromCloseDistance]. Differences are: ... single-time-effect removal included ... returns the standard deviation of the image average [calcStd=True] O...
python
def flatFieldFromCloseDistance2(images, bgImages=None, calcStd=False, nlf=None, nstd=6): ''' Same as [flatFieldFromCloseDistance]. Differences are: ... single-time-effect removal included ... returns the standard deviation of the image average [calcStd=True] O...
[ "def", "flatFieldFromCloseDistance2", "(", "images", ",", "bgImages", "=", "None", ",", "calcStd", "=", "False", ",", "nlf", "=", "None", ",", "nstd", "=", "6", ")", ":", "if", "len", "(", "images", ")", ">", "1", ":", "# start with brightest images\r", ...
Same as [flatFieldFromCloseDistance]. Differences are: ... single-time-effect removal included ... returns the standard deviation of the image average [calcStd=True] Optional: ----------- calcStd -> set to True to also return the standard deviation nlf -> noise level function (callable) ...
[ "Same", "as", "[", "flatFieldFromCloseDistance", "]", ".", "Differences", "are", ":", "...", "single", "-", "time", "-", "effect", "removal", "included", "...", "returns", "the", "standard", "deviation", "of", "the", "image", "average", "[", "calcStd", "=", ...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/flatField/flatFieldFromCloseDistance.py#L41-L96
train
Returns the flat field from close distance images.
radjkarl/imgProcessor
imgProcessor/measure/SNR/SNR_hinken.py
SNR_hinken
def SNR_hinken(imgs, bg=0, roi=None): ''' signal-to-noise ratio (SNR) as mean(images) / std(images) as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766) works on unloaded images no memory overload if too many images are given ''' mean = None M = len(imgs) if bg is...
python
def SNR_hinken(imgs, bg=0, roi=None): ''' signal-to-noise ratio (SNR) as mean(images) / std(images) as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766) works on unloaded images no memory overload if too many images are given ''' mean = None M = len(imgs) if bg is...
[ "def", "SNR_hinken", "(", "imgs", ",", "bg", "=", "0", ",", "roi", "=", "None", ")", ":", "mean", "=", "None", "M", "=", "len", "(", "imgs", ")", "if", "bg", "is", "not", "0", ":", "bg", "=", "imread", "(", "bg", ")", "[", "roi", "]", "if",...
signal-to-noise ratio (SNR) as mean(images) / std(images) as defined in Hinken et.al. 2011 (DOI: 10.1063/1.3541766) works on unloaded images no memory overload if too many images are given
[ "signal", "-", "to", "-", "noise", "ratio", "(", "SNR", ")", "as", "mean", "(", "images", ")", "/", "std", "(", "images", ")", "as", "defined", "in", "Hinken", "et", ".", "al", ".", "2011", "(", "DOI", ":", "10", ".", "1063", "/", "1", ".", "...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/SNR/SNR_hinken.py#L8-L44
train
Calculates the signal - to - noise ratio of the given images.
radjkarl/imgProcessor
imgProcessor/transform/boolImg.py
boolMasksToImage
def boolMasksToImage(masks): ''' Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int) to one 8bit image ''' assert len(masks) <= 8, 'can only transform up to 8 masks into image' masks = np.asarray(masks, dtype=np.uint8) assert masks.ndim == 3, 'layers need to be stack of...
python
def boolMasksToImage(masks): ''' Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int) to one 8bit image ''' assert len(masks) <= 8, 'can only transform up to 8 masks into image' masks = np.asarray(masks, dtype=np.uint8) assert masks.ndim == 3, 'layers need to be stack of...
[ "def", "boolMasksToImage", "(", "masks", ")", ":", "assert", "len", "(", "masks", ")", "<=", "8", ",", "'can only transform up to 8 masks into image'", "masks", "=", "np", ".", "asarray", "(", "masks", ",", "dtype", "=", "np", ".", "uint8", ")", "assert", ...
Transform at maximum 8 bool layers --> 2d arrays, dtype=(bool,int) to one 8bit image
[ "Transform", "at", "maximum", "8", "bool", "layers", "--", ">", "2d", "arrays", "dtype", "=", "(", "bool", "int", ")", "to", "one", "8bit", "image" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/boolImg.py#L4-L12
train
Transform at maximum 8 bool layers --> 2d arrays dtype = bool int array
radjkarl/imgProcessor
imgProcessor/transform/boolImg.py
imageToBoolMasks
def imageToBoolMasks(arr): '''inverse of [boolMasksToImage]''' assert arr.dtype == np.uint8, 'image needs to be dtype=uint8' masks = np.unpackbits(arr).reshape(*arr.shape, 8) return np.swapaxes(masks, 2, 0)
python
def imageToBoolMasks(arr): '''inverse of [boolMasksToImage]''' assert arr.dtype == np.uint8, 'image needs to be dtype=uint8' masks = np.unpackbits(arr).reshape(*arr.shape, 8) return np.swapaxes(masks, 2, 0)
[ "def", "imageToBoolMasks", "(", "arr", ")", ":", "assert", "arr", ".", "dtype", "==", "np", ".", "uint8", ",", "'image needs to be dtype=uint8'", "masks", "=", "np", ".", "unpackbits", "(", "arr", ")", ".", "reshape", "(", "*", "arr", ".", "shape", ",", ...
inverse of [boolMasksToImage]
[ "inverse", "of", "[", "boolMasksToImage", "]" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/boolImg.py#L15-L19
train
inverse of [ boolMasksToImage ]
radjkarl/imgProcessor
imgProcessor/utils/calcAspectRatioFromCorners.py
calcAspectRatioFromCorners
def calcAspectRatioFromCorners(corners, in_plane=False): ''' simple and better alg. than below in_plane -> whether object has no tilt, but only rotation and translation ''' q = corners l0 = [q[0, 0], q[0, 1], q[1, 0], q[1, 1]] l1 = [q[0, 0], q[0, 1], q[-1, 0], q[-1, 1]] l2 = ...
python
def calcAspectRatioFromCorners(corners, in_plane=False): ''' simple and better alg. than below in_plane -> whether object has no tilt, but only rotation and translation ''' q = corners l0 = [q[0, 0], q[0, 1], q[1, 0], q[1, 1]] l1 = [q[0, 0], q[0, 1], q[-1, 0], q[-1, 1]] l2 = ...
[ "def", "calcAspectRatioFromCorners", "(", "corners", ",", "in_plane", "=", "False", ")", ":", "q", "=", "corners", "l0", "=", "[", "q", "[", "0", ",", "0", "]", ",", "q", "[", "0", ",", "1", "]", ",", "q", "[", "1", ",", "0", "]", ",", "q", ...
simple and better alg. than below in_plane -> whether object has no tilt, but only rotation and translation
[ "simple", "and", "better", "alg", ".", "than", "below", "in_plane", "-", ">", "whether", "object", "has", "no", "tilt", "but", "only", "rotation", "and", "translation" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/calcAspectRatioFromCorners.py#L8-L32
train
Calculates the aspect ratio of a new object from a list of corners.
radjkarl/imgProcessor
imgProcessor/utils/putTextAlpha.py
putTextAlpha
def putTextAlpha(img, text, alpha, org, fontFace, fontScale, color, thickness): # , lineType=None ''' Extends cv2.putText with [alpha] argument ''' x, y = cv2.getTextSize(text, fontFace, fontScale, thickness)[0] ox, oy = org imgcut = img...
python
def putTextAlpha(img, text, alpha, org, fontFace, fontScale, color, thickness): # , lineType=None ''' Extends cv2.putText with [alpha] argument ''' x, y = cv2.getTextSize(text, fontFace, fontScale, thickness)[0] ox, oy = org imgcut = img...
[ "def", "putTextAlpha", "(", "img", ",", "text", ",", "alpha", ",", "org", ",", "fontFace", ",", "fontScale", ",", "color", ",", "thickness", ")", ":", "# , lineType=None\r", "x", ",", "y", "=", "cv2", ".", "getTextSize", "(", "text", ",", "fontFace", "...
Extends cv2.putText with [alpha] argument
[ "Extends", "cv2", ".", "putText", "with", "[", "alpha", "]", "argument" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/utils/putTextAlpha.py#L10-L35
train
Adds text to image with alpha color.
radjkarl/imgProcessor
imgProcessor/filters/fastMean.py
fastMean
def fastMean(img, f=10, inplace=False): ''' for bigger ksizes it if often faster to resize an image rather than blur it... ''' s0,s1 = img.shape[:2] ss0 = int(round(s0/f)) ss1 = int(round(s1/f)) small = cv2.resize(img,(ss1,ss0), interpolation=cv2.INTER_AREA) #bigger ...
python
def fastMean(img, f=10, inplace=False): ''' for bigger ksizes it if often faster to resize an image rather than blur it... ''' s0,s1 = img.shape[:2] ss0 = int(round(s0/f)) ss1 = int(round(s1/f)) small = cv2.resize(img,(ss1,ss0), interpolation=cv2.INTER_AREA) #bigger ...
[ "def", "fastMean", "(", "img", ",", "f", "=", "10", ",", "inplace", "=", "False", ")", ":", "s0", ",", "s1", "=", "img", ".", "shape", "[", ":", "2", "]", "ss0", "=", "int", "(", "round", "(", "s0", "/", "f", ")", ")", "ss1", "=", "int", ...
for bigger ksizes it if often faster to resize an image rather than blur it...
[ "for", "bigger", "ksizes", "it", "if", "often", "faster", "to", "resize", "an", "image", "rather", "than", "blur", "it", "..." ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/fastMean.py#L5-L19
train
fast mean resize
radjkarl/imgProcessor
setup.py
read
def read(*paths): """Build a file path from *paths* and return the contents.""" try: f_name = os.path.join(*paths) with open(f_name, 'r') as f: return f.read() except IOError: print('%s not existing ... skipping' % f_name) return ''
python
def read(*paths): """Build a file path from *paths* and return the contents.""" try: f_name = os.path.join(*paths) with open(f_name, 'r') as f: return f.read() except IOError: print('%s not existing ... skipping' % f_name) return ''
[ "def", "read", "(", "*", "paths", ")", ":", "try", ":", "f_name", "=", "os", ".", "path", ".", "join", "(", "*", "paths", ")", "with", "open", "(", "f_name", ",", "'r'", ")", "as", "f", ":", "return", "f", ".", "read", "(", ")", "except", "IO...
Build a file path from *paths* and return the contents.
[ "Build", "a", "file", "path", "from", "*", "paths", "*", "and", "return", "the", "contents", "." ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/setup.py#L16-L24
train
Build a file path from the given list of paths and return the contents.
radjkarl/imgProcessor
imgProcessor/camera/DarkCurrentMap.py
averageSameExpTimes
def averageSameExpTimes(imgs_path): ''' average background images with same exposure time ''' firsts = imgs_path[:2] imgs = imgs_path[2:] for n, i in enumerate(firsts): firsts[n] = np.asfarray(imread(i)) d = DarkCurrentMap(firsts) for i in imgs: i = imread(i) ...
python
def averageSameExpTimes(imgs_path): ''' average background images with same exposure time ''' firsts = imgs_path[:2] imgs = imgs_path[2:] for n, i in enumerate(firsts): firsts[n] = np.asfarray(imread(i)) d = DarkCurrentMap(firsts) for i in imgs: i = imread(i) ...
[ "def", "averageSameExpTimes", "(", "imgs_path", ")", ":", "firsts", "=", "imgs_path", "[", ":", "2", "]", "imgs", "=", "imgs_path", "[", "2", ":", "]", "for", "n", ",", "i", "in", "enumerate", "(", "firsts", ")", ":", "firsts", "[", "n", "]", "=", ...
average background images with same exposure time
[ "average", "background", "images", "with", "same", "exposure", "time" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L46-L58
train
Returns a DarkCurrentMap that has the average background images with same exposure time.
radjkarl/imgProcessor
imgProcessor/camera/DarkCurrentMap.py
getLinearityFunction
def getLinearityFunction(expTimes, imgs, mxIntensity=65535, min_ascent=0.001, ): ''' returns offset, ascent of image(expTime) = offset + ascent*expTime ''' # TODO: calculate [min_ascent] from noise function # instead of having it as variable ascent, offset...
python
def getLinearityFunction(expTimes, imgs, mxIntensity=65535, min_ascent=0.001, ): ''' returns offset, ascent of image(expTime) = offset + ascent*expTime ''' # TODO: calculate [min_ascent] from noise function # instead of having it as variable ascent, offset...
[ "def", "getLinearityFunction", "(", "expTimes", ",", "imgs", ",", "mxIntensity", "=", "65535", ",", "min_ascent", "=", "0.001", ",", ")", ":", "# TODO: calculate [min_ascent] from noise function\r", "# instead of having it as variable\r", "ascent", ",", "offset", ",", "...
returns offset, ascent of image(expTime) = offset + ascent*expTime
[ "returns", "offset", "ascent", "of", "image", "(", "expTime", ")", "=", "offset", "+", "ascent", "*", "expTime" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L61-L80
train
Returns the linear interpolation function for the given set of images.
radjkarl/imgProcessor
imgProcessor/camera/DarkCurrentMap.py
sortForSameExpTime
def sortForSameExpTime(expTimes, img_paths): # , excludeSingleImg=True): ''' return image paths sorted for same exposure time ''' d = {} for e, i in zip(expTimes, img_paths): if e not in d: d[e] = [] d[e].append(i) # for key in list(d.keys()): # if ...
python
def sortForSameExpTime(expTimes, img_paths): # , excludeSingleImg=True): ''' return image paths sorted for same exposure time ''' d = {} for e, i in zip(expTimes, img_paths): if e not in d: d[e] = [] d[e].append(i) # for key in list(d.keys()): # if ...
[ "def", "sortForSameExpTime", "(", "expTimes", ",", "img_paths", ")", ":", "# , excludeSingleImg=True):\r", "d", "=", "{", "}", "for", "e", ",", "i", "in", "zip", "(", "expTimes", ",", "img_paths", ")", ":", "if", "e", "not", "in", "d", ":", "d", "[", ...
return image paths sorted for same exposure time
[ "return", "image", "paths", "sorted", "for", "same", "exposure", "time" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L83-L98
train
sort image paths for same exposure time
radjkarl/imgProcessor
imgProcessor/camera/DarkCurrentMap.py
getDarkCurrentAverages
def getDarkCurrentAverages(exposuretimes, imgs): ''' return exposure times, image averages for each exposure time ''' x, imgs_p = sortForSameExpTime(exposuretimes, imgs) s0, s1 = imgs[0].shape imgs = np.empty(shape=(len(x), s0, s1), dtype=imgs[0].dtype) for i, i...
python
def getDarkCurrentAverages(exposuretimes, imgs): ''' return exposure times, image averages for each exposure time ''' x, imgs_p = sortForSameExpTime(exposuretimes, imgs) s0, s1 = imgs[0].shape imgs = np.empty(shape=(len(x), s0, s1), dtype=imgs[0].dtype) for i, i...
[ "def", "getDarkCurrentAverages", "(", "exposuretimes", ",", "imgs", ")", ":", "x", ",", "imgs_p", "=", "sortForSameExpTime", "(", "exposuretimes", ",", "imgs", ")", "s0", ",", "s1", "=", "imgs", "[", "0", "]", ".", "shape", "imgs", "=", "np", ".", "emp...
return exposure times, image averages for each exposure time
[ "return", "exposure", "times", "image", "averages", "for", "each", "exposure", "time" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L101-L115
train
Returns the exposure times and image averages for each exposure time returns exposure times and image averages for each exposure time returns exposure times imgs averages for each exposure time imgs_p returns imgs_p
radjkarl/imgProcessor
imgProcessor/camera/DarkCurrentMap.py
getDarkCurrentFunction
def getDarkCurrentFunction(exposuretimes, imgs, **kwargs): ''' get dark current function from given images and exposure times ''' exposuretimes, imgs = getDarkCurrentAverages(exposuretimes, imgs) offs, ascent, rmse = getLinearityFunction(exposuretimes, imgs, **kwargs) return offs, ascent, ...
python
def getDarkCurrentFunction(exposuretimes, imgs, **kwargs): ''' get dark current function from given images and exposure times ''' exposuretimes, imgs = getDarkCurrentAverages(exposuretimes, imgs) offs, ascent, rmse = getLinearityFunction(exposuretimes, imgs, **kwargs) return offs, ascent, ...
[ "def", "getDarkCurrentFunction", "(", "exposuretimes", ",", "imgs", ",", "*", "*", "kwargs", ")", ":", "exposuretimes", ",", "imgs", "=", "getDarkCurrentAverages", "(", "exposuretimes", ",", "imgs", ")", "offs", ",", "ascent", ",", "rmse", "=", "getLinearityFu...
get dark current function from given images and exposure times
[ "get", "dark", "current", "function", "from", "given", "images", "and", "exposure", "times" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/DarkCurrentMap.py#L118-L124
train
get dark current function from given images and exposure times
radjkarl/imgProcessor
imgProcessor/transform/alignImageAlongLine.py
alignImageAlongLine
def alignImageAlongLine(img, line, height=15, length=None, zoom=1, fast=False, borderValue=0): ''' return a sub image aligned along given line @param img - numpy.2darray input image to get subimage from @param line - list of 2 points [x0,y0,x1,y1]) @param height - he...
python
def alignImageAlongLine(img, line, height=15, length=None, zoom=1, fast=False, borderValue=0): ''' return a sub image aligned along given line @param img - numpy.2darray input image to get subimage from @param line - list of 2 points [x0,y0,x1,y1]) @param height - he...
[ "def", "alignImageAlongLine", "(", "img", ",", "line", ",", "height", "=", "15", ",", "length", "=", "None", ",", "zoom", "=", "1", ",", "fast", "=", "False", ",", "borderValue", "=", "0", ")", ":", "height", "=", "int", "(", "round", "(", "height"...
return a sub image aligned along given line @param img - numpy.2darray input image to get subimage from @param line - list of 2 points [x0,y0,x1,y1]) @param height - height of output array in y @param length - width of output array @param zoom - zoom factor @param fast - speed up calcul...
[ "return", "a", "sub", "image", "aligned", "along", "given", "line" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/alignImageAlongLine.py#L10-L60
train
Returns a subimage aligned along given line.
radjkarl/imgProcessor
imgProcessor/uncertainty/positionToIntensityUncertainty.py
positionToIntensityUncertainty
def positionToIntensityUncertainty(image, sx, sy, kernelSize=None): ''' calculates the estimated standard deviation map from the changes of neighbouring pixels from a center pixel within a point spread function defined by a std.dev. in x and y taken from the (sx, sy) maps sx,sy -> either 2d ...
python
def positionToIntensityUncertainty(image, sx, sy, kernelSize=None): ''' calculates the estimated standard deviation map from the changes of neighbouring pixels from a center pixel within a point spread function defined by a std.dev. in x and y taken from the (sx, sy) maps sx,sy -> either 2d ...
[ "def", "positionToIntensityUncertainty", "(", "image", ",", "sx", ",", "sy", ",", "kernelSize", "=", "None", ")", ":", "psf_is_const", "=", "not", "isinstance", "(", "sx", ",", "np", ".", "ndarray", ")", "if", "not", "psf_is_const", ":", "assert", "image",...
calculates the estimated standard deviation map from the changes of neighbouring pixels from a center pixel within a point spread function defined by a std.dev. in x and y taken from the (sx, sy) maps sx,sy -> either 2d array of same shape as [image] of single values
[ "calculates", "the", "estimated", "standard", "deviation", "map", "from", "the", "changes", "of", "neighbouring", "pixels", "from", "a", "center", "pixel", "within", "a", "point", "spread", "function", "defined", "by", "a", "std", ".", "dev", ".", "in", "x",...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/positionToIntensityUncertainty.py#L52-L87
train
Returns the estimated standard deviation map from the changes of neighbouring pixels from a center pixel within a point spread function within a center pixel within a point spread function within a center pixel within a point spread function within a center pixel within a point spread function in x and y t...
radjkarl/imgProcessor
imgProcessor/uncertainty/positionToIntensityUncertainty.py
_coarsenImage
def _coarsenImage(image, f): ''' seems to be a more precise (but slower) way to down-scale an image ''' from skimage.morphology import square from skimage.filters import rank from skimage.transform._warps import rescale selem = square(f) arri = rank.mean(image, selem=selem) ...
python
def _coarsenImage(image, f): ''' seems to be a more precise (but slower) way to down-scale an image ''' from skimage.morphology import square from skimage.filters import rank from skimage.transform._warps import rescale selem = square(f) arri = rank.mean(image, selem=selem) ...
[ "def", "_coarsenImage", "(", "image", ",", "f", ")", ":", "from", "skimage", ".", "morphology", "import", "square", "from", "skimage", ".", "filters", "import", "rank", "from", "skimage", ".", "transform", ".", "_warps", "import", "rescale", "selem", "=", ...
seems to be a more precise (but slower) way to down-scale an image
[ "seems", "to", "be", "a", "more", "precise", "(", "but", "slower", ")", "way", "to", "down", "-", "scale", "an", "image" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/positionToIntensityUncertainty.py#L94-L104
train
Returns a new image with the given number of coarsening components.
radjkarl/imgProcessor
imgProcessor/uncertainty/positionToIntensityUncertainty.py
positionToIntensityUncertaintyForPxGroup
def positionToIntensityUncertaintyForPxGroup(image, std, y0, y1, x0, x1): ''' like positionToIntensityUncertainty but calculated average uncertainty for an area [y0:y1,x0:x1] ''' fy, fx = y1 - y0, x1 - x0 if fy != fx: raise Exception('averaged area need to be square ATM') ima...
python
def positionToIntensityUncertaintyForPxGroup(image, std, y0, y1, x0, x1): ''' like positionToIntensityUncertainty but calculated average uncertainty for an area [y0:y1,x0:x1] ''' fy, fx = y1 - y0, x1 - x0 if fy != fx: raise Exception('averaged area need to be square ATM') ima...
[ "def", "positionToIntensityUncertaintyForPxGroup", "(", "image", ",", "std", ",", "y0", ",", "y1", ",", "x0", ",", "x1", ")", ":", "fy", ",", "fx", "=", "y1", "-", "y0", ",", "x1", "-", "x0", "if", "fy", "!=", "fx", ":", "raise", "Exception", "(", ...
like positionToIntensityUncertainty but calculated average uncertainty for an area [y0:y1,x0:x1]
[ "like", "positionToIntensityUncertainty", "but", "calculated", "average", "uncertainty", "for", "an", "area", "[", "y0", ":", "y1", "x0", ":", "x1", "]" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/uncertainty/positionToIntensityUncertainty.py#L107-L121
train
Like positionToIntensityUncertainty but calculated average uncertainty for an area [ y0 x0 x1
radjkarl/imgProcessor
imgProcessor/filters/nan_maximum_filter.py
nan_maximum_filter
def nan_maximum_filter(arr, ksize): ''' same as scipy.filters.maximum_filter but working excluding nans ''' out = np.empty_like(arr) _calc(arr, out, ksize//2) return out
python
def nan_maximum_filter(arr, ksize): ''' same as scipy.filters.maximum_filter but working excluding nans ''' out = np.empty_like(arr) _calc(arr, out, ksize//2) return out
[ "def", "nan_maximum_filter", "(", "arr", ",", "ksize", ")", ":", "out", "=", "np", ".", "empty_like", "(", "arr", ")", "_calc", "(", "arr", ",", "out", ",", "ksize", "//", "2", ")", "return", "out" ]
same as scipy.filters.maximum_filter but working excluding nans
[ "same", "as", "scipy", ".", "filters", ".", "maximum_filter", "but", "working", "excluding", "nans" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/nan_maximum_filter.py#L7-L14
train
same as scipy. filters. maximum_filter but working excluding nan
radjkarl/imgProcessor
imgProcessor/filters/fastFilter.py
fastFilter
def fastFilter(arr, ksize=30, every=None, resize=True, fn='median', interpolation=cv2.INTER_LANCZOS4, smoothksize=0, borderMode=cv2.BORDER_REFLECT): ''' fn['nanmean', 'mean', 'nanmedian', 'median'] a fast 2d filter for large kernel sizes that...
python
def fastFilter(arr, ksize=30, every=None, resize=True, fn='median', interpolation=cv2.INTER_LANCZOS4, smoothksize=0, borderMode=cv2.BORDER_REFLECT): ''' fn['nanmean', 'mean', 'nanmedian', 'median'] a fast 2d filter for large kernel sizes that...
[ "def", "fastFilter", "(", "arr", ",", "ksize", "=", "30", ",", "every", "=", "None", ",", "resize", "=", "True", ",", "fn", "=", "'median'", ",", "interpolation", "=", "cv2", ".", "INTER_LANCZOS4", ",", "smoothksize", "=", "0", ",", "borderMode", "=", ...
fn['nanmean', 'mean', 'nanmedian', 'median'] a fast 2d filter for large kernel sizes that also works with nans the computation speed is increased because only 'every'nsth position within the median kernel is evaluated
[ "fn", "[", "nanmean", "mean", "nanmedian", "median", "]", "a", "fast", "2d", "filter", "for", "large", "kernel", "sizes", "that", "also", "works", "with", "nans", "the", "computation", "speed", "is", "increased", "because", "only", "every", "nsth", "position...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/fastFilter.py#L9-L48
train
fast filter for large kernel sizes
radjkarl/imgProcessor
imgProcessor/reader/elbin.py
elbin
def elbin(filename): ''' Read EL images (*.elbin) created by the RELTRON EL Software http://www.reltron.com/Products/Solar.html ''' # arrs = [] labels = [] # These are all exposure times [s] to be selectable: TIMES = (0.3, 0.4, 0.6, 0.8, 1.2, 1.6, 2.4, 3.2, 4.8, 6.4, 9.6, 12.8,...
python
def elbin(filename): ''' Read EL images (*.elbin) created by the RELTRON EL Software http://www.reltron.com/Products/Solar.html ''' # arrs = [] labels = [] # These are all exposure times [s] to be selectable: TIMES = (0.3, 0.4, 0.6, 0.8, 1.2, 1.6, 2.4, 3.2, 4.8, 6.4, 9.6, 12.8,...
[ "def", "elbin", "(", "filename", ")", ":", "# arrs = []\r", "labels", "=", "[", "]", "# These are all exposure times [s] to be selectable:\r", "TIMES", "=", "(", "0.3", ",", "0.4", ",", "0.6", ",", "0.8", ",", "1.2", ",", "1.6", ",", "2.4", ",", "3.2", ...
Read EL images (*.elbin) created by the RELTRON EL Software http://www.reltron.com/Products/Solar.html
[ "Read", "EL", "images", "(", "*", ".", "elbin", ")", "created", "by", "the", "RELTRON", "EL", "Software", "http", ":", "//", "www", ".", "reltron", ".", "com", "/", "Products", "/", "Solar", ".", "html" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/reader/elbin.py#L7-L40
train
Reads the EL images created by the RELTRON EL Software and returns a list of tuples each containing the current time and the number of times in the image.
radjkarl/imgProcessor
imgProcessor/equations/gaussian2d.py
gaussian2d
def gaussian2d(xy, sx, sy, mx=0, my=0, rho=0, amp=1, offs=0): ''' see http://en.wikipedia.org/wiki/Multivariate_normal_distribution # probability density function of a vector [x,y] sx,sy -> sigma (standard deviation) mx,my: mue (mean position) rho: correlation between x and y ''' ...
python
def gaussian2d(xy, sx, sy, mx=0, my=0, rho=0, amp=1, offs=0): ''' see http://en.wikipedia.org/wiki/Multivariate_normal_distribution # probability density function of a vector [x,y] sx,sy -> sigma (standard deviation) mx,my: mue (mean position) rho: correlation between x and y ''' ...
[ "def", "gaussian2d", "(", "xy", ",", "sx", ",", "sy", ",", "mx", "=", "0", ",", "my", "=", "0", ",", "rho", "=", "0", ",", "amp", "=", "1", ",", "offs", "=", "0", ")", ":", "x", ",", "y", "=", "xy", "return", "offs", "+", "amp", "*", "(...
see http://en.wikipedia.org/wiki/Multivariate_normal_distribution # probability density function of a vector [x,y] sx,sy -> sigma (standard deviation) mx,my: mue (mean position) rho: correlation between x and y
[ "see", "http", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Multivariate_normal_distribution", "#", "probability", "density", "function", "of", "a", "vector", "[", "x", "y", "]", "sx", "sy", "-", ">", "sigma", "(", "standard", "devia...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/equations/gaussian2d.py#L5-L23
train
Returns the 2D gaussian distribution of a vector x y
radjkarl/imgProcessor
imgProcessor/transform/PerspectiveImageStitching.py
PerspectiveImageStitching.fitImg
def fitImg(self, img_rgb): ''' fit perspective and size of the input image to the base image ''' H = self.pattern.findHomography(img_rgb)[0] H_inv = self.pattern.invertHomography(H) s = self.img_orig.shape warped = cv2.warpPerspective(img_rgb, H_inv, (s[1],...
python
def fitImg(self, img_rgb): ''' fit perspective and size of the input image to the base image ''' H = self.pattern.findHomography(img_rgb)[0] H_inv = self.pattern.invertHomography(H) s = self.img_orig.shape warped = cv2.warpPerspective(img_rgb, H_inv, (s[1],...
[ "def", "fitImg", "(", "self", ",", "img_rgb", ")", ":", "H", "=", "self", ".", "pattern", ".", "findHomography", "(", "img_rgb", ")", "[", "0", "]", "H_inv", "=", "self", ".", "pattern", ".", "invertHomography", "(", "H", ")", "s", "=", "self", "."...
fit perspective and size of the input image to the base image
[ "fit", "perspective", "and", "size", "of", "the", "input", "image", "to", "the", "base", "image" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/PerspectiveImageStitching.py#L26-L34
train
fit perspective and size of the input image to the base image
radjkarl/imgProcessor
imgProcessor/imgSignal.py
scaleSignalCut
def scaleSignalCut(img, ratio, nbins=100): ''' scaling img cutting x percent of top and bottom part of histogram ''' start, stop = scaleSignalCutParams(img, ratio, nbins) img = img - start img /= (stop - start) return img
python
def scaleSignalCut(img, ratio, nbins=100): ''' scaling img cutting x percent of top and bottom part of histogram ''' start, stop = scaleSignalCutParams(img, ratio, nbins) img = img - start img /= (stop - start) return img
[ "def", "scaleSignalCut", "(", "img", ",", "ratio", ",", "nbins", "=", "100", ")", ":", "start", ",", "stop", "=", "scaleSignalCutParams", "(", "img", ",", "ratio", ",", "nbins", ")", "img", "=", "img", "-", "start", "img", "/=", "(", "stop", "-", "...
scaling img cutting x percent of top and bottom part of histogram
[ "scaling", "img", "cutting", "x", "percent", "of", "top", "and", "bottom", "part", "of", "histogram" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L14-L21
train
scale the img cutting x percent of top and bottom part of histogram
radjkarl/imgProcessor
imgProcessor/imgSignal.py
scaleSignal
def scaleSignal(img, fitParams=None, backgroundToZero=False, reference=None): ''' scale the image between... backgroundToZero=True -> 0 (average background) and 1 (maximum signal) backgroundToZero=False -> signal+-3std reference -> reference image -- scale image to fit this...
python
def scaleSignal(img, fitParams=None, backgroundToZero=False, reference=None): ''' scale the image between... backgroundToZero=True -> 0 (average background) and 1 (maximum signal) backgroundToZero=False -> signal+-3std reference -> reference image -- scale image to fit this...
[ "def", "scaleSignal", "(", "img", ",", "fitParams", "=", "None", ",", "backgroundToZero", "=", "False", ",", "reference", "=", "None", ")", ":", "img", "=", "imread", "(", "img", ")", "if", "reference", "is", "not", "None", ":", "# def fn(ii, m,n):...
scale the image between... backgroundToZero=True -> 0 (average background) and 1 (maximum signal) backgroundToZero=False -> signal+-3std reference -> reference image -- scale image to fit this one returns: scaled image
[ "scale", "the", "image", "between", "...", "backgroundToZero", "=", "True", "-", ">", "0", "(", "average", "background", ")", "and", "1", "(", "maximum", "signal", ")", "backgroundToZero", "=", "False", "-", ">", "signal", "+", "-", "3std", "reference", ...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L72-L104
train
scale the image between... and 1 - 3std
radjkarl/imgProcessor
imgProcessor/imgSignal.py
getBackgroundRange
def getBackgroundRange(fitParams): ''' return minimum, average, maximum of the background peak ''' smn, _, _ = getSignalParameters(fitParams) bg = fitParams[0] _, avg, std = bg bgmn = max(0, avg - 3 * std) if avg + 4 * std < smn: bgmx = avg + 4 * std if avg + 3 ...
python
def getBackgroundRange(fitParams): ''' return minimum, average, maximum of the background peak ''' smn, _, _ = getSignalParameters(fitParams) bg = fitParams[0] _, avg, std = bg bgmn = max(0, avg - 3 * std) if avg + 4 * std < smn: bgmx = avg + 4 * std if avg + 3 ...
[ "def", "getBackgroundRange", "(", "fitParams", ")", ":", "smn", ",", "_", ",", "_", "=", "getSignalParameters", "(", "fitParams", ")", "bg", "=", "fitParams", "[", "0", "]", "_", ",", "avg", ",", "std", "=", "bg", "bgmn", "=", "max", "(", "0", ",",...
return minimum, average, maximum of the background peak
[ "return", "minimum", "average", "maximum", "of", "the", "background", "peak" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L107-L125
train
Returns the minimum average maximum of the background peak peak
radjkarl/imgProcessor
imgProcessor/imgSignal.py
hasBackground
def hasBackground(fitParams): ''' compare the height of putative bg and signal peak if ratio if too height assume there is no background ''' signal = getSignalPeak(fitParams) bg = getBackgroundPeak(fitParams) if signal == bg: return False r = signal[0] / bg[0] if r ...
python
def hasBackground(fitParams): ''' compare the height of putative bg and signal peak if ratio if too height assume there is no background ''' signal = getSignalPeak(fitParams) bg = getBackgroundPeak(fitParams) if signal == bg: return False r = signal[0] / bg[0] if r ...
[ "def", "hasBackground", "(", "fitParams", ")", ":", "signal", "=", "getSignalPeak", "(", "fitParams", ")", "bg", "=", "getBackgroundPeak", "(", "fitParams", ")", "if", "signal", "==", "bg", ":", "return", "False", "r", "=", "signal", "[", "0", "]", "/", ...
compare the height of putative bg and signal peak if ratio if too height assume there is no background
[ "compare", "the", "height", "of", "putative", "bg", "and", "signal", "peak", "if", "ratio", "if", "too", "height", "assume", "there", "is", "no", "background" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L128-L140
train
check if there is background
radjkarl/imgProcessor
imgProcessor/imgSignal.py
signalMinimum2
def signalMinimum2(img, bins=None): ''' minimum position between signal and background peak ''' f = FitHistogramPeaks(img, bins=bins) i = signalPeakIndex(f.fitParams) spos = f.fitParams[i][1] # spos = getSignalPeak(f.fitParams)[1] # bpos = getBackgroundPeak(f.fitParams)[1] b...
python
def signalMinimum2(img, bins=None): ''' minimum position between signal and background peak ''' f = FitHistogramPeaks(img, bins=bins) i = signalPeakIndex(f.fitParams) spos = f.fitParams[i][1] # spos = getSignalPeak(f.fitParams)[1] # bpos = getBackgroundPeak(f.fitParams)[1] b...
[ "def", "signalMinimum2", "(", "img", ",", "bins", "=", "None", ")", ":", "f", "=", "FitHistogramPeaks", "(", "img", ",", "bins", "=", "bins", ")", "i", "=", "signalPeakIndex", "(", "f", ".", "fitParams", ")", "spos", "=", "f", ".", "fitParams", "[", ...
minimum position between signal and background peak
[ "minimum", "position", "between", "signal", "and", "background", "peak" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L161-L179
train
Returns the minimum position between signal and background peak.
radjkarl/imgProcessor
imgProcessor/imgSignal.py
signalMinimum
def signalMinimum(img, fitParams=None, n_std=3): ''' intersection between signal and background peak ''' if fitParams is None: fitParams = FitHistogramPeaks(img).fitParams assert len(fitParams) > 1, 'need 2 peaks so get minimum signal' i = signalPeakIndex(fitParams) signal ...
python
def signalMinimum(img, fitParams=None, n_std=3): ''' intersection between signal and background peak ''' if fitParams is None: fitParams = FitHistogramPeaks(img).fitParams assert len(fitParams) > 1, 'need 2 peaks so get minimum signal' i = signalPeakIndex(fitParams) signal ...
[ "def", "signalMinimum", "(", "img", ",", "fitParams", "=", "None", ",", "n_std", "=", "3", ")", ":", "if", "fitParams", "is", "None", ":", "fitParams", "=", "FitHistogramPeaks", "(", "img", ")", ".", "fitParams", "assert", "len", "(", "fitParams", ")", ...
intersection between signal and background peak
[ "intersection", "between", "signal", "and", "background", "peak" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L182-L213
train
get minimum signal peak
radjkarl/imgProcessor
imgProcessor/imgSignal.py
getSignalParameters
def getSignalParameters(fitParams, n_std=3): ''' return minimum, average, maximum of the signal peak ''' signal = getSignalPeak(fitParams) mx = signal[1] + n_std * signal[2] mn = signal[1] - n_std * signal[2] if mn < fitParams[0][1]: mn = fitParams[0][1] # set to bg ret...
python
def getSignalParameters(fitParams, n_std=3): ''' return minimum, average, maximum of the signal peak ''' signal = getSignalPeak(fitParams) mx = signal[1] + n_std * signal[2] mn = signal[1] - n_std * signal[2] if mn < fitParams[0][1]: mn = fitParams[0][1] # set to bg ret...
[ "def", "getSignalParameters", "(", "fitParams", ",", "n_std", "=", "3", ")", ":", "signal", "=", "getSignalPeak", "(", "fitParams", ")", "mx", "=", "signal", "[", "1", "]", "+", "n_std", "*", "signal", "[", "2", "]", "mn", "=", "signal", "[", "1", ...
return minimum, average, maximum of the signal peak
[ "return", "minimum", "average", "maximum", "of", "the", "signal", "peak" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/imgSignal.py#L250-L259
train
Returns the minimum average maximum of the signal peak and the signal peak peak.
radjkarl/imgProcessor
imgProcessor/transform/equalizeImage.py
equalizeImage
def equalizeImage(img, save_path=None, name_additive='_eqHist'): ''' Equalize the histogram (contrast) of an image works with RGB/multi-channel images and flat-arrays @param img - image_path or np.array @param save_path if given output images will be saved there @param name_additiv...
python
def equalizeImage(img, save_path=None, name_additive='_eqHist'): ''' Equalize the histogram (contrast) of an image works with RGB/multi-channel images and flat-arrays @param img - image_path or np.array @param save_path if given output images will be saved there @param name_additiv...
[ "def", "equalizeImage", "(", "img", ",", "save_path", "=", "None", ",", "name_additive", "=", "'_eqHist'", ")", ":", "if", "isinstance", "(", "img", ",", "string_types", ")", ":", "img", "=", "PathStr", "(", "img", ")", "if", "not", "img", ".", "exists...
Equalize the histogram (contrast) of an image works with RGB/multi-channel images and flat-arrays @param img - image_path or np.array @param save_path if given output images will be saved there @param name_additive if given this additive will be appended to output images @return outpu...
[ "Equalize", "the", "histogram", "(", "contrast", ")", "of", "an", "image", "works", "with", "RGB", "/", "multi", "-", "channel", "images", "and", "flat", "-", "arrays" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/equalizeImage.py#L11-L47
train
Equalize the histogram of an image
radjkarl/imgProcessor
imgProcessor/transform/equalizeImage.py
_equalizeHistogram
def _equalizeHistogram(img): ''' histogram equalisation not bounded to int() or an image depth of 8 bit works also with negative numbers ''' # to float if int: intType = None if 'f' not in img.dtype.str: TO_FLOAT_TYPES = {np.dtype('uint8'): np.float16, ...
python
def _equalizeHistogram(img): ''' histogram equalisation not bounded to int() or an image depth of 8 bit works also with negative numbers ''' # to float if int: intType = None if 'f' not in img.dtype.str: TO_FLOAT_TYPES = {np.dtype('uint8'): np.float16, ...
[ "def", "_equalizeHistogram", "(", "img", ")", ":", "# to float if int:\r", "intType", "=", "None", "if", "'f'", "not", "in", "img", ".", "dtype", ".", "str", ":", "TO_FLOAT_TYPES", "=", "{", "np", ".", "dtype", "(", "'uint8'", ")", ":", "np", ".", "flo...
histogram equalisation not bounded to int() or an image depth of 8 bit works also with negative numbers
[ "histogram", "equalisation", "not", "bounded", "to", "int", "()", "or", "an", "image", "depth", "of", "8", "bit", "works", "also", "with", "negative", "numbers" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/equalizeImage.py#L50-L83
train
equalize histogram img
radjkarl/imgProcessor
imgProcessor/filters/localizedMaximum.py
localizedMaximum
def localizedMaximum(img, thresh=0, min_increase=0, max_length=0, dtype=bool): ''' Returns the local maximum of a given 2d array thresh -> if given, ignore all values below that value max_length -> limit length between value has to vary > min_increase >>> a = np.array([[0,1,2,3,2,1,0],...
python
def localizedMaximum(img, thresh=0, min_increase=0, max_length=0, dtype=bool): ''' Returns the local maximum of a given 2d array thresh -> if given, ignore all values below that value max_length -> limit length between value has to vary > min_increase >>> a = np.array([[0,1,2,3,2,1,0],...
[ "def", "localizedMaximum", "(", "img", ",", "thresh", "=", "0", ",", "min_increase", "=", "0", ",", "max_length", "=", "0", ",", "dtype", "=", "bool", ")", ":", "# because numba cannot create arrays:\r", "out", "=", "np", ".", "zeros", "(", "shape", "=", ...
Returns the local maximum of a given 2d array thresh -> if given, ignore all values below that value max_length -> limit length between value has to vary > min_increase >>> a = np.array([[0,1,2,3,2,1,0], \ [0,1,2,2,3,1,0], \ [0,1,1,2,2,3,0], \ ...
[ "Returns", "the", "local", "maximum", "of", "a", "given", "2d", "array", "thresh", "-", ">", "if", "given", "ignore", "all", "values", "below", "that", "value", "max_length", "-", ">", "limit", "length", "between", "value", "has", "to", "vary", ">", "min...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/filters/localizedMaximum.py#L5-L33
train
Returns the localized maximum of a given 2d array
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.setReference
def setReference(self, ref): ''' ref ... either quad, grid, homography or reference image quad --> list of four image points(x,y) marking the edges of the quad to correct homography --> h. matrix to correct perspective distortion referenceImage --> image o...
python
def setReference(self, ref): ''' ref ... either quad, grid, homography or reference image quad --> list of four image points(x,y) marking the edges of the quad to correct homography --> h. matrix to correct perspective distortion referenceImage --> image o...
[ "def", "setReference", "(", "self", ",", "ref", ")", ":", "# self.maps = {}\r", "self", ".", "quad", "=", "None", "# self.refQuad = None\r", "self", ".", "_camera_position", "=", "None", "self", ".", "_homography", "=", "None", "self", ".", "_hom...
ref ... either quad, grid, homography or reference image quad --> list of four image points(x,y) marking the edges of the quad to correct homography --> h. matrix to correct perspective distortion referenceImage --> image of same object without perspective distortion
[ "ref", "...", "either", "quad", "grid", "homography", "or", "reference", "image", "quad", "--", ">", "list", "of", "four", "image", "points", "(", "x", "y", ")", "marking", "the", "edges", "of", "the", "quad", "to", "correct", "homography", "--", ">", ...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L97-L131
train
set the reference of the object
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.distort
def distort(self, img, rotX=0, rotY=0, quad=None): ''' Apply perspective distortion ion self.img angles are in DEG and need to be positive to fit into image ''' self.img = imread(img) # fit old image to self.quad: corr = self.correct(self.img) ...
python
def distort(self, img, rotX=0, rotY=0, quad=None): ''' Apply perspective distortion ion self.img angles are in DEG and need to be positive to fit into image ''' self.img = imread(img) # fit old image to self.quad: corr = self.correct(self.img) ...
[ "def", "distort", "(", "self", ",", "img", ",", "rotX", "=", "0", ",", "rotY", "=", "0", ",", "quad", "=", "None", ")", ":", "self", ".", "img", "=", "imread", "(", "img", ")", "# fit old image to self.quad:\r", "corr", "=", "self", ".", "correct", ...
Apply perspective distortion ion self.img angles are in DEG and need to be positive to fit into image
[ "Apply", "perspective", "distortion", "ion", "self", ".", "img", "angles", "are", "in", "DEG", "and", "need", "to", "be", "positive", "to", "fit", "into", "image" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L193-L270
train
Apply perspective distortion ion to image and return a new image.
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.correctGrid
def correctGrid(self, img, grid): ''' grid -> array of polylines=((p0x,p0y),(p1x,p1y),,,) ''' self.img = imread(img) h = self.homography # TODO: cleanup only needed to get newBorder attr. if self.opts['do_correctIntensity']: self.img = self.img / s...
python
def correctGrid(self, img, grid): ''' grid -> array of polylines=((p0x,p0y),(p1x,p1y),,,) ''' self.img = imread(img) h = self.homography # TODO: cleanup only needed to get newBorder attr. if self.opts['do_correctIntensity']: self.img = self.img / s...
[ "def", "correctGrid", "(", "self", ",", "img", ",", "grid", ")", ":", "self", ".", "img", "=", "imread", "(", "img", ")", "h", "=", "self", ".", "homography", "# TODO: cleanup only needed to get newBorder attr.\r", "if", "self", ".", "opts", "[", "'do_correc...
grid -> array of polylines=((p0x,p0y),(p1x,p1y),,,)
[ "grid", "-", ">", "array", "of", "polylines", "=", "((", "p0x", "p0y", ")", "(", "p1x", "p1y", ")", ")" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L281-L372
train
Returns a new image with the new image and the new border.
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.correct
def correct(self, img): ''' ...from perspective distortion: --> perspective transformation --> apply tilt factor (view factor) correction ''' print("CORRECT PERSPECTIVE ...") self.img = imread(img) if not self._homography_is_fixed: ...
python
def correct(self, img): ''' ...from perspective distortion: --> perspective transformation --> apply tilt factor (view factor) correction ''' print("CORRECT PERSPECTIVE ...") self.img = imread(img) if not self._homography_is_fixed: ...
[ "def", "correct", "(", "self", ",", "img", ")", ":", "print", "(", "\"CORRECT PERSPECTIVE ...\"", ")", "self", ".", "img", "=", "imread", "(", "img", ")", "if", "not", "self", ".", "_homography_is_fixed", ":", "self", ".", "_homography", "=", "None", "h"...
...from perspective distortion: --> perspective transformation --> apply tilt factor (view factor) correction
[ "...", "from", "perspective", "distortion", ":", "--", ">", "perspective", "transformation", "--", ">", "apply", "tilt", "factor", "(", "view", "factor", ")", "correction" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L380-L406
train
Correct the image using the perspective distortion transformation and tilt factor.
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.camera_position
def camera_position(self, pose=None): ''' returns camera position in world coordinates using self.rvec and self.tvec from http://stackoverflow.com/questions/14515200/python-opencv-solvepnp-yields-wrong-translation-vector ''' if pose is None: pose = self.pose() ...
python
def camera_position(self, pose=None): ''' returns camera position in world coordinates using self.rvec and self.tvec from http://stackoverflow.com/questions/14515200/python-opencv-solvepnp-yields-wrong-translation-vector ''' if pose is None: pose = self.pose() ...
[ "def", "camera_position", "(", "self", ",", "pose", "=", "None", ")", ":", "if", "pose", "is", "None", ":", "pose", "=", "self", ".", "pose", "(", ")", "t", ",", "r", "=", "pose", "return", "-", "np", ".", "matrix", "(", "cv2", ".", "Rodrigues", ...
returns camera position in world coordinates using self.rvec and self.tvec from http://stackoverflow.com/questions/14515200/python-opencv-solvepnp-yields-wrong-translation-vector
[ "returns", "camera", "position", "in", "world", "coordinates", "using", "self", ".", "rvec", "and", "self", ".", "tvec", "from", "http", ":", "//", "stackoverflow", ".", "com", "/", "questions", "/", "14515200", "/", "python", "-", "opencv", "-", "solvepnp...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L417-L425
train
Returns the camera position in world coordinates using self. rvec and self. tvec
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.viewAngle
def viewAngle(self, **kwargs): ''' calculate view factor between one small and one finite surface vf =1/pi * integral(cos(beta1)*cos(beta2)/s**2) * dA according to VDI heatatlas 2010 p961 ''' v0 = self.cam2PlaneVectorField(**kwargs) # obj cannot be behind c...
python
def viewAngle(self, **kwargs): ''' calculate view factor between one small and one finite surface vf =1/pi * integral(cos(beta1)*cos(beta2)/s**2) * dA according to VDI heatatlas 2010 p961 ''' v0 = self.cam2PlaneVectorField(**kwargs) # obj cannot be behind c...
[ "def", "viewAngle", "(", "self", ",", "*", "*", "kwargs", ")", ":", "v0", "=", "self", ".", "cam2PlaneVectorField", "(", "*", "*", "kwargs", ")", "# obj cannot be behind camera\r", "v0", "[", "2", "]", "[", "v0", "[", "2", "]", "<", "0", "]", "=", ...
calculate view factor between one small and one finite surface vf =1/pi * integral(cos(beta1)*cos(beta2)/s**2) * dA according to VDI heatatlas 2010 p961
[ "calculate", "view", "factor", "between", "one", "small", "and", "one", "finite", "surface", "vf", "=", "1", "/", "pi", "*", "integral", "(", "cos", "(", "beta1", ")", "*", "cos", "(", "beta2", ")", "/", "s", "**", "2", ")", "*", "dA", "according",...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L488-L504
train
calculate view factor between one small and one finite surface
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.foreground
def foreground(self, quad=None): '''return foreground (quad) mask''' fg = np.zeros(shape=self._newBorders[::-1], dtype=np.uint8) if quad is None: quad = self.quad else: quad = quad.astype(np.int32) cv2.fillConvexPoly(fg, quad, 1) return fg....
python
def foreground(self, quad=None): '''return foreground (quad) mask''' fg = np.zeros(shape=self._newBorders[::-1], dtype=np.uint8) if quad is None: quad = self.quad else: quad = quad.astype(np.int32) cv2.fillConvexPoly(fg, quad, 1) return fg....
[ "def", "foreground", "(", "self", ",", "quad", "=", "None", ")", ":", "fg", "=", "np", ".", "zeros", "(", "shape", "=", "self", ".", "_newBorders", "[", ":", ":", "-", "1", "]", ",", "dtype", "=", "np", ".", "uint8", ")", "if", "quad", "is", ...
return foreground (quad) mask
[ "return", "foreground", "(", "quad", ")", "mask" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L506-L514
train
return foreground mask
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.tiltFactor
def tiltFactor(self, midpointdepth=None, printAvAngle=False): ''' get tilt factor from inverse distance law https://en.wikipedia.org/wiki/Inverse-square_law ''' # TODO: can also be only def. with FOV, rot, tilt beta2 = self.viewAngle(midpointdept...
python
def tiltFactor(self, midpointdepth=None, printAvAngle=False): ''' get tilt factor from inverse distance law https://en.wikipedia.org/wiki/Inverse-square_law ''' # TODO: can also be only def. with FOV, rot, tilt beta2 = self.viewAngle(midpointdept...
[ "def", "tiltFactor", "(", "self", ",", "midpointdepth", "=", "None", ",", "printAvAngle", "=", "False", ")", ":", "# TODO: can also be only def. with FOV, rot, tilt\r", "beta2", "=", "self", ".", "viewAngle", "(", "midpointdepth", "=", "midpointdepth", ")", "try", ...
get tilt factor from inverse distance law https://en.wikipedia.org/wiki/Inverse-square_law
[ "get", "tilt", "factor", "from", "inverse", "distance", "law", "https", ":", "//", "en", ".", "wikipedia", ".", "org", "/", "wiki", "/", "Inverse", "-", "square_law" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L516-L539
train
get tilt factor from inverse distance law
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.standardUncertainties
def standardUncertainties(self, focal_Length_mm, f_number, midpointdepth=1000, focusAtYX=None, # sigma_best_focus=0, # quad_pos_err=0, shape=None, uncertainties=(0, ...
python
def standardUncertainties(self, focal_Length_mm, f_number, midpointdepth=1000, focusAtYX=None, # sigma_best_focus=0, # quad_pos_err=0, shape=None, uncertainties=(0, ...
[ "def", "standardUncertainties", "(", "self", ",", "focal_Length_mm", ",", "f_number", ",", "midpointdepth", "=", "1000", ",", "focusAtYX", "=", "None", ",", "# sigma_best_focus=0,\r", "# quad_pos_err=0,\r", "shape", "=", "None", ",", "uncertainties", "=", "(", "0"...
focusAtXY - image position with is in focus if not set it is assumed that the image middle is in focus sigma_best_focus - standard deviation of the PSF within the best focus (default blur) uncertainties - contibutors for standard uncertainty ...
[ "focusAtXY", "-", "image", "position", "with", "is", "in", "focus", "if", "not", "set", "it", "is", "assumed", "that", "the", "image", "middle", "is", "in", "focus", "sigma_best_focus", "-", "standard", "deviation", "of", "the", "PSF", "within", "the", "be...
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L555-L637
train
Returns a new image with the standard uncertainty.
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection._poseFromQuad
def _poseFromQuad(self, quad=None): ''' estimate the pose of the object plane using quad setting: self.rvec -> rotation vector self.tvec -> translation vector ''' if quad is None: quad = self.quad if quad.ndim == 3: qu...
python
def _poseFromQuad(self, quad=None): ''' estimate the pose of the object plane using quad setting: self.rvec -> rotation vector self.tvec -> translation vector ''' if quad is None: quad = self.quad if quad.ndim == 3: qu...
[ "def", "_poseFromQuad", "(", "self", ",", "quad", "=", "None", ")", ":", "if", "quad", "is", "None", ":", "quad", "=", "self", ".", "quad", "if", "quad", ".", "ndim", "==", "3", ":", "quad", "=", "quad", "[", "0", "]", "# http://answers.opencv.org/qu...
estimate the pose of the object plane using quad setting: self.rvec -> rotation vector self.tvec -> translation vector
[ "estimate", "the", "pose", "of", "the", "object", "plane", "using", "quad", "setting", ":", "self", ".", "rvec", "-", ">", "rotation", "vector", "self", ".", "tvec", "-", ">", "translation", "vector" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L692-L718
train
estimate the pose of the object plane using quad
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.drawQuad
def drawQuad(self, img=None, quad=None, thickness=30): ''' Draw the quad into given img ''' if img is None: img = self.img if quad is None: quad = self.quad q = np.int32(quad) c = int(img.max()) cv2.line(img, tuple(q[0]),...
python
def drawQuad(self, img=None, quad=None, thickness=30): ''' Draw the quad into given img ''' if img is None: img = self.img if quad is None: quad = self.quad q = np.int32(quad) c = int(img.max()) cv2.line(img, tuple(q[0]),...
[ "def", "drawQuad", "(", "self", ",", "img", "=", "None", ",", "quad", "=", "None", ",", "thickness", "=", "30", ")", ":", "if", "img", "is", "None", ":", "img", "=", "self", ".", "img", "if", "quad", "is", "None", ":", "quad", "=", "self", ".",...
Draw the quad into given img
[ "Draw", "the", "quad", "into", "given", "img" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L761-L775
train
Draw the quad into given img
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection.draw3dCoordAxis
def draw3dCoordAxis(self, img=None, thickness=8): ''' draw the 3d coordinate axes into given image if image == False: create an empty image ''' if img is None: img = self.img elif img is False: img = np.zeros(shape=self.img.sha...
python
def draw3dCoordAxis(self, img=None, thickness=8): ''' draw the 3d coordinate axes into given image if image == False: create an empty image ''' if img is None: img = self.img elif img is False: img = np.zeros(shape=self.img.sha...
[ "def", "draw3dCoordAxis", "(", "self", ",", "img", "=", "None", ",", "thickness", "=", "8", ")", ":", "if", "img", "is", "None", ":", "img", "=", "self", ".", "img", "elif", "img", "is", "False", ":", "img", "=", "np", ".", "zeros", "(", "shape",...
draw the 3d coordinate axes into given image if image == False: create an empty image
[ "draw", "the", "3d", "coordinate", "axes", "into", "given", "image", "if", "image", "==", "False", ":", "create", "an", "empty", "image" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L777-L807
train
draw the 3d coordinate axes into a given image
radjkarl/imgProcessor
imgProcessor/camera/PerspectiveCorrection.py
PerspectiveCorrection._calcQuadSize
def _calcQuadSize(corners, aspectRatio): ''' return the size of a rectangle in perspective distortion in [px] DEBUG: PUT THAT BACK IN??:: if aspectRatio is not given is will be determined ''' if aspectRatio > 1: # x is bigger -> reduce y x_length =...
python
def _calcQuadSize(corners, aspectRatio): ''' return the size of a rectangle in perspective distortion in [px] DEBUG: PUT THAT BACK IN??:: if aspectRatio is not given is will be determined ''' if aspectRatio > 1: # x is bigger -> reduce y x_length =...
[ "def", "_calcQuadSize", "(", "corners", ",", "aspectRatio", ")", ":", "if", "aspectRatio", ">", "1", ":", "# x is bigger -> reduce y\r", "x_length", "=", "PerspectiveCorrection", ".", "_quadXLength", "(", "corners", ")", "y", "=", "x_length", "/", "aspectRatio", ...
return the size of a rectangle in perspective distortion in [px] DEBUG: PUT THAT BACK IN??:: if aspectRatio is not given is will be determined
[ "return", "the", "size", "of", "a", "rectangle", "in", "perspective", "distortion", "in", "[", "px", "]", "DEBUG", ":", "PUT", "THAT", "BACK", "IN??", "::", "if", "aspectRatio", "is", "not", "given", "is", "will", "be", "determined" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/camera/PerspectiveCorrection.py#L810-L823
train
Calculates the size of a rectangle in perspective distortion in [ px ].
radjkarl/imgProcessor
imgProcessor/transform/polarTransform.py
linearToPolar
def linearToPolar(img, center=None, final_radius=None, initial_radius=None, phase_width=None, interpolation=cv2.INTER_AREA, maps=None, borderValue=0, borderMode=cv2.BORDER_REFLECT, **opts): ''' map a 2d (x,y) Cartes...
python
def linearToPolar(img, center=None, final_radius=None, initial_radius=None, phase_width=None, interpolation=cv2.INTER_AREA, maps=None, borderValue=0, borderMode=cv2.BORDER_REFLECT, **opts): ''' map a 2d (x,y) Cartes...
[ "def", "linearToPolar", "(", "img", ",", "center", "=", "None", ",", "final_radius", "=", "None", ",", "initial_radius", "=", "None", ",", "phase_width", "=", "None", ",", "interpolation", "=", "cv2", ".", "INTER_AREA", ",", "maps", "=", "None", ",", "bo...
map a 2d (x,y) Cartesian array to a polar (r, phi) array using opencv.remap
[ "map", "a", "2d", "(", "x", "y", ")", "Cartesian", "array", "to", "a", "polar", "(", "r", "phi", ")", "array", "using", "opencv", ".", "remap" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/polarTransform.py#L45-L66
train
Returns a 2d array of polar coordinates using opencv. remap
radjkarl/imgProcessor
imgProcessor/transform/polarTransform.py
polarToLinear
def polarToLinear(img, shape=None, center=None, maps=None, interpolation=cv2.INTER_AREA, borderValue=0, borderMode=cv2.BORDER_REFLECT, **opts): ''' map a 2d polar (r, phi) polar array to a Cartesian (x,y) array using opencv.remap ''' if maps is None: ...
python
def polarToLinear(img, shape=None, center=None, maps=None, interpolation=cv2.INTER_AREA, borderValue=0, borderMode=cv2.BORDER_REFLECT, **opts): ''' map a 2d polar (r, phi) polar array to a Cartesian (x,y) array using opencv.remap ''' if maps is None: ...
[ "def", "polarToLinear", "(", "img", ",", "shape", "=", "None", ",", "center", "=", "None", ",", "maps", "=", "None", ",", "interpolation", "=", "cv2", ".", "INTER_AREA", ",", "borderValue", "=", "0", ",", "borderMode", "=", "cv2", ".", "BORDER_REFLECT", ...
map a 2d polar (r, phi) polar array to a Cartesian (x,y) array using opencv.remap
[ "map", "a", "2d", "polar", "(", "r", "phi", ")", "polar", "array", "to", "a", "Cartesian", "(", "x", "y", ")", "array", "using", "opencv", ".", "remap" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/transform/polarTransform.py#L87-L105
train
Returns a 2d array of polar coordinates with a linear interpolation
radjkarl/imgProcessor
imgProcessor/measure/sharpness/parameters.py
modifiedLaplacian
def modifiedLaplacian(img): ''''LAPM' algorithm (Nayar89)''' M = np.array([-1, 2, -1]) G = cv2.getGaussianKernel(ksize=3, sigma=-1) Lx = cv2.sepFilter2D(src=img, ddepth=cv2.CV_64F, kernelX=M, kernelY=G) Ly = cv2.sepFilter2D(src=img, ddepth=cv2.CV_64F, kernelX=G, kernelY=M) FM = np.abs(Lx) ...
python
def modifiedLaplacian(img): ''''LAPM' algorithm (Nayar89)''' M = np.array([-1, 2, -1]) G = cv2.getGaussianKernel(ksize=3, sigma=-1) Lx = cv2.sepFilter2D(src=img, ddepth=cv2.CV_64F, kernelX=M, kernelY=G) Ly = cv2.sepFilter2D(src=img, ddepth=cv2.CV_64F, kernelX=G, kernelY=M) FM = np.abs(Lx) ...
[ "def", "modifiedLaplacian", "(", "img", ")", ":", "M", "=", "np", ".", "array", "(", "[", "-", "1", ",", "2", ",", "-", "1", "]", ")", "G", "=", "cv2", ".", "getGaussianKernel", "(", "ksize", "=", "3", ",", "sigma", "=", "-", "1", ")", "Lx", ...
LAPM' algorithm (Nayar89)
[ "LAPM", "algorithm", "(", "Nayar89", ")" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/parameters.py#L16-L23
train
This function is used to find the modified Laplacian of the image.
radjkarl/imgProcessor
imgProcessor/measure/sharpness/parameters.py
varianceOfLaplacian
def varianceOfLaplacian(img): ''''LAPV' algorithm (Pech2000)''' lap = cv2.Laplacian(img, ddepth=-1)#cv2.cv.CV_64F) stdev = cv2.meanStdDev(lap)[1] s = stdev[0]**2 return s[0]
python
def varianceOfLaplacian(img): ''''LAPV' algorithm (Pech2000)''' lap = cv2.Laplacian(img, ddepth=-1)#cv2.cv.CV_64F) stdev = cv2.meanStdDev(lap)[1] s = stdev[0]**2 return s[0]
[ "def", "varianceOfLaplacian", "(", "img", ")", ":", "lap", "=", "cv2", ".", "Laplacian", "(", "img", ",", "ddepth", "=", "-", "1", ")", "#cv2.cv.CV_64F)\r", "stdev", "=", "cv2", ".", "meanStdDev", "(", "lap", ")", "[", "1", "]", "s", "=", "stdev", ...
LAPV' algorithm (Pech2000)
[ "LAPV", "algorithm", "(", "Pech2000", ")" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/parameters.py#L26-L31
train
Calculates the variance of Laplacian.
radjkarl/imgProcessor
imgProcessor/measure/sharpness/parameters.py
tenengrad
def tenengrad(img, ksize=3): ''''TENG' algorithm (Krotkov86)''' Gx = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=1, dy=0, ksize=ksize) Gy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=ksize) FM = Gx*Gx + Gy*Gy mn = cv2.mean(FM)[0] if np.isnan(mn): return np.nanmean(FM) retur...
python
def tenengrad(img, ksize=3): ''''TENG' algorithm (Krotkov86)''' Gx = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=1, dy=0, ksize=ksize) Gy = cv2.Sobel(img, ddepth=cv2.CV_64F, dx=0, dy=1, ksize=ksize) FM = Gx*Gx + Gy*Gy mn = cv2.mean(FM)[0] if np.isnan(mn): return np.nanmean(FM) retur...
[ "def", "tenengrad", "(", "img", ",", "ksize", "=", "3", ")", ":", "Gx", "=", "cv2", ".", "Sobel", "(", "img", ",", "ddepth", "=", "cv2", ".", "CV_64F", ",", "dx", "=", "1", ",", "dy", "=", "0", ",", "ksize", "=", "ksize", ")", "Gy", "=", "c...
TENG' algorithm (Krotkov86)
[ "TENG", "algorithm", "(", "Krotkov86", ")" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/parameters.py#L34-L42
train
TENG algorithm
radjkarl/imgProcessor
imgProcessor/measure/sharpness/parameters.py
normalizedGraylevelVariance
def normalizedGraylevelVariance(img): ''''GLVN' algorithm (Santos97)''' mean, stdev = cv2.meanStdDev(img) s = stdev[0]**2 / mean[0] return s[0]
python
def normalizedGraylevelVariance(img): ''''GLVN' algorithm (Santos97)''' mean, stdev = cv2.meanStdDev(img) s = stdev[0]**2 / mean[0] return s[0]
[ "def", "normalizedGraylevelVariance", "(", "img", ")", ":", "mean", ",", "stdev", "=", "cv2", ".", "meanStdDev", "(", "img", ")", "s", "=", "stdev", "[", "0", "]", "**", "2", "/", "mean", "[", "0", "]", "return", "s", "[", "0", "]" ]
GLVN' algorithm (Santos97)
[ "GLVN", "algorithm", "(", "Santos97", ")" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/sharpness/parameters.py#L45-L49
train
Returns the normalized graylevel variance of the image.
radjkarl/imgProcessor
imgProcessor/measure/linePlot.py
linePlot
def linePlot(img, x0, y0, x1, y1, resolution=None, order=3): ''' returns [img] intensity values along line defined by [x0, y0, x1, y1] resolution ... number or data points to evaluate order ... interpolation precision ''' if resolution is None: resolution = int( ((x1-x0...
python
def linePlot(img, x0, y0, x1, y1, resolution=None, order=3): ''' returns [img] intensity values along line defined by [x0, y0, x1, y1] resolution ... number or data points to evaluate order ... interpolation precision ''' if resolution is None: resolution = int( ((x1-x0...
[ "def", "linePlot", "(", "img", ",", "x0", ",", "y0", ",", "x1", ",", "y1", ",", "resolution", "=", "None", ",", "order", "=", "3", ")", ":", "if", "resolution", "is", "None", ":", "resolution", "=", "int", "(", "(", "(", "x1", "-", "x0", ")", ...
returns [img] intensity values along line defined by [x0, y0, x1, y1] resolution ... number or data points to evaluate order ... interpolation precision
[ "returns", "[", "img", "]", "intensity", "values", "along", "line", "defined", "by", "[", "x0", "y0", "x1", "y1", "]", "resolution", "...", "number", "or", "data", "points", "to", "evaluate", "order", "...", "interpolation", "precision" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/imgProcessor/measure/linePlot.py#L10-L28
train
Returns a line plot of the image along a given line defined by [ x0 y0 x1 y1.
radjkarl/imgProcessor
DUMP/FlatFieldFromImgFit.py
FlatFieldFromImgFit.flatFieldFromFunction
def flatFieldFromFunction(self): ''' calculate flatField from fitting vignetting function to averaged fit-image returns flatField, average background level, fitted image, valid indices mask ''' fitimg, mask = self._prepare() mask = ~mask s0, s1 = fitimg.s...
python
def flatFieldFromFunction(self): ''' calculate flatField from fitting vignetting function to averaged fit-image returns flatField, average background level, fitted image, valid indices mask ''' fitimg, mask = self._prepare() mask = ~mask s0, s1 = fitimg.s...
[ "def", "flatFieldFromFunction", "(", "self", ")", ":", "fitimg", ",", "mask", "=", "self", ".", "_prepare", "(", ")", "mask", "=", "~", "mask", "s0", ",", "s1", "=", "fitimg", ".", "shape", "#f-value, alpha, fx, cx, cy\r", "guess", "=", "(", "s1", "*...
calculate flatField from fitting vignetting function to averaged fit-image returns flatField, average background level, fitted image, valid indices mask
[ "calculate", "flatField", "from", "fitting", "vignetting", "function", "to", "averaged", "fit", "-", "image", "returns", "flatField", "average", "background", "level", "fitted", "image", "valid", "indices", "mask" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/DUMP/FlatFieldFromImgFit.py#L104-L125
train
calculate flatField from fitting vignetting function to averaged fit - image returns flatField average background level fitted image valid indices mask
radjkarl/imgProcessor
DUMP/FlatFieldFromImgFit.py
FlatFieldFromImgFit.flatFieldFromFit
def flatFieldFromFit(self): ''' calculate flatField from 2d-polynomal fit filling all high gradient areas within averaged fit-image returns flatField, average background level, fitted image, valid indices mask ''' fitimg, mask = self._prepare() out = fi...
python
def flatFieldFromFit(self): ''' calculate flatField from 2d-polynomal fit filling all high gradient areas within averaged fit-image returns flatField, average background level, fitted image, valid indices mask ''' fitimg, mask = self._prepare() out = fi...
[ "def", "flatFieldFromFit", "(", "self", ")", ":", "fitimg", ",", "mask", "=", "self", ".", "_prepare", "(", ")", "out", "=", "fitimg", ".", "copy", "(", ")", "lastm", "=", "0", "for", "_", "in", "range", "(", "10", ")", ":", "out", "=", "polyfit2...
calculate flatField from 2d-polynomal fit filling all high gradient areas within averaged fit-image returns flatField, average background level, fitted image, valid indices mask
[ "calculate", "flatField", "from", "2d", "-", "polynomal", "fit", "filling", "all", "high", "gradient", "areas", "within", "averaged", "fit", "-", "image", "returns", "flatField", "average", "background", "level", "fitted", "image", "valid", "indices", "mask" ]
7c5a28718f81c01a430152c60a686ac50afbfd7c
https://github.com/radjkarl/imgProcessor/blob/7c5a28718f81c01a430152c60a686ac50afbfd7c/DUMP/FlatFieldFromImgFit.py#L133-L156
train
calculate flatField from 2d - polaral fit filling all high gradient areas within averaged fit - image returns flatField average background level fitted image valid indices mask
kevinpt/hdlparse
hdlparse/vhdl_parser.py
parse_vhdl_file
def parse_vhdl_file(fname): '''Parse a named VHDL file Args: fname(str): Name of file to parse Returns: Parsed objects. ''' with open(fname, 'rt') as fh: text = fh.read() return parse_vhdl(text)
python
def parse_vhdl_file(fname): '''Parse a named VHDL file Args: fname(str): Name of file to parse Returns: Parsed objects. ''' with open(fname, 'rt') as fh: text = fh.read() return parse_vhdl(text)
[ "def", "parse_vhdl_file", "(", "fname", ")", ":", "with", "open", "(", "fname", ",", "'rt'", ")", "as", "fh", ":", "text", "=", "fh", ".", "read", "(", ")", "return", "parse_vhdl", "(", "text", ")" ]
Parse a named VHDL file Args: fname(str): Name of file to parse Returns: Parsed objects.
[ "Parse", "a", "named", "VHDL", "file", "Args", ":", "fname", "(", "str", ")", ":", "Name", "of", "file", "to", "parse", "Returns", ":", "Parsed", "objects", "." ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L322-L332
train
Parse a named VHDL file
kevinpt/hdlparse
hdlparse/vhdl_parser.py
parse_vhdl
def parse_vhdl(text): '''Parse a text buffer of VHDL code Args: text(str): Source code to parse Returns: Parsed objects. ''' lex = VhdlLexer name = None kind = None saved_type = None end_param_group = False cur_package = None metacomments = [] parameters = [] param_items = [] g...
python
def parse_vhdl(text): '''Parse a text buffer of VHDL code Args: text(str): Source code to parse Returns: Parsed objects. ''' lex = VhdlLexer name = None kind = None saved_type = None end_param_group = False cur_package = None metacomments = [] parameters = [] param_items = [] g...
[ "def", "parse_vhdl", "(", "text", ")", ":", "lex", "=", "VhdlLexer", "name", "=", "None", "kind", "=", "None", "saved_type", "=", "None", "end_param_group", "=", "False", "cur_package", "=", "None", "metacomments", "=", "[", "]", "parameters", "=", "[", ...
Parse a text buffer of VHDL code Args: text(str): Source code to parse Returns: Parsed objects.
[ "Parse", "a", "text", "buffer", "of", "VHDL", "code" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L334-L508
train
Parse a text buffer of VHDL code into a list of Parsed objects.
kevinpt/hdlparse
hdlparse/vhdl_parser.py
subprogram_prototype
def subprogram_prototype(vo): '''Generate a canonical prototype string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Prototype string. ''' plist = '; '.join(str(p) for p in vo.parameters) if isinstance(vo, VhdlFunction): if len(vo.parameters) > 0: proto = 'functio...
python
def subprogram_prototype(vo): '''Generate a canonical prototype string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Prototype string. ''' plist = '; '.join(str(p) for p in vo.parameters) if isinstance(vo, VhdlFunction): if len(vo.parameters) > 0: proto = 'functio...
[ "def", "subprogram_prototype", "(", "vo", ")", ":", "plist", "=", "'; '", ".", "join", "(", "str", "(", "p", ")", "for", "p", "in", "vo", ".", "parameters", ")", "if", "isinstance", "(", "vo", ",", "VhdlFunction", ")", ":", "if", "len", "(", "vo", ...
Generate a canonical prototype string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Prototype string.
[ "Generate", "a", "canonical", "prototype", "string", "Args", ":", "vo", "(", "VhdlFunction", "VhdlProcedure", ")", ":", "Subprogram", "object", "Returns", ":", "Prototype", "string", "." ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L511-L531
train
Generate a canonical prototype string for a sequence of subprogram objects.
kevinpt/hdlparse
hdlparse/vhdl_parser.py
subprogram_signature
def subprogram_signature(vo, fullname=None): '''Generate a signature string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Signature string. ''' if fullname is None: fullname = vo.name if isinstance(vo, VhdlFunction): plist = ','.join(p.data_type for p in vo.paramete...
python
def subprogram_signature(vo, fullname=None): '''Generate a signature string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Signature string. ''' if fullname is None: fullname = vo.name if isinstance(vo, VhdlFunction): plist = ','.join(p.data_type for p in vo.paramete...
[ "def", "subprogram_signature", "(", "vo", ",", "fullname", "=", "None", ")", ":", "if", "fullname", "is", "None", ":", "fullname", "=", "vo", ".", "name", "if", "isinstance", "(", "vo", ",", "VhdlFunction", ")", ":", "plist", "=", "','", ".", "join", ...
Generate a signature string Args: vo (VhdlFunction, VhdlProcedure): Subprogram object Returns: Signature string.
[ "Generate", "a", "signature", "string", "Args", ":", "vo", "(", "VhdlFunction", "VhdlProcedure", ")", ":", "Subprogram", "object", "Returns", ":", "Signature", "string", "." ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L533-L552
train
Generate a signature string for a sequence of subprogram objects.
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor.extract_objects_from_source
def extract_objects_from_source(self, text, type_filter=None): '''Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects. ''' objects = parse_vhdl(text) ...
python
def extract_objects_from_source(self, text, type_filter=None): '''Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects. ''' objects = parse_vhdl(text) ...
[ "def", "extract_objects_from_source", "(", "self", ",", "text", ",", "type_filter", "=", "None", ")", ":", "objects", "=", "parse_vhdl", "(", "text", ")", "self", ".", "_register_array_types", "(", "objects", ")", "if", "type_filter", ":", "objects", "=", "[...
Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects.
[ "Extract", "object", "declarations", "from", "a", "text", "buffer" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L603-L618
train
Extract object declarations from a text buffer containing a single object.
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor.is_array
def is_array(self, data_type): '''Check if a type is a known array type Args: data_type (str): Name of type to check Returns: True if ``data_type`` is a known array type. ''' # Split off any brackets data_type = data_type.split('[')[0].strip() return data_type.lower() in s...
python
def is_array(self, data_type): '''Check if a type is a known array type Args: data_type (str): Name of type to check Returns: True if ``data_type`` is a known array type. ''' # Split off any brackets data_type = data_type.split('[')[0].strip() return data_type.lower() in s...
[ "def", "is_array", "(", "self", ",", "data_type", ")", ":", "# Split off any brackets", "data_type", "=", "data_type", ".", "split", "(", "'['", ")", "[", "0", "]", ".", "strip", "(", ")", "return", "data_type", ".", "lower", "(", ")", "in", "self", "....
Check if a type is a known array type Args: data_type (str): Name of type to check Returns: True if ``data_type`` is a known array type.
[ "Check", "if", "a", "type", "is", "a", "known", "array", "type", "Args", ":", "data_type", "(", "str", ")", ":", "Name", "of", "type", "to", "check", "Returns", ":", "True", "if", "data_type", "is", "a", "known", "array", "type", "." ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L621-L633
train
Check if a type is a known array type.
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor.load_array_types
def load_array_types(self, fname): '''Load file of previously extracted data types Args: fname (str): Name of file to load array database from ''' type_defs = '' with open(fname, 'rt') as fh: type_defs = fh.read() try: type_defs = ast.literal_eval(type_defs) except Sy...
python
def load_array_types(self, fname): '''Load file of previously extracted data types Args: fname (str): Name of file to load array database from ''' type_defs = '' with open(fname, 'rt') as fh: type_defs = fh.read() try: type_defs = ast.literal_eval(type_defs) except Sy...
[ "def", "load_array_types", "(", "self", ",", "fname", ")", ":", "type_defs", "=", "''", "with", "open", "(", "fname", ",", "'rt'", ")", "as", "fh", ":", "type_defs", "=", "fh", ".", "read", "(", ")", "try", ":", "type_defs", "=", "ast", ".", "liter...
Load file of previously extracted data types Args: fname (str): Name of file to load array database from
[ "Load", "file", "of", "previously", "extracted", "data", "types", "Args", ":", "fname", "(", "str", ")", ":", "Name", "of", "file", "to", "load", "array", "database", "from" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L645-L660
train
Load file of previously extracted data types
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor.save_array_types
def save_array_types(self, fname): '''Save array type registry to a file Args: fname (str): Name of file to save array database to ''' type_defs = {'arrays': sorted(list(self.array_types))} with open(fname, 'wt') as fh: pprint(type_defs, stream=fh)
python
def save_array_types(self, fname): '''Save array type registry to a file Args: fname (str): Name of file to save array database to ''' type_defs = {'arrays': sorted(list(self.array_types))} with open(fname, 'wt') as fh: pprint(type_defs, stream=fh)
[ "def", "save_array_types", "(", "self", ",", "fname", ")", ":", "type_defs", "=", "{", "'arrays'", ":", "sorted", "(", "list", "(", "self", ".", "array_types", ")", ")", "}", "with", "open", "(", "fname", ",", "'wt'", ")", "as", "fh", ":", "pprint", ...
Save array type registry to a file Args: fname (str): Name of file to save array database to
[ "Save", "array", "type", "registry", "to", "a", "file", "Args", ":", "fname", "(", "str", ")", ":", "Name", "of", "file", "to", "save", "array", "database", "to" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L662-L670
train
Save array type registry to a file
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor._register_array_types
def _register_array_types(self, objects): '''Add array type definitions to internal registry Args: objects (list of VhdlType or VhdlSubtype): Array types to track ''' # Add all array types directly types = [o for o in objects if isinstance(o, VhdlType) and o.type_of == 'array_type'] f...
python
def _register_array_types(self, objects): '''Add array type definitions to internal registry Args: objects (list of VhdlType or VhdlSubtype): Array types to track ''' # Add all array types directly types = [o for o in objects if isinstance(o, VhdlType) and o.type_of == 'array_type'] f...
[ "def", "_register_array_types", "(", "self", ",", "objects", ")", ":", "# Add all array types directly", "types", "=", "[", "o", "for", "o", "in", "objects", "if", "isinstance", "(", "o", ",", "VhdlType", ")", "and", "o", ".", "type_of", "==", "'array_type'"...
Add array type definitions to internal registry Args: objects (list of VhdlType or VhdlSubtype): Array types to track
[ "Add", "array", "type", "definitions", "to", "internal", "registry", "Args", ":", "objects", "(", "list", "of", "VhdlType", "or", "VhdlSubtype", ")", ":", "Array", "types", "to", "track" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L672-L690
train
Add array type definitions to internal registry
kevinpt/hdlparse
hdlparse/vhdl_parser.py
VhdlExtractor.register_array_types_from_sources
def register_array_types_from_sources(self, source_files): '''Add array type definitions from a file list to internal registry Args: source_files (list of str): Files to parse for array definitions ''' for fname in source_files: if is_vhdl(fname): self._register_array_types(self.ext...
python
def register_array_types_from_sources(self, source_files): '''Add array type definitions from a file list to internal registry Args: source_files (list of str): Files to parse for array definitions ''' for fname in source_files: if is_vhdl(fname): self._register_array_types(self.ext...
[ "def", "register_array_types_from_sources", "(", "self", ",", "source_files", ")", ":", "for", "fname", "in", "source_files", ":", "if", "is_vhdl", "(", "fname", ")", ":", "self", ".", "_register_array_types", "(", "self", ".", "extract_objects", "(", "fname", ...
Add array type definitions from a file list to internal registry Args: source_files (list of str): Files to parse for array definitions
[ "Add", "array", "type", "definitions", "from", "a", "file", "list", "to", "internal", "registry" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/vhdl_parser.py#L692-L700
train
Add array type definitions from a list of source files to internal registry
kevinpt/hdlparse
hdlparse/minilexer.py
MiniLexer.run
def run(self, text): '''Run lexer rules against a source text Args: text (str): Text to apply lexer to Yields: A sequence of lexer matches. ''' stack = ['root'] pos = 0 patterns = self.tokens[stack[-1]] while True: for pat, action, new_state in patterns: m ...
python
def run(self, text): '''Run lexer rules against a source text Args: text (str): Text to apply lexer to Yields: A sequence of lexer matches. ''' stack = ['root'] pos = 0 patterns = self.tokens[stack[-1]] while True: for pat, action, new_state in patterns: m ...
[ "def", "run", "(", "self", ",", "text", ")", ":", "stack", "=", "[", "'root'", "]", "pos", "=", "0", "patterns", "=", "self", ".", "tokens", "[", "stack", "[", "-", "1", "]", "]", "while", "True", ":", "for", "pat", ",", "action", ",", "new_sta...
Run lexer rules against a source text Args: text (str): Text to apply lexer to Yields: A sequence of lexer matches.
[ "Run", "lexer", "rules", "against", "a", "source", "text" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/minilexer.py#L43-L86
train
Run lexer rules against a source text.
kevinpt/hdlparse
doc/conf.py
get_package_version
def get_package_version(verfile): '''Scan the script for the version string''' version = None with open(verfile) as fh: try: version = [line.split('=')[1].strip().strip("'") for line in fh if \ line.startswith('__version__')][0] except IndexError: pass return versio...
python
def get_package_version(verfile): '''Scan the script for the version string''' version = None with open(verfile) as fh: try: version = [line.split('=')[1].strip().strip("'") for line in fh if \ line.startswith('__version__')][0] except IndexError: pass return versio...
[ "def", "get_package_version", "(", "verfile", ")", ":", "version", "=", "None", "with", "open", "(", "verfile", ")", "as", "fh", ":", "try", ":", "version", "=", "[", "line", ".", "split", "(", "'='", ")", "[", "1", "]", ".", "strip", "(", ")", "...
Scan the script for the version string
[ "Scan", "the", "script", "for", "the", "version", "string" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/doc/conf.py#L57-L66
train
Scan the script for the version string
kevinpt/hdlparse
hdlparse/verilog_parser.py
parse_verilog_file
def parse_verilog_file(fname): '''Parse a named Verilog file Args: fname (str): File to parse. Returns: List of parsed objects. ''' with open(fname, 'rt') as fh: text = fh.read() return parse_verilog(text)
python
def parse_verilog_file(fname): '''Parse a named Verilog file Args: fname (str): File to parse. Returns: List of parsed objects. ''' with open(fname, 'rt') as fh: text = fh.read() return parse_verilog(text)
[ "def", "parse_verilog_file", "(", "fname", ")", ":", "with", "open", "(", "fname", ",", "'rt'", ")", "as", "fh", ":", "text", "=", "fh", ".", "read", "(", ")", "return", "parse_verilog", "(", "text", ")" ]
Parse a named Verilog file Args: fname (str): File to parse. Returns: List of parsed objects.
[ "Parse", "a", "named", "Verilog", "file", "Args", ":", "fname", "(", "str", ")", ":", "File", "to", "parse", ".", "Returns", ":", "List", "of", "parsed", "objects", "." ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/verilog_parser.py#L90-L100
train
Parse a named Verilog file
kevinpt/hdlparse
hdlparse/verilog_parser.py
parse_verilog
def parse_verilog(text): '''Parse a text buffer of Verilog code Args: text (str): Source code to parse Returns: List of parsed objects. ''' lex = VerilogLexer name = None kind = None saved_type = None mode = 'input' ptype = 'wire' metacomments = [] parameters = [] param_items = [] ...
python
def parse_verilog(text): '''Parse a text buffer of Verilog code Args: text (str): Source code to parse Returns: List of parsed objects. ''' lex = VerilogLexer name = None kind = None saved_type = None mode = 'input' ptype = 'wire' metacomments = [] parameters = [] param_items = [] ...
[ "def", "parse_verilog", "(", "text", ")", ":", "lex", "=", "VerilogLexer", "name", "=", "None", "kind", "=", "None", "saved_type", "=", "None", "mode", "=", "'input'", "ptype", "=", "'wire'", "metacomments", "=", "[", "]", "parameters", "=", "[", "]", ...
Parse a text buffer of Verilog code Args: text (str): Source code to parse Returns: List of parsed objects.
[ "Parse", "a", "text", "buffer", "of", "Verilog", "code" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/verilog_parser.py#L102-L206
train
Parse a text buffer of Verilog code into a list of objects.
kevinpt/hdlparse
hdlparse/verilog_parser.py
VerilogExtractor.extract_objects
def extract_objects(self, fname, type_filter=None): '''Extract objects from a source file Args: fname(str): Name of file to read from type_filter (class, optional): Object class to filter results Returns: List of objects extracted from the file. ''' objects = [] if fname in se...
python
def extract_objects(self, fname, type_filter=None): '''Extract objects from a source file Args: fname(str): Name of file to read from type_filter (class, optional): Object class to filter results Returns: List of objects extracted from the file. ''' objects = [] if fname in se...
[ "def", "extract_objects", "(", "self", ",", "fname", ",", "type_filter", "=", "None", ")", ":", "objects", "=", "[", "]", "if", "fname", "in", "self", ".", "object_cache", ":", "objects", "=", "self", ".", "object_cache", "[", "fname", "]", "else", ":"...
Extract objects from a source file Args: fname(str): Name of file to read from type_filter (class, optional): Object class to filter results Returns: List of objects extracted from the file.
[ "Extract", "objects", "from", "a", "source", "file" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/verilog_parser.py#L225-L246
train
Extract objects from a source file
kevinpt/hdlparse
hdlparse/verilog_parser.py
VerilogExtractor.extract_objects_from_source
def extract_objects_from_source(self, text, type_filter=None): '''Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects. ''' objects = parse_verilog(text) ...
python
def extract_objects_from_source(self, text, type_filter=None): '''Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects. ''' objects = parse_verilog(text) ...
[ "def", "extract_objects_from_source", "(", "self", ",", "text", ",", "type_filter", "=", "None", ")", ":", "objects", "=", "parse_verilog", "(", "text", ")", "if", "type_filter", ":", "objects", "=", "[", "o", "for", "o", "in", "objects", "if", "isinstance...
Extract object declarations from a text buffer Args: text (str): Source code to parse type_filter (class, optional): Object class to filter results Returns: List of parsed objects.
[ "Extract", "object", "declarations", "from", "a", "text", "buffer" ]
be7cdab08a8c18815cc4504003ce9ca7fff41022
https://github.com/kevinpt/hdlparse/blob/be7cdab08a8c18815cc4504003ce9ca7fff41022/hdlparse/verilog_parser.py#L249-L263
train
Extract object declarations from a text buffer containing a verilog file.
ueg1990/faker-schema
faker_schema/schema_loader.py
load_json_from_file
def load_json_from_file(file_path): """Load schema from a JSON file""" try: with open(file_path) as f: json_data = json.load(f) except ValueError as e: raise ValueError('Given file {} is not a valid JSON file: {}'.format(file_path, e)) else: return json_data
python
def load_json_from_file(file_path): """Load schema from a JSON file""" try: with open(file_path) as f: json_data = json.load(f) except ValueError as e: raise ValueError('Given file {} is not a valid JSON file: {}'.format(file_path, e)) else: return json_data
[ "def", "load_json_from_file", "(", "file_path", ")", ":", "try", ":", "with", "open", "(", "file_path", ")", "as", "f", ":", "json_data", "=", "json", ".", "load", "(", "f", ")", "except", "ValueError", "as", "e", ":", "raise", "ValueError", "(", "'Giv...
Load schema from a JSON file
[ "Load", "schema", "from", "a", "JSON", "file" ]
419175eaf34baa43b306dd05c17362763948ec49
https://github.com/ueg1990/faker-schema/blob/419175eaf34baa43b306dd05c17362763948ec49/faker_schema/schema_loader.py#L4-L12
train
Load schema from a JSON file
ueg1990/faker-schema
faker_schema/schema_loader.py
load_json_from_string
def load_json_from_string(string): """Load schema from JSON string""" try: json_data = json.loads(string) except ValueError as e: raise ValueError('Given string is not valid JSON: {}'.format(e)) else: return json_data
python
def load_json_from_string(string): """Load schema from JSON string""" try: json_data = json.loads(string) except ValueError as e: raise ValueError('Given string is not valid JSON: {}'.format(e)) else: return json_data
[ "def", "load_json_from_string", "(", "string", ")", ":", "try", ":", "json_data", "=", "json", ".", "loads", "(", "string", ")", "except", "ValueError", "as", "e", ":", "raise", "ValueError", "(", "'Given string is not valid JSON: {}'", ".", "format", "(", "e"...
Load schema from JSON string
[ "Load", "schema", "from", "JSON", "string" ]
419175eaf34baa43b306dd05c17362763948ec49
https://github.com/ueg1990/faker-schema/blob/419175eaf34baa43b306dd05c17362763948ec49/faker_schema/schema_loader.py#L15-L22
train
Load schema from JSON string
ueg1990/faker-schema
faker_schema/faker_schema.py
FakerSchema._generate_one_fake
def _generate_one_fake(self, schema): """ Recursively traverse schema dictionary and for each "leaf node", evaluate the fake value Implementation: For each key-value pair: 1) If value is not an iterable (i.e. dict or list), evaluate the fake data (base case) 2) I...
python
def _generate_one_fake(self, schema): """ Recursively traverse schema dictionary and for each "leaf node", evaluate the fake value Implementation: For each key-value pair: 1) If value is not an iterable (i.e. dict or list), evaluate the fake data (base case) 2) I...
[ "def", "_generate_one_fake", "(", "self", ",", "schema", ")", ":", "data", "=", "{", "}", "for", "k", ",", "v", "in", "schema", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "data", "[", "k", "]", "=", "self"...
Recursively traverse schema dictionary and for each "leaf node", evaluate the fake value Implementation: For each key-value pair: 1) If value is not an iterable (i.e. dict or list), evaluate the fake data (base case) 2) If value is a dictionary, recurse 3) If value is a ...
[ "Recursively", "traverse", "schema", "dictionary", "and", "for", "each", "leaf", "node", "evaluate", "the", "fake", "value" ]
419175eaf34baa43b306dd05c17362763948ec49
https://github.com/ueg1990/faker-schema/blob/419175eaf34baa43b306dd05c17362763948ec49/faker_schema/faker_schema.py#L13-L32
train
Recursively traverse the schema dictionary and evaluate the fake data
russ-/pychallonge
challonge/api.py
fetch
def fetch(method, uri, params_prefix=None, **params): """Fetch the given uri and return the contents of the response.""" params = urlencode(_prepare_params(params, params_prefix)) binary_params = params.encode('ASCII') # build the HTTP request url = "https://%s/%s.xml" % (CHALLONGE_API_URL, uri) ...
python
def fetch(method, uri, params_prefix=None, **params): """Fetch the given uri and return the contents of the response.""" params = urlencode(_prepare_params(params, params_prefix)) binary_params = params.encode('ASCII') # build the HTTP request url = "https://%s/%s.xml" % (CHALLONGE_API_URL, uri) ...
[ "def", "fetch", "(", "method", ",", "uri", ",", "params_prefix", "=", "None", ",", "*", "*", "params", ")", ":", "params", "=", "urlencode", "(", "_prepare_params", "(", "params", ",", "params_prefix", ")", ")", "binary_params", "=", "params", ".", "enco...
Fetch the given uri and return the contents of the response.
[ "Fetch", "the", "given", "uri", "and", "return", "the", "contents", "of", "the", "response", "." ]
bc202d7140cb08d11d345564f721c2f57129b84f
https://github.com/russ-/pychallonge/blob/bc202d7140cb08d11d345564f721c2f57129b84f/challonge/api.py#L41-L74
train
Fetch the given uri and return the contents of the response.
russ-/pychallonge
challonge/api.py
fetch_and_parse
def fetch_and_parse(method, uri, params_prefix=None, **params): """Fetch the given uri and return the root Element of the response.""" doc = ElementTree.parse(fetch(method, uri, params_prefix, **params)) return _parse(doc.getroot())
python
def fetch_and_parse(method, uri, params_prefix=None, **params): """Fetch the given uri and return the root Element of the response.""" doc = ElementTree.parse(fetch(method, uri, params_prefix, **params)) return _parse(doc.getroot())
[ "def", "fetch_and_parse", "(", "method", ",", "uri", ",", "params_prefix", "=", "None", ",", "*", "*", "params", ")", ":", "doc", "=", "ElementTree", ".", "parse", "(", "fetch", "(", "method", ",", "uri", ",", "params_prefix", ",", "*", "*", "params", ...
Fetch the given uri and return the root Element of the response.
[ "Fetch", "the", "given", "uri", "and", "return", "the", "root", "Element", "of", "the", "response", "." ]
bc202d7140cb08d11d345564f721c2f57129b84f
https://github.com/russ-/pychallonge/blob/bc202d7140cb08d11d345564f721c2f57129b84f/challonge/api.py#L77-L80
train
Fetch the given uri and return the root Element of the response.
russ-/pychallonge
challonge/api.py
_parse
def _parse(root): """Recursively convert an Element into python data types""" if root.tag == "nil-classes": return [] elif root.get("type") == "array": return [_parse(child) for child in root] d = {} for child in root: type = child.get("type") or "string" if child.g...
python
def _parse(root): """Recursively convert an Element into python data types""" if root.tag == "nil-classes": return [] elif root.get("type") == "array": return [_parse(child) for child in root] d = {} for child in root: type = child.get("type") or "string" if child.g...
[ "def", "_parse", "(", "root", ")", ":", "if", "root", ".", "tag", "==", "\"nil-classes\"", ":", "return", "[", "]", "elif", "root", ".", "get", "(", "\"type\"", ")", "==", "\"array\"", ":", "return", "[", "_parse", "(", "child", ")", "for", "child", ...
Recursively convert an Element into python data types
[ "Recursively", "convert", "an", "Element", "into", "python", "data", "types" ]
bc202d7140cb08d11d345564f721c2f57129b84f
https://github.com/russ-/pychallonge/blob/bc202d7140cb08d11d345564f721c2f57129b84f/challonge/api.py#L83-L108
train
Recursively convert an Element into python data types
russ-/pychallonge
challonge/api.py
_prepare_params
def _prepare_params(dirty_params, prefix=None): """Prepares parameters to be sent to challonge.com. The `prefix` can be used to convert parameters with keys that look like ("name", "url", "tournament_type") into something like ("tournament[name]", "tournament[url]", "tournament[tournament_type]"), ...
python
def _prepare_params(dirty_params, prefix=None): """Prepares parameters to be sent to challonge.com. The `prefix` can be used to convert parameters with keys that look like ("name", "url", "tournament_type") into something like ("tournament[name]", "tournament[url]", "tournament[tournament_type]"), ...
[ "def", "_prepare_params", "(", "dirty_params", ",", "prefix", "=", "None", ")", ":", "params", "=", "{", "}", "for", "k", ",", "v", "in", "dirty_params", ".", "items", "(", ")", ":", "if", "hasattr", "(", "v", ",", "\"isoformat\"", ")", ":", "v", "...
Prepares parameters to be sent to challonge.com. The `prefix` can be used to convert parameters with keys that look like ("name", "url", "tournament_type") into something like ("tournament[name]", "tournament[url]", "tournament[tournament_type]"), which is how challonge.com expects parameters describin...
[ "Prepares", "parameters", "to", "be", "sent", "to", "challonge", ".", "com", "." ]
bc202d7140cb08d11d345564f721c2f57129b84f
https://github.com/russ-/pychallonge/blob/bc202d7140cb08d11d345564f721c2f57129b84f/challonge/api.py#L111-L134
train
Prepares parameters to be sent to challonge. com.
alvinwan/md2py
md2py/md2py.py
TreeOfContents.expandDescendants
def expandDescendants(self, branches): """ Expand descendants from list of branches :param list branches: list of immediate children as TreeOfContents objs :return: list of all descendants """ return sum([b.descendants() for b in branches], []) + \ [b.source ...
python
def expandDescendants(self, branches): """ Expand descendants from list of branches :param list branches: list of immediate children as TreeOfContents objs :return: list of all descendants """ return sum([b.descendants() for b in branches], []) + \ [b.source ...
[ "def", "expandDescendants", "(", "self", ",", "branches", ")", ":", "return", "sum", "(", "[", "b", ".", "descendants", "(", ")", "for", "b", "in", "branches", "]", ",", "[", "]", ")", "+", "[", "b", ".", "source", "for", "b", "in", "branches", "...
Expand descendants from list of branches :param list branches: list of immediate children as TreeOfContents objs :return: list of all descendants
[ "Expand", "descendants", "from", "list", "of", "branches" ]
7f28a008367d7d9b5b3c8bbf7baf17985271489f
https://github.com/alvinwan/md2py/blob/7f28a008367d7d9b5b3c8bbf7baf17985271489f/md2py/md2py.py#L72-L80
train
Expand descendants from list of branches as TreeOfContents objs
alvinwan/md2py
md2py/md2py.py
TreeOfContents.parseBranches
def parseBranches(self, descendants): """ Parse top level of markdown :param list elements: list of source objects :return: list of filtered TreeOfContents objects """ parsed, parent, cond = [], False, lambda b: (b.string or '').strip() for branch in filter(cond,...
python
def parseBranches(self, descendants): """ Parse top level of markdown :param list elements: list of source objects :return: list of filtered TreeOfContents objects """ parsed, parent, cond = [], False, lambda b: (b.string or '').strip() for branch in filter(cond,...
[ "def", "parseBranches", "(", "self", ",", "descendants", ")", ":", "parsed", ",", "parent", ",", "cond", "=", "[", "]", ",", "False", ",", "lambda", "b", ":", "(", "b", ".", "string", "or", "''", ")", ".", "strip", "(", ")", "for", "branch", "in"...
Parse top level of markdown :param list elements: list of source objects :return: list of filtered TreeOfContents objects
[ "Parse", "top", "level", "of", "markdown" ]
7f28a008367d7d9b5b3c8bbf7baf17985271489f
https://github.com/alvinwan/md2py/blob/7f28a008367d7d9b5b3c8bbf7baf17985271489f/md2py/md2py.py#L82-L98
train
Parse top level of markdown tree of contents.
alvinwan/md2py
md2py/md2py.py
TreeOfContents.fromMarkdown
def fromMarkdown(md, *args, **kwargs): """ Creates abstraction using path to file :param str path: path to markdown file :return: TreeOfContents object """ return TOC.fromHTML(markdown(md, *args, **kwargs))
python
def fromMarkdown(md, *args, **kwargs): """ Creates abstraction using path to file :param str path: path to markdown file :return: TreeOfContents object """ return TOC.fromHTML(markdown(md, *args, **kwargs))
[ "def", "fromMarkdown", "(", "md", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "TOC", ".", "fromHTML", "(", "markdown", "(", "md", ",", "*", "args", ",", "*", "*", "kwargs", ")", ")" ]
Creates abstraction using path to file :param str path: path to markdown file :return: TreeOfContents object
[ "Creates", "abstraction", "using", "path", "to", "file" ]
7f28a008367d7d9b5b3c8bbf7baf17985271489f
https://github.com/alvinwan/md2py/blob/7f28a008367d7d9b5b3c8bbf7baf17985271489f/md2py/md2py.py#L130-L137
train
Creates a TreeOfContents object from a markdown string.
alvinwan/md2py
md2py/md2py.py
TreeOfContents.fromHTML
def fromHTML(html, *args, **kwargs): """ Creates abstraction using HTML :param str html: HTML :return: TreeOfContents object """ source = BeautifulSoup(html, 'html.parser', *args, **kwargs) return TOC('[document]', source=source, descendan...
python
def fromHTML(html, *args, **kwargs): """ Creates abstraction using HTML :param str html: HTML :return: TreeOfContents object """ source = BeautifulSoup(html, 'html.parser', *args, **kwargs) return TOC('[document]', source=source, descendan...
[ "def", "fromHTML", "(", "html", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "source", "=", "BeautifulSoup", "(", "html", ",", "'html.parser'", ",", "*", "args", ",", "*", "*", "kwargs", ")", "return", "TOC", "(", "'[document]'", ",", "source...
Creates abstraction using HTML :param str html: HTML :return: TreeOfContents object
[ "Creates", "abstraction", "using", "HTML" ]
7f28a008367d7d9b5b3c8bbf7baf17985271489f
https://github.com/alvinwan/md2py/blob/7f28a008367d7d9b5b3c8bbf7baf17985271489f/md2py/md2py.py#L140-L150
train
Creates a TreeOfContents object from a HTML string.