Split out more jupter cells in acquire
parent
028135f768
commit
edd9b593ef
159
acquire.ipynb
159
acquire.ipynb
|
@ -38,7 +38,9 @@
|
|||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def capture_pi(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live, cfg):\n",
|
||||
|
@ -141,7 +143,9 @@
|
|||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"source": [
|
||||
"Capture images from cv2"
|
||||
]
|
||||
|
@ -243,7 +247,9 @@
|
|||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"metadata": {
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"def capture_asi(image_queue, z1, t1, z2, t2, nx, ny, nz, tend, device_id, live, cfg):\n",
|
||||
|
@ -567,9 +573,6 @@
|
|||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {
|
||||
"jupyter": {
|
||||
"source_hidden": true
|
||||
},
|
||||
"tags": []
|
||||
},
|
||||
"outputs": [],
|
||||
|
@ -656,7 +659,7 @@
|
|||
"outputs": [],
|
||||
"source": [
|
||||
" # Testing mode\n",
|
||||
" test_duration = 31\n",
|
||||
" test_duration = 10\n",
|
||||
" testing = True\n",
|
||||
" logger.info(\"Test mode: %s\" % testing)\n",
|
||||
" if (testing):\n",
|
||||
|
@ -672,21 +675,57 @@
|
|||
" # Live mode\n",
|
||||
" live = False\n",
|
||||
" #live = True if args.live else False\n",
|
||||
" logger.info(\"Live mode: %s\" % live)\n",
|
||||
"\n",
|
||||
" logger.info(\"Live mode: %s\" % live)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Get camera type\n",
|
||||
" camera_type = cfg.get('Camera', 'camera_type')\n",
|
||||
"\n",
|
||||
" camera_type = cfg.get('Camera', 'camera_type')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Get device id\n",
|
||||
" device_id = cfg.getint(camera_type, 'device_id')\n",
|
||||
"\n",
|
||||
" device_id = cfg.getint(camera_type, 'device_id')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Current time\n",
|
||||
" tnow = Time.now()\n",
|
||||
"\n",
|
||||
" tnow = Time.now()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Set location\n",
|
||||
" loc = EarthLocation(lat=cfg.getfloat('Common', 'observer_lat')*u.deg,\n",
|
||||
" lon=cfg.getfloat('Common', 'observer_lon')*u.deg,\n",
|
||||
" height=cfg.getfloat('Common', 'observer_height')*u.m)\n",
|
||||
" height=cfg.getfloat('Common', 'observer_height')*u.m)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" if not testing:\n",
|
||||
" # Reference altitudes\n",
|
||||
" refalt_set = cfg.getfloat('Control', 'alt_sunset')*u.deg\n",
|
||||
|
@ -720,13 +759,27 @@
|
|||
" else:\n",
|
||||
" tend = tnow + test_duration*u.s\n",
|
||||
" logger.info(\"Starting data acquisition\")\n",
|
||||
" logger.info(\"Acquisition will end after \"+tend.isot)\n",
|
||||
"\n",
|
||||
" logger.info(\"Acquisition will end after \"+tend.isot)"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Get settings\n",
|
||||
" nx = cfg.getint(camera_type, 'nx')\n",
|
||||
" ny = cfg.getint(camera_type, 'ny')\n",
|
||||
" nz = cfg.getint(camera_type, 'nframes')\n",
|
||||
"\n",
|
||||
" nz = cfg.getint(camera_type, 'nframes')"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Initialize arrays\n",
|
||||
" z1base = multiprocessing.Array(ctypes.c_uint8, nx*ny*nz)\n",
|
||||
" z1 = np.ctypeslib.as_array(z1base.get_obj()).reshape(nz, ny, nx)\n",
|
||||
|
@ -736,29 +789,68 @@
|
|||
" z2 = np.ctypeslib.as_array(z2base.get_obj()).reshape(nz, ny, nx)\n",
|
||||
" t2base = multiprocessing.Array(ctypes.c_double, nz)\n",
|
||||
" t2 = np.ctypeslib.as_array(t2base.get_obj())\n",
|
||||
" image_queue = multiprocessing.Queue()\n",
|
||||
"\n",
|
||||
" image_queue = multiprocessing.Queue()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Set processes\n",
|
||||
" pcompress = multiprocessing.Process(target=compress,\n",
|
||||
" args=(image_queue, z1, t1, z2, t2, nx, ny,\n",
|
||||
" nz, tend.unix, path, device_id, cfg))\n",
|
||||
" nz, tend.unix, path, device_id, cfg))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" if camera_type == \"PI\":\n",
|
||||
" pcapture = multiprocessing.Process(target=capture_pi,\n",
|
||||
" args=(image_queue, z1, t1, z2, t2,\n",
|
||||
" nx, ny, nz, tend.unix, device_id, live, cfg))\n",
|
||||
"\n",
|
||||
" elif camera_type == \"CV2\":\n",
|
||||
" pcapture = multiprocessing.Process(target=capture_cv2,\n",
|
||||
" args=(image_queue, z1, t1, z2, t2,\n",
|
||||
" nx, ny, nz, tend.unix, device_id, live, cfg))\n",
|
||||
"\n",
|
||||
" elif camera_type == \"ASI\":\n",
|
||||
" pcapture = multiprocessing.Process(target=capture_asi,\n",
|
||||
" args=(image_queue, z1, t1, z2, t2,\n",
|
||||
" nx, ny, nz, tend.unix, device_id, live, cfg))\n",
|
||||
"\n",
|
||||
" nx, ny, nz, tend.unix, device_id, live, cfg))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Start\n",
|
||||
" pcapture.start()\n",
|
||||
" pcompress.start()\n",
|
||||
"\n",
|
||||
" pcapture.start()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" pcompress.start()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # End\n",
|
||||
" try:\n",
|
||||
" pcapture.join()\n",
|
||||
|
@ -769,8 +861,15 @@
|
|||
" logger.error(\"Memory error %s\" % e)\n",
|
||||
" finally:\n",
|
||||
" pcapture.terminate()\n",
|
||||
" pcompress.terminate()\n",
|
||||
"\n",
|
||||
" pcompress.terminate()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
" # Release device\n",
|
||||
"# if live is True:\n",
|
||||
"# cv2.destroyAllWindows()"
|
||||
|
|
Loading…
Reference in New Issue