Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CasaXPS data analysis results parsing #99

Merged

Conversation

lukaspie
Copy link
Collaborator

@lukaspie lukaspie commented Nov 15, 2024

This implements parsing the data analysis as performed in CasaXPS to fill the NXfit group in the NeXus file. The resulting file (tests/data/vms_analysis/vms_analysis_ref.nxs) looks like this:

image

Summary by Sourcery

Implement parsing of CasaXPS data analysis results to populate the NXfit group in NeXus files. Store peak fitting parameters, including regions, components, backgrounds, and atomic concentrations, in the NXxps structure.

New Features:

  • Parse CasaXPS analysis results, including peak fitting parameters and atomic concentrations, and store them in the NXfit group within NeXus files, adhering to the NXxps application definition.

Tests:

  • Added a reference NeXus file containing CasaXPS analysis results.

@lukaspie lukaspie linked an issue Nov 15, 2024 that may be closed by this pull request
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch from 9bc363b to 0e76bf2 Compare November 18, 2024 09:49
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch 2 times, most recently from fcab3fe to 7758dde Compare January 29, 2025 15:29
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch from 7758dde to 7de621c Compare February 3, 2025 10:39
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch from d2d427f to 53a6308 Compare February 3, 2025 12:19
@lukaspie lukaspie changed the title CASA XPS data analysis results parsing CasaXPS data analysis results parsing Feb 3, 2025
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch from 2783301 to 7956705 Compare February 3, 2025 14:04
@lukaspie lukaspie marked this pull request as ready for review February 3, 2025 14:09
Copy link

sourcery-ai bot commented Feb 3, 2025

Reviewer's Guide by Sourcery

This pull request implements parsing of data analysis results from CasaXPS, which are stored in the VAMAS comments, and maps them to the NXfit group in the NeXus file. It also includes a new reader for TXT files exported from CasaXPS.

Sequence diagram for CasaXPS data analysis parsing

sequenceDiagram
    participant VamasMapper
    participant CasaProcess
    participant Region
    participant Component

    VamasMapper->>CasaProcess: process_comments(comment_list)
    CasaProcess->>Region: calculate_background(x, y)
    Region-->>CasaProcess: background data
    CasaProcess->>Component: calculate_lineshape(x)
    Component-->>CasaProcess: peak data
    CasaProcess->>VamasMapper: flattened_metadata()
    VamasMapper->>NXfit: map data to NXfit group
Loading

Class diagram for peak fitting and background models

classDiagram
    class Peak {
        +float position
        +float width
        +float area
        +__init__(position, width, area)
    }

    class Gaussian {
        +calc_lineshape(x)
        +formula()
    }

    class Lorentzian {
        +calc_lineshape(x)
        +formula()
    }

    class GaussianLorentzianSum {
        +float fraction_gauss
        +calc_lineshape(x)
        +formula()
    }

    class GaussianLorentzianProduct {
        +float fraction_gauss
        +calc_lineshape(x)
        +formula()
    }

    class DoniachSunjic {
        +float beta
        +calc_lineshape(x)
        +formula()
    }

    Peak <|-- Gaussian
    Peak <|-- Lorentzian
    Peak <|-- GaussianLorentzianSum
    Peak <|-- GaussianLorentzianProduct
    Peak <|-- DoniachSunjic
Loading

File-Level Changes

Change Details Files
Implements parsing of CasaXPS data analysis results from VAMAS comments.
  • Adds a new class CasaProcess to parse CasaXPS data analysis results.
  • Adds classes for different CasaXPS data analysis parameters, such as CasaEnergyCalibration, CasaIntensityCalibration, CasaRegion, and CasaComponent.
  • Updates the VamasMapper class to parse the CasaXPS data analysis results and map them to the NXfit group.
  • Updates the XPSReader class to handle the new CasaXPS data analysis results.
  • Adds documentation for the new CasaXPS data analysis results parsing.
  • Adds a new test case for the CasaXPS data analysis results parsing.
  • Adds a new example for the CasaXPS data analysis results parsing.
  • Adds a new script to regenerate the reference files for the CasaXPS data analysis results parsing.
  • Adds a new script to regenerate the examples for the CasaXPS data analysis results parsing.
  • Adds a new script to regenerate the examples for the CasaXPS data analysis results parsing without documentation.
  • Adds a new script to generate the reference JSON files for the CasaXPS data analysis results parsing.
  • Adds a new example ELN file for the CasaXPS data analysis results parsing.
  • Adds a new test ELN file for the CasaXPS data analysis results parsing.
  • Adds a new module for the models used in the CasaXPS data analysis results parsing.
  • Adds a new README file for the CasaXPS data analysis results parsing example.
  • Adds a new example VAMAS file for the CasaXPS data analysis results parsing.
  • Adds a new example CSV file for the CasaXPS data analysis results parsing.
  • Adds a new test VAMAS file for the CasaXPS data analysis results parsing.
  • Adds a new test TXT file for the CasaXPS data analysis results parsing.
  • Adds a new test CSV file for the CasaXPS data analysis results parsing.
  • Adds new classes for the different lineshapes used in the CasaXPS data analysis results parsing.
  • Adds new classes for the different backgrounds used in the CasaXPS data analysis results parsing.
