Revision 66615279
Added by Benoit Parmentier about 10 years ago
climate/research/oregon/interpolation/Database_stations_covariates_processing_function.R | ||
---|---|---|
228 | 228 |
#This must be set up in master script |
229 | 229 |
#target_max_nb <- 100,000 #this is not actually used yet in the current implementation,can be set to very high value... |
230 | 230 |
#target_min_nb <- 600 #this is the target number of stations we would like for daily and 1000x3000 tiles |
231 |
#to be set by Alberto... |
|
231 |
#to be set by Alberto...THIS differentent than monthly number!!! |
|
232 |
|
|
232 | 233 |
##max_dist <- 1000 # the maximum distance used for pruning ie removes stations that are closer than 1000m, this in degree...? |
233 | 234 |
#max_dist <- 0.009*5 #5km in degree |
234 | 235 |
#min_dist <- 0 #minimum distance to start with |
235 | 236 |
#step_dist <- 0.009 #iteration step to remove the stations |
236 | 237 |
|
237 | 238 |
#test5 <- sub_sampling_by_dist_nb_stat(target_range_nb=target_range_nb,dist_range=dist_range,step_dist=step_dist,data_in=data_month,sampling=T,combined=F) |
239 |
|
|
240 |
#Daily range set at the begining...line 199! |
|
241 |
|
|
242 |
#target_range_daily_nb <- list_param$target_range_daily_nb #desired number range of daily stations |
|
243 |
|
|
238 | 244 |
if(sub_sampling_day==TRUE){ |
239 | 245 |
|
240 | 246 |
sub_sampling_obj <- sub_sampling_by_dist_nb_stat(target_range_nb=target_range_day_nb,dist_range=dist_range,step_dist=step_dist,data_in=data_RST_SDF,sampling=T,combined=F) |
241 | 247 |
data_RST_SDF <- sub_sampling_obj$data #get sub-sampled data...for monhtly stations |
242 | 248 |
#save the information for later use (validation at monthly step!!) |
243 |
save(sub_sampling_obj,file= file.path(out_path,paste("sub_sampling_obj_","dayly_",interpolation_method,"_", out_prefix,".RData",sep="")))
|
|
249 |
save(sub_sampling_obj,file= file.path(out_path,paste("sub_sampling_obj_","daily_",interpolation_method,"_", out_prefix,".RData",sep="")))
|
|
244 | 250 |
} |
245 | 251 |
|
246 | 252 |
#Make sure this is still a shapefile...!! This might need to be uncommented... |
... | ... | |
339 | 345 |
coordinates(dst)<-coords #Assign coordinates to the data frame |
340 | 346 |
proj4string(dst)<-CRS_interp #Assign coordinates reference system in PROJ4 format |
341 | 347 |
|
348 |
##Added 01-07-2015 |
|
349 |
dst$id <- dst$station #the id field is needed for possible subsampling |
|
350 |
|
|
342 | 351 |
### ADD SCREENING HERE BEFORE WRITING OUT DATA |
343 | 352 |
#Covariates ok since screening done in covariate script |
344 | 353 |
#screening on var i.e. value, TMIN, TMAX... |
345 | 354 |
|
346 |
#### Adding subsampling for regions that have too many stations... |
|
355 |
#### Adding subsampling for regions that have too many stations...This is for monthly stations...
|
|
347 | 356 |
|
348 | 357 |
#This must be set up in master script |
349 | 358 |
#target_max_nb <- 100,000 #this is not actually used yet in the current implementation,can be set to very high value... |
... | ... | |
354 | 363 |
#step_dist <- 0.009 #iteration step to remove the stations |
355 | 364 |
|
356 | 365 |
#test5 <- sub_sampling_by_dist_nb_stat(target_range_nb=target_range_nb,dist_range=dist_range,step_dist=step_dist,data_in=data_month,sampling=T,combined=F) |
357 |
if(sub_sampling==TRUE){ |
|
366 |
#note that this is for monthly stations. |
|
367 |
|
|
368 |
if(sub_sampling==TRUE){ #sub_sampling is an option for the monthly station |
|
358 | 369 |
sub_sampling_obj <- sub_sampling_by_dist_nb_stat(target_range_nb=target_range_nb,dist_range=dist_range,step_dist=step_dist,data_in=dst,sampling=T,combined=F) |
359 | 370 |
dst <- sub_sampling_obj$data #get sub-sampled data...for monhtly stations |
360 | 371 |
#save the information for later use (validation at monthly step!!) |
Also available in: Unified diff
data preparation script, modifications to solve subsampling issue in North America