Closed lilyclements closed 2 months ago
@lilyclements , should be added the last item on Climatic > File
, that is below Export to Climpact
?
@Vitalis95 that sounds suitable - thanks for the suggestion
@lilyclements , I am done with the design
@Vitalis95 this is great, well done! There's two new receivers to add if that's ok:
The R Function is called export_r_instat_to_bucket
. There are a few parameters:
The first four receivers select a data frame (not a column):
data
: value in the data receiver (read as a string)data_by_year
: value in the data_by_year receiver (read as a string)data_by_year_month
: value in the data_by_year_month receiver (read as a string)crop_data
: value in the data receiver (read as a string)The next five receivers select a column from a data frame:
rain
: value in the rainfall receivertmin
: value in the tmin receivertmax
: value in the tmax receiveryear
: value in the year receivermonth
: value in the month receiverThen the next options are:
summaries
: We have summaries = c(...)
where in c
we list the items that were checked - "annual_rainfall", "annual_temperature", "monthly_temperature", "extremes", "crop_success", "start_season"
. Is it ok to be done this way? I can simplify it if you would like to annual_rainfall = TRUE
if checked, annual_rainfall = FALSE
if not. Let me know.file_name
The name to save the file as in the input boxinclude_summary_data
: TRUE
if the checkbox is checked, otherwise FALSE
Does this make sense?
To access the function:
The function is in the epicsawrap
package. This can be accessed by:
devtools::install_github("IDEMSInternational/epicsawrap")
Is it possible to add that package into R-Instat too?
To test the function: We can go through this - perhaps by a call? Or I can create and send a video outlining it :)
Example of the code An example of the R code is:
export_r_instat_to_bucket(data = "ghana",
data_by_year = "ghana_by_station_year",
data_by_year_month = "ghana_by_station_year_month_abbr",
crop_data_name = "crop_def",
rain = "rainfall",
tmin = "min_temperature",
tmax = "max_temperature",
year = "year",
month = "month_abbr",
summaries = c("annual_rainfall", "annual_temperature", "monthly_temperature", "extremes", "crop_success", "start_season"),
station_id = "test_3",
country = "zm",
include_summary_data = TRUE,
annual_rainfall_data = annual_rain,
annual_temperature_data = annual_temp,
monthly_temperature_data = monthly_temp,
crop_success_data = crop_prop,
season_start_data = crop_def)
@lilyclements thank you for the code
for thesummaries
make it to be annual_rainfall = TRUE
if checked, annual_rainfall = FALSE
if not
The file will be saved in whichformat
? i.e csv
, txt
, ...
Then we can arrange a call for a time that suits you. Thanks
@Vitalis95 saved in json format. Thanks! Let’s have a call next week?
@Vitalis95 saved in json format. Thanks! Let’s have a call next week?
@lilyclements, Schedule a meeting when it works for you
A few changes:
station_id
and country
annual_rainfall_data = annual_rain
when the define button is checked. (If this button is not pressed, then annual_rain
does not exist.The sub dialog is where we define our variables for Annual Rainfall. The layout would be like a "mini-define" dialog. We have many single receivers and labels:
Receiver Label | R Parameter |
---|---|
Station | station_col |
Year | year_col |
Start Rains (DOY) | start_rains_doy_col |
Start Rains (Date) | start_rains_date_col |
End Rains (DOY) | end_rains_doy_col |
End Rains (Date) | end_rains_date_col |
End Season (DOY) | end_season_doy_col |
End Season (Date) | end_season_date_col |
Seasonal Rain | seasonal_rain_col |
Number of Rainy Days in Season | n_seasonal_rain_col |
Seasonal Length | season_length_col |
Annual Rain | annual_rain_col |
Number of Rainy Days in Year | n_rain_col |
The code run here is
annual_rain <- data_book$get_data_frame("ghana_by_station_year")
annual_rain <- reformat_annual_summaries(data = annual_rain, station = "station", ...)
This should be run before the main dialog R code.
crop_prop = reformat_crop_success(...)
crop_success_data = crop_prop
when the define button is checked. (If this button is not pressed, then crop_prop
may not exist).Sub Dialog:
Receiver Label | R Parameter |
---|---|
Station | station_col |
Total rainfall | total_rain_col |
Planting day | plant_day_col |
Planting length | plant_length_col |
Proportion of success | prop_success_col |
season_data = reformat_season_start(...)
season_start_data = season_data
when the define button is checked. (If this button is not pressed, then season_data
may not exist).Sub Dialog:
Receiver Label | R Parameter |
---|---|
Station | station_col |
Year | year_col |
Planting day | plant_day_col |
Planting day condition (L) | plant_day_cond_col |
annual_temp = reformat_temperature_summaries(...)
annual_temperature_data = annual_temp
when the define button is checked. (If this button is not pressed, then annual_temp
may not exist).Sub Dialog:
Receiver Label | R Parameter |
---|---|
Station | station_col |
Year | year_col |
Mean minimum temperature | mean_tmin_col |
Min minimum temperature | min_tmin_col |
Max minimum temperature | max_tmin_col |
Mean maximum temperature | mean_tmax_col |
Min maximum temperature | min_tmax_col |
Max maximum temperature | max_tmax_col |
monthly_temp = reformat_temperature_summaries(...)
monthly_temperature_data = monthly_temp
when the define button is checked. (If this button is not pressed, then monthly_temp
may not exist).Sub Dialog (same as above, but with a month receiver):
Receiver Label | R Parameter |
---|---|
Station | station_col |
Year | year_col |
Month | month_col |
Mean minimum temperature | mean_tmin_col |
Min minimum temperature | min_tmin_col |
Max minimum temperature | max_tmin_col |
Mean maximum temperature | mean_tmax_col |
Min maximum temperature | min_tmax_col |
Max maximum temperature | max_tmax_col |
Can we have a new button above the selector which says "Connect to Google Buckets"
When clicked, a very simple sub-dialog comes up, looking somewhat like this:
Then the code that is run by this dialog is:
epicsawrap::gcs_auth_file(file = " FILE PATH.json ")
On the "Import from Climsoft" dialog, we have in red that no connection is made if there is no connection, and then this turns green if a valid connection is made. If this is straight forward, can we have this as well? If it isn't straightforward then no worries. It would just be a useful way to say if OK can be enabled or not.
@Vitalis95 I note the requests by @lilyclements that now include a feature from the Import from Climsoft, that was done by @Patowhiz . Just to mention the importance of using our user controls and adapting existing ones, rather than making new ones. If that's tricky here, maybe Patrick can help?
As part of an EPICSA project, we are currently developing a series of functions in epicsawrap which aim to read the climatic definitions from R-Instat and export them to google buckets. All this is just background stuff which no one else needs to worry about.
The R code on this is in progress, but we would like to have a front end for it in R-Instat. This should just require one function to be called in the dialog with some simple parameters. I don't think this would be a complex dialog at all, and if someone could start on the design that would be great.
Here is the design:
Notes
@N-thony could you suggest someone who might be suitable for this task?