When observing data, the key question is: What can I learn from the observation? Bayesian inference treats all parameters of the model as random variables. The main task is to update their distribution as new data is observed. Hence, quantifying uncertainty of the parameter estimation is always part of the task. In this course we will introduce the basic theoretical concepts of Bayesian Statistics and Bayesian inference. We discuss the computational techniques and their implementations, different types of models as well as model selection procedures. We will exercise on the existing datasets using the PyMC3 framework for practicals.
Information
The overall goals of this course were the following:
Bayes theorem, Prior and Posterior distributions;
Computational challenges and techniques: MCMC, variational approaches;
This plugin allows a number of configurations to be passed:
outputFile: Output PO file name (default is the ${currentFileProcessed}.po)
outputDir: Output directory (default is dir of the current file being processed)
includeReference: Whether to include a file reference for PO entries (default false)
baseReferenceDir: Directory that should be used as a staring point for reference paths
charset: Character set for the PO (default UTF-8)
headers: Object indicating all PO headers to include. See the default headers here.
component/function: Objects customizing the extraction for component/function respectively. This includes the React component name to look for, the function names, and so on. See the default configuration here.
// Verbose style, specifying gettext args via props<Messageid="You have a cat."idPlural="You have {cats} cats!"comment="User profile description for a public profile"count={numCats}cats={numCatsFormatted}/>// Shortform style, using gettext function directly<Messagei18n={_('Hello World')}/>_c('Flag','Physical Object')
Output (someCode.js.po)
msgid ""
msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Plural-Forms: nplurals=2; plural=(n!=1);\n"
"Language: en_US\n"
"PO-Revision-Date: 2017-02-08T05:27:35.094Z\n"
#: someCode.js
#. User profile description for a public profile
msgid "You have a cat."
msgid_plural "You have {cats} cats!"
msgstr[0] ""
msgstr[1] ""
#: someCode.js
msgctxt "Physical Object"
msgid "Flag"
msgstr ""
#: someCode.js
msgid "Hello World"
msgstr ""
Next Steps
You can use my other library react-translations, which plays nicely with this babel plugin. Otherwise you’ll need to build out these components and hook them up to a basic gettext client such as Jed.
Motivation
Why not use ICU MessageFormat?
ICU patterns strings, while pretty powerful, can become clunkly very fast. Gettext style strings should be enough to cover the typical use cases and are easy to use and understand. More importantly, ICU strings are not always supported by translators and translation providers, whereas the PO format is a de facto standard.
Why not use xgettext to extract?
xgettext is a difficult dependency to install and manage since it’s not native to the JS ecosystem. Also, xgettext will only support extraction from call expressions. Regardless, the tool definitely does not support JSX/ES6, so you’ll be running your code through Babel anyway.
Why not use a simple JSON format for strings (or some format X)?
Many extraction tools invent their own format, or use a basic JSON structure, which either ends up being too simple (e.g. not able to support pluralization) and/or not translator friendly (translators are used to working with certain formats). Gettext/PO is a proven method for translation that satisfies everyone: translators, developers, product, and users.
Acknowledgements
Thanks to the folks over at Sentry for their blog post, and their extractor tool, both of which served as an inspiration for me to utilize Babel to extend the extraction process to React.
The ISWOC Treebank is a dependency treebank with morphosyntactic and
information-structure annotation. It includes texts in several older
Indo-European languages and is freely available under a Creative Commons
Attribution-NonCommercial-ShareAlike 3.0 License.
Please cite as
Bech, Kristin and Kristine Eide. 2014. The ISWOC corpus. Department of Literature, Area Studies and European Languages, University of Oslo. http://iswoc.github.com.
Releases of the ISWOC Treebank are hosted on Github.
Contents
The following texts are included in this release of the treebank:
Text
Language
Filename
Size
Ælfric’s Lives of Saints
Old English
æls
3137 tokens
Apollonius of Tyre
Old English
apt
5541 tokens
Anglo-Saxon Chronicles
Old English
chrona
5939 tokens
Orosius
Old English
or
1728 tokens
West-Saxon Gospels
Old English
wscp
13061 tokens
La Vie Saint Eustace
Old French
eustace
2340 tokens
Crónica Geral de Espanha 2-12
Portuguese
cge1
12074 tokens
Crónica Geral de Espanha 155-167
Portuguese
cge2
10547 tokens
Décadas Livro 5, VIII, 9-14
Portuguese
coutdec-v-8
13794 tokens
Crónica de Alfonso XI
Spanish
alfonso-xi
7942 tokens
Crónica de España
Spanish
ce
4627 tokens
El Conde Lucanor
Spanish
cdeluc
17551 tokens
Estoria de Espanna I
Spanish
ee1
9488 tokens
General Estoria parte IV Daniel
Spanish
ge4
9233 tokens
Libro delos claros varones
Spanish
varones
5820 tokens
(The ‘size’ column in the table above shows the number of annotated tokens in
a text. The number of tokens will be slightly larger than the number of words
in the original printed edition as some words have been split into multiple
tokens and some tokens have been inserted during annotation.)
Please see the XML files for detailed metadata and a full list of contributors.
Data formats
The texts are available on two formats:
PROIEL XML: These files are the authoritative source files and the only ones
that contain all available annotation. They contain the complete morphological,
syntactic and information-structure annotation, as well as the complete text,
including punctuation, section headers etc. The schema is defined in proiel.xsd.
DB_NAME – optional Your database name from mongoDB. Default will be ‘my’
STRING – optional Session String For Premium Users To Upload 4GB File
LOG_CHANNEL – Channel Id to Store Files renamed files. Act as a Dump
Commands
Copy and paste the command in Botfather
start - Start Messsage
viewthumb - View Your Saved thumbnail
delthumb - Delete Your Thumbnail
about - About Bot
broadcast - (Admin Use Only)Send Message To All Users
addpremium - (Admin Use Only)Add Users To Rename More Then 4Gb Files and Remove Time Limit
og tag scrapper is an api to scrap og tags / meta tags
and return title, description, images in the api
Description
Og Tag Scrapper exposes an api that will take a site url and return the meta tags values of title, description, and images used in the site. It will first try to find the Open Graph (og) meta tags on the site.
If there any above of og tags not found it will fallback to site meta tags.
This library provides a comprehensive set of static methods for file and
directory operations, including high-performance batch operations for processing
multiple files efficiently.
All methods are available through the AlexSkrypnyk\File\File class.
useAlexSkrypnyk\File\Exception\FileException;useAlexSkrypnyk\File\ExtendedSplFileInfo;useAlexSkrypnyk\File\File;
try {
// Get current working directory$cwd = File::cwd();
// Copy a directory recursively
File::copy('/path/to/source', '/path/to/destination');
// Check if a file contains a stringif (File::contains('/path/to/file.txt', 'search term')) {
// Do something
}
// Process string content directly$content = File::read('/path/to/file.txt');
$processed = File::replaceContent($content, 'old', 'new');
$processed = File::removeToken($processed, '# BEGIN', '# END');
File::dump('/path/to/file.txt', $processed);
// Or use batch operations for better performance
File::addTaskDirectory(function(ExtendedSplFileInfo$file_info): ExtendedSplFileInfo {
$content = File::replaceContent($file_info->getContent(), 'old', 'new');
$file_info->setContent($content);
return$file_info;
});
File::runTaskDirectory('/path/to/directory');
} catch (FileException$exception) {
// Handle any file operation errorsecho$exception->getMessage();
}
Available Functions
Function
Description
absolute()
Get absolute path for provided absolute or relative file.
compare()
Compare files between source and destination directories.
contains()
Check if file contains a specific string or matches a pattern.
containsInDir()
Find all files in directory containing a specific string.
copy()
Copy file or directory.
copyIfExists()
Copy file or directory if it exists.
cwd()
Get current working directory with absolute path.
diff()
Create diff files between baseline and destination directories. See Diff Operations below.
dir()
Get absolute path for existing directory.
dirIsEmpty()
Check if directory is empty.
dump()
Write content to a file.
exists()
Check if file or directory exists.
findMatchingPath()
Find first path that matches a needle among provided paths.
mkdir()
Creates a directory if it doesn’t exist.
patch()
Apply patch files to a baseline and produce a destination.
read()
Read file contents.
realpath()
Replacement for PHP’s realpath resolves non-existing paths.
remove()
Remove file or directory.
removeLine()
Remove lines containing a specific string from a file.
removeToken()
Remove tokens and optionally content between tokens from a string.
removeTokenInFile()
Remove tokens and optionally content between tokens from a file.
removeTokenInDir()
Remove tokens and optionally content between tokens from all files in a directory.
renameInDir()
Rename files in directory by replacing part of the filename.
replaceContent()
Replace content in a string.
replaceContentCallback()
Replace content in a string using a callback processor.
replaceContentInFile()
Replace content in a file.
replaceContentCallbackInFile()
Replace content in a file using a callback processor.
replaceContentInDir()
Replace content in all files in a directory.
replaceContentCallbackInDir()
Replace content in all files in a directory using a callback processor.
collapseRepeatedEmptyLines()
Remove multiple consecutive empty lines, keeping at most one empty line between content blocks.
rmdir()
Remove directory recursively.
rmdirEmpty()
Remove directory recursively if empty.
scandirRecursive()
Recursively scan directory for files.
sync()
Synchronize files from source to destination directory.
tmpdir()
Create temporary directory.
Batch Operations
For improved performance when processing multiple files, the library provides
batch operations that minimize directory scans and optimize I/O operations:
Function
Description
addTaskDirectory()
Add a batch task to be executed on all files in a directory.
runTaskDirectory()
Execute all queued tasks on files in a directory with optimized I/O.
clearTaskDirectory()
Clear all queued batch tasks.
replaceContent()
Replace content in a string (base method for batch processing).
replaceContentCallback()
Replace content in a string using a callback processor (base method for batch processing).
removeToken()
Remove tokens from a string (base method for batch processing).
collapseRepeatedEmptyLines()
Remove multiple consecutive empty lines from a string (base method for batch processing).
Performance Benefits
The batch operations provide significant performance improvements over
traditional file operations:
Single directory scan: Instead of scanning the directory multiple times
Single I/O per file: Each file is read once, processed by all tasks, then
written once
Memory efficient: Uses generators to handle large file sets without
loading everything into memory
Performance Results: In tests with 5,000 files across 100 directories
performing 10 operations per file:
Traditional approach: ~16s (multiple directory scans, multiple I/O per file)
Batch approach: ~1.7s (~89% faster, single directory scan, single I/O per
file)
Architecture
The batch operations are powered by an internal Tasker queue management system
that:
Uses PHP generators for memory-efficient processing of large file sets
Implements a two-way communication pattern between the queue and file
processors
Leverages ExtendedSplFileInfo objects for rich file context and metadata
Provides type-safe object validation to ensure data integrity
Maintains complete separation between the generic queue system and
file-specific operations
This architecture allows the library to scale efficiently from small single-file
operations to large-scale batch processing scenarios.
Diff Operations
The diff(), patch(), and compare() functions provide powerful tools for
working with file differences between directories:
useAlexSkrypnyk\File\File;
useAlexSkrypnyk\File\Exception\PatchException;
// Generate diff files between baseline and destination directories
File::diff('/path/to/baseline', '/path/to/destination', '/path/to/diff');
// Compare directories to determine if they're equal$result = File::compare('/path/to/source', '/path/to/destination');
// Apply patches to transform a baseline directorytry {
File::patch('/path/to/baseline', '/path/to/diff', '/path/to/patched');
} catch (PatchException$exception) {
echo$exception->getMessage(); // Returns a detailed error message.// Additional contextual information$path = $exception->getFilePath(); // Gets the affected file path.$line_number = $exception->getLineNumber(); // Gets the line number where the error occurred.$line_content = $exception->getLineContent(); // Gets the content of the problematic line.
}
The diff functionality allows you to:
Generate differences between two directory structures
Store those differences as patch files
Apply those patches to recreate directory structures elsewhere
The PatchException provides detailed error messages with contextual
information when patch operations fail, making debugging easier.
Ignoring Files and Content Changes
You can create a .ignorecontent file in your directories to specify patterns
for files or content that should be ignored during comparison. This is useful
for timestamps, randomly generated values, or files that shouldn’t be compared.
The syntax for .ignorecontent file is similar to .gitignore with additional
content ignoring capabilities:
# Comments start with #
file.txt # Ignore this specific file
logs/ # Ignore this directory and all subdirectories
temp/* # Ignore all files in directory, but not subdirectories
^config.json # Ignore content changes in this file, but check file exists
^data/ # Ignore content changes in all files in dir and subdirs
^cache/* # Ignore content changes in all files in dir, but not subdirs
!important.txt # Do not ignore this file (exception)
!^settings.php # Do not ignore content changes in this file
Prefix meanings:
No prefix: Ignore file/directory completely
^: Ignore content changes but verify file/directory exists
!: Exception – do not ignore this file/directory
!^: Exception – do not ignore content changes in this file/directory
When parsing these rules, the library may throw a RulesException if there are
issues:
The library includes PHPUnit traits for testing files and directories:
Directory Assertions Trait
Assertion Method
Description
assertDirectoryContainsString()
Assert that a directory contains files with a specific string.
assertDirectoryNotContainsString()
Assert that a directory does not contain files with a specific string.
assertDirectoryContainsWord()
Assert that a directory contains files with a specific word (bounded by word boundaries).
assertDirectoryNotContainsWord()
Assert that a directory does not contain files with a specific word.
assertDirectoryEqualsDirectory()
Assert that two directories have identical structure and content.
assertDirectoryEqualsPatchedBaseline()
Assert that a directory is equal to the patched baseline (baseline + diff).
Usage example:
usePHPUnit\Framework\TestCase;
useAlexSkrypnyk\File\Tests\Traits\DirectoryAssertionsTrait;
class MyTest extends TestCase {
use DirectoryAssertionsTrait;
publicfunctiontestDirectories(): void {
// Assert directory contains "example" string in at least one file$this->assertDirectoryContainsString('example', '/path/to/directory');
// Assert two directories are identical$this->assertDirectoryEqualsDirectory('/path/to/dir1', '/path/to/dir2');
}
}
File Assertions Trait
Assertion Method
Description
assertFileContainsString()
Assert that a file contains a specific string.
assertFileNotContainsString()
Assert that a file does not contain a specific string.
assertFileContainsWord()
Assert that a file contains a specific word (bounded by word boundaries).
assertFileNotContainsWord()
Assert that a file does not contain a specific word.
assertFileEqualsFile()
Assert that a file equals another file in contents.
assertFileNotEqualsFile()
Assert that a file does not equal another file in contents.
Usage example:
usePHPUnit\Framework\TestCase;
useAlexSkrypnyk\File\Tests\Traits\FileAssertionsTrait;
class MyTest extends TestCase {
use FileAssertionsTrait;
publicfunctiontestFiles(): void {
// Assert file contains "example" string$this->assertFileContainsString('example', '/path/to/file.txt');
// Assert file contains "test" as a complete word$this->assertFileContainsWord('test', '/path/to/file.txt');
// Assert file does not contain a partial word$this->assertFileNotContainsWord('exampl', '/path/to/file.txt');
// Assert two files have identical content$this->assertFileEqualsFile('/path/to/expected.txt', '/path/to/actual.txt');
// Assert two files have different content$this->assertFileNotEqualsFile('/path/to/expected.txt', '/path/to/actual.txt');
}
}
This library provides a comprehensive set of static methods for file and
directory operations, including high-performance batch operations for processing
multiple files efficiently.
All methods are available through the AlexSkrypnyk\File\File class.
useAlexSkrypnyk\File\Exception\FileException;useAlexSkrypnyk\File\ExtendedSplFileInfo;useAlexSkrypnyk\File\File;
try {
// Get current working directory$cwd = File::cwd();
// Copy a directory recursively
File::copy('/path/to/source', '/path/to/destination');
// Check if a file contains a stringif (File::contains('/path/to/file.txt', 'search term')) {
// Do something
}
// Process string content directly$content = File::read('/path/to/file.txt');
$processed = File::replaceContent($content, 'old', 'new');
$processed = File::removeToken($processed, '# BEGIN', '# END');
File::dump('/path/to/file.txt', $processed);
// Or use batch operations for better performance
File::addTaskDirectory(function(ExtendedSplFileInfo$file_info): ExtendedSplFileInfo {
$content = File::replaceContent($file_info->getContent(), 'old', 'new');
$file_info->setContent($content);
return$file_info;
});
File::runTaskDirectory('/path/to/directory');
} catch (FileException$exception) {
// Handle any file operation errorsecho$exception->getMessage();
}
Available Functions
Function
Description
absolute()
Get absolute path for provided absolute or relative file.
compare()
Compare files between source and destination directories.
contains()
Check if file contains a specific string or matches a pattern.
containsInDir()
Find all files in directory containing a specific string.
copy()
Copy file or directory.
copyIfExists()
Copy file or directory if it exists.
cwd()
Get current working directory with absolute path.
diff()
Create diff files between baseline and destination directories. See Diff Operations below.
dir()
Get absolute path for existing directory.
dirIsEmpty()
Check if directory is empty.
dump()
Write content to a file.
exists()
Check if file or directory exists.
findMatchingPath()
Find first path that matches a needle among provided paths.
mkdir()
Creates a directory if it doesn’t exist.
patch()
Apply patch files to a baseline and produce a destination.
read()
Read file contents.
realpath()
Replacement for PHP’s realpath resolves non-existing paths.
remove()
Remove file or directory.
removeLine()
Remove lines containing a specific string from a file.
removeToken()
Remove tokens and optionally content between tokens from a string.
removeTokenInFile()
Remove tokens and optionally content between tokens from a file.
removeTokenInDir()
Remove tokens and optionally content between tokens from all files in a directory.
renameInDir()
Rename files in directory by replacing part of the filename.
replaceContent()
Replace content in a string.
replaceContentCallback()
Replace content in a string using a callback processor.
replaceContentInFile()
Replace content in a file.
replaceContentCallbackInFile()
Replace content in a file using a callback processor.
replaceContentInDir()
Replace content in all files in a directory.
replaceContentCallbackInDir()
Replace content in all files in a directory using a callback processor.
collapseRepeatedEmptyLines()
Remove multiple consecutive empty lines, keeping at most one empty line between content blocks.
rmdir()
Remove directory recursively.
rmdirEmpty()
Remove directory recursively if empty.
scandirRecursive()
Recursively scan directory for files.
sync()
Synchronize files from source to destination directory.
tmpdir()
Create temporary directory.
Batch Operations
For improved performance when processing multiple files, the library provides
batch operations that minimize directory scans and optimize I/O operations:
Function
Description
addTaskDirectory()
Add a batch task to be executed on all files in a directory.
runTaskDirectory()
Execute all queued tasks on files in a directory with optimized I/O.
clearTaskDirectory()
Clear all queued batch tasks.
replaceContent()
Replace content in a string (base method for batch processing).
replaceContentCallback()
Replace content in a string using a callback processor (base method for batch processing).
removeToken()
Remove tokens from a string (base method for batch processing).
collapseRepeatedEmptyLines()
Remove multiple consecutive empty lines from a string (base method for batch processing).
Performance Benefits
The batch operations provide significant performance improvements over
traditional file operations:
Single directory scan: Instead of scanning the directory multiple times
Single I/O per file: Each file is read once, processed by all tasks, then
written once
Memory efficient: Uses generators to handle large file sets without
loading everything into memory
Performance Results: In tests with 5,000 files across 100 directories
performing 10 operations per file:
Traditional approach: ~16s (multiple directory scans, multiple I/O per file)
Batch approach: ~1.7s (~89% faster, single directory scan, single I/O per
file)
Architecture
The batch operations are powered by an internal Tasker queue management system
that:
Uses PHP generators for memory-efficient processing of large file sets
Implements a two-way communication pattern between the queue and file
processors
Leverages ExtendedSplFileInfo objects for rich file context and metadata
Provides type-safe object validation to ensure data integrity
Maintains complete separation between the generic queue system and
file-specific operations
This architecture allows the library to scale efficiently from small single-file
operations to large-scale batch processing scenarios.
Diff Operations
The diff(), patch(), and compare() functions provide powerful tools for
working with file differences between directories:
useAlexSkrypnyk\File\File;
useAlexSkrypnyk\File\Exception\PatchException;
// Generate diff files between baseline and destination directories
File::diff('/path/to/baseline', '/path/to/destination', '/path/to/diff');
// Compare directories to determine if they're equal$result = File::compare('/path/to/source', '/path/to/destination');
// Apply patches to transform a baseline directorytry {
File::patch('/path/to/baseline', '/path/to/diff', '/path/to/patched');
} catch (PatchException$exception) {
echo$exception->getMessage(); // Returns a detailed error message.// Additional contextual information$path = $exception->getFilePath(); // Gets the affected file path.$line_number = $exception->getLineNumber(); // Gets the line number where the error occurred.$line_content = $exception->getLineContent(); // Gets the content of the problematic line.
}
The diff functionality allows you to:
Generate differences between two directory structures
Store those differences as patch files
Apply those patches to recreate directory structures elsewhere
The PatchException provides detailed error messages with contextual
information when patch operations fail, making debugging easier.
Ignoring Files and Content Changes
You can create a .ignorecontent file in your directories to specify patterns
for files or content that should be ignored during comparison. This is useful
for timestamps, randomly generated values, or files that shouldn’t be compared.
The syntax for .ignorecontent file is similar to .gitignore with additional
content ignoring capabilities:
# Comments start with #
file.txt # Ignore this specific file
logs/ # Ignore this directory and all subdirectories
temp/* # Ignore all files in directory, but not subdirectories
^config.json # Ignore content changes in this file, but check file exists
^data/ # Ignore content changes in all files in dir and subdirs
^cache/* # Ignore content changes in all files in dir, but not subdirs
!important.txt # Do not ignore this file (exception)
!^settings.php # Do not ignore content changes in this file
Prefix meanings:
No prefix: Ignore file/directory completely
^: Ignore content changes but verify file/directory exists
!: Exception – do not ignore this file/directory
!^: Exception – do not ignore content changes in this file/directory
When parsing these rules, the library may throw a RulesException if there are
issues:
The library includes PHPUnit traits for testing files and directories:
Directory Assertions Trait
Assertion Method
Description
assertDirectoryContainsString()
Assert that a directory contains files with a specific string.
assertDirectoryNotContainsString()
Assert that a directory does not contain files with a specific string.
assertDirectoryContainsWord()
Assert that a directory contains files with a specific word (bounded by word boundaries).
assertDirectoryNotContainsWord()
Assert that a directory does not contain files with a specific word.
assertDirectoryEqualsDirectory()
Assert that two directories have identical structure and content.
assertDirectoryEqualsPatchedBaseline()
Assert that a directory is equal to the patched baseline (baseline + diff).
Usage example:
usePHPUnit\Framework\TestCase;
useAlexSkrypnyk\File\Tests\Traits\DirectoryAssertionsTrait;
class MyTest extends TestCase {
use DirectoryAssertionsTrait;
publicfunctiontestDirectories(): void {
// Assert directory contains "example" string in at least one file$this->assertDirectoryContainsString('example', '/path/to/directory');
// Assert two directories are identical$this->assertDirectoryEqualsDirectory('/path/to/dir1', '/path/to/dir2');
}
}
File Assertions Trait
Assertion Method
Description
assertFileContainsString()
Assert that a file contains a specific string.
assertFileNotContainsString()
Assert that a file does not contain a specific string.
assertFileContainsWord()
Assert that a file contains a specific word (bounded by word boundaries).
assertFileNotContainsWord()
Assert that a file does not contain a specific word.
assertFileEqualsFile()
Assert that a file equals another file in contents.
assertFileNotEqualsFile()
Assert that a file does not equal another file in contents.
Usage example:
usePHPUnit\Framework\TestCase;
useAlexSkrypnyk\File\Tests\Traits\FileAssertionsTrait;
class MyTest extends TestCase {
use FileAssertionsTrait;
publicfunctiontestFiles(): void {
// Assert file contains "example" string$this->assertFileContainsString('example', '/path/to/file.txt');
// Assert file contains "test" as a complete word$this->assertFileContainsWord('test', '/path/to/file.txt');
// Assert file does not contain a partial word$this->assertFileNotContainsWord('exampl', '/path/to/file.txt');
// Assert two files have identical content$this->assertFileEqualsFile('/path/to/expected.txt', '/path/to/actual.txt');
// Assert two files have different content$this->assertFileNotEqualsFile('/path/to/expected.txt', '/path/to/actual.txt');
}
}
glimpse is a Python package built for quickly and precisely analyzing time-lapse photographs of glaciers.
Some useful things one can do with glimpse:
Camera calibration
glimpse.Camera: Model a distorted camera and perform incoming and outgoing ray projections, accounting for earth curvature and atmospheric refraction.
glimpse.convert: Convert between MATLAB, OpenCV, Agisoft PhotoScan, PhotoModeler, and glimpse camera formats, accounting for uncertainties in camera parameters.
glimpse.optimize: Perform single and multi-camera calibrations (controlling which parameters are fixed, varied, or synched across multiple cameras) using points and lines in image and world coordinates.
glimpse.svg: Load manual vector image annotations as inputs for camera calibration.
glimpse.Raster.horizon(): Compute the visible horizon from a position as input for camera calibration.
glimpse.Camera.project_dem(): Generate photorealistic synthetic images (and depth maps) from a camera model, gridded elevations, and optional orthophoto for automated control point collection and camera model validation.
glimpse.optimize.KeypointMatcher: Stabilize photographic sequences of arbitrary length using automatic image matching and globally optimal orientation estimates.
Velocity tracking
glimpse.Tracker: Compute the velocity (and corresponding uncertainty) of points visible in photographs taken from one or more positions.
glimpse.Raster.viewshed(): Compute the viewshed of a position, for tracking point selection.
References
The methods implemented in this software are described in great detail across two PhD dissertations.
Douglas Brinkerhoff (2017): Bayesian methods in glaciology, chapter 4. Uses particle filtering to extract velocities from one year of oblique time-lapse images of Columbia Glacier, Alaska.
Ethan Welty (2018): High-precision photogrammetry for glaciology. Calibrates and stabilizes time-lapse cameras using landscape cues, extends the particle filter from 2-d to 3-d (to account for uncertain surface elevations), and uses the methods on thirteen years of oblique time-lapse images of Columbia Glacier, Alaska.
Installation
glimpse has not yet been released for distribution, but can still be installed with pip from the source code on GitHub:
Thank you for considering contributing to glimpse!
What follows is intended to make contribution more accessible by codifying conventions.
Don’t be afraid to open unfinished pull requests or to ask questions if something is unclear!
No contribution is too small.
Try to limit each pull request to one change only (one bug fix, one new feature).
Always add tests and docstrings for your code.
Make sure your changes pass the continuous integration tests.
Code & docstrings
Code follows PEP 8.
It is formatted (automatically, if you use the pre-commit hooks)
to conform to the black code style and import order
with a maximum line length of 88 characters.
Docstrings follow PEP 257 and the Google style, with the exception of using section title "Arguments:" instead of "Args:".
Argument and return types are specified as type annotations and not included in the docstrings.
Examples are formatted for testing by doctest.
Unless the docstring fits in a single line, the """ are on separate lines.
defxyz_to_uv(xyz: np.ndarray) ->np.ndarray:
""" Convert world coordinates to image coordinates. Arguments: xyz: World coordinates (n, [x, y, z]). Returns: Image coordinates (n, 2). Examples: >>> xyz = np.array([[0., 1., 0.]]) >>> xyz_to_uv(xyz) array([[ 50., 50.]]) """
Tests
Unit tests are written for pytest.
As with the rest of the code, they should include type annotations and good docstrings.
To run the full test suite on the current Python version, simply run:
make test
if you have make installed, or run the equivalent:
poetry run pytest --doctest-modules src tests
The package manager poetry (see below) will manage the virtual environment and dependencies for you.
To easily install and switch between different Python versions,
consider using pyenv.
Development environment
Before you begin, you will need to have gdal,
a modern stable release of Python 3,
and the package manager poetry.
For example, using conda:
conda activate base
conda install -c conda-forge python=3.8 gdal=3.2.0 poetry=1
First, clone the glimpse repository and change into the newly created directory:
git clone https://github.com/ezwelty/glimpse
cd glimpse
Use poetry to install glimpse (and its dependencies) into a new virtual environment
linked to your current Python version:
poetry install
Run commands on this virtual environment using poetry run.
For example, run unit tests with:
poetry run pytest
or open a Python console with:
poetry run python
To avoid committing code that breaks tests or violates the style guide,
consider installing pre-commit (if needed)
and installing the hooks:
pre-commit install
You can run the pre-commit hooks anytime using:
pre-commit run --all-files
Other useful commands are listed in the Makefile.
For example, to build the documentation:
make docs
# Equivalent to:# poetry run sphinx-build docs docs/build