[AstroPy] Tying model bounds to other parameters in compound models

Moustakas, John jmoustakas at siena.edu
Tue Oct 5 15:02:07 EDT 2021


Hi Azalee--

Perhaps other power users can give you a solution, but my take of the
code base is that what you're trying to do is not possible.

I believe you're going to have to add a new Parameter which is the
amplitude ratio of the two lines, and put bounds on that parameter.
The amplitude of the weaker component of the doublet will then be the
ratio times the amplitude of the stronger component (effectively
leaving you with the same number of free parameters).

In case it's helpful you're welcome to use some or all of the
line-fitting code I put together as part of this ticket (see the zip
file in the body of the issue)--
  https://github.com/astropy/astropy/issues/12089#issue-974636724

Good luck!

Cheers,
-John

--
John Moustakas, PhD
Associate Professor & Department Chair
Department of Physics & Astronomy
Siena College
515 Loudon Road
Loudonville, NY 12211
518-783-4274
jmoustakas at siena.edu
Pronouns: he|him|his


On Mon, Oct 4, 2021 at 3:14 PM Azalee Bostroem <abostroem at gmail.com> wrote:
>
> Hi,
>
> I am trying to fit the [OI] doublet at 6300, 6364 A as a compound model (Const1D+Gaussian1D+Gaussian1D). This doublet has a known ratio range of 1:1 to 1:3 and I would like fix the bounds of the amplitude of the second gaussian to be between 1/3 and 1 times the amplitude of the first gaussian. I know its possible to tie model parameters to each other (e.g.
>
> def fix_offset(oi_emission):
>     mean_2 = oi_emission.mean_1 + 64
>     return mean_2
>
> emission_model.mean_2.tied = fix_offset
>
> ) and to set bounds on parameters (e.g.
>
> emission_model.amplitude_1.min = 0
>
> ). Is it possible to tie bounds to other parameters? My naive approach of
>
> def fixed_amp_ratio(oi_emission):
>     amplitude_2.min = 0.3*oi_emission.amplitude_1
>     return amplitude2.min
>
> emission_model.amplitude_2.min.tied = fixed_amp_ratio
>
>  Didn’t work because min has no attribute tied.
>
> Please let me know if I’ve missed anything,
>
> Thanks,
> Azalee
> _______________________________________________
> AstroPy mailing list
> AstroPy at python.org
> https://mail.python.org/mailman/listinfo/astropy


More information about the AstroPy mailing list