Skip to main content

CLPU Utilities

Project description

This file describes the module of CLPU utilities and related aspects to users and maintainers.

CLPU Utilities

Abstract: This module bundels functions which are frequently used for applications at the Centro de Laseres Pulsados, Villamayor, Spain. Although we intend to deliver reliable software solutions, we can not guarantee that every implementation is flawless. We encourage the user to re-read the code and alert us if bugs are found.

Scripts

Management Module

Rename Incoming Files CatchAndRename

This class waits for new files in a directory and renames them to str(prefix+"_"+number+"."+extension) according to

  • an optional input variable prefix with default "",
  • counting up from an optional input variable number that defaults to number = 0,
  • and without changing the original extension.

The chase for new files is activated by setting the input parameter loop = True. The class can be used in a functional way

from pyclpu import manager

chase = manager.CatchAndRename(directory = "path/to/directory/", prefix = "any_string", number = 42, loop=True)

with

A more object oriented use case is described below. The chase for new files is activated by setting the input parameter loop = True and paused by setting loop = False.

from pyclpu import manager
import time

chase = manager.CatchAndRename()

chase.directory = "path/to/test"
chase.prefix = "any_string"
chase.number = 42

chase.loop = True

time.sleep(100)

chase.loop = False`

time.sleep(100)

chase.loop = True

Files that arrive in the directory during a pause will be ignored when switching on the loop again with loop = True.

Image Module

Warp Transform PerspectiveTransform

The class allows to transform a linearly distorted input image into a trapez-corrected view on it. The class can be used in a functional way

from pyclpu import image

warp = image.PerspectiveTransform(source = image.imread("path/to/test.jpg")) 

with output

  • the warped image in warp.warped and
  • the coordinates of cornes from the source image stored in warp.sourcecorners.

Note that the source image is not part of the object in its final form. The coordinates of the corner points of the target rectangle can also be parsed to the function as np.array() of shape (4,2) with the keyword sourcecorners. A more object oriented use case can deal with loops where all warps have the same source corner coordinates

from pyclpu import image

warp_it = image.PerspectiveTransform()

image_stack = image.imread(path/to/directory/with/many/images/)

warp = []

for image in image_stack:
    warp_it.source = image
    warp.append[{"warped" : warp_it.warped, "sourcecorners" : warp_it.sourcecorners}]

with results beeing stored in a list warp. The dynamic modification of warp.sourcecorners is possible.

Installation

Run pip install pyclpu when connected to the internet; or if not connected to the internet pip install . within the main folder of the project (where you find also files like README.md, setup.py, LICENCE).

Developper's Guide

To get started, clone the project into your working directory git clone https://srvgitlab.clpu.int/mehret/pyclpu.git and hop inside cd pyclpu. Create the anaconda environment in Anaconda based on the clpu.yml file delivered in the main folder of the project, e.g. in the Anaconda prompt with conda env create -f clpu.yml and activate it with conda activate clpu.

Integration and Testing

Install actualized versions from the main folder with pip install ..

Export

Before exporting a new version of the module

  • increase the version counters in setup.py and pyclpu\__init__.py,
  • update the .ymlfile if needed via conda env export --from-history > clpu.yml,
  • update the documentation via pdoc --html pyclpu.

Export with python setup.py sdist to dist/. Then to upload all distributions created under dist/ execute twine upload dist/*or to upload the source distribution with a gpg signature twine upload dist/pyexample-0.1.0.tar.gz pyexample-0.1.0.tar.gz.asc. Now the distribution is updated in pyPIP. For the Anaconda version, run

Close the procedure orderly:

  • git-commit the code into the developper's branch dev with a note on the new version number,
  • git-merge the developper's branch into the main branch master.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyclpu-0.1.2.tar.gz (22.8 kB view details)

Uploaded Source

File details

Details for the file pyclpu-0.1.2.tar.gz.

File metadata

  • Download URL: pyclpu-0.1.2.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.63.0 CPython/3.6.15

File hashes

Hashes for pyclpu-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8876eec5917de19bb36da7b44fd79e9864a6f7cc866d1c680502268c15bec01c
MD5 e317eeb40c283f4641e194a2459e536b
BLAKE2b-256 3e74f2e9d22ccf170c912e95d21296c47838e3bd318951c6e0cec633e41af18e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page