cristallina package¶
Submodules¶
cristallina.SEA_GraphClient module¶
client for SEA GraphServer
Usage:
# open a client to host ‘samenv’, port 8764 # the port number for the graph server may be retrived by # the command ‘sea list’ on the samenv machine
client = GraphClient(‘samenv:8764’)
# get one curve
tlist, vlist, period = client.get_curves(start, end, name)
or
# get all important curves curves = client.get_curves(start, end)
# where:
start, end: interval (unix time, as retrieved from time.time()) name: the name of a curve (if no name or a list of names
is given, the result is a curves dict)
curves: dict <name> of [tlist, vlist, period] tlist: time axis (unix time) vlist: values (y-axis) period: the expected resolution (a hint for graphic clients,
saying that for a time step t(n) - t(n-1) significantly bigger than period, an additional point should be added at t(n) - period)
- class cristallina.SEA_GraphClient.GraphClient(hostport)[source]¶
Bases:
object- get_curves(start, end, name=None, none_value=None, nmax=None)[source]¶
get curves
- start, end: interval (unix time, as retrieved from time.time())
non positive values are taken relative to the current time
name: a single name or a list of names or None to get all curves (as shown in the SEA GUI) none_value: replacement when no value is defined nmax: max. number of points per curve
when name is a string, returns [tlist, vlist, period] when name is None or a list of strings (names) returns a dict <name> of [tlist, vlist, period]
tlist: time axis (unix time) vlist: values (y-axis) period: the expected resolution (a hint for graphic clients)
cristallina.analysis module¶
- cristallina.analysis.fit_2d_gaussian(image, roi: ROI | None = None)[source]¶
2D Gaussian fit using LMFit for a given image and an optional region of interest.
Returns the x, y coordinates of the center and the results object which contains further fit statistics.
cristallina.config module¶
cristallina.plot module¶
- cristallina.plot.ju_patch_less_verbose(ju_module)[source]¶
Quick monkey patch to suppress verbose messages from gain & pedestal file searcher.
- cristallina.plot.plot_1d_channel(data: SFDataFiles, channel_name, ax=None)[source]¶
Plots channel data for a channel that contains a single numeric value per pulse.
- cristallina.plot.plot_2d_channel(data: SFDataFiles, channel_name, ax=None)[source]¶
Plots channel data for a channel that contains a 1d array of numeric values per pulse.
- cristallina.plot.plot_channel(data: SFDataFiles, channel_name, ax=None)[source]¶
Plots a given channel from an SFDataFiles object.
Optionally: a matplotlib axis to plot into
- cristallina.plot.plot_correlation(x, y, ax=None, **ax_kwargs)[source]¶
Plots the correlation of x and y in a normalized scatterplot. If no axis is given a figure and axis are created.
- Returns: The axis object and the correlation coefficient between
x and y.
- cristallina.plot.plot_image_channel(data: SFDataFiles, channel_name, pulse=0, ax=None, rois=None, norms=None)[source]¶
Plots channel data for a channel that contains an image (2d array) of numeric values per pulse.
- cristallina.plot.plot_spectrum_channel(data: SFDataFiles, channel_name_x, channel_name_y, average=True, pulse=0, ax=None)[source]¶
Plots channel data for two channels where the first is taken as the (constant) x-axis and the second as the y-axis (here we take by default the mean over the individual pulses).
cristallina.skeleton module¶
This is a skeleton file that can serve as a starting point for a Python
console script. To run this script uncomment the following lines in the
[options.entry_points] section in setup.cfg:
console_scripts =
fibonacci = cristallina.skeleton:run
Then run pip install . (or pip install -e . for editable mode)
which will install the command fibonacci inside your current environment.
Besides console scripts, the header (i.e. until _logger…) of this file can
also be used as template for Python modules.
Note
This file can be renamed depending on your needs or safely removed if not needed.
References
- cristallina.skeleton.main(args)[source]¶
Wrapper allowing
fib()to be called with string arguments in a CLI fashionInstead of returning the value from
fib(), it prints the result to thestdoutin a nicely formatted message.- Parameters:
args (List[str]) – command line parameters as list of strings (for example
["--verbose", "42"]).
- cristallina.skeleton.parse_args(args)[source]¶
Parse command line parameters
- Parameters:
args (List[str]) – command line parameters as list of strings (for example
["--help"]).- Returns:
command line parameters namespace
- Return type:
cristallina.utils module¶
- class cristallina.utils.ROI(left: int | None = None, right: int | None = None, top: int | None = None, bottom: int | None = None, center_x: int | None = None, center_y: int | None = None, width: int | None = None, height: int | None = None, name: str | None = None)[source]¶
Bases:
objectDefinition of region of interest (ROI) in image coordinates.
Example: ROI(left=10, right=20, bottom=100, top=200).
Directions assume that lower left corner of image is at (x=0, y=0).
- property LeftRightBottomTop¶
- property cols¶
- property height¶
- property rows¶
- property width¶
- cristallina.utils.channel_names(run_number, verbose=False)[source]¶
Prints channel names for a given run_number or scan object
- cristallina.utils.find_nearest(array, value)[source]¶
Finds an index in an array with a value that is nearest to given number
- cristallina.utils.find_two_nearest(time_array, percentage)[source]¶
Finds indeces of the two values that are the nearest to the given value in an array
- cristallina.utils.gauss_fit(x, y, fit_details=None, plot=None)[source]¶
Returns [baseline_offset, Amplitude, center, sigma, FWHM]
- cristallina.utils.heuristic_extract_base_path()[source]¶
The function tries to guess the full path where the raw data is saved.
- cristallina.utils.heuristic_extract_pgroup(path=None)[source]¶
The function tries to guess the current p-group from the current working directory (default) or the contents of the given path.
- cristallina.utils.heuristic_extract_smalldata_path()[source]¶
The function tries to guess the full path where the small data is saved.
- cristallina.utils.photon_energy_from_wavelength(wavelength)[source]¶
Returns photon energy in eV from wavelength in meters. Source https://www.kmlabs.com/en/wavelength-to-photon-energy-calculator
- cristallina.utils.print_run_info(run_number=42, print_channels=True, extra_verbose=False, base_path=None)[source]¶
Prints overview of run information.
Extra verbose output contains all files and pids.
- cristallina.utils.process_run(run_number, rois, detector='JF16T03V01', calculate=None, only_shots=slice(None, None, None), n_jobs=16)[source]¶
Process rois for a given detector. Save the results small data in the res/small_data/run… By default only sum of rois is calculated, [mean,std,img] can be added to the “calculate” optional parameter.
- cristallina.utils.scan_info(run_number, base_path=None, small_data=True)[source]¶
Returns SFScanInfo object for a given run number. If there is are small data channels, they will be added (small_data=False to suppress their loading).
- cristallina.utils.wavelength_from_photon_energy(Eph)[source]¶
Returns wavelength in meters from photon energy in eV. Source https://www.kmlabs.com/en/wavelength-to-photon-energy-calculator