xrf_explorer.server.file_system.workspace package

Submodules

xrf_explorer.server.file_system.workspace.contextual_images module

get_base_image_name(data_source: str) str | None[source]

Get the name to the base image of the data source.

Parameters:

data_source – The data source to get the base image from

Returns:

The name of the base image

get_contextual_image(image_path: str) Image | None[source]

Open and returns an image at a specified path.

Parameters:

image_path – The path to the image file

Returns:

The image

get_contextual_image_data(data_source: str, name: str) dict | None[source]

Returns a contextual image from workspace.json. Returns None if the image or data_source does not exist.

Parameters:
  • data_source – The data source to fetch the image from

  • name – The name of the image. Must be present in workspace.json for the data source as the base image or a contextual image

Returns:

Dict containing the name, imageLocation and recipeLocation of a contextual image

get_contextual_image_path(data_source: str, name: str) str | None[source]

Returns the path of the requested contextual image. If no file is found, it will return None. This will also happen if the config file is empty.

Parameters:
  • data_source – The data source to fetch the image from

  • name – The name of the image. Must be present in workspace.json for the data source as the base image or a contextual image

Returns:

The path to the requested contextual image

get_contextual_image_recipe_path(data_source: str, name: str) str | None[source]

Returns the path of the registering recipe of the requested contextual image. If no file is found, it will return None. This will also happen if the config file is empty.

Parameters:
  • data_source – The data source to fetch the image from

  • name – The name of the image. Must be present in workspace.json for the data source as the base image or a contextual image

Returns:

The path to the recipe of the requested contextual image

get_contextual_image_size(image_path: str) tuple[int, int] | None[source]

Get the size of an image.

Parameters:

image_path – The path to the image file

Returns:

The dimensions of the image

get_path_to_base_image(data_source: str) str | None[source]

Get the path to the base image of the data source.

Parameters:

data_source – The data source to get the base image from

Returns:

The path to the base image

is_base_image(data_source: str, name: str) bool | None[source]

Check if the image is the base image of the data source.

Parameters:
  • data_source – The data source to check whether the name is the base image

  • name – The name of the image. Must be present in workspace.json for the data source as the base image or a contextual image

Returns:

True if the image is the base image, False otherwise

xrf_explorer.server.file_system.workspace.file_access module

get_base_image_name(data_source_folder_name: str) str | None[source]

Get the name of the rgb image of a given data source.

Parameters:

data_source_folder_name – Name of the data source folder

Returns:

Name of the rgb image

get_base_image_path(data_source_folder_name: str) str | None[source]

Get the path to RGB image of a data source.

Parameters:

data_source_folder_name – Name of the data source folder

Returns:

Path to the RGB image

get_elemental_cube_file_names(data_source: str) list[str] | None[source]

Get the names of the elemental cube files of a given datasource.

Parameters:

data_source – Name of the data source folder

Returns:

Names of the elemental cube files

get_elemental_cube_path(data_source_folder: str) str | None[source]

Get the path to the elemental data cube of a data source.

Parameters:

data_source_folder – Name of the data source folder

Returns:

Path to the elemental data cube

get_elemental_cube_path_from_name(data_source: str, cube_name: str) str | None[source]

Get the path to the elemental data cube of the given cube and data source.

Parameters:
  • data_source – Name of the data source folder

  • cube_name – Name of the elemental cube

Returns:

Path to the elemental data cube with the given name

get_elemental_cube_recipe_path(data_source: str) str | None[source]

Get the location of the elemental cube recipe file of a given datasource.

Parameters:

data_source – Name of the datasource

Returns:

Path string pointing to the recipe of the elemental cube

get_raw_rpl_names(data_source: str) tuple[str, str][source]

Get the name of the raw data file (.raw) and the .rpl file of a given datasource.

Parameters:

data_source – Name of the data source

Returns:

Names of the raw data and rpl files

get_raw_rpl_paths(data_source: str) tuple[str, str][source]

Get the paths to the raw data file (.raw) and the .rpl file of a given datasource.

Parameters:

data_source – Name of the data source

Returns:

Paths to the raw data and rpl files

get_spectral_cube_recipe_path(data_source_folder_name: str) str | None[source]

Returns the path of the spectral data cube recipe of the specified data source. If the data cube does not have a recipe, the function returns None.

Parameters:

data_source_folder_name – Name of the data source folder

Returns:

Path of the data cube recipe

get_workspace_dict(data_source_folder_name: str) dict | None[source]

Returns the workspace of the specified data source in dictionary format.

Parameters:

data_source_folder_name – Name of the data source folder

Returns:

Dictionary format of the workspace.json

set_binned(data_source: str, binned: bool)[source]

Sets the binned boolean attribute of a workspace.

Parameters:
  • data_source – Name of the data source

  • binned – Boolean to set binned to

xrf_explorer.server.file_system.workspace.workspace_handler module

get_path_to_workspace(datasource: str) str[source]

Get the path to the workspace.json file for a given datasource.

Parameters:

datasource – The name of the datasource

Returns:

The path to the workspace.json file for the given datasource. If the workspace does not exist, return an empty string

update_workspace(datasource: str, new_workspace: any) bool[source]

Update the workspace.json file for a given datasource.

Parameters:
  • datasource – The name of the datasource

  • new_workspace – The data to write to the workspace

Returns:

True if the workspace was updated successfully, False otherwise

Module contents

Module to handle file system operations for workspaces and specific data sources.