chuchichaestli.dwt.functional
Separable N-dimensional discrete wavelet transforms.
Subbands carry one character per transformed axis, 'a' for the approximation
and 'd' for the detail branch, so a two-dimensional transform yields aa,
ad, da and dd (the classical LL, LH, HL, HH).
Functions:
| Name | Description |
|---|---|
dwt |
Single-level wavelet transform along one axis. |
dwt_coeff_len |
Number of coefficients one level of the transform produces per subband. |
dwt_max_level |
Number of levels a signal supports before it is shorter than the filter. |
dwtn |
Single-level separable wavelet transform over one or more axes. |
dwtn_approx |
Approximation band of a single-level transform. |
idwt |
Invert a single-level wavelet transform along one axis. |
idwtn |
Invert a single-level separable wavelet transform. |
subband_keys |
Subband names of a |
wavedec |
Multi-level wavelet transform along one axis. |
wavedecn |
Multi-level separable wavelet transform, recursing on the approximation. |
waverec |
Invert a multi-level wavelet transform along one axis. |
waverecn |
Invert a multi-level separable wavelet transform. |
dwt
dwt(
data: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axis: int = -1,
) -> tuple[torch.Tensor, torch.Tensor]
Single-level wavelet transform along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor
|
Input tensor of any rank. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
axis
|
int
|
Axis to transform. |
-1
|
Returns:
| Type | Description |
|---|---|
tuple[torch.Tensor, torch.Tensor]
|
The approximation and the detail coefficients. |
Source code in src/chuchichaestli/dwt/functional.py
628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 | |
dwt_coeff_len
dwt_coeff_len(
data_len: int,
filter_len: int,
mode: ExtensionModeTypes = "zero",
) -> int
Number of coefficients one level of the transform produces per subband.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_len
|
int
|
Length of the signal. |
required |
filter_len
|
int
|
Length of the decomposition filters. |
required |
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/chuchichaestli/dwt/functional.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
dwt_max_level
dwt_max_level(data_len: int, filter_len: int) -> int
Number of levels a signal supports before it is shorter than the filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data_len
|
int
|
Length of the signal. |
required |
filter_len
|
int
|
Length of the decomposition filters. |
required |
Source code in src/chuchichaestli/dwt/functional.py
54 55 56 57 58 59 60 61 62 63 | |
dwtn
dwtn(
data: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axes: Sequence[int] | None = None,
) -> dict[str, torch.Tensor]
Single-level separable wavelet transform over one or more axes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor
|
Input tensor of any rank. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
axes
|
Sequence[int] | None
|
Axes to transform; the trailing one if omitted. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, torch.Tensor]
|
The subbands, keyed by their |
Source code in src/chuchichaestli/dwt/functional.py
358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 | |
dwtn_approx
dwtn_approx(
data: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axes: Sequence[int] | None = None,
) -> torch.Tensor
Approximation band of a single-level transform.
The compiled kernel splits every band at once for less than a convolution costs to pad for, so it is taken where it serves and its detail bands dropped; the convolution only skips them where there is no kernel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor
|
Input tensor of any rank. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
axes
|
Sequence[int] | None
|
Axes to transform; the trailing one if omitted. |
None
|
Source code in src/chuchichaestli/dwt/functional.py
493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
idwt
idwt(
approx: torch.Tensor,
detail: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axis: int = -1,
output_size: int | None = None,
) -> torch.Tensor
Invert a single-level wavelet transform along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
approx
|
torch.Tensor
|
Approximation coefficients. |
required |
detail
|
torch.Tensor
|
Detail coefficients. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode the decomposition used. |
'zero'
|
axis
|
int
|
Axis that was transformed. |
-1
|
output_size
|
int | None
|
Length of the reconstructed axis. |
None
|
Source code in src/chuchichaestli/dwt/functional.py
649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 | |
idwtn
idwtn(
coeffs: dict[str, torch.Tensor],
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axes: Sequence[int] | None = None,
output_size: Sequence[int] | None = None,
) -> torch.Tensor
Invert a single-level separable wavelet transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
dict[str, torch.Tensor]
|
Subbands keyed by their |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode the decomposition used. |
'zero'
|
axes
|
Sequence[int] | None
|
Axes that were transformed; the trailing one if omitted. |
None
|
output_size
|
Sequence[int] | None
|
Length of each transformed axis in the reconstruction; an even length is assumed if omitted. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a subband is missing or the subbands disagree in shape. |
Source code in src/chuchichaestli/dwt/functional.py
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 | |
subband_keys
cached
subband_keys(dimensions: int) -> tuple[str, ...]
Subband names of a dimensions-dimensional transform, in output order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dimensions
|
int
|
Number of transformed axes. |
required |
Source code in src/chuchichaestli/dwt/functional.py
41 42 43 44 45 46 47 48 49 50 51 | |
wavedec
wavedec(
data: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
level: int | None = None,
axis: int = -1,
) -> list[torch.Tensor]
Multi-level wavelet transform along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor
|
Input tensor of any rank. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
level
|
int | None
|
Number of levels; the maximum the axis supports if omitted. |
None
|
axis
|
int
|
Axis to transform. |
-1
|
Returns:
| Type | Description |
|---|---|
list[torch.Tensor]
|
|
Source code in src/chuchichaestli/dwt/functional.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 | |
wavedecn
wavedecn(
data: torch.Tensor,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
level: int | None = None,
axes: Sequence[int] | None = None,
) -> list
Multi-level separable wavelet transform, recursing on the approximation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
torch.Tensor
|
Input tensor of any rank. |
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode. |
'zero'
|
level
|
int | None
|
Number of levels; the maximum the shortest axis supports if omitted. |
None
|
axes
|
Sequence[int] | None
|
Axes to transform; the trailing one if omitted. |
None
|
Returns:
| Type | Description |
|---|---|
list
|
|
list
|
holding every subband but the all-approximation one. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/chuchichaestli/dwt/functional.py
671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 | |
waverec
waverec(
coeffs: Sequence[torch.Tensor],
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axis: int = -1,
output_size: Sequence[int] | None = None,
) -> torch.Tensor
Invert a multi-level wavelet transform along one axis.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
Sequence[torch.Tensor]
|
|
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode the decomposition used. |
'zero'
|
axis
|
int
|
Axis that was transformed. |
-1
|
output_size
|
Sequence[int] | None
|
Length of the axis at each level, coarsest level first. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/chuchichaestli/dwt/functional.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | |
waverecn
waverecn(
coeffs: list,
wavelet: str | Wavelet = "haar",
mode: ExtensionModeTypes = "zero",
axes: Sequence[int] | None = None,
output_size: Sequence[Sequence[int]] | None = None,
) -> torch.Tensor
Invert a multi-level separable wavelet transform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
coeffs
|
list
|
|
required |
wavelet
|
str | Wavelet
|
Wavelet, by name or as a |
'haar'
|
mode
|
ExtensionModeTypes
|
Signal extension mode the decomposition used. |
'zero'
|
axes
|
Sequence[int] | None
|
Axes that were transformed; the trailing one if omitted. |
None
|
output_size
|
Sequence[Sequence[int]] | None
|
Per level, the length of each transformed axis, coarsest level first. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/chuchichaestli/dwt/functional.py
772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 | |