Skip to content

Commit

Permalink
Added License, in progress support for spatially-varying fits
Browse files Browse the repository at this point in the history
  • Loading branch information
Jashcraf committed Sep 8, 2024
1 parent 5247930 commit 6eccd15
Show file tree
Hide file tree
Showing 3 changed files with 502 additions and 3 deletions.
9 changes: 9 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
The MIT License (MIT)

Copyright (c) 2024 Jaren N. Ashcraft

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
469 changes: 469 additions & 0 deletions docs/notebooks/SpatiallyVaryingData.ipynb

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions katsu/mueller.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,14 @@ def linear_retarder(a, r, shape=None):
else:
a = np.broadcast_to(a, [*M.shape[:-2]])

r = np.broadcast_to(r, [*M.shape[:-2]])
if isinstance(r, np.ndarray):
r = r
else:
r = np.broadcast_to(r, [*M.shape[:-2]])

if M.ndim > 4:
a = a[..., np.newaxis]
r = r[..., np.newaxis]

if np.__name__ == "jax.numpy":
# First row
Expand Down Expand Up @@ -321,15 +328,29 @@ def linear_diattenuator(a, Tmin, Tmax=1, shape=None):

# make sure everything is the right size
if M.ndim > 2:
a = np.broadcast_to(a, [*M.shape[:-2]])
Tmin = np.broadcast_to(Tmin, [*M.shape[:-2]])
if isinstance(a, np.ndarray):
a = a # leave it alone
else:
a = np.broadcast_to(a, [*M.shape[:-2]])

if isinstance(Tmin, np.ndarray):
Tmin = Tmin
else:
Tmin = np.broadcast_to(Tmin, [*M.shape[:-2]])

A = Tmax + Tmin
B = Tmax - Tmin
C = 2 * np.sqrt(Tmax * Tmin)
cos2a = np.cos(2 * a)
sin2a = np.sin(2 * a)

if M.ndim > 4:
A = A[..., np.newaxis]
B = B[..., np.newaxis]
C = C[..., np.newaxis]
cos2a = cos2a[..., np.newaxis]
sin2a = sin2a[..., np.newaxis]

if np.__name__ == "jax.numpy":
# first row
M = M.at[..., 0, 0].set(A)
Expand Down

0 comments on commit 6eccd15

Please sign in to comment.