src/pynxtools_xps/vms/vamas.py
src/pynxtools_xps/vms/casa_data_model.py
src/pynxtools_xps/vms/vamas_comment_handler.py
src/pynxtools_xps/reader.py
docs/explanation/data_processing.md
docs/reference/vms.md
tests/test_reader.py
scripts/regenerate_ref_nxs_files.sh
scripts/regenerate_examples.sh
scripts/regenerate_examples_undocumented.sh
scripts/generate_ref_comments_jsons.py
examples/vms/data_analysis/eln.yaml
tests/data/vms_analysis/eln.yaml
src/pynxtools_xps/models/__init__.py
examples/vms/data_analysis/README.md
examples/vms/data_analysis/FeO_analyzed.vms
examples/vms/data_analysis/FeO_analyzed_results.csv
tests/data/vms_analysis/FeO_analyzed.vms
tests/data/vms_analysis/FeO_analyzed_lineshapes_cols.txt
tests/data/vms_analysis/FeO_analyzed_results.csv
src/pynxtools_xps/models/lineshapes.py
src/pynxtools_xps/models/backgrounds.py
Adds a new reader for TXT files exported from CasaXPS.
  • Adds a new class TxtMapperVamasExport to parse TXT files exported from CasaXPS.
  • Adds a new class TextParserRows to parse TXT files exported from CasaXPS using the 'Rows of Tables' option.
  • Adds a new class TextParserColumns to parse TXT files exported from CasaXPS using the 'Columns of Tables' option.
  • Updates the XPSReader class to handle the new TXT files exported from CasaXPS.
  • Adds a new README file for the TXT export example.
  • Adds a new example TXT file for the TXT export example.
  • Adds a new script to regenerate the examples for the TXT export example.
  • Adds a new script to regenerate the examples for the TXT export example without documentation.
src/pynxtools_xps/vms/vamas_export.py
src/pynxtools_xps/reader.py
examples/vms/txt_export/README.md
examples/vms/vms_txt_export.txt
scripts/regenerate_examples.sh
scripts/regenerate_examples_undocumented.sh
Adds a new reader for CSV files exported from CasaXPS.
  • Adds a new class CsvMapperVamasResult to parse CSV files exported from CasaXPS.
  • Adds a new class CsvResultParser to parse CSV files exported from CasaXPS.
  • Updates the XPSReader class to handle the new CSV files exported from CasaXPS.
src/pynxtools_xps/vms/vamas_export.py
src/pynxtools_xps/reader.py
Adds a new function to check for multiple file extensions.
  • Adds a new function _check_multiple_extensions to check for multiple file extensions.
src/pynxtools_xps/reader.py
Adds a new parameter to the XPSReader to overwrite keys.
  • Adds a new parameter overwrite_keys to the XPSReader class.
src/pynxtools_xps/reader.py
Adds a new function to convert from kinetic to binding energy.
  • Adds a new function convert_to_binding_energy_scale to the VamasBlock class.
src/pynxtools_xps/vms/vamas_data_model.py
Adds a new function to split a string after the leading letters.
  • Adds a new function split_after_letters to split a string after the leading letters.
src/pynxtools_xps/vms/casa_data_model.py
Adds a new function to handle repetitions in a list of strings.
  • Adds a new function handle_repetitions to handle repetitions in a list of strings.
src/pynxtools_xps/vms/vamas_export.py
Adds a new function to select items from a list according to a specified pattern.
  • Adds a new function select_from_list to select items from a list according to a specified pattern.
src/pynxtools_xps/vms/vamas_export.py
Adds a new function to map a list of header strings to their corresponding keys.
  • Adds a new function get_dict_keys to map a list of header strings to their corresponding keys.
src/pynxtools_xps/vms/vamas_export.py
Removes the root path from the XPSMapper class.
  • Removes the _root_path attribute from the XPSMapper class.
src/pynxtools_xps/reader_utils.py
Adds a new function to align name parts.
  • Adds a new function align_name_part to align name parts.
src/pynxtools_xps/reader_utils.py
Updates the config file for the VAMAS reader.
  • Updates the config file for the VAMAS reader.
src/pynxtools_xps/config/config_vms.json
Removes the config file for the TXT VAMAS export reader.
  • Removes the config file for the TXT VAMAS export reader.
src/pynxtools_xps/config/config_txt_vamas_export.json
Removes the TXT VAMAS export reader.
  • Removes the TXT VAMAS export reader.
src/pynxtools_xps/vms/txt_vamas_export.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @lukaspie - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

docs/explanation/data_processing.md Show resolved Hide resolved
src/pynxtools_xps/reader.py Outdated Show resolved Hide resolved
src/pynxtools_xps/vms/vamas.py Outdated Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Outdated Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Outdated Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Outdated Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Show resolved Hide resolved
src/pynxtools_xps/vms/vamas_export.py Outdated Show resolved Hide resolved
@FAIRmat-NFDI FAIRmat-NFDI deleted a comment from sourcery-ai bot Feb 3, 2025
@FAIRmat-NFDI FAIRmat-NFDI deleted a comment from sourcery-ai bot Feb 3, 2025
@FAIRmat-NFDI FAIRmat-NFDI deleted a comment from sourcery-ai bot Feb 3, 2025
@FAIRmat-NFDI FAIRmat-NFDI deleted a comment from sourcery-ai bot Feb 3, 2025
@FAIRmat-NFDI FAIRmat-NFDI deleted a comment from sourcery-ai bot Feb 3, 2025
@lukaspie lukaspie force-pushed the 21-xps-data-analysis-results-parsing-through-config-file branch from fc78899 to a86e4a1 Compare February 3, 2025 14:31
@lukaspie lukaspie merged commit a3eaa48 into main Feb 3, 2025
7 checks passed
@lukaspie lukaspie deleted the 21-xps-data-analysis-results-parsing-through-config-file branch February 3, 2025 17:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

XPS data analysis results parsing through config file
2 participants