Skip to content
Snippets Groups Projects
Commit 254ffaf7 authored by Steffen Hauf's avatar Steffen Hauf
Browse files

Add LPD Flatfield

parent 117b816d
No related branches found
No related tags found
1 merge request!6Clean
This diff is collapsed.
#!/usr/bin/env python
import argparse
from datetime import datetime
import nbconvert
......@@ -114,6 +116,30 @@ def first_markdown_cell(nb):
if cell.cell_type == 'markdown':
return cell
def make_epilog(nb, caltype=None):
""" Make an epilog from the notebook to add to parser help
"""
msg = ""
header_cell = first_markdown_cell(nb)
lines = header_cell.source.split("\n")
if caltype:
msg+= "{:<15} {}".format(caltype, lines[0]) + "\n"
else:
msg+= "{}".format(lines[0]) + "\n"
pp = pprint.PrettyPrinter(indent=(17 if caltype else 0))
if len(lines[1:]):
plines = pp.pformat(lines[1:])[1:-1].split("\n")
for line in plines:
sline = line.replace("'", "", 1)
sline = sline.replace("', '", " "*(17 if caltype else 0), 1)
sline = sline[::-1].replace("'", "", 1)[::-1]
sline = sline.replace(" ,", " ")
if sline[0] == ",":
sline = sline[1:]
msg += sline + "\n"
msg += "\n"
return msg
# extend the parser according to user input
# the first case is if a detector was given, but no calibration type
if len(sys.argv) == 3 and "-h" in sys.argv[2]:
......@@ -137,19 +163,7 @@ if len(sys.argv) == 3 and "-h" in sys.argv[2]:
for caltype, notebook in det_notebooks.items():
with open(notebook["notebook"], "r") as f:
nb = nbformat.read(f, as_version=4)
header_cell = first_markdown_cell(nb)
lines = header_cell.source.split("\n")
msg+= "{:<15} {}".format(caltype, lines[0]) + "\n"
pp = pprint.PrettyPrinter(indent=17)
if len(lines[1:]):
plines = pp.pformat(lines[1:])[1:-1].split("\n")
for line in plines:
sline = line.replace("'", "", 1)
sline = sline.replace("', '", " "*17, 1)
sline = sline[::-1].replace("'", "", 1)[::-1]
sline = sline.replace(" ,", " ")
msg += sline + "\n"
msg += "\n"
msg += make_epilog(nb, caltype=caltype)
parser.epilog=msg
# second case is if no detector was given either
......@@ -172,6 +186,7 @@ elif len(sys.argv) >= 3:
exit()
with open(notebook, "r") as f:
nb = nbformat.read(f, as_version=4)
parser.description = make_epilog(nb)
parms = extract_parameters(nb)
for p in parms:
helpstr = ("Default: %(default)s" if not p.comment
......
......@@ -44,6 +44,12 @@ notebooks = {
"default concurrency": 16,
"cluster cores": 32},
},
"FF": {
"notebook": "LPD/LPD_FlatField_Radial_per_pixel_CI_NBC.ipynb",
"concurrency": {"parameter": None,
"default concurrency": None,
"cluster cores": 8},
},
"CORRECT": {
"notebook": "LPD/LPD_Correct_and_Verify.ipynb",
"concurrency": {"parameter": None,
......
......@@ -16,18 +16,19 @@ class PostInstallCommand(install):
print("...found!")
return
except:
"Not PyDetLib installation found, attempting to install"
"No PyDetLib installation found, attempting to install"
check_call("karabo -g https://in.xfel.eu/gitlab install pyDetLib master".split())
else:
print("Python environment seems to not be a Karabo environment. "+
"Please innstall PyDetLib manually.")
"Please install PyDetLib manually.")
setup(
name='European XFEL Offline Calibration',
version='1.0',
packages=['cal_tools',],
package_dir={'cal_tools': 'cal_tools/cal_tools'},
version="1.0",
packages=['cal_tools', 'calibrate'],
package_dir={'cal_tools': 'cal_tools/cal_tools',
'calibrate': './'},
cmdclass={
'install': PostInstallCommand,
},
......@@ -35,6 +36,12 @@ setup(
license='(c) European XFEL GmbH 2018',
author='Steffen Hauf',
author_email='steffen.hauf@xfel.eu',
description=''
description='',
entry_points = {
'console_scripts': [
'xfel-calibrate = calibrate:run',
],
},
)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment