Skip to content

Templates in Jupyter Analysis

This guide explains how to create and use Jupyter Analysis Templates in NOMAD. Templates let you define reusable notebook structures that can be applied to multiple JupyterAnalysis entries, ensuring consistency across your workflows.

To read about JupyterAnalysis schema, check out the Analysis with Jupyter Notebooks guide.

When to Use Templates

Templates are useful when:

  • You have a standardized analysis workflow that you want to reuse across multiple entries
  • You want to share a working analysis notebook with your team as a starting point
  • You need to ensure consistency in how analyses are performed within a project
  • You want to avoid rewriting the same boilerplate code for each new analysis

If your analysis workflows vary significantly between entries, or you only need to run an analysis once, creating a template may not be necessary. In such cases, you can simply use the JupyterAnalysis schema directly.

Creating a Template

Create a Jupyter Analysis Template Entry

  • Navigate to your upload in NOMAD
  • Click Create Entry and provide a name (e.g., "XRD Analysis Template")
  • Select Built-in Schemas and choose Jupyter Analysis Template
  • Click Create

Add a Template Notebook

You have two options:

Option A: Upload a notebook directly

If you already have a Jupyter notebook that you want to use as a template:

  • Find the template_notebook field in the entry
  • Upload your .ipynb file

Option B: Generate from an existing analysis

If you have a JupyterAnalysis entry with a working notebook that you want to turn into a template:

  • Find the from_analysis field and reference your existing analysis entry
  • Click the Generate From Analysis button
  • The notebook from the referenced analysis will be copied and linked as the template

Header Cells in Templates

A notebook generated by a JupyterAnalysis entry has header cells (tagged with nomad-analysis-header) containing metadata related the entry. When you use such a notebook as a template, these header cells are automatically replaced with template-specific headers. The rest of the notebook content is preserved.

Using a Template in Jupyter Analysis

Once you have a template, you can use it when creating new analyses:

  • Create a new JupyterAnalysis entry
  • In the template field, search for and select your template entry
  • Click Generate Notebook

The generated notebook will use the template's structure instead of the default pre-defined cells. The header cells are updated to reflect the new analysis entry's metadata.

How It Works

When a notebook is generated from a template:

  • The template notebook is read from the referenced JupyterAnalysisTemplate entry
  • Header cells (tagged with nomad-analysis-header) are replaced with new headers containing the current analysis entry's metadata
  • All other cells from the template are preserved
  • The new notebook is saved in the upload folder and linked to the analysis entry

This means any analysis code, markdown documentation, or helper functions in your template notebook will be available in the generated notebook.

Learn More