Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with "'x' and 'y' must be given in ascending order" after using subsetGrid #35

Open
rbalmaceda opened this issue Nov 26, 2020 · 4 comments

Comments

@rbalmaceda
Copy link

Hi,
Im using subsetGrid function to select some stations. Then I want to calculate bias, or correlations using valueMeasure from package climate4R.value but I get this error:

[2020-11-26 01:32:58] Computing member 1 out of 11
Error in mat2Dto3Darray(mat, xy$x, xy$y) :
Coordinates 'x' and 'y' must be given in ascending order

Im not very clear what the problem is,maybe you can guide me. The error only appears when I use subsetGrid first.
Thanks a lot :)

@jorgebanomedina
Copy link
Collaborator

jorgebanomedina commented Nov 26, 2020 via email

@rbalmaceda
Copy link
Author

Thanks Jorge for your quick response. I realized that I was a bit confused about the error. I think I have two different problems. I attach some data with 2 objects that are BindGrids after using downscale.CV: 1 analog and 1 GLM
In the case of analogs, I already have them in a specific region, and the error come up after ScaleGrid .
In the case of the GLM that I have them in a larger domain, I first calculate the anomalies but then I cannot select the stations. I was able to solve it by changing the attributes of the data matrix.
I hope it is understood, and thank you very much!

This is my code:
`#########analogs in Region 1
ANOM_ERA_analogos.cv_R1=scaleGrid(ERA_analogos.cv_Tn_R1_tt,time.frame = "daily")
ANOM_cor_ERA.cv_R1=valueMeasure(subsetDimension(ANOM_ERA_analogos.cv_R1,dimension = "member", indices =1),subsetDimension(ANOM_ERA_analogos.cv_R1,dimension = "member", indices = c(2:3)), measure.code = "ts.rp",return.NApercentage=FALSE)

############################################ GLM
estaciones_grupo1=c( "10178", "10332", "10221", "10156", "10204", "10190", "10159", "10166",
"10334", "10134", "10453", "10170","10148", "10210", "10369", "10113",
"10456", "10206", "10177", "10133", "10154", "10192", "10451", "10311",
"10490", "10446", "10400", "10216", "10900", "10358", "10902", "10421",
"10502", "10907", "10114", "10145", "10492", "10912")
tt=attributes(ERA_GLM_cv_tt$Data)
anom_modelos_ERA_GLM.cv=scaleGrid(grid=ERA_GLM_cv_tt,base=ERA_GLM_cv_tt,time.frame = "daily")
attributes(anom_modelos_ERA_GLM.cv$Data)=tt
ANOM_ERA_GLM.cv_R1=subsetGrid(anom_modelos_ERA_GLM.cv,station.id = estaciones_grupo1)
ANOM_cor_ERA_GLM.cv_R1=valueMeasure(subsetDimension(ANOM_ERA_GLM.cv_R1,dimension = "member", indices =1),subsetDimension(ANOM_ERA_GLM.cv_R1,dimension = "member", indices = c(2:3)), measure.code = "ts.rp",return.NApercentage=FALSE)#, measure.cor(deseason = 1, method = pearson))
`

example.zip

@jorgebanomedina
Copy link
Collaborator

jorgebanomedina commented Dec 3, 2020 via email

@rbalmaceda
Copy link
Author

Thank u Jorge, I was able to solve the problem by reinstalling transformeR to version 2.0.1 after heeding this warning:

WARNING: Your current version of transformeR (v2.0.2) is ahead of the master branch version (2.0.1)
Development version may have an unexpected behaviour

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants