Skip to content

Commit

Permalink
[pre-commit.ci] pre-commit autoupdate (#112)
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] authored Sep 2, 2024
1 parent 16b9ae0 commit a88c737
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.5.6
rev: v0.6.3
hooks:
- id: ruff
args: [ --fix ]
Expand Down
54 changes: 38 additions & 16 deletions dev/notebooks/lanczos_interp_devel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,24 @@
"source": [
"fig, axs = pplt.subplots(figsize=(7, 7))\n",
"\n",
"\n",
"def _s(x, c, m):\n",
" return 1.0 / (1.0 + np.exp(-(x-m)/c))\n",
" return 1.0 / (1.0 + np.exp(-(x - m) / c))\n",
"\n",
"\n",
"def _approx(order, tol):\n",
" plaw = np.exp(4.8 + 9.2e-4 * np.log(tol/1e-8)**2 - 0.33 * np.log(tol/1e-8) - 0.66 * np.log(order))\n",
" sval = _s(np.log(order), np.log(15), 0.1) * (1.0 - _s(np.log(tol), np.log(1e-2), 0.1))\n",
" plaw = np.exp(\n",
" 4.8\n",
" + 9.2e-4 * np.log(tol / 1e-8) ** 2\n",
" - 0.33 * np.log(tol / 1e-8)\n",
" - 0.66 * np.log(order)\n",
" )\n",
" sval = _s(np.log(order), np.log(15), 0.1) * (\n",
" 1.0 - _s(np.log(tol), np.log(1e-2), 0.1)\n",
" )\n",
" return np.maximum(sval * 1.5 + (1.0 - sval) * plaw, 0.55)\n",
"\n",
"\n",
"m = []\n",
"orders = np.arange(1, 31, dtype=int)\n",
"tols = np.logspace(-8, 0, 10)\n",
Expand All @@ -37,19 +47,20 @@
"for j, tol in enumerate(tols):\n",
" yv = []\n",
" for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" yv.append(lz._i.urange())\n",
" vals[j, :] = np.array(yv)\n",
" m.append(axs.loglog(orders, yv, label=\"log10(tol) = %d\" % np.log10(tol)))\n",
" axs.loglog(\n",
" orders, \n",
" _approx(orders, tol), \n",
" \":\", \n",
" orders,\n",
" _approx(orders, tol),\n",
" \":\",\n",
" color=\"k\",\n",
" )\n",
"axs.legend(m, loc=\"ur\", ncols=4, frameon=False)\n",
"axs.format(xlabel=\"Lanczos order\", ylabel=\"urange [$2\\pi$/pixels]\")\n",
" "
"axs.format(xlabel=\"Lanczos order\", ylabel=\"urange [$2\\pi$/pixels]\")"
]
},
{
Expand All @@ -63,25 +74,33 @@
"source": [
"print(\"_posflux_conserve_dc = {\")\n",
"for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: %r,\" % (i, lz.positive_flux))\n",
"print(\"}\")\n",
"\n",
"print(\"_posflux_no_conserve_dc = {\")\n",
"for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: %r,\" % (i, lz.positive_flux))\n",
"print(\"}\")\n",
"\n",
"print(\"_negflux_conserve_dc = {\")\n",
"for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: %r,\" % (i, lz.negative_flux))\n",
"print(\"}\")\n",
"\n",
"print(\"_negflux_no_conserve_dc = {\")\n",
"for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: %r,\" % (i, lz.negative_flux))\n",
"print(\"}\")"
]
Expand All @@ -96,16 +115,19 @@
"outputs": [],
"source": [
"with np.printoptions(floatmode=\"unique\"):\n",
"\n",
" print(\"_unit_integrals_no_conserve_dc = {\")\n",
" for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=False, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: jnp.%s, dtype=float),\" % (i, repr(lz.unit_integrals())[:-1]))\n",
" print(\"}\")\n",
"\n",
" print(\"_unit_integrals_conserve_dc = {\")\n",
" for i in orders:\n",
" lz = galsim.interpolant.Lanczos(i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol))\n",
" lz = galsim.interpolant.Lanczos(\n",
" i, conserve_dc=True, gsparams=galsim.GSParams(kvalue_accuracy=tol)\n",
" )\n",
" print(\" %d: jnp.%s, dtype=float),\" % (i, repr(lz.unit_integrals())[:-1]))\n",
" print(\"}\")"
]
Expand Down

0 comments on commit a88c737

Please sign in to comment.