Code formatting
This commit is contained in:
parent
0234b20ce3
commit
2bfb988460
60 changed files with 392 additions and 396 deletions
|
|
@ -1,8 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
import atexit
|
||||
import logging
|
||||
import logging.handlers
|
||||
import sys
|
||||
import time
|
||||
import atexit
|
||||
import logging, logging.handlers
|
||||
|
||||
# Look for debug flag
|
||||
if "-d" in sys.argv or "--debug" in sys.argv:
|
||||
|
|
@ -17,33 +18,27 @@ root_log.setLevel(log_level)
|
|||
|
||||
|
||||
import os
|
||||
import pkg_resources
|
||||
|
||||
from flask import Flask, send_file, abort
|
||||
|
||||
from datetime import datetime
|
||||
|
||||
import pkg_resources
|
||||
from flask import Flask, abort, send_file
|
||||
from flask_cors import CORS, cross_origin
|
||||
|
||||
from openflexure_microscope.api.utilities import list_routes, init_default_extensions
|
||||
|
||||
from openflexure_microscope.config import JSONEncoder
|
||||
from openflexure_microscope.paths import (
|
||||
OPENFLEXURE_VAR_PATH,
|
||||
OPENFLEXURE_EXTENSIONS_PATH,
|
||||
settings_file_path,
|
||||
logs_file_path,
|
||||
)
|
||||
|
||||
from labthings import create_app
|
||||
from labthings.extensions import find_extensions
|
||||
|
||||
from openflexure_microscope.api.microscope import default_microscope as api_microscope
|
||||
|
||||
from openflexure_microscope.api.utilities import init_default_extensions, list_routes
|
||||
from openflexure_microscope.api.v2 import views
|
||||
from openflexure_microscope.config import JSONEncoder
|
||||
from openflexure_microscope.paths import (
|
||||
OPENFLEXURE_EXTENSIONS_PATH,
|
||||
OPENFLEXURE_VAR_PATH,
|
||||
logs_file_path,
|
||||
settings_file_path,
|
||||
)
|
||||
|
||||
# Handle logging
|
||||
access_log = logging.getLogger('werkzeug')
|
||||
access_log = logging.getLogger("werkzeug")
|
||||
# Block the access logs from propagating up to the root logger
|
||||
access_log.propagate = False
|
||||
|
||||
|
|
@ -207,6 +202,7 @@ atexit.register(cleanup)
|
|||
# Start the app
|
||||
if __name__ == "__main__":
|
||||
from labthings import Server
|
||||
|
||||
logging.info("Starting OpenFlexure Microscope Server...")
|
||||
server = Server(app)
|
||||
server.run(host="0.0.0.0", port=5000, debug=False, zeroconf=True)
|
||||
|
|
|
|||
|
|
@ -1,18 +1,16 @@
|
|||
from labthings import fields, find_component, current_action
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import View, ActionView, PropertyView
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request, abort
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
import time
|
||||
import numpy as np
|
||||
|
||||
import logging
|
||||
from scipy import ndimage
|
||||
import time
|
||||
from contextlib import contextmanager
|
||||
from threading import Event, Thread
|
||||
|
||||
from threading import Thread, Event
|
||||
import numpy as np
|
||||
from labthings import current_action, fields, find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, PropertyView, View
|
||||
from scipy import ndimage
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, abort, request
|
||||
from openflexure_microscope.utilities import set_properties
|
||||
|
||||
### Autofocus utilities
|
||||
|
||||
|
|
@ -447,4 +445,3 @@ autofocus_extension_v2.add_view(
|
|||
autofocus_extension_v2.add_view(
|
||||
MoveAndMeasureAPI, "/move_and_measure", endpoint="move_and_measure"
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -1,21 +1,18 @@
|
|||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import View, PropertyView
|
||||
from labthings import fields, find_component
|
||||
|
||||
from openflexure_microscope.paths import settings_file_path, check_rw
|
||||
from openflexure_microscope.config import OpenflexureSettingsFile
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
|
||||
from openflexure_microscope.api.utilities.gui import build_gui
|
||||
|
||||
from flask import abort
|
||||
import logging
|
||||
import os
|
||||
import psutil
|
||||
|
||||
from sys import platform
|
||||
|
||||
import psutil
|
||||
from flask import abort
|
||||
from labthings import fields, find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import PropertyView, View
|
||||
|
||||
from openflexure_microscope.api.utilities.gui import build_gui
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.config import OpenflexureSettingsFile
|
||||
from openflexure_microscope.paths import check_rw, settings_file_path
|
||||
|
||||
AS_SETTINGS_PATH = settings_file_path("autostorage_settings.json")
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,18 @@
|
|||
from labthings import find_component
|
||||
from labthings.views import View, ActionView
|
||||
from labthings.extensions import BaseExtension
|
||||
|
||||
from flask import abort
|
||||
|
||||
from contextlib import contextmanager
|
||||
import logging
|
||||
from contextlib import contextmanager
|
||||
|
||||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
from flask import abort
|
||||
from labthings import find_component
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
from .recalibrate_utils import (
|
||||
recalibrate_camera,
|
||||
auto_expose_and_freeze_settings,
|
||||
flat_lens_shading_table,
|
||||
recalibrate_camera,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -125,5 +124,9 @@ lst_extension_v2.add_method(
|
|||
)
|
||||
|
||||
lst_extension_v2.add_view(RecalibrateView, "/recalibrate", endpoint="recalibrate")
|
||||
lst_extension_v2.add_view(FlattenLSTView, "/flatten_lens_shading_table", endpoint="flatten_lens_shading_table")
|
||||
lst_extension_v2.add_view(DeleteLSTView, "/delete_lens_shading_table", endpoint="delete_lens_shading_table")
|
||||
lst_extension_v2.add_view(
|
||||
FlattenLSTView, "/flatten_lens_shading_table", endpoint="flatten_lens_shading_table"
|
||||
)
|
||||
lst_extension_v2.add_view(
|
||||
DeleteLSTView, "/delete_lens_shading_table", endpoint="delete_lens_shading_table"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import numpy as np
|
||||
import time
|
||||
import logging
|
||||
import time
|
||||
|
||||
import numpy as np
|
||||
from picamerax import PiCamera
|
||||
from picamerax.array import PiRGBArray, PiBayerArray
|
||||
from picamerax.array import PiBayerArray, PiRGBArray
|
||||
|
||||
|
||||
def rgb_image(camera, resize=None, **kwargs):
|
||||
|
|
|
|||
|
|
@ -1,21 +1,24 @@
|
|||
import datetime
|
||||
import itertools
|
||||
import logging
|
||||
import time
|
||||
import uuid
|
||||
import datetime
|
||||
from typing import Tuple
|
||||
from functools import reduce
|
||||
from typing import Tuple
|
||||
|
||||
from labthings import (
|
||||
current_action,
|
||||
fields,
|
||||
find_component,
|
||||
find_extension,
|
||||
update_action_progress,
|
||||
)
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
from openflexure_microscope.captures.capture_manager import generate_basename
|
||||
|
||||
from labthings import fields, find_component, find_extension, current_action, update_action_progress
|
||||
from labthings.views import View, ActionView
|
||||
from labthings.extensions import BaseExtension
|
||||
|
||||
from openflexure_microscope.devel import abort
|
||||
|
||||
import time
|
||||
|
||||
|
||||
### Grid construction
|
||||
|
||||
|
||||
|
|
@ -56,9 +59,6 @@ def flatten_grid(grid):
|
|||
### Capturing
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class ScanExtension(BaseExtension):
|
||||
def __init__(self):
|
||||
self._images_to_be_captured: int = 1
|
||||
|
|
@ -83,7 +83,12 @@ class ScanExtension(BaseExtension):
|
|||
if namemode == "coordinates":
|
||||
filename = "{}_{}_{}_{}".format(basename, *microscope.stage.position)
|
||||
else:
|
||||
filename = "{}_{}".format(basename, str(self._images_captured_so_far).zfill(len(str(self._images_to_be_captured))))
|
||||
filename = "{}_{}".format(
|
||||
basename,
|
||||
str(self._images_captured_so_far).zfill(
|
||||
len(str(self._images_to_be_captured))
|
||||
),
|
||||
)
|
||||
folder = "SCAN_{}".format(basename)
|
||||
|
||||
# Do capture
|
||||
|
|
@ -97,14 +102,14 @@ class ScanExtension(BaseExtension):
|
|||
annotations=annotations,
|
||||
tags=tags,
|
||||
metadata=metadata,
|
||||
cache_key=folder
|
||||
cache_key=folder,
|
||||
)
|
||||
|
||||
def progress(self):
|
||||
progress = (self._images_captured_so_far / self._images_to_be_captured) * 100
|
||||
logging.info(progress)
|
||||
return progress
|
||||
|
||||
|
||||
### Scanning
|
||||
def tile(
|
||||
self,
|
||||
|
|
@ -164,7 +169,9 @@ class ScanExtension(BaseExtension):
|
|||
autofocus_enabled = False
|
||||
|
||||
# Construct an x-y grid (worry about z later)
|
||||
x_y_grid = construct_grid(initial_position, stride_size[:2], grid[:2], style=style)
|
||||
x_y_grid = construct_grid(
|
||||
initial_position, stride_size[:2], grid[:2], style=style
|
||||
)
|
||||
|
||||
# Keep the initial Z position the same as our current position
|
||||
initial_z = initial_position[2]
|
||||
|
|
@ -245,7 +252,6 @@ class ScanExtension(BaseExtension):
|
|||
end = time.time()
|
||||
logging.info(f"Scan took {end - start} seconds")
|
||||
|
||||
|
||||
def stack(
|
||||
self,
|
||||
microscope,
|
||||
|
|
@ -304,6 +310,7 @@ class ScanExtension(BaseExtension):
|
|||
|
||||
scan_extension_v2 = ScanExtension()
|
||||
|
||||
|
||||
class TileScanAPI(ActionView):
|
||||
args = {
|
||||
"filename": fields.String(missing=None, example=None),
|
||||
|
|
@ -365,4 +372,5 @@ class TileScanAPI(ActionView):
|
|||
tags=args.get("tags"),
|
||||
)
|
||||
|
||||
|
||||
scan_extension_v2.add_view(TileScanAPI, "/tile", endpoint="tile")
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
from openflexure_microscope.devel import (
|
||||
JsonResponse,
|
||||
request,
|
||||
)
|
||||
|
||||
from flask import send_file, abort, url_for
|
||||
|
||||
import uuid
|
||||
import os
|
||||
import zipfile
|
||||
import tempfile
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
import uuid
|
||||
import zipfile
|
||||
|
||||
from flask import abort, send_file, url_for
|
||||
from labthings import fields, find_component, update_action_progress
|
||||
from labthings.views import View, ActionView, PropertyView
|
||||
from labthings.schema import Schema, pre_dump
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.schema import Schema, pre_dump
|
||||
from labthings.utilities import description_from_view
|
||||
from labthings.views import ActionView, PropertyView, View
|
||||
|
||||
from openflexure_microscope.devel import JsonResponse, request
|
||||
|
||||
|
||||
class ZipObjectSchema(Schema):
|
||||
|
|
@ -137,9 +133,7 @@ class ZipBuilderAPIView(ActionView):
|
|||
microscope = find_component("org.openflexure.microscope")
|
||||
|
||||
# Return a handle on the autofocus task
|
||||
return default_zip_manager.marshaled_build_zip_from_capture_ids(
|
||||
microscope, ids
|
||||
)
|
||||
return default_zip_manager.marshaled_build_zip_from_capture_ids(microscope, ids)
|
||||
|
||||
|
||||
class ZipListAPIView(PropertyView):
|
||||
|
|
@ -191,7 +185,9 @@ zip_extension_v2 = BaseExtension(
|
|||
description="Build and download capture collections as ZIP files",
|
||||
)
|
||||
|
||||
zip_extension_v2.add_view(ZipGetterAPIView, "/get/<string:session_id>", endpoint="get_id")
|
||||
zip_extension_v2.add_view(
|
||||
ZipGetterAPIView, "/get/<string:session_id>", endpoint="get_id"
|
||||
)
|
||||
zip_extension_v2.add_view(ZipListAPIView, "/get", endpoint="get")
|
||||
|
||||
zip_extension_v2.add_view(ZipBuilderAPIView, "/build", endpoint="build")
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
from .tools import devtools_extension_v2
|
||||
from .tools import devtools_extension_v2
|
||||
|
|
|
|||
|
|
@ -1,14 +1,16 @@
|
|||
import logging
|
||||
import time
|
||||
|
||||
from labthings import fields
|
||||
from labthings.extensions import BaseExtension
|
||||
from labthings.views import ActionView
|
||||
|
||||
import logging
|
||||
import time
|
||||
|
||||
class RaiseException(ActionView):
|
||||
def post(self):
|
||||
raise Exception("The developer raised an exception")
|
||||
|
||||
|
||||
class SleepFor(ActionView):
|
||||
schema = {"TimeAsleep": fields.Float()}
|
||||
args = {"time": fields.Float(description="Time to sleep, in seconds", example=0.5)}
|
||||
|
|
@ -22,6 +24,7 @@ class SleepFor(ActionView):
|
|||
logging.info("Waking up!")
|
||||
return {"TimeAsleep": (end - start)}
|
||||
|
||||
|
||||
devtools_extension_v2 = BaseExtension(
|
||||
"org.openflexure.dev.tools",
|
||||
version="0.1.0",
|
||||
|
|
@ -29,4 +32,4 @@ devtools_extension_v2 = BaseExtension(
|
|||
)
|
||||
|
||||
devtools_extension_v2.add_view(RaiseException, "/raise")
|
||||
devtools_extension_v2.add_view(SleepFor, "/sleep")
|
||||
devtools_extension_v2.add_view(SleepFor, "/sleep")
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
from openflexure_microscope.microscope import Microscope
|
||||
|
||||
import logging
|
||||
|
||||
from openflexure_microscope.microscope import Microscope
|
||||
|
||||
default_microscope = Microscope()
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
import errno
|
||||
import logging
|
||||
import os
|
||||
import errno
|
||||
|
||||
from flask import Blueprint, current_app, url_for
|
||||
from werkzeug.exceptions import BadRequest
|
||||
from flask import url_for, Blueprint, current_app
|
||||
|
||||
from . import gui
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
from .actions import enabled_root_actions
|
||||
from .captures import *
|
||||
from .instrument import *
|
||||
from .streams import *
|
||||
from .stage import *
|
||||
from .streams import *
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@
|
|||
Top-level representation of enabled actions
|
||||
"""
|
||||
from flask import url_for
|
||||
from . import camera, stage, system
|
||||
|
||||
from labthings import current_labthing
|
||||
from labthings.views import View
|
||||
from labthings.utilities import description_from_view
|
||||
from labthings.views import View
|
||||
|
||||
from . import camera, stage, system
|
||||
|
||||
_actions = {
|
||||
"capture": {
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
from labthings.views import View, ActionView
|
||||
from labthings import find_component, fields
|
||||
|
||||
from openflexure_microscope.utilities import filter_dict
|
||||
|
||||
from openflexure_microscope.api.v2.views.captures import CaptureSchema
|
||||
|
||||
import logging
|
||||
import io
|
||||
from flask import request, abort, url_for, redirect, send_file
|
||||
import logging
|
||||
|
||||
from flask import abort, redirect, request, send_file, url_for
|
||||
from labthings import fields, find_component
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse, get_bool
|
||||
from openflexure_microscope.api.v2.views.captures import CaptureSchema
|
||||
from openflexure_microscope.utilities import filter_dict
|
||||
|
||||
|
||||
class CaptureAPI(ActionView):
|
||||
|
|
@ -58,11 +57,10 @@ class CaptureAPI(ActionView):
|
|||
resize=resize,
|
||||
bayer=args.get("bayer"),
|
||||
annotations=args.get("annotations"),
|
||||
tags=args.get("tags")
|
||||
tags=args.get("tags"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
class RAMCaptureAPI(ActionView):
|
||||
"""
|
||||
Take a non-persistant image capture.
|
||||
|
|
@ -77,12 +75,8 @@ class RAMCaptureAPI(ActionView):
|
|||
missing=None, example={"width": 640, "height": 480}
|
||||
), # TODO: Validate keys
|
||||
}
|
||||
|
||||
responses = {
|
||||
200: {
|
||||
"content_type": "image/jpeg"
|
||||
}
|
||||
}
|
||||
|
||||
responses = {200: {"content_type": "image/jpeg"}}
|
||||
|
||||
def post(self, args):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,12 +1,11 @@
|
|||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
from labthings.views import View, ActionView
|
||||
from labthings import find_component, fields
|
||||
|
||||
from openflexure_microscope.utilities import axes_to_array, filter_dict
|
||||
import logging
|
||||
|
||||
from flask import Blueprint, request
|
||||
from labthings import fields, find_component
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
import logging
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
from openflexure_microscope.utilities import axes_to_array, filter_dict
|
||||
|
||||
|
||||
class MoveStageAPI(ActionView):
|
||||
|
|
@ -65,5 +64,3 @@ class ZeroStageAPI(ActionView):
|
|||
|
||||
# TODO: Make schema for microscope state
|
||||
return microscope.state["stage"]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
from labthings.views import View, ActionView
|
||||
import subprocess
|
||||
import os
|
||||
import subprocess
|
||||
from sys import platform
|
||||
|
||||
from labthings.views import ActionView, View
|
||||
|
||||
|
||||
def is_raspberrypi(raise_on_errors=False):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import logging
|
||||
from flask import abort, request, redirect, url_for, send_file
|
||||
|
||||
from openflexure_microscope.api.utilities import get_bool, JsonResponse
|
||||
|
||||
from flask import abort, redirect, request, send_file, url_for
|
||||
from labthings import Schema, fields, find_component
|
||||
from labthings.views import View, PropertyView
|
||||
from labthings.utilities import description_from_view
|
||||
from labthings.marshalling import marshal_with
|
||||
|
||||
from labthings.utilities import description_from_view
|
||||
from labthings.views import PropertyView, View
|
||||
from marshmallow import pre_dump
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse, get_bool
|
||||
|
||||
|
||||
class InstrumentSchema(Schema):
|
||||
id = fields.UUID()
|
||||
|
|
@ -130,11 +129,7 @@ class CaptureView(View):
|
|||
|
||||
class CaptureDownload(View):
|
||||
tags = ["captures"]
|
||||
responses = {
|
||||
200: {
|
||||
"content_type": "image/jpeg"
|
||||
}
|
||||
}
|
||||
responses = {200: {"content_type": "image/jpeg"}}
|
||||
|
||||
def get(self, id, filename):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,12 +1,12 @@
|
|||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
|
||||
from labthings import find_component
|
||||
from labthings.views import View, PropertyView
|
||||
from labthings.utilities import get_by_path, set_by_path, create_from_path
|
||||
|
||||
from flask import request, abort
|
||||
import logging
|
||||
|
||||
from flask import abort, request
|
||||
from labthings import find_component
|
||||
from labthings.utilities import create_from_path, get_by_path, set_by_path
|
||||
from labthings.views import PropertyView, View
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
|
||||
|
||||
class SettingsProperty(PropertyView):
|
||||
def get(self):
|
||||
|
|
@ -34,9 +34,7 @@ class SettingsProperty(PropertyView):
|
|||
|
||||
class NestedSettingsProperty(View):
|
||||
tags = ["properties"]
|
||||
responses = {
|
||||
404: {"description": "Settings key cannot be found"}
|
||||
}
|
||||
responses = {404: {"description": "Settings key cannot be found"}}
|
||||
|
||||
def get(self, route):
|
||||
"""
|
||||
|
|
@ -80,9 +78,7 @@ class StateProperty(PropertyView):
|
|||
|
||||
class NestedStateProperty(View):
|
||||
tags = ["properties"]
|
||||
responses = {
|
||||
404: {"description": "Status key cannot be found"}
|
||||
}
|
||||
responses = {404: {"description": "Status key cannot be found"}}
|
||||
|
||||
def get(self, route):
|
||||
"""
|
||||
|
|
@ -110,9 +106,7 @@ class ConfigurationProperty(PropertyView):
|
|||
|
||||
class NestedConfigurationProperty(View):
|
||||
tags = ["properties"]
|
||||
responses = {
|
||||
404: {"description": "Status key cannot be found"}
|
||||
}
|
||||
responses = {404: {"description": "Status key cannot be found"}}
|
||||
|
||||
def get(self, route):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
from labthings import find_component, fields, schema
|
||||
from labthings.views import PropertyView
|
||||
|
||||
import logging
|
||||
|
||||
from labthings import fields, find_component, schema
|
||||
from labthings.views import PropertyView
|
||||
|
||||
|
||||
class StageTypeProperty(PropertyView):
|
||||
"""The type of the stage"""
|
||||
|
|
|
|||
|
|
@ -1,21 +1,17 @@
|
|||
from openflexure_microscope.api.utilities import gen, JsonResponse
|
||||
|
||||
from labthings import find_component
|
||||
from labthings.utilities import get_by_path, set_by_path, create_from_path
|
||||
from labthings.views import View, PropertyView
|
||||
|
||||
from flask import Response
|
||||
from labthings import find_component
|
||||
from labthings.utilities import create_from_path, get_by_path, set_by_path
|
||||
from labthings.views import PropertyView, View
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse, gen
|
||||
|
||||
|
||||
class MjpegStream(PropertyView):
|
||||
"""
|
||||
Real-time MJPEG stream from the microscope camera
|
||||
"""
|
||||
responses = {
|
||||
200: {
|
||||
"content_type": "multipart/x-mixed-replace"
|
||||
}
|
||||
}
|
||||
|
||||
responses = {200: {"content_type": "multipart/x-mixed-replace"}}
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
|
|
@ -44,12 +40,7 @@ class SnapshotStream(PropertyView):
|
|||
Single JPEG snapshot from the camera stream
|
||||
"""
|
||||
|
||||
responses = {
|
||||
200: {
|
||||
"content_type": "image/jpeg",
|
||||
"description": "Snapshot taken"
|
||||
}
|
||||
}
|
||||
responses = {200: {"content_type": "image/jpeg", "description": "Snapshot taken"}}
|
||||
|
||||
def get(self):
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -1,15 +1,13 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
import time
|
||||
import os
|
||||
import shutil
|
||||
import datetime
|
||||
import logging
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import threading
|
||||
|
||||
import time
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
from labthings import StrictLock, ClientEvent
|
||||
from labthings import ClientEvent, StrictLock
|
||||
|
||||
|
||||
class BaseCamera(metaclass=ABCMeta):
|
||||
|
|
|
|||
|
|
@ -6,20 +6,19 @@
|
|||
from __future__ import division
|
||||
|
||||
import io
|
||||
import time
|
||||
import numpy as np
|
||||
from PIL import Image, ImageFont, ImageDraw
|
||||
from datetime import datetime
|
||||
|
||||
import logging
|
||||
import time
|
||||
from datetime import datetime
|
||||
|
||||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
from PIL import Image, ImageDraw, ImageFont
|
||||
|
||||
from openflexure_microscope.camera.base import BaseCamera
|
||||
from openflexure_microscope.captures import CaptureObject
|
||||
|
||||
|
||||
"""
|
||||
PIL spams the logger with debug-level information. This is a pain when debugging api.app.
|
||||
We override the logging settings in api.app by setting a level for PIL here.
|
||||
|
|
|
|||
|
|
@ -29,31 +29,31 @@ to temporarily increase the capture resolution.
|
|||
from __future__ import division
|
||||
|
||||
import io
|
||||
import time
|
||||
import numpy as np
|
||||
import os
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
|
||||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
import numpy as np
|
||||
|
||||
# Pi camera
|
||||
import picamerax
|
||||
import picamerax.array
|
||||
|
||||
# Type hinting
|
||||
from typing import Tuple
|
||||
|
||||
from openflexure_microscope.camera.base import BaseCamera
|
||||
from openflexure_microscope.captures import CaptureObject
|
||||
from openflexure_microscope.paths import settings_file_path
|
||||
from openflexure_microscope.utilities import (
|
||||
json_to_ndarray,
|
||||
ndarray_to_json,
|
||||
serialise_array_b64,
|
||||
)
|
||||
|
||||
# Richard's fix gain
|
||||
from .set_picamera_gain import set_analog_gain, set_digital_gain
|
||||
|
||||
from openflexure_microscope.paths import settings_file_path
|
||||
from openflexure_microscope.utilities import (
|
||||
serialise_array_b64,
|
||||
ndarray_to_json,
|
||||
json_to_ndarray,
|
||||
)
|
||||
|
||||
|
||||
# MAIN CLASS
|
||||
class PiCameraStreamer(BaseCamera):
|
||||
|
|
@ -115,7 +115,7 @@ class PiCameraStreamer(BaseCamera):
|
|||
self.picamera_lst_path = settings_file_path(
|
||||
"picamera_lst.npy"
|
||||
) #: str: Path of .npy lens shading table file
|
||||
|
||||
|
||||
# Start the stream worker on init
|
||||
self.start_worker()
|
||||
|
||||
|
|
@ -348,7 +348,7 @@ class PiCameraStreamer(BaseCamera):
|
|||
"Suppressed a ValueError exception in start_preview. Exception: {}".format(
|
||||
e
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
def stop_preview(self):
|
||||
"""Stop the on board GPU camera preview."""
|
||||
|
|
@ -538,7 +538,7 @@ class PiCameraStreamer(BaseCamera):
|
|||
bayer=(not use_video_port) and bayer,
|
||||
use_video_port=use_video_port,
|
||||
)
|
||||
#time.sleep(0.1)
|
||||
# time.sleep(0.1)
|
||||
|
||||
# Set resolution and start stream recording if necessary
|
||||
if not use_video_port:
|
||||
|
|
|
|||
|
|
@ -1,10 +1,9 @@
|
|||
from ._remove import remove
|
||||
from ._load import load
|
||||
from ._dump import dump
|
||||
from ._transplant import transplant
|
||||
from ._insert import insert
|
||||
from ._exif import *
|
||||
from ._exceptions import *
|
||||
|
||||
from ._exif import *
|
||||
from ._insert import insert
|
||||
from ._load import load
|
||||
from ._remove import remove
|
||||
from ._transplant import transplant
|
||||
|
||||
VERSION = "1.1.2"
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import struct
|
|||
from ._common import *
|
||||
from ._exif import *
|
||||
|
||||
|
||||
TIFF_HEADER_LENGTH = 8
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2,9 +2,9 @@ import io
|
|||
import struct
|
||||
import sys
|
||||
|
||||
from . import _webp
|
||||
from ._common import *
|
||||
from ._exceptions import InvalidImageDataError
|
||||
from . import _webp
|
||||
|
||||
|
||||
def insert(exif, image, new_file=None):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
import struct
|
||||
import sys
|
||||
|
||||
from . import _webp
|
||||
from ._common import *
|
||||
from ._exceptions import InvalidImageDataError
|
||||
from ._exif import *
|
||||
from . import _webp
|
||||
|
||||
LITTLE_ENDIAN = b"\x49\x49"
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import io
|
||||
|
||||
from ._common import *
|
||||
from . import _webp
|
||||
from ._common import *
|
||||
|
||||
|
||||
def remove(src, new_file=None):
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
from __future__ import print_function
|
||||
|
||||
import picamerax
|
||||
from picamerax import mmal, mmalobj, exc
|
||||
from picamerax.mmalobj import to_rational
|
||||
import time
|
||||
import logging
|
||||
import time
|
||||
|
||||
import picamerax
|
||||
from picamerax import exc, mmal, mmalobj
|
||||
from picamerax.mmalobj import to_rational
|
||||
|
||||
MMAL_PARAMETER_ANALOG_GAIN = mmal.MMAL_PARAMETER_GROUP_CAMERA + 0x59
|
||||
MMAL_PARAMETER_DIGITAL_GAIN = mmal.MMAL_PARAMETER_GROUP_CAMERA + 0x5A
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
from .capture_manager import CaptureManager
|
||||
from . import capture, capture_manager
|
||||
from .capture import CaptureObject
|
||||
from . import capture_manager, capture
|
||||
from .capture_manager import CaptureManager
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
import uuid
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
import glob
|
||||
import atexit
|
||||
import datetime
|
||||
import glob
|
||||
import io
|
||||
import json
|
||||
import logging
|
||||
from PIL import Image
|
||||
import dateutil.parser
|
||||
import atexit
|
||||
|
||||
import os
|
||||
import shutil
|
||||
import uuid
|
||||
from collections import OrderedDict
|
||||
|
||||
import dateutil.parser
|
||||
from PIL import Image
|
||||
|
||||
from openflexure_microscope.camera import piexif
|
||||
from openflexure_microscope.camera.piexif._exceptions import InvalidImageDataError
|
||||
from openflexure_microscope.config import JSONEncoder
|
||||
|
|
@ -156,7 +156,7 @@ class CaptureObject(object):
|
|||
|
||||
def flush(self):
|
||||
logging.info(f"Writing to disk {self.file}")
|
||||
with open(self.file, "wb") as outfile:
|
||||
with open(self.file, "wb") as outfile:
|
||||
outfile.write(self.stream.getbuffer())
|
||||
self.stream.close()
|
||||
logging.info(f"Finished writing to disk {self.file}")
|
||||
|
|
@ -233,7 +233,9 @@ class CaptureObject(object):
|
|||
self._metadata.update(data)
|
||||
self.save_metadata()
|
||||
|
||||
def put_and_save(self, tags: list = None, annotations: dict = None, metadata: dict = None):
|
||||
def put_and_save(
|
||||
self, tags: list = None, annotations: dict = None, metadata: dict = None
|
||||
):
|
||||
"""
|
||||
Batch-write tags, metadata, and annotations in a single disk operation
|
||||
"""
|
||||
|
|
@ -243,7 +245,7 @@ class CaptureObject(object):
|
|||
annotations = {}
|
||||
if not metadata:
|
||||
metadata = {}
|
||||
|
||||
|
||||
# Tags
|
||||
for tag in tags:
|
||||
if tag not in self.tags:
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
import os
|
||||
import datetime
|
||||
import shutil
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from collections import OrderedDict
|
||||
|
||||
from labthings import StrictLock
|
||||
|
||||
from openflexure_microscope.utilities import entry_by_uuid
|
||||
from openflexure_microscope.paths import data_file_path
|
||||
from openflexure_microscope.utilities import entry_by_uuid
|
||||
|
||||
from .capture import CaptureObject, build_captures_from_exif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
import json
|
||||
import flask
|
||||
import os
|
||||
import errno
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import shutil
|
||||
from uuid import UUID
|
||||
import numpy as np
|
||||
from fractions import Fraction
|
||||
from uuid import UUID
|
||||
|
||||
import flask
|
||||
import numpy as np
|
||||
from labthings.json import LabThingsJSONEncoder
|
||||
|
||||
from .paths import (
|
||||
SETTINGS_FILE_PATH,
|
||||
DEFAULT_SETTINGS_FILE_PATH,
|
||||
CONFIGURATION_FILE_PATH,
|
||||
DEFAULT_CONFIGURATION_FILE_PATH,
|
||||
DEFAULT_SETTINGS_FILE_PATH,
|
||||
SETTINGS_FILE_PATH,
|
||||
)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -5,19 +5,15 @@ Here we include some classes used frequently in plugin development,
|
|||
as well as some Flask imports to simplify API route development
|
||||
"""
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
# Flask things
|
||||
from flask import Response, abort, escape, request
|
||||
|
||||
# Task management
|
||||
from labthings import (
|
||||
current_action as current_task,
|
||||
update_action_progress as update_task_progress,
|
||||
update_action_data as update_task_data,
|
||||
)
|
||||
|
||||
|
||||
# Flask things
|
||||
from flask import abort, escape, Response, request
|
||||
from labthings import current_action as current_task
|
||||
from labthings import update_action_data as update_task_data
|
||||
from labthings import update_action_progress as update_task_progress
|
||||
|
||||
from openflexure_microscope.api.utilities import JsonResponse
|
||||
|
||||
__all__ = [
|
||||
"current_task",
|
||||
|
|
|
|||
|
|
@ -1,14 +1,17 @@
|
|||
import os
|
||||
|
||||
from pynpm import NPMPackage
|
||||
import os
|
||||
|
||||
dir_path = os.path.dirname(os.path.realpath(__file__))
|
||||
pkg_path = os.path.join(dir_path, "api", "static", "package.json")
|
||||
|
||||
pkg = NPMPackage(pkg_path)
|
||||
|
||||
|
||||
def install():
|
||||
pkg.install()
|
||||
|
||||
|
||||
def build():
|
||||
pkg.install()
|
||||
pkg.run_script('build')
|
||||
pkg.run_script("build")
|
||||
|
|
|
|||
|
|
@ -3,29 +3,28 @@
|
|||
Defines a microscope object, binding a camera and stage with basic functionality.
|
||||
"""
|
||||
import logging
|
||||
import pkg_resources
|
||||
import uuid
|
||||
from typing import Tuple
|
||||
|
||||
import pkg_resources
|
||||
from expiringdict import ExpiringDict
|
||||
|
||||
from openflexure_microscope.captures import CaptureManager
|
||||
|
||||
from openflexure_microscope.stage.mock import MissingStage
|
||||
from openflexure_microscope.camera.mock import MissingCamera
|
||||
from openflexure_microscope.stage.sanga import SangaStage, SangaDeltaStage
|
||||
from openflexure_microscope.captures import CaptureManager
|
||||
from openflexure_microscope.stage.mock import MissingStage
|
||||
from openflexure_microscope.stage.sanga import SangaDeltaStage, SangaStage
|
||||
|
||||
try:
|
||||
from openflexure_microscope.camera.pi import PiCameraStreamer
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
logging.warning("Unable to import PiCameraStreamer")
|
||||
from openflexure_microscope.camera.mock import MissingCamera
|
||||
|
||||
from openflexure_microscope.utilities import serialise_array_b64, Timer
|
||||
from openflexure_microscope.config import user_settings, user_configuration
|
||||
|
||||
from labthings import CompositeLock
|
||||
|
||||
from openflexure_microscope.camera.mock import MissingCamera
|
||||
from openflexure_microscope.config import user_configuration, user_settings
|
||||
from openflexure_microscope.utilities import Timer, serialise_array_b64
|
||||
|
||||
|
||||
class Microscope:
|
||||
"""
|
||||
|
|
@ -106,7 +105,6 @@ class Microscope:
|
|||
|
||||
### Stage
|
||||
self.set_stage(configuration=configuration)
|
||||
|
||||
|
||||
logging.info("Handling fallbacks")
|
||||
### Fallbacks
|
||||
|
|
@ -131,20 +129,19 @@ class Microscope:
|
|||
|
||||
if stage_type:
|
||||
if stage_type == configuration["stage"].get("type"):
|
||||
logging.info("Stage already set to that stage type")
|
||||
return
|
||||
logging.info("Stage already set to that stage type")
|
||||
return
|
||||
else:
|
||||
stage_type = configuration["stage"].get("type")
|
||||
|
||||
|
||||
### Close any existing stages
|
||||
if self.stage:
|
||||
stage_port = self.stage.port
|
||||
self.stage.close()
|
||||
|
||||
stage_port = self.stage.port
|
||||
self.stage.close()
|
||||
|
||||
logging.info("Setting stage")
|
||||
stage_port = configuration["stage"].get("port")
|
||||
|
||||
stage_port = configuration["stage"].get("port")
|
||||
|
||||
if stage_type in ("SangaBoard", "SangaStage"):
|
||||
try:
|
||||
logging.info("Trying SangaStage")
|
||||
|
|
@ -156,17 +153,17 @@ class Microscope:
|
|||
try:
|
||||
logging.info("Trying SangaDeltaStage")
|
||||
self.stage = SangaDeltaStage(port=stage_port)
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logging.error(e)
|
||||
logging.warning("No compatible Sangaboard hardware found.")
|
||||
else:
|
||||
logging.warning("The stage type is incorrectly defined.")
|
||||
logging.warning("The stage type is incorrectly defined.")
|
||||
|
||||
logging.info("Saving new stage type configuration")
|
||||
configuration["stage"]["type"] = stage_type
|
||||
self.configuration_file.save(configuration)
|
||||
|
||||
|
||||
def has_real_stage(self) -> bool:
|
||||
"""
|
||||
Check if a real (non-mock) stage is currently attached.
|
||||
|
|
@ -249,13 +246,13 @@ class Microscope:
|
|||
with self.lock:
|
||||
# If attached to a camera
|
||||
if self.camera:
|
||||
settings_current_camera = self.camera.read_settings()
|
||||
settings_current["camera"] = settings_current_camera
|
||||
settings_current_camera = self.camera.read_settings()
|
||||
settings_current["camera"] = settings_current_camera
|
||||
|
||||
# If attached to a stage
|
||||
if self.stage:
|
||||
settings_current_stage = self.stage.read_settings()
|
||||
settings_current["stage"] = settings_current_stage
|
||||
settings_current_stage = self.stage.read_settings()
|
||||
settings_current["stage"] = settings_current_stage
|
||||
|
||||
# Capture manager
|
||||
settings_current_captures = self.captures.read_settings()
|
||||
|
|
@ -346,11 +343,9 @@ class Microscope:
|
|||
else:
|
||||
logging.debug(f"Building microscope metadata: {cache_key}")
|
||||
metadata = self.force_get_metadata()
|
||||
|
||||
|
||||
# Keys that should never be cached
|
||||
metadata.update({
|
||||
"state": self.state,
|
||||
})
|
||||
metadata.update({"state": self.state})
|
||||
|
||||
return metadata
|
||||
|
||||
|
|
@ -370,7 +365,7 @@ class Microscope:
|
|||
annotations: dict = None,
|
||||
tags: list = None,
|
||||
metadata: dict = None,
|
||||
cache_key: str = None
|
||||
cache_key: str = None,
|
||||
):
|
||||
logging.debug(f"Microscope capturing to {filename}")
|
||||
if not annotations:
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
import logging
|
||||
import os
|
||||
|
||||
# UTILITIES
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import logging
|
||||
import os
|
||||
|
||||
from openflexure_microscope.paths import (
|
||||
FALLBACK_OPENFLEXURE_VAR_PATH,
|
||||
PREFERRED_OPENFLEXURE_VAR_PATH,
|
||||
)
|
||||
import logging
|
||||
import os
|
||||
|
||||
from . import check_settings, check_capture_reload
|
||||
from . import check_capture_reload, check_settings
|
||||
|
||||
# Paths for suggestions
|
||||
LOGS_PATHS = [
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
from openflexure_microscope.rescue.monitor_timeout import launch_timeout_test_process
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
from openflexure_microscope.config import user_settings
|
||||
|
||||
import logging
|
||||
|
||||
from openflexure_microscope.captures.capture import build_captures_from_exif
|
||||
from openflexure_microscope.captures.capture_manager import BASE_CAPTURE_PATH
|
||||
from openflexure_microscope.config import user_settings
|
||||
from openflexure_microscope.rescue.monitor_timeout import launch_timeout_test_process
|
||||
|
||||
|
||||
def check_capture_rebuild(timeout=10):
|
||||
logging.info("Loading user settings...")
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import logging
|
||||
import json
|
||||
import logging
|
||||
|
||||
ERROR_SOURCES = []
|
||||
|
||||
|
|
|
|||
|
|
@ -20,8 +20,8 @@
|
|||
# */5 * * * * /root/bin/monitor_service.py prosody > /dev/null 2>&1
|
||||
#
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
class ServiceMonitor(object):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import multiprocessing
|
||||
import logging
|
||||
import multiprocessing
|
||||
import time
|
||||
|
||||
|
||||
# bar
|
||||
def test_long_fn():
|
||||
for _ in range(100):
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import numpy as np
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import numpy as np
|
||||
from labthings import StrictLock
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
import logging
|
||||
import time
|
||||
from collections.abc import Iterable
|
||||
|
||||
import numpy as np
|
||||
|
||||
from openflexure_microscope.stage.base import BaseStage
|
||||
from openflexure_microscope.utilities import axes_to_array
|
||||
|
||||
from collections.abc import Iterable
|
||||
import numpy as np
|
||||
import time
|
||||
import logging
|
||||
|
||||
|
||||
class MissingStage(BaseStage):
|
||||
def __init__(self, port=None, **kwargs):
|
||||
|
|
|
|||
|
|
@ -1,8 +1,10 @@
|
|||
import numpy as np
|
||||
import time
|
||||
import logging
|
||||
import time
|
||||
from collections.abc import Iterable
|
||||
|
||||
import numpy as np
|
||||
from sangaboard import Sangaboard
|
||||
|
||||
from openflexure_microscope.stage.base import BaseStage
|
||||
from openflexure_microscope.utilities import axes_to_array
|
||||
|
||||
|
|
@ -189,39 +191,48 @@ class SangaStage(BaseStage):
|
|||
print("Move completed, raising exception...")
|
||||
raise value # Propagate the exception
|
||||
|
||||
|
||||
class SangaDeltaStage(SangaStage):
|
||||
def __init__(self, port=None, flex_h=80, flex_a=50, flex_b=50, camera_angle=0, **kwargs):
|
||||
def __init__(
|
||||
self, port=None, flex_h=80, flex_a=50, flex_b=50, camera_angle=0, **kwargs
|
||||
):
|
||||
self.flex_h = flex_h
|
||||
self.flex_a = flex_a
|
||||
self.flex_b = flex_b
|
||||
|
||||
# Set up camera rotation relative to stage
|
||||
camera_theta = (camera_angle/180)*np.pi
|
||||
self.R_camera = np.array([
|
||||
[np.cos(camera_theta), -np.sin(camera_theta), 0],
|
||||
[np.sin(camera_theta), np.cos(camera_theta), 0],
|
||||
[0, 0, 1]
|
||||
])
|
||||
camera_theta = (camera_angle / 180) * np.pi
|
||||
self.R_camera = np.array(
|
||||
[
|
||||
[np.cos(camera_theta), -np.sin(camera_theta), 0],
|
||||
[np.sin(camera_theta), np.cos(camera_theta), 0],
|
||||
[0, 0, 1],
|
||||
]
|
||||
)
|
||||
|
||||
logging.debug(self.R_camera)
|
||||
|
||||
# Transformation matrix converting delta into cartesian
|
||||
x_fac = -1 * np.multiply(np.divide(2, np.sqrt(3)), np.divide(self.flex_b, self.flex_h))
|
||||
x_fac = -1 * np.multiply(
|
||||
np.divide(2, np.sqrt(3)), np.divide(self.flex_b, self.flex_h)
|
||||
)
|
||||
y_fac = -1 * np.divide(self.flex_b, self.flex_h)
|
||||
z_fac = np.multiply(np.divide(1, 3), np.divide(self.flex_b, self.flex_a))
|
||||
|
||||
self.Tvd = np.array([
|
||||
[-x_fac, x_fac, 0],
|
||||
[0.5 * y_fac, 0.5 * y_fac, -y_fac],
|
||||
[z_fac, z_fac, z_fac]
|
||||
])
|
||||
self.Tvd = np.array(
|
||||
[
|
||||
[-x_fac, x_fac, 0],
|
||||
[0.5 * y_fac, 0.5 * y_fac, -y_fac],
|
||||
[z_fac, z_fac, z_fac],
|
||||
]
|
||||
)
|
||||
logging.debug(self.Tvd)
|
||||
|
||||
self.Tdv = np.linalg.inv(self.Tvd)
|
||||
logging.debug(self.Tdv)
|
||||
|
||||
SangaStage.__init__(self, port=port, **kwargs)
|
||||
|
||||
|
||||
@property
|
||||
def position(self):
|
||||
# TODO: Account for camera rotation
|
||||
|
|
@ -253,4 +264,4 @@ class SangaDeltaStage(SangaStage):
|
|||
logging.debug("Delta final: {}".format(final))
|
||||
|
||||
# Do the move
|
||||
SangaStage.move_abs(self, final, **kwargs)
|
||||
SangaStage.move_abs(self, final, **kwargs)
|
||||
|
|
|
|||
|
|
@ -1,22 +1,26 @@
|
|||
import re
|
||||
import copy
|
||||
import operator
|
||||
import base64
|
||||
from uuid import UUID
|
||||
import numpy as np
|
||||
import copy
|
||||
import logging
|
||||
import operator
|
||||
import re
|
||||
import time
|
||||
from collections import abc
|
||||
from functools import reduce
|
||||
from contextlib import contextmanager
|
||||
from functools import reduce
|
||||
from uuid import UUID
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
class Timer(object):
|
||||
def __init__(self, name):
|
||||
self.name = name
|
||||
self.start = None
|
||||
self.end = None
|
||||
|
||||
def __enter__(self):
|
||||
self.start = time.time()
|
||||
|
||||
def __exit__(self, type, value, traceback):
|
||||
self.end = time.time()
|
||||
logging.debug(f"{self.name} time: {self.end - self.start}")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue