{"id":15899026,"url":"https://github.com/danporter/babelscan","last_synced_at":"2026-01-19T07:33:26.883Z","repository":{"id":57413611,"uuid":"360529209","full_name":"DanPorter/babelscan","owner":"DanPorter","description":"BabelScan is a format independent data structure for holding different types of data from a scan file","archived":false,"fork":false,"pushed_at":"2024-08-14T08:48:43.000Z","size":7302,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-20T17:38:40.277Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DanPorter.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-04-22T13:29:22.000Z","updated_at":"2024-08-14T08:48:46.000Z","dependencies_parsed_at":"2024-08-14T10:03:16.184Z","dependency_job_id":"0860f0af-ed3f-44bf-8f40-c7f5fdc18439","html_url":"https://github.com/DanPorter/babelscan","commit_stats":{"total_commits":29,"total_committers":1,"mean_commits":29.0,"dds":0.0,"last_synced_commit":"75f0bb7e676959b7f518b6cb57f7c544ea7794c9"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanPorter%2Fbabelscan","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanPorter%2Fbabelscan/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanPorter%2Fbabelscan/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DanPorter%2Fbabelscan/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DanPorter","download_url":"https://codeload.github.com/DanPorter/babelscan/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247517918,"owners_count":20951719,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-06T10:10:36.212Z","updated_at":"2026-01-19T07:33:26.834Z","avatar_url":"https://github.com/DanPorter.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BabelScan\nBabelScan is a format independent data structure for holding different types of data from a scan file.\n\nVarious file formats are supported, including Nexus and HDF formats, as well as older ASCII file formats. \nBabelScan is implicitly Lazy Loading and only loads data when requested, making it fast and lightweight.\n\nData fields are stored in a format independent way, with the abiliity to find close matches to a \nrequested field.\n\n3D datasets such as images from detectors are specially handelled and contain several special functions.\n\nIf packages lmfit and matplotlib are available, fitting and plotting options are included in the BabelScan object.\n\nA FolderMonitor class allows loading of specific files in numeric order\n\nAn Instrument class holds specific configuration for generation of bespoke BabelScan objects.\n\nYou can read the documentation [here!](https://babelscan.readthedocs.io/en/latest/) \n\n[![Documentation Status](https://readthedocs.org/projects/babelscan/badge/?version=latest)](https://babelscan.readthedocs.io/en/latest/?badge=latest)\n\nBy Dan Porter, Diamond Light Source Ltd. 2024\n\n### Usage\n```python\n# Python script\nimport babelscan\nscan1 = babelscan.file_loader('12345.nxs')\nscan2 = babelscan.file_loader('i16_1234.dat')\nexp = babelscan.FolderMonitor('/path/to/files')\nscan3 = exp.scan(0)  # returns latest scan in directory\nscans = scan1 + scan2 + scan3  # creates MultiScan object that combines the 3 datasets\n\n# Folder monitor:\nmon = babelscan.FolderMonitor('/some/folder', **options)\nscan = mon.scan(0)  # creates scan from latest file in folder\n\n# intrument configuration file\ni16 = babelscan.instrument_from_config('config_files/i16.config')\nexperiment = i16.experiment('/data/folder')\nscan = experiment.scan(12345)\nprint(scan)  # displays I16 metadata by default\n```\n\n### Installation\n**requirements:** *numpy, h5py, imageio, python-dateutil*, [**optional:** *matplotlib, lmfit*]\n\n**available from: https://github.com/DanPorter/babelscan**\n\nLatest version from github:\n```commandline\npip install git+https://github.com/DanPorter/babelscan.git\n```\nStable version from [PyPI](https://pypi.org/project/babelscan/):\n```commandline\npip install babelscan\n```\n\n\n### Examples\n\n```python\nimport babelscan\n\nscan = babelscan.file_loader('12345.nxs')\n\nprint(scan)  # prints scan information\n\nen = scan('energy')  # finds data field named 'energy', returns data\nval = scan('sum/Transmission')  # Finds 'sum' and 'Transmission' fields, evaluates result\n\nx = scan('axes')  # finds default xaxis in Nexus files\ny = scan('signal')  # finds default yaxis in Nexus files\n\ntitle = scan.title()  # generates a plot title\n\nim = scan.image(0)  # returns first detector image if scan contains 3D data\n\n# Automatically generate x, y, error data and labels for plotting\n# Here we also show off the automatic \"region of interest\" specification,\n# as well as the automatic normalisation and error generation\nx, y, dy, xlab, ylab = scan.get_plot_data('axes', 'nroi_peak[31,31]', '/count_time/Transmission', 'np.sqrt(x+0.1)')\n\n# If matplotlib is installed, plotting behaviour is enabled:\nscan.plot()  # creates a figure and plots the default axes\nscan.plot.plotline('axes', 'signal', 'b-')  # command similar to plt.plot\nscan.plot.image(index)  # creates figure and plots detector image\n\n# If lmfit is installed, fitting behaviour is enabled:\nscan.fit()  # fits a gaussian peak to the default axes\nscan.fit.fit('axes', 'signal')  # Fits a gaussian peak to choosen axes\nscan.fit.multi_peak_fit('axes', 'signal')  # Automatically runs a peak search and fits multiple peaks\n# The resulting parameters are stored in the namespace:\nscan('amplitude, stderr_amplitude')\n```\nSee the included example_*.py files for more examples.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanporter%2Fbabelscan","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanporter%2Fbabelscan","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanporter%2Fbabelscan/lists"}