IDEMSInternational / R-Instat

A statistics software package powered by R
http://r-instat.org/
GNU General Public License v3.0
38 stars 103 forks source link

Reading data from the evapotranspiration package #7060

Open rdstern opened 2 years ago

rdstern commented 2 years ago

The evapotranspiration dialogue has an issue with the data. The last dataset - processed data can't be read. I wonder why not, and can we do anything about that. It is the example used in the evapotranspiration package, so I assume it reads ok with rstudio? You may also like to look briefly at the reading of the constants data, which inputs into 37 separate data frames with one cell in each. That isn't a real problem, because Append works fine and turns them into a single data frame with 2 variables and 37 rows.

mmulahvictor commented 2 years ago

@ChrisMarsh82 The processed dataset from the evapotranspiration package cannot be read when opened from R-Instat because it is a list of different objects with different length. I have discussed with @shadrackkibet and @rdstern about this problem and there is no clear solution to this for there is a possibility of other datasets not opening also. @rdstern has suggested that we should not concentrate too much on this task for now.

rdstern commented 1 year ago

First I note a possible problem with the new evapotranspiration dialogue, that might need a quick fix. It seems to work, but I think it also produces a copy of all the results in the output window! I suggest that isn't needed. However, it may be useful that something is produced, to reassure the user that it has worked. Maybe just a one-liner initially saying Evapotranspiration produced using Penman Monteith for xxx data points.

@MeSophie can you come back to the topic above, even if you can't read those data directly into R-Instat. Please read them into RStudio then and produce a copy that can be read into R-Instat to use it with our evapotranspiration dialogue. Please also look at this and the other examples of data in the package and report on how they can be used. I read one set in, on constants, which produced many data frames with a single observation in each. Then I used append to produce a single data frame. But then I am not sure how this is supposed to be used. I assume some functions in the package use them. Do we need to include options for some of the constants?

And use at least one of these sets with the evapotranspiration dialogue. I note the package uses those as examples, so we should be able to do that, either from your dialogue, or from a script.

And I note, from our last discussion, that ApSim uses a different method to the ones we have programmed. That could be a third button at the top. Probably it will be the middle button, because it needs less data than PM and more than Hargreaves.

You may wish to report here on the proposed dialogue. I am sure it will be similar, but simpler to the one for PM, so you may wish to start with a copy of that.

I am copying @AmsaleEjigu and @Patowhiz on this message, as they may wish to comment further - and you may wish to check things with them.

I would like (soon) to have instructions - video and script and help information on our dialogue, so welcome examples of its use. And the use will depend on the precise data available, so we will then need examples where that varies. So I would like you to pose some what-if questions - and then answer them. For example the first data set has similar variables, to the ones in the dialogue, but not quite the same. How could that be used. And I assume we will sometimes have variables in different units - so what might there be, and what should we do about it? We have a transformations dialogue, and I assume we may wish to add to that, to get the units assumed in the dialogue.

I hope this is clear. The work should include looking for possible problems that Met services may have, and then solving them.

I include an example - it was actually ApSim, but the problem would be the same in the evapotranspiration calculation.

A Met service supplied the elements (including radiation) for running ApSim for groundnuts. ApSim gave very high yields. This was then found to be because the radiation was vary high - presumably in different units to what ApSim assumes. The Met service was unable to specify what the units were, and hence the data could not be used. Shame!

I assume the FAO guide will include a discussion of the different units and how to adapt the calculations, if this is not available in the evapotranspiration package documentation.

MeSophie commented 1 year ago

@rdstern I notice that the parameter data in Evapotranspiration Panmen Monteith is a list (may be it is the raison why I can't directly use bohicon data whith this function i R).

image

This is the error that I get trying to use Bohicon data.

image

I also notice that in the code produce by Evapotranspiration dialog, the final form of Bohicon data is a list.

So since we have already a proccess to transform data frame to a list, It can also be go to see how to transform list to a data frame I this this can be helpful in the futur.

The evapotranspiration package contains two databases that contain the parameters needed for the calculation of evapotranspiration: Processeddata and Climatedata. As you know Processeddata is not readable in R-instat but runs perfectly in R. While Climatedata opens in R-Instat but does not run in the function in R. It could be executed in our dialogue if we introduce the parameters Temp and RH which I suppose are respectively the daily average temperature and relative humidity. Running the function with climatedata, I got the following error :

image

Means that if we don't have Tmin and Tmax we can use Temp which can be a daily mean temperature.

https://rdrr.io/cran/Evapotranspiration/man/climatedata.html.

I am still find how to solve all these errors in R

rdstern commented 1 year ago

@MeSophie those are both good finds. Are you able to solve them yourself? a) I assume the need for a list is general, and (just?) needs the R code that is generated to be corrected. I am assuming your R is probably sufficient for this. If not, then perhaps @AmsaleEjigu can help? If not then one of you should ask Lily, but in a way that you use this as an example to improve your R skills, so you can do this in the future. b) And the flexibility of being able to use tmean, rather than tmax and tmin is something we have added to the Climatic > Prepare > Transform > Degrees button. So it would be good if you can make the same small change to the Evapotranspiration dialogue. Please also check that those options work on the degrees dialogue. Then the code for evapotranspiration dialogue will have to be adapted too.