|
|
Hi, this should be the main place for collaborative documentation of extra_mmm.
|
|
|
Hi, this should be the main place for collaborative documentation of extra_mmm.
|
|
|
|
|
|
## Sample notebooks
|
|
|
|
... | ... | @@ -21,6 +21,7 @@ Opens one run and plots all diagnostics which scientist dreams of. |
|
|
Developed for the 'typical relaxed experiment'. Shows data from the actual shot (it finds the trainNumber of shot within specific run) and compares them to the preshot (integrated images over all trains). The version from proposal 2621 is showing the SAXS, PCI, and HAPG spectrometer.
|
|
|
|
|
|
## Snippets
|
|
|
|
|
|
Some useful snippets of code might be stored here to help the usage and understanding.
|
|
|
|
|
|
[Reading train Ids](https://gitlab.hzdr.de/relax-xfel/extra_mmm/-/wikis/Snippet:-reading-the-trainIds)
|
... | ... | @@ -39,24 +40,35 @@ Or a more complex one (comparing laser shot to preshot) at: |
|
|
|
|
|
The basic routines are:
|
|
|
|
|
|
### open_run()
|
|
|
### open_run(proposal, runNo, data='all',verbose=0)
|
|
|
|
|
|
proposal - int - number of the proposal
|
|
|
|
|
|
runNo - int - number of the run
|
|
|
|
|
|
data - str - either 'raw', 'proc', or 'all'. If 'all', the system will provide 'proc' data if available, otherwise falls back to 'raw'. The ‘proc’ defines that we are reading the processed data, i.e. after subtraction of dark frames and after gain correction. For Jungfrau detector that means, that resulting data are already calibrated, and value of each pixel corresponds to deposited energy in \[keV\]. It is possible to read the ‘raw’ data as well; those could be available faster, but might be harder to interpret (not recommended).
|
|
|
|
|
|
verbose - if True, will make more output
|
|
|
|
|
|
return run - the object to be passed to further functions.
|
|
|
|
|
|
run = open_run(proposal, runNo, data='proc')\
|
|
|
The data=‘proc’ defines that we are reading the processed data, i.e. after subtraction of dark frames and after gain correction. For Jungfrau detector that means, that resulting data are already calibrated, and value of each pixel corresponds to deposited energy in \[keV\]. It is possible to read the ‘raw’ data as well; those could be available faster, but might be harder to interpret (not recommended).
|
|
|
### get_shot_trainId_2(run,diag='JF4',debug=0,use_cache=1)
|
|
|
|
|
|
### get_shot_trainId()
|
|
|
Tries to find out which run contained the data with laser shot. It will find it as a trainId with the strongest data in diagnostics given by 'diag'. if use_cache, then it will store the result in local pickle and read it later for faster access.
|
|
|
|
|
|
trainId=em.get_shot_trainId(run) - tries to find out which run contained the data with laser shot. Might need to be updated for new campaigns.
|
|
|
return trainId, ratio - ratio is the ratio between strongest and second strongest shot, so you can use it to say if it was real and good laser shot.
|
|
|
|
|
|
### get_image()
|
|
|
### get_image(run,diag_nickname,trainId=-1,average=True,diag='',recalc=0,threshold_lower=-1,threshold_upper=-1,debug=0,save=False)
|
|
|
|
|
|
jf=em.get_image(run,runNo,'JF1',trainId,debug,threshold_lower,recalc)
|
|
|
run - the run object from open_run
|
|
|
|
|
|
First 2 arguments are from open_run. The third argument is a ‘nickname’ of diagnostics to get image from. The dictionary of nicknames can be seen and ajdusted at the beginning of the source code. It contains:\[nickame, data source name, trainID offset\]
|
|
|
diag_nickname - name of the diagnostics in the local dictionary. The dictionary of nicknames can be seen and ajdusted at the beginning of the source code. It contains:\[nickame, data source name, trainID offset\]
|
|
|
|
|
|
If **train Id**==-1, the the function returns mean of all trains in given run, otherwise it will return image for the single train.
|
|
|
If **train Id**==-1, the the function returns mean or sum of all trains in given run, otherwise it will return image for the single train.
|
|
|
|
|
|
**Threshold_lower**. If this parameter is set, all pixel with values below this value will be zeroed. And this is done before averaging over trains, so very useful for removing noise on long accumulations
|
|
|
average - works for trainId=-1. If true, will return average, otherwise returns sum.
|
|
|
|
|
|
**threshold_lower**. If this parameter is set, all pixel with values below this value will be zeroed. And this is done before averaging over trains, so very useful for removing noise on long accumulations
|
|
|
|
|
|
The **debug** parameter (boolean) can just turn on verbose output.
|
|
|
|
... | ... | @@ -64,10 +76,17 @@ The image is saved (cached) as tiff file into a ‘./data’ folder. From there, |
|
|
|
|
|
The **dictionary** with the diagnostics can be avoided and the source name provided directly. In that case, not trainId offset is used, i.e. Jungfrau_image=em.get_image(run,runNo,diag_nickname='whatever', diag=”HED_IA1_JF500K1/DET/JNGFR01:daqOutput”, trainId=trainId,debug=debug,recalc=recalc)
|
|
|
|
|
|
#### Image calibration
|
|
|
Image calibration is now made only very simply for ePix 1. It works like that you load an array with the dark run into extra_mmm.ePix1_dark, then the code automatcially subtracts this image from all the ePix data.
|
|
|
Example:
|
|
|
```
|
|
|
### **get_array_raw(run,diag_nickname,diag='')**
|
|
|
|
|
|
Somehow similar to get_image. gets you a numpy array of diagnostics given by diag_nickname in given run. The cache is not yet implemented here.
|
|
|
|
|
|
return values,trains
|
|
|
|
|
|
#### Image calibration (in progress, used only for ePix)
|
|
|
|
|
|
Image calibration is now made only very simply for ePix 1. It works like that you load an array with the dark run into extra_mmm.ePix1_dark, then the code automatcially subtracts this image from all the ePix data. Example:
|
|
|
|
|
|
```plaintext
|
|
|
dark = np.array(Image.open('data/ePixDark.tif'))
|
|
|
em.ePix_dark=dark
|
|
|
epix_corrected_image=em.get_image(run,runNo,'ePix1')
|
... | ... | |