rTPC icon indicating copy to clipboard operation
rTPC copied to clipboard

get_tpc_as_formula fails when there needs to be a fixed parameter passed

Open padpadpadpad opened this issue 4 months ago • 2 comments

get_tpc_as_formula() fails when the user needs to set a tref (reference temperature)

The output of get_tpc_as_formula('sharpeschoolhigh_1981', 'temp', 'rate') is currently:

rate ~ sharpeschoolhigh_1981(temp = temp, r_tref, e, eh, th, tref)

Whereas for this to work with quickfit_tpc() we need this function to output a tref value (e.g. tref = 20, but it could be hard to do this.

Any thoughts @fwimp?

padpadpadpad avatar Aug 26 '25 17:08 padpadpadpad

Just so I understand this correctly, tref should be an optional argument that defaults to 20?

I think we can sort that by making tref have a default value of 20 in the sharpschoolhigh_1981() definition. That can then get detected and extracted using formals() (which returns a list where the names of entries are the arguments provided to a function and the value of each entry in the list is the default value [if present] of that argument.)

If users need to be able to define a tref themselves, we need to think a touch harder. Are there other arguments that this may be important for? If so then we can make get_tpc_as_formula() parse a named list of fixed values to inject into the formula object if they are present within the args of the function. If not we can just take an additional argument of tref and deal with it that way.

fwimp avatar Aug 29 '25 18:08 fwimp

So it should probably default to a value halfway between the estimated topt and the minimum temperature sampled (or even the minimum temperature sampled), instead of 20. This will probably be sufficient for most use-cases. Slightly different values for the full and low sharpe-schoolfield might be needed. Need to check if those sorts of arguments exist elsewhere.

For quickfit_tpc() this default behaviour is probably fine and if people want to define it themselves then they should probably not use quickfit_tpc().

padpadpadpad avatar Sep 05 '25 13:09 padpadpadpad