Skip to content

Commit

Permalink
Merge pull request #74 from kmnhan/manager-jupyter
Browse files Browse the repository at this point in the history
Add lazy-loader support and improve imagetool functionality
  • Loading branch information
kmnhan authored Dec 14, 2024
2 parents 5a68584 + 8048b36 commit e7c8ea8
Show file tree
Hide file tree
Showing 73 changed files with 1,269 additions and 655 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
schedule:
# Every friday at 22:00 UTC (Every saturday at 07:00 KST/JST)
- cron: "0 22 * * FRI"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
FORCE_COLOR: 1

Expand All @@ -22,7 +25,6 @@ jobs:
matrix:
python-version: ["3.11", "3.12"]
qt-api: ["pyqt6", "pyside6"]

steps:
- uses: actions/checkout@v4
with:
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ on:
workflow_dispatch:
env:
FORCE_COLOR: 1
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
release:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ repos:
hooks:
# Run the linter.
- id: ruff
args: [ --fix ]
args: [ --fix, --show-fixes ]
# Run the formatter.
- id: ruff-format

Expand Down
34 changes: 11 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
<h1 align="center">
ERLabPy
</h1>
<p align="center">
<a href="https://pypi.org/project/erlab/" alt="Supported Python Versions">
<img src="https://img.shields.io/pypi/pyversions/erlab?logo=python&logoColor=white" /></a>
<a href="https://pypi.org/project/erlab/" alt="PyPi">
<img src="https://img.shields.io/pypi/v/erlab?logo=pypi&logoColor=white" /></a>
<a href="https://anaconda.org/conda-forge/erlab" alt="Conda Version">
<img src="https://img.shields.io/conda/vn/conda-forge/erlab?logo=condaforge&logoColor=white" /></a>
</p><p align="center">
<a href="https://github.com/kmnhan/erlabpy/actions/workflows/ci.yml" alt="Workflow Status">
<img src="https://img.shields.io/github/actions/workflow/status/kmnhan/erlabpy/ci.yml?logo=github&label=tests" /></a>
<a href="https://erlabpy.readthedocs.io/" alt="Documentation Status">
<img src="https://img.shields.io/readthedocs/erlabpy?logo=readthedocs&logoColor=white" /></a>
<a href="https://results.pre-commit.ci/latest/github/kmnhan/erlabpy/main" alt="pre-commit.ci status">
<img src="https://results.pre-commit.ci/badge/github/kmnhan/erlabpy/main.svg" /></a>
<a href="https://codecov.io/gh/kmnhan/erlabpy" alt="Codecov Coverage">
<img src="https://img.shields.io/codecov/c/github/kmnhan/erlabpy?logo=codecov&logoColor=white" /></a>
<a href="https://github.com/astral-sh/ruff" alt="Ruff">
<img src="https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json" /></a>
</p>
# ERLabPy

