Forum: open-discussion


RE: List of soil properties as an argument [ Reply ] By: Julien Moeys on 2010-10-15 11:38 | [forum:3500] |
I don't fully master all details about methods in R, but you are certainly right. If it happens that you have some times to write this, please use S3 methods, I am struggling a bit to have S4 methods & the inlinedocs documentation system to work together (another thing I have to look/fix in the future). J |
RE: List of soil properties as an argument [ Reply ] By: Mikhail Titov on 2010-10-13 18:38 | [forum:3489] |
In my opinion all methods can be implemented. I'd just rely on UseMethod function and provide wrapper fun.vangenuchten.theta.h2.list that calls fun.vangenuchten.theta.h2.default (your original code). You can add me as a developer, in case I'd have a couple of minutes before you have one:-) |
RE: List of soil properties as an argument [ Reply ] By: Julien Moeys on 2010-10-13 07:53 | [forum:3482] |
Well, you are right about the fact that it is easy to convert a matrix to a list (I realise I am overcomplicating things) A 3rd alternative would be to have a function like fun.vangenuchten.theta.h2() that accepts data.frame or matrix (like outputted by ptf.wosten()) as argument (and would return a matrix of theta, with 1 row per soil layer and 1 column per h values). Then, if you provide a table with just 1 row, you get just 1 row of results... That would not be complicated to implement in fact. If I find the time to code that in the next weeks (months?) I may try to do that J |
RE: List of soil properties as an argument [ Reply ] By: Mikhail Titov on 2010-10-12 07:56 | [forum:3479] |
Well... it is kind of late night here so I gave no so short example of conversion ptf.wosten results into a list:-) It can be just as.list(res[1,]) |
RE: List of soil properties as an argument [ Reply ] By: Mikhail Titov on 2010-10-12 07:52 | [forum:3478] |
Well, I have no complaints about ptf.wosten as matrix can be easily converted to data.frame which can be accessed as list. So there is no reason to change the result of ptf.wosten. Perhaps just to return data.frame. But it is only my preference and I don't really care since it can be converted any way like here http://pastebin.com/q2z4vfiC . But I would personally definitely like fun.vangenuchten.theta.h2 with list() argument. I don't see any burdens for using lists for batch computing. They can be easily converted into whatever is desirable. I'm not sure if it is a good idea to mix two functions in one like calculating VGM functions from soil composition. It is just IMHO and I don't insist:-) |
RE: List of soil properties as an argument [ Reply ] By: Julien Moeys on 2010-10-11 21:26 | [forum:3476] |
If I understand you correctly, you would then like to have a function, say ptf.wosten that can also outputs results in the form res = lit( S1 = list( alpha = ..., n =..., thetaR = ..., ... ), S2 = ... ) and then a function, say fun.vangenuchten.theta.h2(), that would accept an element of this list as a single parmeter, like fun.vangenuchten.theta.h2( h = -1:158, res[[1]] ) This would effectively be quite "handy" in some cases. Or maybe a simple vector or single row data.frame of parameter values would work as well in fact (I tend to favour tabulate outputs rather than lists, this is more efficient for batch computing). I also have though about implementing functions that would dirctly compute van Genuchten functions result from soil properties, like: fun.vangenuchten.theta.h2( h = -1:158, clay = 40, silt = 30, sand = 30, om = 2, ... ) which would internally calculate VG parameters with some PTFs. The 2 ideas are not incomatible in fact. with best /Julien |
List of soil properties as an argument [ Reply ] By: Mikhail Titov on 2010-10-08 14:42 | [forum:3470] |
IMHO it would be convinient to add functions that accept all soil properties as a single list argument along with current functions definitions. Thus a user won't have to type the same parameters again and again when calling different functions. Once you set up soil parameters and store them in a list, you can just pass this list to whatever function. |