Skip to content

Commit

Permalink
fix notebook 03, fit lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Camilla Pacifici committed Oct 29, 2024
1 parent e1a7136 commit c842502
Showing 1 changed file with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@
"from astropy.modeling import models\n",
"from astropy.modeling.polynomial import Chebyshev1D\n",
"\n",
"from specutils.spectra import Spectrum1D\n",
"from specutils.spectra import Spectrum1D, SpectralRegion\n",
"from specutils.fitting import fit_lines\n",
"from specutils.fitting import continuum\n",
"from specutils.manipulation import extract_region\n",
"\n",
"from astropy import __version__ as astropy_version\n",
"print('astropy', astropy_version)"
Expand Down Expand Up @@ -428,18 +429,18 @@
"spectrum_cut = Spectrum1D(flux=line_2d[yy, :][con]*spec_unit,\n",
" spectral_axis=wave_2d[yy, :][con]*u.um)\n",
"\n",
"# !!! Some tweaks may be needed for initial value, to successfuully run the fit;\n",
"# !!! Some tweaks may be needed for initial value, to successfully run the fit;\n",
"\n",
"# For Hb\n",
"g1_init = models.Gaussian1D(amplitude=40*spec_unit, mean=1.5*u.um, stddev=0.005*u.um)\n",
"g1_init = models.Gaussian1D(amplitude=100*spec_unit, mean=1.51*u.um, stddev=0.009*u.um)\n",
"\n",
"# For O3 blue\n",
"g2_init = models.Gaussian1D(amplitude=50.*spec_unit, mean=1.535*u.um, stddev=0.002*u.um)\n",
"g2_init = models.Gaussian1D(amplitude=80.*spec_unit, mean=1.53*u.um, stddev=0.006*u.um)\n",
"\n",
"# For O3 red\n",
"g3_init = models.Gaussian1D(amplitude=45.*spec_unit, mean=1.55*u.um, stddev=0.001*u.um)\n",
"g3_init = models.Gaussian1D(amplitude=200.*spec_unit, mean=1.55*u.um, stddev=0.006*u.um)\n",
"\n",
"g123_fit = fit_lines(spectrum_cut, g1_init+g2_init+g3_init, window=[0.01*u.um, 0.001*u.um, 0.001*u.um])\n",
"g123_fit = fit_lines(spectrum_cut, g1_init+g2_init+g3_init)\n",
"y_fit = g123_fit(wave_2d[yy, :]*u.um)\n",
"\n",
"print(g123_fit)"
Expand Down Expand Up @@ -515,12 +516,12 @@
" # !!! Some tweaks may be needed for initial value, to successfuully run the fit;\n",
"\n",
" # For Hb\n",
" g1_init = models.Gaussian1D(amplitude=40*spec_unit, mean=1.5*u.um, stddev=0.005*u.um)\n",
" g1_init = models.Gaussian1D(amplitude=100*spec_unit, mean=1.51*u.um, stddev=0.009*u.um)\n",
" # For O3 blue\n",
" g2_init = models.Gaussian1D(amplitude=50.*spec_unit, mean=1.535*u.um, stddev=0.002*u.um)\n",
" g2_init = models.Gaussian1D(amplitude=80.*spec_unit, mean=1.53*u.um, stddev=0.006*u.um)\n",
" # For O3 red\n",
" g3_init = models.Gaussian1D(amplitude=45.*spec_unit, mean=1.55*u.um, stddev=0.001*u.um)\n",
" g123_fit = fit_lines(spectrum_cut, g1_init+g2_init+g3_init, window=[0.01*u.um, 0.001*u.um, 0.001*u.um])\n",
" g3_init = models.Gaussian1D(amplitude=200.*spec_unit, mean=1.55*u.um, stddev=0.006*u.um)\n",
" g123_fit = fit_lines(spectrum_cut, g1_init+g2_init+g3_init)\n",
" y_fit = g123_fit(wave_2d[yy, :]*u.um)\n",
"\n",
" # This has to be done at each y pixel, as wavelength array can be tilted.\n",
Expand Down Expand Up @@ -593,7 +594,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
"version": "3.11.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit c842502

Please sign in to comment.