Revision fe4c013a
Added by Adam Wilson about 11 years ago
climate/procedures/MOD35C5_Evaluation.r | ||
---|---|---|
238 | 238 |
tind2=tind1[!is.na(tind1)&!is.na(tval1)] #which classes exist without NAs? |
239 | 239 |
if(length(unique(tind2))<2) return(255) #if only one class, return 255 |
240 | 240 |
if(sort(table(tind2),dec=T)[2]<5) return(254) # if too few observations of class 2, return 254 |
241 |
return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, return p.value*100 |
|
241 |
# return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, return p.value*100 |
|
242 |
m=mean(tval1,na.rm=T) |
|
243 |
dif=round(diff(range(tapply(tval1,tind1,mean)))/m*100) |
|
244 |
return(dif) # if it works, return p.value*100 |
|
242 | 245 |
})),nrow=nby,ncol=ncol(mod35c5),byrow=T)) # turn it back into a raster |
243 |
## udpate raster and write it
|
|
246 |
## update raster and write it
|
|
244 | 247 |
extent(pp_bias)=extent(mod35c5[ti:(ti+nby-1),1:ncol(mod35c5),drop=F]) |
245 | 248 |
projection(pp_bias)=projection(mod35c5) |
246 | 249 |
NAvalue(pp_bias) <- 255 |
... | ... | |
253 | 256 |
tind2=tind1[!is.na(tind1)&!is.na(tval1)] #which classes exist without NAs? |
254 | 257 |
if(length(unique(tind2))<2) return(255) #if only one class, return 255 |
255 | 258 |
if(sort(table(tind2),dec=T)[2]<5) return(254) # if too few observations of class 2, return 254 |
256 |
return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, get p.value*100 |
|
259 |
# return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, get p.value*100 |
|
260 |
m=mean(tval1,na.rm=T) |
|
261 |
dif=round(diff(range(tapply(tval1,tind1,mean)))/m*100) |
|
262 |
return(dif) # if it works, return the normalized difference |
|
257 | 263 |
})),nrow=nby,ncol=ncol(mod35c5),byrow=T)) # turn it back into a raster |
258 | 264 |
## udpate raster and write it |
259 | 265 |
extent(lulc_bias)=extent(mod35c5[ti:(ti+nby-1),1:ncol(mod35c5),drop=F]) |
... | ... | |
269 | 275 |
tind2=tind1[!is.na(tind1)&!is.na(tval1)] #which classes exist without NAs? |
270 | 276 |
if(length(unique(tind2))<2) return(255) #if only one class, return 255 |
271 | 277 |
if(sort(table(tind2),dec=T)[2]<5) return(254) # if too few observations of class 2, return 254 |
272 |
return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, get p.value*100 |
|
278 |
# return(round(kruskal.test(tval1,tind1)$p.value*100)) # if it works, get p.value*100 |
|
279 |
m=mean(tval1,na.rm=T) |
|
280 |
dif=round(diff(range(tapply(tval1,tind1,mean)))/m*100) |
|
281 |
return(dif) # if it works, return normalized difference |
|
273 | 282 |
})),nrow=nby,ncol=ncol(mod35c5),byrow=T)) # turn it back into a raster |
274 | 283 |
## udpate raster and write it |
275 | 284 |
extent(mod09_lulc_bias)=extent(mod09[ti:(ti+nby-1),1:ncol(mod09),drop=F]) |
Also available in: Unified diff
Changed bias metric to % change rather than p-value