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

E. Madison Bray erik.m.bray at gmail.com
Fri Oct 8 11:39:05 EDT 2021


Hi Azalee,

I'm not sure if this would actually work, but instead of using a "min"
bound you could effectively use tied to implement a (dynamic) bound,
something like:

```
def fixed_amp_ratio(oi_emission):
    return min(oi_emission.amplitude_2, 0.3 * oe_emission.amplitude_1)

emission_model.amplitude_2.tied = fixed_amp_ratio
```

Or, as you wrote:

> 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

You could do something like:

```
def fixed_amp_ratio(oi_emission):
    return max(min(oi_emission.amplitude_2, 0.3 *
oi_emission.amplitude_1), oi_emssion.amplitude_1)
```

That should keep 0.3*A_1 < A_2, < A_1.

John's answer might make more sense, but I thought this seemed like a
simple possibility, since in some ways the way upper/lower bounds are
evaluated are just a special case of "tied".

On Mon, Oct 4, 2021 at 9: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