@@ -84,7 +84,7 @@ tmp[!is.na(tmp)] <- 0
8484tmp [lat_calib_id , lon_calib_id ] <- 1
8585values(static_prob [[1 ]]) <- tmp
8686
87- if (! is.na(gpr $ calib_2_start )) {
87+ if (! is.na(gpr $ calib_2_start ) & abs(difftime( gpr $ calib_2_end , gpr $ crop_end , units = " days " )) < 3 ) {
8888 if (! is.na(gpr $ calib_2_lat )) {
8989 lon_calib_id <- which.min(abs(gpr $ calib_2_lon - lon ))
9090 lat_calib_id <- which.min(abs(gpr $ calib_2_lat - lat ))
@@ -101,22 +101,67 @@ if (!is.na(gpr$calib_2_start)) {
101101path <- geopressure_map2path(static_prob )
102102static_timeserie <- geopressure_ts_path(path , pam $ pressure )
103103
104-
105104if (debug ) {
106105 # GeopressureViz
107- geopressureviz <- list (
106+ path_modified <- geopressureviz (
108107 pam = pam ,
109108 static_prob = static_prob ,
110109 pressure_prob = pressure_prob ,
111110 light_prob = light_prob ,
112111 pressure_timeserie = static_timeserie
113112 )
114- save(geopressureviz , file = " ~/geopressureviz.RData" )
115-
116- appDir <- system.file(" geopressureviz" , package = " GeoPressureR" )
117- shiny :: runApp(appDir , launch.browser = getOption(" browser" ))
118113
114+ # Pressure
115+ path_modified_timeserie <- geopressure_ts_path(path_modified , pam $ pressure )
116+
117+ path_modified_ts_bind <- do.call(" rbind" , path_modified_timeserie ) %> %
118+ filter(! is.na(sta_id ))
119+
120+ # To make the labeling easier, you can replace pam$pressure$obs by the difference between
121+ # pam$pressure$obs and pressure_timeserie$pressure0 to see the anomalies.
122+ # Because trainset_read does not read the actual value of obs, but simply the label, it won't
123+ # impact your code
124+ pam_diff <- pam
125+ pam_diff $ pressure <- pam_diff $ pressure %> %
126+ left_join(path_modified_ts_bind %> % dplyr :: select(c(" date" ," pressure0" )), by = " date" ) %> %
127+ rename(obs_ref = pressure0 )
128+
129+ trainset_write(pam_diff , " data/1_pressure/labels/" , filename = paste0(pam $ id , " _act_pres" ))
130+
131+ # We can automatically extract some outlier based on s value
132+ # pam_diff_pressure <- pam_diff_pressure %>%
133+ # mutate( isoutlier = ifelse(!isoutlier&abs(diff)>4*gpr$prob_map_s&sta_id>0, TRUE, isoutlier))
134+ # message(sum(pam_diff_pressure$isoutlier)-sum(pam$pressure$isoutlier), " new outlier automatically added")
135+ twl_path <- left_join(twl , path_modified ) %> %
136+ mutate(
137+ twilight = twilight(twilight ,
138+ lon = lon , lat = lat , rise = rise , zenith = 96 )
139+ ) %> %
140+ filter(! is.na(twilight ))
141+
142+ write.csv(
143+ df <- rbind(
144+ data.frame (
145+ series = ifelse(twl $ rise , " Rise" , " Set" ),
146+ timestamp = strftime(twl $ twilight , " %Y-%m-%dT00:00:00Z" , tz = " UTC" ),
147+ value = (as.numeric(format(twl $ twilight , " %H" )) * 60 + as.numeric(format(twl $ twilight , " %M" ))
148+ + gpr $ shift_k / 60 + 60 * 12 ) %% (60 * 24 ),
149+ label = ifelse(is.na(twl $ delete ), " " , ifelse(twl $ delete , " Delete" , " " ))
150+ ),
151+ data.frame (
152+ series = ifelse(twl_path $ rise , " Set_ref" , " Rise_ref" ),
153+ timestamp = strftime(twl_path $ twilight , " %Y-%m-%dT00:00:00Z" , tz = " UTC" ),
154+ value = (as.numeric(format(twl_path $ twilight , " %H" )) * 60 + as.numeric(format(twl_path $ twilight , " %M" ))
155+ + gpr $ shift_k / 60 + 60 * 12 ) %% (60 * 24 ),
156+ label = " "
157+ )
158+ ),
159+ paste0(" data/2_light/labels/" , gpr $ gdl_id , " _light.csv" ),
160+ row.names = FALSE
161+ )
162+ }
119163
164+ if (debug ) {
120165 # Check 1
121166 static_prob_n <- lapply(static_prob , function (x ) {
122167 probt <- raster :: as.matrix(x )
0 commit comments