Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ci:

repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.11.13"
rev: "v0.16.4"
hooks:
- id: ruff
types_or: [python, pyi, jupyter]
Expand All @@ -17,7 +17,7 @@ repos:
types_or: [python, pyi, jupyter]

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
exclude: '.*\.fits$'
Expand All @@ -31,7 +31,7 @@ repos:
args: ["--maxkb=10000"]

- repo: https://github.com/kynan/nbstripout
rev: 0.8.1
rev: 0.9.1
hooks:
- id: nbstripout
args: ["--extra-keys=metadata.kernelspec metadata.language_info.version metadata.toc"]
32 changes: 13 additions & 19 deletions 1_models-quick-fit.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from astropy.modeling import models, fitting\n",
"from astroquery.vizier import Vizier\n",
"import numpy as np\n",
"import scipy.optimize\n",
"from astropy.modeling import fitting, models\n",
"from astroquery.vizier import Vizier\n",
"\n",
"# Make plots display in notebooks\n",
"%matplotlib inline"
Expand Down Expand Up @@ -439,7 +439,7 @@
"outputs": [],
"source": [
"reduced_chi_squared = calc_reduced_chi_square(best_fit_poly(x1), x1, y1, y1_err, N, 4)\n",
"print(\"Reduced Chi Squared with LinearLSQFitter: {}\".format(reduced_chi_squared))"
"print(f\"Reduced Chi Squared with LinearLSQFitter: {reduced_chi_squared}\")"
]
},
{
Expand All @@ -449,7 +449,7 @@
"outputs": [],
"source": [
"reduced_chi_squared = calc_reduced_chi_square(best_fit_poly_2(x1), x1, y1, y1_err, N, 4)\n",
"print(\"Reduced Chi Squared with SimplexLSQFitter: {}\".format(reduced_chi_squared))"
"print(f\"Reduced Chi Squared with SimplexLSQFitter: {reduced_chi_squared}\")"
]
},
{
Expand Down Expand Up @@ -592,15 +592,9 @@
"metadata": {},
"outputs": [],
"source": [
"print(\n",
" \"Amplitude: {} +\\- {}\".format(best_fit_gauss.amplitude.value, np.sqrt(cov_diag[0]))\n",
")\n",
"print(\"Mean: {} +\\- {}\".format(best_fit_gauss.mean.value, np.sqrt(cov_diag[1])))\n",
"print(\n",
" \"Standard Deviation: {} +\\- {}\".format(\n",
" best_fit_gauss.stddev.value, np.sqrt(cov_diag[2])\n",
" )\n",
")"
"print(rf\"Amplitude: {best_fit_gauss.amplitude.value} +\\- {np.sqrt(cov_diag[0])}\")\n",
"print(rf\"Mean: {best_fit_gauss.mean.value} +\\- {np.sqrt(cov_diag[1])}\")\n",
"print(rf\"Standard Deviation: {best_fit_gauss.stddev.value} +\\- {np.sqrt(cov_diag[2])}\")"
]
},
{
Expand Down Expand Up @@ -646,9 +640,9 @@
"metadata": {},
"outputs": [],
"source": [
"print(\"Amplitude: {} +\\- {}\".format(p_opt[0], np.sqrt(p_cov[0, 0])))\n",
"print(\"Mean: {} +\\- {}\".format(p_opt[1], np.sqrt(p_cov[1, 1])))\n",
"print(\"Standard Deviation: {} +\\- {}\".format(p_opt[2], np.sqrt(p_cov[2, 2])))"
"print(rf\"Amplitude: {p_opt[0]} +\\- {np.sqrt(p_cov[0, 0])}\")\n",
"print(rf\"Mean: {p_opt[1]} +\\- {np.sqrt(p_cov[1, 1])}\")\n",
"print(rf\"Standard Deviation: {p_opt[2]} +\\- {np.sqrt(p_cov[2, 2])}\")"
]
},
{
Expand All @@ -665,7 +659,7 @@
"outputs": [],
"source": [
"reduced_chi_squared = calc_reduced_chi_square(best_fit_gauss(x2), x2, y2, y2_err, N2, 3)\n",
"print(\"Reduced Chi Squared using astropy.modeling: {}\".format(reduced_chi_squared))"
"print(f\"Reduced Chi Squared using astropy.modeling: {reduced_chi_squared}\")"
]
},
{
Expand All @@ -675,7 +669,7 @@
"outputs": [],
"source": [
"reduced_chi_squared = calc_reduced_chi_square(best_fit_gauss_2, x2, y2, y2_err, N2, 3)\n",
"print(\"Reduced Chi Squared using scipy: {}\".format(reduced_chi_squared))"
"print(f\"Reduced Chi Squared using scipy: {reduced_chi_squared}\")"
]
},
{
Expand Down
17 changes: 8 additions & 9 deletions 2_user-defined-model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,10 @@
"metadata": {},
"outputs": [],
"source": [
"import numpy as np\n",
"import matplotlib.pyplot as plt\n",
"from astropy.modeling import models, fitting\n",
"import numpy as np\n",
"from astropy.modeling import Fittable1DModel, Parameter, fitting, models\n",
"from astropy.modeling.models import custom_model\n",
"from astropy.modeling import Fittable1DModel, Parameter\n",
"from astroquery.sdss import SDSS"
]
},
Expand Down Expand Up @@ -207,8 +206,8 @@
"plt.plot(lam, flux, color=\"k\")\n",
"plt.xlim(6300, 6700)\n",
"plt.axvline(x=6563, linestyle=\"--\")\n",
"plt.xlabel(\"Wavelength ({})\".format(units_wavelength))\n",
"plt.ylabel(\"Flux ({})\".format(units_flux))\n",
"plt.xlabel(f\"Wavelength ({units_wavelength})\")\n",
"plt.ylabel(f\"Flux ({units_flux})\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -265,7 +264,7 @@
"plt.plot(lam, gaussian_fit(lam), color=\"darkorange\")\n",
"plt.xlim(6300, 6700)\n",
"plt.xlabel(\"Wavelength (Angstroms)\")\n",
"plt.ylabel(\"Flux ({})\".format(units_flux))\n",
"plt.ylabel(f\"Flux ({units_flux})\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -353,7 +352,7 @@
"plt.plot(lam, compound_fit(lam), color=\"darkorange\")\n",
"plt.xlim(6300, 6700)\n",
"plt.xlabel(\"Wavelength (Angstroms)\")\n",
"plt.ylabel(\"Flux ({})\".format(units_flux))\n",
"plt.ylabel(f\"Flux ({units_flux})\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -459,7 +458,7 @@
"plt.plot(lam, compound_fit_fixed(lam), color=\"darkorange\")\n",
"plt.xlim(6300, 6700)\n",
"plt.xlabel(\"Wavelength (Angstroms)\")\n",
"plt.ylabel(\"Flux ({})\".format(units_flux))\n",
"plt.ylabel(f\"Flux ({units_flux})\")\n",
"plt.show()"
]
},
Expand Down Expand Up @@ -505,7 +504,7 @@
"plt.plot(lam, compound_fit_bounded(lam), color=\"darkorange\")\n",
"plt.xlim(6300, 6700)\n",
"plt.xlabel(\"Wavelength (Angstroms)\")\n",
"plt.ylabel(\"Flux ({})\".format(units_flux))\n",
"plt.ylabel(f\"Flux ({units_flux})\")\n",
"plt.show()"
]
},
Expand Down