Open TianyaImpression opened 1 year ago
Hi @TianyaImpression, thanks for sharing a reproducible example. It's a very weird bug that occurs on the Python side (I will report it on the weekend!). Here is a solution, so basically avoid using 'f' as an argument.
Replace:
month_med = ee$List$sequence(1, 12)
#The following code runs an error:Error in py_call_impl(callable, dots$args, dots$keywords) :
TypeError: 'ComputedObject' object is not callable
Modis_med = ee$ImageCollection$fromImages(month_med$map(ee_utils_pyfunc(
function(f){
month1 = Modism$filter(ee$Filter$eq('month', f))
return(month1$reduce(ee$Reducer$median())$
rename('MMD')$
set('month', f))
}
)))
By:
monthly_reducer <- function(x) {
month1 <- Modism$filter(ee$Filter$eq('month', x))
month1$reduce(ee$Reducer$median())$
rename('MMD')$
set('month', x)
}
Modis_med <- ee$List$sequence(1, 12) %>%
ee$List$map(
ee_utils_pyfunc(monthly_reducer)
) %>%
ee$ImageCollection$fromImages()
UPDATE: No, this bug happens on the rgee side :face_with_spiral_eyes: , basically it's a dumb mistake in the ee_utils_pyfunc
, I will solve it ASAP! Thank you!
Hi @TianyaImpression, thanks for sharing a reproducible example. It's a very weird bug that occurs on the Python side (I will report it on the weekend!). Here is a solution, so basically avoid using 'f' as an argument.
Replace:
month_med = ee$List$sequence(1, 12) #The following code runs an error:Error in py_call_impl(callable, dots$args, dots$keywords) : TypeError: 'ComputedObject' object is not callable Modis_med = ee$ImageCollection$fromImages(month_med$map(ee_utils_pyfunc( function(f){ month1 = Modism$filter(ee$Filter$eq('month', f)) return(month1$reduce(ee$Reducer$median())$ rename('MMD')$ set('month', f)) } )))
By:
monthly_reducer <- function(x) { month1 <- Modism$filter(ee$Filter$eq('month', x)) month1$reduce(ee$Reducer$median())$ rename('MMD')$ set('month', x) } Modis_med <- ee$List$sequence(1, 12) %>% ee$List$map( ee_utils_pyfunc(monthly_reducer) ) %>% ee$ImageCollection$fromImages()
UPDATE: No, this bug happens on the rgee side 😵💫 , basically it's a dumb mistake in the
ee_utils_pyfunc
, I will solve it ASAP! Thank you!
Thank you for your reply!
I replaced "f" for "x", the code is ok!
At submit an issue, please attached the following information of your
rgee
session:[yes ] You have the Python API installed (from terminal):
[ yes] You can find the credentials file on your system:
[yes ] You can run a simple EE command from R:
Attach your Python (reticulate) configuration:
Description
I am trying to convert JS version of GEE codes to rgee codes: JS code: https://code.earthengine.google.com/aa97a56d2df0dfc6796175859da470fe
JS code 160-170 convert rgee codes report error:TypeError: 'ComputedObject' object is not callable
What I Did
I suspect that there is a bug when rgee executes map and reduce, or is there any other reason why the rgee version code cannot be executed?
Thank you for your help!