Created
August 31, 2021 08:19
-
-
Save kif/a427d2c6e7dd9fd36961d54d8102aeb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"id": "superior-terry", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pyFAI\n", | |
"import numpy\n", | |
"from pyFAI.detectors import Detector" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"id": "integrated-behalf", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"module_shape = (512, 1024)\n", | |
"module_assembly = (4, 2)\n", | |
"pixel_size = 75e-6\n", | |
"#Gaps are not implemented" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"id": "pharmaceutical-filter", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"input: (4096, 1024), output: [2048, 2048]\n" | |
] | |
} | |
], | |
"source": [ | |
"stack_shape = numpy.prod(module_assembly)*module_shape[0], module_shape[1]\n", | |
"square_shape = [i*j for i,j in zip(module_shape, module_assembly)]\n", | |
"print(f\"input: {stack_shape}, output: {square_shape}\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"id": "junior-worthy", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"Detector Detector\t Spline= None\t PixelSize= 7.500e-05, 7.500e-05 m \n", | |
" Detector Detector\t Spline= None\t PixelSize= 7.500e-05, 7.500e-05 m\n" | |
] | |
} | |
], | |
"source": [ | |
"JF_square = Detector(pixel1=pixel_size, pixel2=pixel_size, max_shape=square_shape)\n", | |
"JF_stack = Detector(pixel1=pixel_size, pixel2=pixel_size, max_shape=stack_shape)\n", | |
"print(JF_square, \"\\n\",JF_stack)" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 5, | |
"id": "lyric-headquarters", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"corners_stack = JF_stack.get_pixel_corners()\n", | |
"corners_square = JF_square.get_pixel_corners()\n", | |
"JF_stack.IS_CONTIGUOUS = False" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 6, | |
"id": "graphic-advancement", | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"0 0 0\n", | |
"1 1 0\n", | |
"2 0 1\n", | |
"3 1 1\n", | |
"4 0 2\n", | |
"5 1 2\n", | |
"6 0 3\n", | |
"7 1 3\n" | |
] | |
} | |
], | |
"source": [ | |
"for y in range(module_assembly[0]):\n", | |
" for x in range(module_assembly[1]):\n", | |
" i = x + y * module_assembly[-1]\n", | |
" print(i,x,y)\n", | |
" corners_stack[i*module_shape[0]:(i+1)*module_shape[0], :] = corners_square[y*module_shape[0]:(y+1)*module_shape[0],\\\n", | |
" x*module_shape[1]:(x+1)*module_shape[1]]" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 7, | |
"id": "historic-hazard", | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"JF_stack.set_pixel_corners(corners_stack)\n", | |
"JF_stack.save(\"JF4M_stacked.h5\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": null, | |
"id": "opening-dress", | |
"metadata": {}, | |
"outputs": [], | |
"source": [] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.9.2" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 5 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment