reflectometry / refl1d

1-D reflectometry fitting
https://refl1d.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
18 stars 24 forks source link

Intensity range doesn't default to reasonable values when selected for fitting #179

Open mdoucet opened 3 months ago

mdoucet commented 3 months ago

After creating a model with the builder and loading data into it, one then selects parameters to fit. If any parameter is selected, is usually appears on the summary tab with a reasonable range around its current value. The intensity doesn't do that and the range boxes are left blank. One has to enter the min and max by hand before fitting.

bmaranville commented 3 months ago

Yes, this is a good idea. What about a simple hard coded range from 0.8 to 1.2?

andyfaff commented 3 months ago

That's fine if it's normalized, but xrr data often isn't.

bmaranville commented 3 months ago

If they are not normalized, do they have resolution defined or any other reduction steps typically? This is a good discussion for ORSO, but I feel like making widely available reduction available is preferable to fitting footprint etc

bmaranville commented 3 months ago

Though it wouldn't take much to add footprint and constant background to a model...

mdoucet commented 3 months ago

This is interesting. I'm a little biased because our data come out of the reduction normalized, so it's "supposed" to be 1. So 0.8 to 1.2 is a good default then. But this might not be true for others. Even if the default range was -inf to inf I'd be OK with that. At the moment the default scale is one, but it won't fit until you enter a range manually (which users will forget and complain about). I'd be OK with -inf to inf if that works for everyone. As long as there's a default.

bmaranville commented 3 months ago

Null should be converted to -inf and inf and it should let you fit. If that's not happening it's a different bug...

bmaranville commented 3 months ago

The prior is indeed being set to -inf to inf when the bounds are empty (like they are after you add intensity as a fitted parameter), and the fit nearly completes...

The error is triggered when the fit message is generated and it tries to format the fit range for that parameter, and it's looking for parameter.bounds. I've fixed it so it looks for parameter.prior.bounds (which includes the limits and user bounds), then falls back to parameter.bounds, then falls back to the limits (which are defined for every parameter)

bumps/bumps