Skip to content
Snippets Groups Projects
Commit fd8a9da0 authored by Astrid Muennich's avatar Astrid Muennich
Browse files

added files for tutorial

parent 6e1cb761
No related branches found
No related tags found
1 merge request!15Tutorial
Installation and Configuration
=============================
1. log into max-exfl
2. install karabo in your home directory or under /gpfs/exfel/data/scratch/username:
wget http://exflserv05.desy.de/karabo/karaboFramework/tags/2.2.4/karabo-2.2.4-Release-CentOS-7-x86_64.sh
chmod +x karabo-2.2.4-Release-CentOS-7-x86_64.sh
./karabo-2.2.4-Release-CentOS-7-x86_64.sh
source karabo/activate
3. get pycalibration
git clone https://git.xfel.eu/gitlab/detectors/pycalibration.git
4. install requirements:
cd pycalibration
pip install -r requirements.txt .
5. adjust xfel_calibrate/settings.py:
change karabo_activate_path and ipcluster_path according to where you installed karabo
Create your own notebook
========================
1. Create a new notebook or re-arrange an existing on following the guidelines explained here: https://in.xfel.eu/readthedocs/docs/european-xfel-offline-calibration/en/latest/workflow.html
2. register you notebook:
add an entry to xfel_calibrate/notebooks.py
Note: use all capital letters for DETECTOR and TYPE
3. update:
pip install --upgrade .
Running the notebook
====================
1. make sure output folders exist
2. run it:
xfel-calibrate Tutorial TEST
3. Look at generated report in output folder
%% Cell type:markdown id: tags:
# Tutorial Calculation #
Author: Astrid Muennich, Version 0.1
A small example how to adapt a notebook to run with the offline calibration package "pycalibation".
The first cell contains all parameters that should be exposed to the command line.
%% Cell type:code id: tags:
``` python
out_folder = "/gpfs/exfel/data/scratch/amunnich/tutorial" # output folder
sensor_size = [10, 30] # defining the picture size
random_seed = 2345 # random seed for filling of fake data array. Change it to produce different results.
runs = 500 # how may iterations to fill histograms
cluster_profile = "tutorial"
```
%% Cell type:markdown id: tags:
First include what we need and set up the cluster profile. Everything that has a written response ina cell will show up in the report, e.g. prints but also return values or errors.
%% Cell type:code id: tags:
``` python
import matplotlib
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
from ipyparallel import Client
print("Connecting to profile {}".format(cluster_profile))
view = Client(profile=cluster_profile)[:]
view.use_dill()
```
%% Output
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-75-f535e80204a3> in <module>()
5 import matplotlib.pyplot as plt
6
----> 7 from ipyparallel import Client
8
9 print("Connecting to profile {}".format(cluster_profile))
ImportError: No module named 'ipyparallel'
%% Cell type:markdown id: tags:
## Create some random data
%% Cell type:code id: tags:
``` python
def data_creation(random_seed):
np.random.seed = random_seed
return np.random.random((sensor_size))
```
%% Cell type:code id: tags:
``` python
fake_data = []
for i in range(runs):
fake_data.append(data_creation(random_seed+10*i))
```
%% Cell type:markdown id: tags:
Plot the random image. everything we write here in the markup cells will show up as text in the report.
%% Cell type:code id: tags:
``` python
plt.subplot(211)
plt.imshow(fake_data[0], interpolation="nearest")
plt.title('Random Image')
plt.ylabel('sensor height')
plt.subplot(212)
plt.imshow(fake_data[5], interpolation="nearest")
plt.xlabel('sensor width')
plt.ylabel('sensor height')
plt.subplots_adjust(bottom=0.1, right=0.8, top=0.9)
cax = plt.axes([0.85, 0.1, 0.075, 0.9])
plt.colorbar(cax=cax).ax.set_ylabel("# counts")
plt.show()
```
%% Output
%% Cell type:markdown id: tags:
These plots show two randomly filled sensor images. We can use markup cells also as captions for images.
%% Cell type:markdown id: tags:
## Simple Analysis
%% Cell type:code id: tags:
``` python
mean = []
std = []
for im in fake_data:
mean.append(im.mean())
std.append(im.std())
```
%% Cell type:markdown id: tags:
We calculate the mean value of all images, as well as the standard deviation.
%% Cell type:code id: tags:
``` python
plt.hist(mean, 50)
plt.xlabel('mean')
plt.ylabel('counts')
plt.title('Mean value')
plt.show()
```
%% Output
%% Cell type:code id: tags:
``` python
plt.hist(std, 50)
plt.xlabel('mean')
plt.ylabel('counts')
plt.title('Mean value')
plt.show()
```
%% Output
%% Cell type:markdown id: tags:
Create a small simple notebook, without thinking about parameters or maxwell
%% Cell type:code id: tags:
``` python
import matplotlib
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
```
%% Cell type:code id: tags:
``` python
sensor_size = [10,20]
random_seed = 2345
np.random.seed = random_seed
fake_data = np.random.random((sensor_size))
```
%% Cell type:code id: tags:
``` python
plt.imshow(fake_data, interpolation="nearest")
plt.colorbar()
```
%% Output
<matplotlib.colorbar.Colorbar at 0x7f9f38551d30>
%% Cell type:markdown id: tags:
Calculate some stuff from the data
%% Cell type:code id: tags:
``` python
my_mean = fake_data.mean()
my_std = fake_data.std()
my_mean, my_std
```
%% Output
(0.5116986708989778, 0.29529469463486308)
%% Cell type:code id: tags:
``` python
```
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