[![Supported Python Versions](https://img.shields.io/pypi/pyversions/erlab?logo=python&logoColor=white)](https://pypi.org/project/erlab/)
[![PyPi](https://img.shields.io/pypi/v/erlab?logo=pypi&logoColor=white)](https://pypi.org/project/erlab/)
[![Conda Version](https://img.shields.io/conda/vn/conda-forge/erlab?logo=condaforge&logoColor=white)](https://anaconda.org/conda-forge/erlab)
[![Workflow Status](https://img.shields.io/github/actions/workflow/status/kmnhan/erlabpy/ci.yml?logo=github&label=tests)](https://github.com/kmnhan/erlabpy/actions/workflows/ci.yml)
[![Documentation Status](https://img.shields.io/readthedocs/erlabpy?logo=readthedocs&logoColor=white)](https://erlabpy.readthedocs.io/)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kmnhan/erlabpy/main.svg)](https://results.pre-commit.ci/latest/github/kmnhan/erlabpy/main)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/kmnhan/erlabpy?logo=codecov&logoColor=white)](https://codecov.io/gh/kmnhan/erlabpy)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)
[![SPEC 1 — Lazy Loading of Submodules and Functions](https://img.shields.io/badge/SPEC-1-green?labelColor=%23004811&color=%235CA038)](https://scientific-python.org/specs/spec-0001/)

A library that provides a set of tools and utilities to handle, manipulate, and
visualize data from condensed matter physics experiments, with a focus on angle-resolved
Expand Down Expand Up @@ -71,7 +60,6 @@ with dark mode enabled will show the dark mode screenshots.
<img alt="Imagetool in action." src="https://github.com/kmnhan/erlabpy/blob/main/docs/source/images/ktool_1_light.png?raw=true">
</picture>


## Getting Started

To get started, see [installation instructions](https://erlabpy.readthedocs.io/en/stable/getting-started.html).
Expand Down
12 changes: 0 additions & 12 deletions docs/source/erlab.plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,3 @@
================================

.. automodule:: erlab.plotting







.. rubric:: Functions

.. autosummary::

load_igor_ct
8 changes: 4 additions & 4 deletions docs/source/getting-started.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,17 @@ Once installed, you can import ERLabPy in your Python scripts or interactive ses

The following import conventions are recommended for ERLabPy modules: ::

import erlab
import erlab.analysis as era
import erlab.interactive as eri
import erlab.io
import erlab.plotting.erplot as eplt
import erlab.plotting as eplt

Along with frequently used modules, your import statements may look like this: ::

import erlab
import erlab.analysis as era
import erlab.interactive as eri
import erlab.io
import erlab.plotting.erplot as eplt
import erlab.plotting as eplt
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
Expand Down
2 changes: 1 addition & 1 deletion docs/source/pyplots/norms.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import numpy as np
from pyqtgraph.colormap import modulatedBarData

import erlab.plotting.erplot as eplt
import erlab.plotting as eplt

plt.style.use("khan")

Expand Down
89 changes: 43 additions & 46 deletions docs/source/user-guide/curve-fitting.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
"metadata": {},
"outputs": [],
"source": [
"import erlab.plotting.erplot as eplt\n",
"import erlab.analysis as era\n",
"import erlab.plotting as eplt\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"import xarray as xr\n",
"from erlab.io.exampledata import generate_data"
"import xarray as xr"
]
},
{
Expand Down Expand Up @@ -351,9 +351,9 @@
"metadata": {},
"outputs": [],
"source": [
"from erlab.analysis.fit.models import MultiPeakModel\n",
"\n",
"model = MultiPeakModel(npeaks=1, peak_shapes=[\"gaussian\"], fd=False, convolve=False)\n",
"model = era.fit.models.MultiPeakModel(\n",
" npeaks=1, peak_shapes=[\"gaussian\"], fd=False, background=\"linear\", convolve=False\n",
")\n",
"params = model.make_params(p0_center=5.0, p0_width=0.2, p0_height=3.0)\n",
"params"
]
Expand Down Expand Up @@ -402,7 +402,9 @@
"metadata": {},
"outputs": [],
"source": [
"data = generate_data(bandshift=-0.2, count=5e8, seed=1).T\n",
"from erlab.io.exampledata import generate_data\n",
"\n",
"data = generate_data(seed=1).T\n",
"cut = data.qsel(ky=0.3)\n",
"cut.qplot(colorbar=True)"
]
Expand Down Expand Up @@ -430,19 +432,15 @@
"metadata": {},
"outputs": [],
"source": [
"from erlab.analysis.fit.models import MultiPeakModel\n",
"\n",
"model = MultiPeakModel(npeaks=4, peak_shapes=[\"lorentzian\"], fd=False, convolve=True)\n",
"model = era.fit.models.MultiPeakModel(\n",
" npeaks=2, peak_shapes=[\"lorentzian\"], fd=False, background=\"linear\", convolve=True\n",
")\n",
"\n",
"params = model.make_params(\n",
" p0_center=-0.6,\n",
" p1_center=-0.45,\n",
" p2_center=0.45,\n",
" p3_center=0.6,\n",
" p0_width=0.02,\n",
" p1_width=0.02,\n",
" p2_width=0.02,\n",
" p3_width=0.02,\n",
" p0_center=-0.5,\n",
" p1_center=0.5,\n",
" p0_width=0.03,\n",
" p1_width=0.03,\n",
" lin_bkg={\"value\": 0.0, \"vary\": False},\n",
" const_bkg=0.0,\n",
" resolution=0.03,\n",
Expand Down Expand Up @@ -557,10 +555,9 @@
"metadata": {},
"outputs": [],
"source": [
"from erlab.analysis.fit.models import FermiEdgeModel\n",
"from erlab.io.exampledata import generate_gold_edge\n",
"\n",
"gold = generate_gold_edge(temp=100, Eres=0.02, count=5e5, seed=1)\n",
"gold = generate_gold_edge(temp=100, Eres=0.02, seed=1)\n",
"gold.qplot(cmap=\"Greys\")"
]
},
Expand All @@ -580,7 +577,10 @@
"source": [
"gold_selected = gold.sel(eV=slice(-0.2, 0.2))\n",
"result_ds = gold_selected.modelfit(\n",
" \"eV\", FermiEdgeModel(), params={\"temp\": {\"value\": 100.0, \"vary\": False}}, guess=True\n",
" \"eV\",\n",
" era.fit.models.FermiEdgeModel(),\n",
" params={\"temp\": {\"value\": 100.0, \"vary\": False}},\n",
" guess=True,\n",
")\n",
"result_ds"
]
Expand Down Expand Up @@ -649,12 +649,10 @@
"metadata": {},
"outputs": [],
"source": [
"from erlab.analysis.fit.models import FermiEdge2dModel\n",
"\n",
"gold_norm = gold_selected / gold_selected.mean(\"eV\")\n",
"result_ds = gold_norm.T.modelfit(\n",
" coords=[\"eV\", \"alpha\"],\n",
" model=FermiEdge2dModel(),\n",
" model=era.fit.models.FermiEdge2dModel(),\n",
" params={\"temp\": {\"value\": 100.0, \"vary\": False}},\n",
" guess=True,\n",
")\n",
Expand Down Expand Up @@ -1001,6 +999,7 @@
"outputs": [],
"source": [
"from erlab.io.exampledata import generate_gold_edge\n",
"import erlab.plotting as eplt\n",
"\n",
"plt.rcParams[\"figure.constrained_layout.use\"] = True"
]
Expand All @@ -1011,10 +1010,8 @@
"metadata": {},
"outputs": [],
"source": [
"import erlab.analysis as era\n",
"import erlab.plotting.erplot as eplt\n",
"\n",
"gold = generate_gold_edge(temp=100, seed=1)\n",
"\n",
"result = era.gold.poly(\n",
" gold,\n",
" angle_range=(-15, 15),\n",
Expand Down Expand Up @@ -1093,27 +1090,20 @@
"metadata": {},
"outputs": [],
"source": [
"from erlab.analysis.fit.minuit import Minuit\n",
"from erlab.analysis.fit.models import MultiPeakModel\n",
"\n",
"model = MultiPeakModel(npeaks=4, peak_shapes=[\"lorentzian\"], fd=False, convolve=True)\n",
"model = era.fit.models.MultiPeakModel(\n",
" npeaks=2, peak_shapes=[\"lorentzian\"], fd=False, convolve=True\n",
")\n",
"\n",
"m = Minuit.from_lmfit(\n",
"m = era.fit.minuit.Minuit.from_lmfit(\n",
" model,\n",
" mdc,\n",
" mdc.kx,\n",
" p0_center=-0.6,\n",
" p1_center=-0.45,\n",
" p2_center=0.45,\n",
" p3_center=0.6,\n",
" p0_width=0.02,\n",
" p1_width=0.02,\n",
" p2_width=0.02,\n",
" p3_width=0.02,\n",
" p0_height=1500,\n",
" p1_height=50,\n",
" p2_height=50,\n",
" p3_height=1500,\n",
" p0_center=-0.5,\n",
" p1_center=0.5,\n",
" p0_width=0.03,\n",
" p1_width=0.03,\n",
" p0_height=1000,\n",
" p1_height=1000,\n",
" lin_bkg={\"value\": 0.0, \"vary\": False},\n",
" const_bkg=0.0,\n",
" resolution=0.03,\n",
Expand Down Expand Up @@ -1162,11 +1152,18 @@
"source": [
"m.interactive()"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "erlab",
"language": "python",
"name": "python3"
},
Expand All @@ -1180,7 +1177,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
9 changes: 5 additions & 4 deletions docs/source/user-guide/indexing.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"id": "fd4ee1a3",
"metadata": {},
"source": [
"First, let us generate some example data: a simple tight binding simulation of graphene."
"First, let us generate some example data: a simple tight binding simulation of\n",
"graphene-like bands with an exaggerated lattice constant."
]
},
{
Expand Down Expand Up @@ -426,7 +427,7 @@
"metadata": {},
"outputs": [],
"source": [
"import erlab.plotting.erplot as eplt\n",
"import erlab.plotting as eplt\n",
"import matplotlib.pyplot as plt\n",
"import numpy as np\n",
"\n",
Expand Down Expand Up @@ -529,7 +530,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "erlab",
"language": "python",
"name": "python3"
},
Expand All @@ -543,7 +544,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.12.6"
"version": "3.12.7"
}
},
"nbformat": 4,
Expand Down
6 changes: 3 additions & 3 deletions docs/source/user-guide/io.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@
},
"outputs": [],
"source": [
"import erlab.io\n",
"import erlab\n",
"\n",
"erlab.io.loaders"
]
Expand Down Expand Up @@ -925,7 +925,7 @@
"\n",
"import numpy as np\n",
"\n",
"import erlab.io\n",
"import erlab\n",
"from erlab.io.exampledata import generate_data_angles\n",
"\n",
"\n",
Expand Down Expand Up @@ -1494,7 +1494,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"display_name": "erlab",
"language": "python",
"name": "python3"
},
Expand Down
Loading

0 comments on commit e7c8ea8

Please sign in to comment.