Skip to content

Instantly share code, notes, and snippets.

View andyfaff's full-sized avatar

Andrew Nelson andyfaff

  • Sydney, Australia
View GitHub Profile
@andyfaff
andyfaff / JAX-reflect
Last active April 17, 2024 06:28
Patch for basic JAX usage with Objective/ReflectModel/Structure
diff --git a/refnx/analysis/objective.py b/refnx/analysis/objective.py
index 9ff56057..c77139ad 100644
--- a/refnx/analysis/objective.py
+++ b/refnx/analysis/objective.py
@@ -674,8 +674,8 @@ class Objective(BaseObjective):
logl += (y - model) ** 2 / var_y
# nans play havoc
- if np.isnan(logl).any():
- raise RuntimeError("Objective.logl encountered a NaN.")
@andyfaff
andyfaff / Python_openmp_notes.md
Last active April 11, 2024 15:09
Investigating openmp on macOS.

Investigating use of openmp on macOS for Python related things

This assumes you have installed the command line tools on macOS. The first two sections look into installing OpenMP from scratch. However, on macOS it might be easier just to use homebrew.

Install cmake

  1. Download source from https://github.com/Kitware/CMake/releases/download/v3.15.1/cmake-3.15.1.tar.gz (there may be a later release).
  2. Untar the files: tar xzvf cmake-3.15.1.tar.gz
Function/S wottpy(r0, d0)
variable r0, d0
// Paths must be POSIX paths (using /).
// Paths containing spaces or other nonstandard characters
// must be single-quoted. See Apple Techical Note TN2065 for
// more on shell scripting via AppleScript.
string r0s, d0s
r0s = num2str(r0)
d0s = num2str(d0)
@andyfaff
andyfaff / run_locator.ipynb
Created March 1, 2024 01:00
Run locator for PLP
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / Volume_fraction_calculator.ipynb
Created May 12, 2023 02:22
Volume fraction profile generator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / AutoReducer.ipynb
Last active May 11, 2023 01:04
AutoReducer
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / Simpson_rule_even_points.ipynb
Created March 28, 2023 03:57
Simpson's rule even number of points
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / find_adequate_resolution.ipynb
Created March 17, 2023 01:04
Find an adequate resolution smearing oversample
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andyfaff
andyfaff / numba_reflectivity.ipynb
Created March 9, 2023 22:17
Numba reflectivity kernel investigation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.