Here, a SpecsScan class instance is created as per the configuration provided in config.yaml. The user may set the entries in config.yaml file, for example, the data path and conversion parameters as per the requirements before creating this instance.
-
In addition to the provided config files, config files from different locations are optionally included as well (see documentation).
The load_scan method loads the scan as an xarray of the data converted into angular/energy coordinates along with the metadata of the scan.
-
-
[3]:
-
-
-
path="../tests/data/"# Path to the test data set
-# The path may be changed to point to the scan folder of the data of interest (for example, on a server drive)
-res_xarray=sps.load_scan(
- scan=4450,# Scan number for an example mirror scan
- path=path,
-)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Gathering metadata from different locations
-Collecting time stamps...
-Done!
-
-
-
The data are from a mirror scan, showing the mirror position as third dimension:
-
-
[4]:
-
-
-
res_xarray.dims
-
-
-
-
-
[4]:
-
-
-
-
-('Angle', 'Ekin', 'mirrorX')
-
-
-
We can plot, e.g., selected steps of the scan:
-
-
[5]:
-
-
-
plt.figure()
-res_xarray[:,:,0].plot()
-
-
-
-
-
[5]:
-
-
-
-
-<matplotlib.collections.QuadMesh at 0x7f0d29f53b20>
-
The image contains data beyond the boundaries given by the illuminated area of the MCP, which should be removed. For this, the crop option of the converter can be used:
-
-
[6]:
-
-
-
res_xarray=sps.load_scan(
- scan=4450,# Scan number for an example mirror scan
- path=path,
- crop=True,
-)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Warning: Cropping parameters not found, use method crop_tool() after loading.
-Gathering metadata from different locations
-Collecting time stamps...
-Done!
-
-
-
The loader has given a warning saying that the cropping parameters do not exist yet. Therefore, an interactive cropping tool can be used to crop the data while also saving the crop ranges into a class attribute for later scans. Pressing crop applies the cropping to the test image, and stores the cropping information in the class.
-
One can provide relative cropping ranges either as keyword parameters, or in the config file, and optionally directly apply the settings to make the tool non-interactive.
In order to remove the meshgrid artifact present in the data, an fft filtering is applied already in the data loaded previously. For this, parameters of the fft peaks corresponding to the grid are required which can be provided in the config file. Alternatively, one can also interactively optimize the parameters using the fft tool
-
-
[9]:
-
-
-
sps.fft_tool(
- amplitude=1,
- pos_x=82,
- pos_y=116,
- sigma_x=15,
- sigma_y=23,
- apply=True# Use apply=False for interactive mode
-)
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
Load the scan again for the new changes to apply to all the images
3D scans, where the images are recorded as a function of a third parameter (generally delay or in this case, mirrorX), can also be loaded with an option to average only the given iterations passed as a list or slice object.
-Using saved crop parameters...
-Gathering metadata from different locations
-Collecting time stamps...
-Done!
-
-
-
-
[13]:
-
-
-
-
-<matplotlib.collections.QuadMesh at 0x7f0d21c8c1f0>
-
-
-
-
-
-
-
-
-
Another useful functionality is to load a 3D scan as a function of iterations averaged over the scan parameter (in this case, mirrorX). This is done using the check_scan method
-
-
[14]:
-
-
-
res_xarray_check=sps.check_scan(
- scan=4450,
- delays=0,# for a fixed delay of index, 1
- path=path,
-)
-plt.figure()
-res_xarray_check.loc[{"Angle":slice(-5,5)}].sum(axis=(0)).plot()
-
-
-
-
-
-
-
-
-Averaging over delays...
-
-
-
-
-
-
-
-
-
-
-
-
-
-Using saved crop parameters...
-Gathering metadata from different locations
-Collecting time stamps...
-Done!
-
-
-
-
[14]:
-
-
-
-
-<matplotlib.collections.QuadMesh at 0x7f0d21d0a320>
-
Data can be saved, e.g., as hdf5 files including metadata for convenient processing in other notebooks or software.
-
-
[15]:
-
-
-
sps.load_scan(
- scan=4450,# Scan number for an example mirror scan
- path=path,
-)
-sps.save("example_data.h5")
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-Using saved crop parameters...
-Gathering metadata from different locations
-Collecting time stamps...
-Done!
-saving data to example_data.h5
-Saved iterations as string.
-Saved fft_filter_peaks as string.
-Saving complete!
-
user_config (dict | str, optional): user-based config dictionary or file path. The loaded dictionary is completed with the user-based values, taking preference over system and default values.
- Defaults to the file ".specsanalyzer/config.yaml" in the current user's home directory.
+ Defaults to the file ".config/specsanalyzer/config_v1.yaml" in the current user's home
+ directory. system_config (dict | str, optional): system-wide config dictionary or file path. The loaded dictionary is completed with the system-wide values, taking preference over default values.
- Defaults to the file "/etc/specsanalyzer/config.yaml" on linux,
- and "%ALLUSERSPROFILE%/specsanalyzer/config.yaml" on windows.
+ Defaults to the file "/etc/specsanalyzer/config_v1.yaml" on linux,
+ and "%ALLUSERSPROFILE%/specsanalyzer/config_v1.yaml" on windows. default_config (dict | str, optional): default config dictionary or file path. The loaded dictionary is completed with the default values. Defaults to *package_dir*/config/default.yaml".
@@ -615,7 +633,7 @@
+
+
+def_parse_env_file(file_path:Path)->dict:
+"""Helper function to parse a .env file into a dictionary.
+
+ Args:
+ file_path (Path): Path to the .env file
+
+ Returns:
+ dict: Dictionary of environment variables from the file
+ """
+ env_content={}
+ iffile_path.exists():
+ withopen(file_path)asf:
+ forlineinf:
+ line=line.strip()
+ iflineand"="inline:
+ key,val=line.split("=",1)
+ env_content[key.strip()]=val.strip()
+ returnenv_content
+
+
+
+[docs]
+defread_env_var(var_name:str)->str|None:
+"""Read an environment variable from multiple locations in order:
+ 1. OS environment variables
+ 2. .env file in current directory
+ 3. .env file in user config directory
+ 4. .env file in system config directory
+
+ Args:
+ var_name (str): Name of the environment variable to read
+
+ Returns:
+ str | None: Value of the environment variable or None if not found
+ """
+ # 1. check OS environment variables
+ value=os.getenv(var_name)
+ ifvalueisnotNone:
+ logger.debug(f"Found {var_name} in OS environment variables")
+ returnvalue
+
+ # 2. check .env in current directory
+ local_vars=_parse_env_file(Path(".env"))
+ ifvar_nameinlocal_vars:
+ logger.debug(f"Found {var_name} in ./.env file")
+ returnlocal_vars[var_name]
+
+ # 3. check .env in user config directory
+ user_vars=_parse_env_file(USER_CONFIG_PATH/".env")
+ ifvar_nameinuser_vars:
+ logger.debug(f"Found {var_name} in user config .env file")
+ returnuser_vars[var_name]
+
+ # 4. check .env in system config directory
+ system_vars=_parse_env_file(SYSTEM_CONFIG_PATH/".env")
+ ifvar_nameinsystem_vars:
+ logger.debug(f"Found {var_name} in system config .env file")
+ returnsystem_vars[var_name]
+
+ logger.debug(f"Environment variable {var_name} not found in any location")
+ returnNone
+
+
+
+
+[docs]
+defsave_env_var(var_name:str,value:str)->None:
+"""Save an environment variable to the .env file in the user config directory.
+ If the file exists, preserves other variables. If not, creates a new file.
+
+ Args:
+ var_name (str): Name of the environment variable to save
+ value (str): Value to save for the environment variable
+ """
+ env_path=USER_CONFIG_PATH/".env"
+ env_content=_parse_env_file(env_path)
+
+ # Update or add new variable
+ env_content[var_name]=value
+
+ # Write all variables back to file
+ withopen(env_path,"w")asf:
+ forkey,valinenv_content.items():
+ f.write(f"{key}={val}\n")
+ logger.debug(f"Environment variable {var_name} saved to .env file")
"/entry/sample/transformations/sample_polar":"Polar","/entry/sample/transformations/sample_tilt":"Tilt","/entry/sample/transformations/sample_azimuth":"Azimuth",
+ "/entry/instrument/beam_pump/pulse_delay":"delay",}# store data for resolved axis coordinates
@@ -825,14 +840,16 @@
exceptFileNotFoundErrorasexc:raiseFileNotFoundError("info.txt file not found.")fromexc
+ if"DelayStage"ininfo_dictand"TimeZero"ininfo_dict:
+ info_dict["delay"]=mm_to_fs(info_dict["DelayStage"],info_dict["TimeZero"])
+
returninfo_dict
@@ -923,11 +935,13 @@
Source code for specsscan.helpers
df_lut:pd.DataFrame,scan_info:dict,config:dict,
+ scan:int,fast_axes:list[str],slow_axes:list[str],projection:str,metadata:dict=None,collect_metadata:bool=False,
+ token:str=None,)->dict:"""Helper function for the handling metadata from different files
@@ -936,22 +950,24 @@
Source code for specsscan.helpers
from ``parse_lut_to_df()`` scan_info (dict): scan_info class dict containing containing the contents of info.txt file config (dict): config dictionary containing the contents of config.yaml file
+ scan (int): Scan number fast_axes (list[str]): The fast-axis dimensions of the scan slow_axes (list[str]): The slow-axis dimensions of the scan metadata (dict, optional): Metadata dictionary with additional metadata for the scan. Defaults to empty dictionary. collect_metadata (bool, optional): Option to collect further metadata e.g. from EPICS archiver needed for NeXus conversion. Defaults to False.
+ token (str, optional):: The elabFTW api token to use for fetching metadata Returns: dict: metadata dictionary containing additional metadata from the EPICS
- archive.
+ archive and elabFTW. """ifmetadataisNone:metadata={}
- print("Gathering metadata from different locations")
+ logger.info("Gathering metadata from different locations")# get metadata from LUT dataframelut_meta={}energy_scan_mode="snapshot"
@@ -969,10 +985,10 @@
Source code for specsscan.helpers
metadata["scan_info"]=complete_dictionary(metadata.get("scan_info",{}),
- complete_dictionary(lut_meta,scan_info),
+ complete_dictionary(scan_info,lut_meta),)# merging dictionaries
- print("Collecting time stamps...")
+ logger.info("Collecting time stamps...")if"time"inmetadata["scan_info"]:time_list=[metadata["scan_info"]["time"][0],metadata["scan_info"]["time"][-1]]elif"StartTime"inmetadata["scan_info"]:
@@ -996,53 +1012,18 @@
Source code for specsscan.helpers
}ifcollect_metadata:
- # Get metadata from Epics archive if not present already
- start=dt.datetime.utcfromtimestamp(ts_from).isoformat()
+ metadata_retriever=MetadataRetriever(config,token)
- # replace metadata names by epics channels
- try:
- replace_dict=config["epics_channels"]
- forkeyinlist(metadata["scan_info"]):
- ifkey.lower()inreplace_dict:
- metadata["scan_info"][replace_dict[key.lower()]]=metadata["scan_info"][key]
- metadata["scan_info"].pop(key)
- epics_channels=replace_dict.values()
- exceptKeyError:
- epics_channels=[]
-
- channels_missing=set(epics_channels)-set(metadata["scan_info"].keys())
- ifchannels_missing:
- print("Collecting data from the EPICS archive...")
- forchannelinchannels_missing:
- try:
- _,vals=get_archiver_data(
- archiver_url=config.get("archiver_url"),
- archiver_channel=channel,
- ts_from=ts_from,
- ts_to=ts_to,
- )
- metadata["scan_info"][f"{channel}"]=np.mean(vals)
+ metadata=metadata_retriever.fetch_epics_metadata(
+ ts_from=ts_from,
+ ts_to=ts_to,
+ metadata=metadata,
+ )
- exceptIndexError:
- metadata["scan_info"][f"{channel}"]=np.nan
- print(
- f"Data for channel {channel} doesn't exist for time {start}",
- )
- exceptHTTPErrorasexc:
- print(
- f"Incorrect URL for the archive channel {channel}. "
- "Make sure that the channel name and file start and end times are "
- "correct.",
- )
- print("Error code: ",exc)
- exceptURLErrorasexc:
- print(
- f"Cannot access the archive URL for channel {channel}. "
- f"Make sure that you are within the FHI network."
- f"Skipping over channels {channels_missing}.",
- )
- print("Error code: ",exc)
- break
+ metadata=metadata_retriever.fetch_elab_metadata(
+ scan=scan,
+ metadata=metadata,
+ )metadata["scan_info"]["energy_scan_mode"]=energy_scan_mode
@@ -1054,43 +1035,10 @@
-[docs]
-defget_archiver_data(
- archiver_url:str,
- archiver_channel:str,
- ts_from:float,
- ts_to:float,
-)->tuple[np.ndarray,np.ndarray]:
-"""Extract time stamps and corresponding data from and EPICS archiver instance
-
- Args:
- archiver_url (str): URL of the archiver data extraction interface
- archiver_channel (str): EPICS channel to extract data for
- ts_from (float): starting time stamp of the range of interest
- ts_to (float): ending time stamp of the range of interest
-
- Returns:
- tuple[List, List]: The extracted time stamps and corresponding data
- """
- iso_from=dt.datetime.utcfromtimestamp(ts_from).isoformat()
- iso_to=dt.datetime.utcfromtimestamp(ts_to).isoformat()
- req_str=archiver_url+archiver_channel+"&from="+iso_from+"Z&to="+iso_to+"Z"
- withurlopen(req_str)asreq:
- data=json.load(req)
- secs=[x["secs"]+x["nanos"]*1e-9forxindata[0]["data"]]
- vals=[x["val"]forxindata[0]["data"]]
-
- return(np.asarray(secs),np.asarray(vals))
Returns: List[Path]: scan_path: Path object pointing to the scan folder """
- print("Scan path not provided, searching directories...")
+ logger.info("Scan path not provided, searching directories...")forfileinpath.iterdir():iffile.is_dir():try:
@@ -1117,7 +1065,7 @@
Source code for specsscan.helpers
file.glob(f"*/*/Raw Data/{scan}"),)ifscan_path:
- print("Scan found at path:",scan_path[0])
+ logger.info(f"Scan found at path: {scan_path[0]}")breakelse:scan_path=[]
diff --git a/specsanalyzer/latest/_sources/getting_started.rst.txt b/specsanalyzer/v0.6.0a2/_sources/getting_started.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/getting_started.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/getting_started.rst.txt
diff --git a/specsanalyzer/latest/_sources/index.rst.txt b/specsanalyzer/v0.6.0a2/_sources/index.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/index.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/index.rst.txt
diff --git a/specsanalyzer/latest/_sources/misc/maintain.rst.txt b/specsanalyzer/v0.6.0a2/_sources/misc/maintain.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/misc/maintain.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/misc/maintain.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsanalyzer/config.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/config.rst.txt
similarity index 78%
rename from specsanalyzer/latest/_sources/specsanalyzer/config.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsanalyzer/config.rst.txt
index 4165f69..34ce2f1 100644
--- a/specsanalyzer/latest/_sources/specsanalyzer/config.rst.txt
+++ b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/config.rst.txt
@@ -4,8 +4,8 @@ The config module contains a mechanics to collect configuration parameters from
It will load an (optional) provided config file, or alternatively use a passed python dictionary as initial config dictionary, and subsequently look for the following additional config files to load:
* ``folder_config``: A config file of name :file:`specs_config.yaml` in the current working directory. This is mostly intended to pass calibration parameters of the workflow between different notebook instances.
-* ``user_config``: A config file provided by the user, stored as :file:`.specsanalyzer/config.yaml` in the current user's home directly. This is intended to give a user the option for individual configuration modifications of system settings.
-* ``system_config``: A config file provided by the system administrator, stored as :file:`/etc/specsanalyzer/config.yaml` on Linux-based systems, and :file:`%ALLUSERSPROFILE%/specsanalyzer/config.yaml` on Windows. This should provide all necessary default parameters for using the specsanalyzer processor with a given setup. For an example for the setup at the Fritz Haber Institute setup, see :ref:`example_config`
+* ``user_config``: A config file provided by the user, stored as :file:`.config/specsanalyzer/config_v1.yaml` in the current user's home directly. This is intended to give a user the option for individual configuration modifications of system settings.
+* ``system_config``: A config file provided by the system administrator, stored as :file:`/etc/specsanalyzer/config_v1.yaml` on Linux-based systems, and :file:`%ALLUSERSPROFILE%/specsanalyzer/config_v1.yaml` on Windows. This should provide all necessary default parameters for using the specsanalyzer processor with a given setup. For an example for the setup at the Fritz Haber Institute setup, see :ref:`example_config`
* ``default_config``: The default configuration shipped with the package. Typically, all parameters here should be overwritten by any of the other configuration files.
The config mechanism returns the combined dictionary, and reports the loaded configuration files. In order to disable or overwrite any of the configuration files, they can be also given as optional parameters (path to a file, or python dictionary).
diff --git a/specsanalyzer/latest/_sources/specsanalyzer/convert.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/convert.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsanalyzer/convert.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsanalyzer/convert.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsanalyzer/core.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/core.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsanalyzer/core.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsanalyzer/core.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsanalyzer/img_tools.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/img_tools.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsanalyzer/img_tools.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsanalyzer/img_tools.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsanalyzer/io.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsanalyzer/io.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsanalyzer/io.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsanalyzer/io.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsscan/core.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsscan/core.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsscan/core.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsscan/core.rst.txt
diff --git a/specsanalyzer/latest/_sources/specsscan/helpers.rst.txt b/specsanalyzer/v0.6.0a2/_sources/specsscan/helpers.rst.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/specsscan/helpers.rst.txt
rename to specsanalyzer/v0.6.0a2/_sources/specsscan/helpers.rst.txt
diff --git a/specsanalyzer/latest/_sources/tutorial/1_specsanalyzer_conversion_examples.ipynb.txt b/specsanalyzer/v0.6.0a2/_sources/tutorial/1_specsanalyzer_conversion_examples.ipynb.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/tutorial/1_specsanalyzer_conversion_examples.ipynb.txt
rename to specsanalyzer/v0.6.0a2/_sources/tutorial/1_specsanalyzer_conversion_examples.ipynb.txt
diff --git a/specsanalyzer/latest/_sources/tutorial/2_specsscan_example.ipynb.txt b/specsanalyzer/v0.6.0a2/_sources/tutorial/2_specsscan_example.ipynb.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/tutorial/2_specsscan_example.ipynb.txt
rename to specsanalyzer/v0.6.0a2/_sources/tutorial/2_specsscan_example.ipynb.txt
diff --git a/specsanalyzer/latest/_sources/tutorial/3_specsscan_conversion_to_NeXus.ipynb.txt b/specsanalyzer/v0.6.0a2/_sources/tutorial/3_specsscan_conversion_to_NeXus.ipynb.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/tutorial/3_specsscan_conversion_to_NeXus.ipynb.txt
rename to specsanalyzer/v0.6.0a2/_sources/tutorial/3_specsscan_conversion_to_NeXus.ipynb.txt
diff --git a/specsanalyzer/latest/_sources/tutorial/4_specsscan_load_sweep_scan.ipynb.txt b/specsanalyzer/v0.6.0a2/_sources/tutorial/4_specsscan_load_sweep_scan.ipynb.txt
similarity index 100%
rename from specsanalyzer/latest/_sources/tutorial/4_specsscan_load_sweep_scan.ipynb.txt
rename to specsanalyzer/v0.6.0a2/_sources/tutorial/4_specsscan_load_sweep_scan.ipynb.txt
diff --git a/specsanalyzer/latest/_static/basic.css b/specsanalyzer/v0.6.0a2/_static/basic.css
similarity index 100%
rename from specsanalyzer/latest/_static/basic.css
rename to specsanalyzer/v0.6.0a2/_static/basic.css
diff --git a/specsanalyzer/latest/_static/doctools.js b/specsanalyzer/v0.6.0a2/_static/doctools.js
similarity index 100%
rename from specsanalyzer/latest/_static/doctools.js
rename to specsanalyzer/v0.6.0a2/_static/doctools.js
diff --git a/specsanalyzer/latest/_static/documentation_options.js b/specsanalyzer/v0.6.0a2/_static/documentation_options.js
similarity index 89%
rename from specsanalyzer/latest/_static/documentation_options.js
rename to specsanalyzer/v0.6.0a2/_static/documentation_options.js
index 0287497..0fe88c8 100644
--- a/specsanalyzer/latest/_static/documentation_options.js
+++ b/specsanalyzer/v0.6.0a2/_static/documentation_options.js
@@ -1,5 +1,5 @@
const DOCUMENTATION_OPTIONS = {
- VERSION: '0.5.2.dev2+gd6a55dd',
+ VERSION: '0.6.0a2',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
diff --git a/specsanalyzer/latest/_static/file.png b/specsanalyzer/v0.6.0a2/_static/file.png
similarity index 100%
rename from specsanalyzer/latest/_static/file.png
rename to specsanalyzer/v0.6.0a2/_static/file.png
diff --git a/specsanalyzer/latest/_static/language_data.js b/specsanalyzer/v0.6.0a2/_static/language_data.js
similarity index 100%
rename from specsanalyzer/latest/_static/language_data.js
rename to specsanalyzer/v0.6.0a2/_static/language_data.js
diff --git a/specsanalyzer/latest/_static/minus.png b/specsanalyzer/v0.6.0a2/_static/minus.png
similarity index 100%
rename from specsanalyzer/latest/_static/minus.png
rename to specsanalyzer/v0.6.0a2/_static/minus.png
diff --git a/specsanalyzer/latest/_static/nbsphinx-broken-thumbnail.svg b/specsanalyzer/v0.6.0a2/_static/nbsphinx-broken-thumbnail.svg
similarity index 100%
rename from specsanalyzer/latest/_static/nbsphinx-broken-thumbnail.svg
rename to specsanalyzer/v0.6.0a2/_static/nbsphinx-broken-thumbnail.svg
diff --git a/specsanalyzer/latest/_static/nbsphinx-code-cells.css b/specsanalyzer/v0.6.0a2/_static/nbsphinx-code-cells.css
similarity index 100%
rename from specsanalyzer/latest/_static/nbsphinx-code-cells.css
rename to specsanalyzer/v0.6.0a2/_static/nbsphinx-code-cells.css
diff --git a/specsanalyzer/latest/_static/nbsphinx-gallery.css b/specsanalyzer/v0.6.0a2/_static/nbsphinx-gallery.css
similarity index 100%
rename from specsanalyzer/latest/_static/nbsphinx-gallery.css
rename to specsanalyzer/v0.6.0a2/_static/nbsphinx-gallery.css
diff --git a/specsanalyzer/latest/_static/nbsphinx-no-thumbnail.svg b/specsanalyzer/v0.6.0a2/_static/nbsphinx-no-thumbnail.svg
similarity index 100%
rename from specsanalyzer/latest/_static/nbsphinx-no-thumbnail.svg
rename to specsanalyzer/v0.6.0a2/_static/nbsphinx-no-thumbnail.svg
diff --git a/specsanalyzer/latest/_static/plus.png b/specsanalyzer/v0.6.0a2/_static/plus.png
similarity index 100%
rename from specsanalyzer/latest/_static/plus.png
rename to specsanalyzer/v0.6.0a2/_static/plus.png
diff --git a/specsanalyzer/latest/_static/pygments.css b/specsanalyzer/v0.6.0a2/_static/pygments.css
similarity index 100%
rename from specsanalyzer/latest/_static/pygments.css
rename to specsanalyzer/v0.6.0a2/_static/pygments.css
diff --git a/specsanalyzer/latest/_static/scripts/bootstrap.js b/specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/bootstrap.js
rename to specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js
diff --git a/specsanalyzer/latest/_static/scripts/bootstrap.js.LICENSE.txt b/specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js.LICENSE.txt
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/bootstrap.js.LICENSE.txt
rename to specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js.LICENSE.txt
diff --git a/specsanalyzer/latest/_static/scripts/bootstrap.js.map b/specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js.map
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/bootstrap.js.map
rename to specsanalyzer/v0.6.0a2/_static/scripts/bootstrap.js.map
diff --git a/specsanalyzer/latest/_static/scripts/fontawesome.js b/specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/fontawesome.js
rename to specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js
diff --git a/specsanalyzer/latest/_static/scripts/fontawesome.js.LICENSE.txt b/specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js.LICENSE.txt
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/fontawesome.js.LICENSE.txt
rename to specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js.LICENSE.txt
diff --git a/specsanalyzer/latest/_static/scripts/fontawesome.js.map b/specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js.map
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/fontawesome.js.map
rename to specsanalyzer/v0.6.0a2/_static/scripts/fontawesome.js.map
diff --git a/specsanalyzer/latest/_static/scripts/pydata-sphinx-theme.js b/specsanalyzer/v0.6.0a2/_static/scripts/pydata-sphinx-theme.js
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/pydata-sphinx-theme.js
rename to specsanalyzer/v0.6.0a2/_static/scripts/pydata-sphinx-theme.js
diff --git a/specsanalyzer/latest/_static/scripts/pydata-sphinx-theme.js.map b/specsanalyzer/v0.6.0a2/_static/scripts/pydata-sphinx-theme.js.map
similarity index 100%
rename from specsanalyzer/latest/_static/scripts/pydata-sphinx-theme.js.map
rename to specsanalyzer/v0.6.0a2/_static/scripts/pydata-sphinx-theme.js.map
diff --git a/specsanalyzer/latest/_static/searchtools.js b/specsanalyzer/v0.6.0a2/_static/searchtools.js
similarity index 100%
rename from specsanalyzer/latest/_static/searchtools.js
rename to specsanalyzer/v0.6.0a2/_static/searchtools.js
diff --git a/specsanalyzer/latest/_static/sphinx_highlight.js b/specsanalyzer/v0.6.0a2/_static/sphinx_highlight.js
similarity index 100%
rename from specsanalyzer/latest/_static/sphinx_highlight.js
rename to specsanalyzer/v0.6.0a2/_static/sphinx_highlight.js
diff --git a/specsanalyzer/latest/_static/styles/pydata-sphinx-theme.css b/specsanalyzer/v0.6.0a2/_static/styles/pydata-sphinx-theme.css
similarity index 100%
rename from specsanalyzer/latest/_static/styles/pydata-sphinx-theme.css
rename to specsanalyzer/v0.6.0a2/_static/styles/pydata-sphinx-theme.css
diff --git a/specsanalyzer/latest/_static/styles/pydata-sphinx-theme.css.map b/specsanalyzer/v0.6.0a2/_static/styles/pydata-sphinx-theme.css.map
similarity index 100%
rename from specsanalyzer/latest/_static/styles/pydata-sphinx-theme.css.map
rename to specsanalyzer/v0.6.0a2/_static/styles/pydata-sphinx-theme.css.map
diff --git a/specsanalyzer/latest/_static/styles/theme.css b/specsanalyzer/v0.6.0a2/_static/styles/theme.css
similarity index 100%
rename from specsanalyzer/latest/_static/styles/theme.css
rename to specsanalyzer/v0.6.0a2/_static/styles/theme.css
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-brands-400.ttf b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-brands-400.ttf
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-brands-400.ttf
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-brands-400.ttf
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-brands-400.woff2 b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-brands-400.woff2
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-brands-400.woff2
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-brands-400.woff2
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-regular-400.ttf b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-regular-400.ttf
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-regular-400.ttf
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-regular-400.ttf
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-regular-400.woff2 b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-regular-400.woff2
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-regular-400.woff2
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-regular-400.woff2
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-solid-900.ttf b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-solid-900.ttf
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-solid-900.ttf
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-solid-900.ttf
diff --git a/specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-solid-900.woff2 b/specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-solid-900.woff2
similarity index 100%
rename from specsanalyzer/latest/_static/vendor/fontawesome/webfonts/fa-solid-900.woff2
rename to specsanalyzer/v0.6.0a2/_static/vendor/fontawesome/webfonts/fa-solid-900.woff2
diff --git a/specsanalyzer/latest/_static/webpack-macros.html b/specsanalyzer/v0.6.0a2/_static/webpack-macros.html
similarity index 100%
rename from specsanalyzer/latest/_static/webpack-macros.html
rename to specsanalyzer/v0.6.0a2/_static/webpack-macros.html
diff --git a/specsanalyzer/latest/genindex.html b/specsanalyzer/v0.6.0a2/genindex.html
similarity index 96%
rename from specsanalyzer/latest/genindex.html
rename to specsanalyzer/v0.6.0a2/genindex.html
index e2c77db..64fa64e 100644
--- a/specsanalyzer/latest/genindex.html
+++ b/specsanalyzer/v0.6.0a2/genindex.html
@@ -7,7 +7,7 @@
- Index — specsanalyzer 0.5.2.dev2+gd6a55dd documentation
+ Index — specsanalyzer 0.6.0a2 documentation
@@ -37,7 +37,7 @@
-
+
@@ -46,7 +46,7 @@
@@ -54,7 +54,7 @@
-
+
@@ -116,7 +116,7 @@
-
folder_config: A config file of name specs_config.yaml in the current working directory. This is mostly intended to pass calibration parameters of the workflow between different notebook instances.
-
user_config: A config file provided by the user, stored as .specsanalyzer/config.yaml in the current user’s home directly. This is intended to give a user the option for individual configuration modifications of system settings.
-
system_config: A config file provided by the system administrator, stored as /etc/specsanalyzer/config.yaml on Linux-based systems, and %ALLUSERSPROFILE%/specsanalyzer/config.yaml on Windows. This should provide all necessary default parameters for using the specsanalyzer processor with a given setup. For an example for the setup at the Fritz Haber Institute setup, see Default specsanalyzer configuration settings
+
user_config: A config file provided by the user, stored as .config/specsanalyzer/config_v1.yaml in the current user’s home directly. This is intended to give a user the option for individual configuration modifications of system settings.
+
system_config: A config file provided by the system administrator, stored as /etc/specsanalyzer/config_v1.yaml on Linux-based systems, and %ALLUSERSPROFILE%/specsanalyzer/config_v1.yaml on Windows. This should provide all necessary default parameters for using the specsanalyzer processor with a given setup. For an example for the setup at the Fritz Haber Institute setup, see Default specsanalyzer configuration settings
default_config: The default configuration shipped with the package. Typically, all parameters here should be overwritten by any of the other configuration files.
The config mechanism returns the combined dictionary, and reports the loaded configuration files. In order to disable or overwrite any of the configuration files, they can be also given as optional parameters (path to a file, or python dictionary).
user_config (dict | str, optional) – user-based config dictionary
or file path. The loaded dictionary is completed with the user-based values,
taking preference over system and default values.
-Defaults to the file “.specsanalyzer/config.yaml” in the current user’s home directory.
+Defaults to the file “.config/specsanalyzer/config_v1.yaml” in the current user’s home
+directory.
system_config (dict | str, optional) – system-wide config dictionary
or file path. The loaded dictionary is completed with the system-wide values,
taking preference over default values.
-Defaults to the file “/etc/specsanalyzer/config.yaml” on linux,
-and “%ALLUSERSPROFILE%/specsanalyzer/config.yaml” on windows.
+Defaults to the file “/etc/specsanalyzer/config_v1.yaml” on linux,
+and “%ALLUSERSPROFILE%/specsanalyzer/config_v1.yaml” on windows.
default_config (dict | str, optional) – default config dictionary
or file path. The loaded dictionary is completed with the default values.
Defaults to package_dir/config/default.yaml”.
Read an environment variable from multiple locations in order:
+1. OS environment variables
+2. .env file in current directory
+3. .env file in user config directory
+4. .env file in system config directory
+
+
Parameters:
+
var_name (str) – Name of the environment variable to read
+
+
Returns:
+
Value of the environment variable or None if not found
Save an environment variable to the .env file in the user config directory.
+If the file exists, preserves other variables. If not, creates a new file.
+
+
Parameters:
+
+
var_name (str) – Name of the environment variable to save
+
value (str) – Value to save for the environment variable
SpecsAnalyzer: A class to convert photoemission data from a SPECS Phoibos analyzer from
camera image coordinates into physical units (energy, angle, position).
SpecsAnalyzer class for loading scans and data from SPECS Phoibos electron analyzers,
generated with the ARPESControl software at Fritz Haber Institute, Berlin, and EPFL, Lausanne.
Here, a SpecsScan class instance is created as per the configuration provided in config.yaml. The user may set the entries in config.yaml file, for example, the data path and conversion parameters as per the requirements before creating this instance.
+
In addition to the provided config files, config files from different locations are optionally included as well (see documentation).
The load_scan method loads the scan as an xarray of the data converted into angular/energy coordinates along with the metadata of the scan.
+
+
[3]:
+
+
+
path="../tests/data/"# Path to the test data set
+# The path may be changed to point to the scan folder of the data of interest (for example, on a server drive)
+res_xarray=sps.load_scan(
+ scan=4450,# Scan number for an example mirror scan
+ path=path,
+)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+INFO - Gathering metadata from different locations
+INFO - Collecting time stamps...
+
+
+
The data are from a mirror scan, showing the mirror position as third dimension:
+
+
[4]:
+
+
+
res_xarray.dims
+
+
+
+
+
[4]:
+
+
+
+
+('Angle', 'Ekin', 'mirrorX')
+
+
+
We can plot, e.g., selected steps of the scan:
+
+
[5]:
+
+
+
plt.figure()
+res_xarray[:,:,0].plot()
+
+
+
+
+
[5]:
+
+
+
+
+<matplotlib.collections.QuadMesh at 0x7f6631cc07f0>
+
The image contains data beyond the boundaries given by the illuminated area of the MCP, which should be removed. For this, the crop option of the converter can be used:
+
+
[6]:
+
+
+
res_xarray=sps.load_scan(
+ scan=4450,# Scan number for an example mirror scan
+ path=path,
+ crop=True,
+)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+WARNING - Warning: Cropping parameters not found, use method crop_tool() after loading.
+INFO - Gathering metadata from different locations
+INFO - Collecting time stamps...
+
+
+
The loader has given a warning saying that the cropping parameters do not exist yet. Therefore, an interactive cropping tool can be used to crop the data while also saving the crop ranges into a class attribute for later scans. Pressing crop applies the cropping to the test image, and stores the cropping information in the class.
+
One can provide relative cropping ranges either as keyword parameters, or in the config file, and optionally directly apply the settings to make the tool non-interactive.
In order to remove the meshgrid artifact present in the data, an fft filtering is applied already in the data loaded previously. For this, parameters of the fft peaks corresponding to the grid are required which can be provided in the config file. Alternatively, one can also interactively optimize the parameters using the fft tool
+
+
[9]:
+
+
+
sps.fft_tool(
+ amplitude=1,
+ pos_x=82,
+ pos_y=116,
+ sigma_x=15,
+ sigma_y=23,
+ apply=True# Use apply=False for interactive mode
+)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Load the scan again for the new changes to apply to all the images
3D scans, where the images are recorded as a function of a third parameter (generally delay or in this case, mirrorX), can also be loaded with an option to average only the given iterations passed as a list or slice object.
+INFO - Using saved crop parameters...
+INFO - Gathering metadata from different locations
+INFO - Collecting time stamps...
+
+
+
+
[13]:
+
+
+
+
+<matplotlib.collections.QuadMesh at 0x7f6630982680>
+
+
+
+
+
+
+
+
+
Another useful functionality is to load a 3D scan as a function of iterations averaged over the scan parameter (in this case, mirrorX). This is done using the check_scan method
+
+
[14]:
+
+
+
res_xarray_check=sps.check_scan(
+ scan=4450,
+ delays=0,# for a fixed delay of index, 1
+ path=path,
+)
+plt.figure()
+res_xarray_check.loc[{"Angle":slice(-5,5)}].sum(axis=(0)).plot()
+
+
+
+
+
+
+
+
+INFO - Averaging over delays...
+
+
+
+
+
+
+
+
+
+
+
+
+
+INFO - Using saved crop parameters...
+INFO - Gathering metadata from different locations
+INFO - Collecting time stamps...
+
+
+
+
[14]:
+
+
+
+
+<matplotlib.collections.QuadMesh at 0x7f6629ef5630>
+
Data can be saved, e.g., as hdf5 files including metadata for convenient processing in other notebooks or software.
+
+
[15]:
+
+
+
sps.load_scan(
+ scan=4450,# Scan number for an example mirror scan
+ path=path,
+)
+sps.save("example_data.h5")
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+INFO - Using saved crop parameters...
+INFO - Gathering metadata from different locations
+INFO - Collecting time stamps...
+saving data to example_data.h5
+Saved iterations as string.
+Saved fft_filter_peaks as string.
+Saving complete!
+