Skip to content

Commit 8464df8

Browse files
author
cjgleason_umass_edu
committed
change to fixed slopes and permissive filter
1 parent faf7f77 commit 8464df8

File tree

8 files changed

+2696
-902
lines changed

8 files changed

+2696
-902
lines changed

.ipynb_checkpoints/test_prediag-checkpoint.ipynb

Lines changed: 1261 additions & 546 deletions
Large diffs are not rendered by default.

prediagnostics/.ipynb_checkpoints/config-checkpoint.R

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,44 @@
1717
# # wse_r_u_max = 0.5 ## deprecated in v002
1818
# )
1919

20-
# # Jan 13 2025 v "permissive" params
21-
# GLOBAL_PARAMS = list (
22-
# prior_width_min_m = 80 ,
23-
# prior_slope_min = 3.4e-5,
24-
# reach_length_min_m=7000,
25-
# cross_track_dist_min_m= 10000,
26-
# cross_track_dist_max_m= 60000,
27-
# ice_max = 0,
28-
# target_bit_reach= 507510784, #FUNCTIONALLY EQUIVALENT TO _q<=2
29-
# target_bit_node= 532680192 , #adds flags 9,10, 11, 23, and 24 to the reach
30-
# dark_max = 0.4,
31-
# obs_frac_min= 0.5,
32-
# xover_cal_q_max = 1,
33-
# Tukey_number = 1.5,
34-
# n_node_pix_min =10
35-
# # slope_r_u_max=10e-5 ## deprecated in v002
36-
# # wse_r_u_max = 0.5 ## deprecated in v002
37-
# )
38-
39-
# Jan 17 2025 v "strict" params
20+
# Jan 13 2025 v "permissive" params
4021
GLOBAL_PARAMS = list (
41-
prior_width_min_m = 80 ,#same as Kostas
42-
prior_slope_min = 1.7e-5,#same as Kostas
43-
reach_length_min_m=7000,#same as Kostas
44-
cross_track_dist_min_m= 15000,#same as Kostas
45-
cross_track_dist_max_m= 600000, #setting to high number to reflect no max in Kostas run
46-
ice_max = 0,#same as Kostas
47-
target_bit_reach= 168298510, #same as Kostas
48-
target_bit_node= 168298510, #same as Kostas
49-
dark_max = 0.1,#same as Kostas
50-
obs_frac_min= 0.01, #setting super low to recreate Kostas run, which didn't have this filter
51-
xover_cal_q_max = 1,#same as Kostas
52-
Tukey_number = 1.5,#same as Kostas
53-
n_node_pix_min =1 #setting super low to recreate Kostas run, which didn't have this filter
54-
# slope_r_u_max=10e-5 ## deprecated
55-
# wse_r_u_max = 0.5 ## deprecated
22+
prior_width_min_m = 80 ,
23+
prior_slope_min = 3.4e-5,
24+
reach_length_min_m=7000,
25+
cross_track_dist_min_m= 10000,
26+
cross_track_dist_max_m= 60000,
27+
ice_max = 0,
28+
target_bit_reach= 507510784, #FUNCTIONALLY EQUIVALENT TO _q<=2
29+
target_bit_node= 532680192 , #adds flags 9,10, 11, 23, and 24 to the reach
30+
dark_max = 0.4,
31+
obs_frac_min= 0.5,
32+
xover_cal_q_max = 1,
33+
Tukey_number = 1.5,
34+
n_node_pix_min =10
35+
# slope_r_u_max=10e-5 ## deprecated in v002
36+
# wse_r_u_max = 0.5 ## deprecated in v002
5637
)
5738

39+
# # Jan 17 2025 v "strict" params
40+
# GLOBAL_PARAMS = list (
41+
# prior_width_min_m = 80 ,#same as Kostas
42+
# prior_slope_min = 1.7e-5,#same as Kostas
43+
# reach_length_min_m=7000,#same as Kostas
44+
# cross_track_dist_min_m= 15000,#same as Kostas
45+
# cross_track_dist_max_m= 600000, #setting to high number to reflect no max in Kostas run
46+
# ice_max = 0,#same as Kostas
47+
# target_bit_reach= 168298510, #same as Kostas
48+
# target_bit_node= 168298510, #same as Kostas
49+
# dark_max = 0.1,#same as Kostas
50+
# obs_frac_min= 0.01, #setting super low to recreate Kostas run, which didn't have this filter
51+
# xover_cal_q_max = 1,#same as Kostas
52+
# Tukey_number = 1.5,#same as Kostas
53+
# n_node_pix_min =1 #setting super low to recreate Kostas run, which didn't have this filter
54+
# # slope_r_u_max=10e-5 ## deprecated
55+
# # wse_r_u_max = 0.5 ## deprecated
56+
# )
57+
5858
#v 0001 params, pre December 2024
5959
#GLOBAL_PARAMS = list (
6060
# wse_r_u_max = 0.5,

prediagnostics/.ipynb_checkpoints/input-checkpoint.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ get_data <- function(reach_files) {
3737
time_str = var.get.nc(r_grp, "time_str")
3838
close.nc(swot)
3939

40-
# ##-------------------------------------------------------
41-
# #debugging toggle for when patched sword is not avaailable
42-
# sword_base='/nas/cee-water/cjgleason/data/SWORD/SWORDv16/netcdf/'
43-
# bleh=reach_files$sword
44-
# split1=strsplit(bleh,'/')[[1]][11]
45-
# split2=paste(strsplit(split1,'_')[[1]][1:3],collapse="_")
46-
# split3=paste0(split2,'.nc')
47-
# reach_files$sword=paste0(sword_base,split3)
48-
# ##-------------------------------------------------------
40+
# ##-------------------------------------------------------
41+
# #debugging toggle for when patched sword is not avaailable
42+
# sword_base='/nas/cee-water/cjgleason/data/SWORD/SWORDv16/netcdf/'
43+
# bleh=reach_files$sword
44+
# split1=strsplit(bleh,'/')[[1]][11]
45+
# split2=paste(strsplit(split1,'_')[[1]][1:3],collapse="_")
46+
# split3=paste0(split2,'.nc')
47+
# reach_files$sword=paste0(sword_base,split3)
48+
# ##-------------------------------------------------------
4949

5050

5151

prediagnostics/.ipynb_checkpoints/prediagnostics-checkpoint.R

Lines changed: 75 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -719,56 +719,88 @@ low_slope=function(data, sword_slope, min_slope, level){
719719
# print('read into low slope diags')
720720
# print(data$slope)}
721721

722-
###MIXED SLOPE TOGGLE 1/2/25
722+
###MIXED SLOPE TOGGLE 1/2/25---------------------
723723

724724
#we want to use the sword slope, unless it is less than the slope minimum
725725
#check sword against the slope min, and then assign whichever is higher to
726726
#swot data that are < the slope minimum.
727-
if (sword_slope > min_slope) {
728-
slope_value <- sword_slope
729-
} else {
730-
slope_value <- min_slope
731-
}
732-
733-
#reset any slope less than the minimum slope value to the slope value
734-
data$slope[data$slope< min_slope]= slope_value
735-
data$slope2[data$slope2< min_slope]= slope_value
736-
# #return a '1' where we have masked to slope
737-
# #the +() syntax will binarize
738-
slope_flags=+(data$slope< min_slope)
727+
# if (sword_slope > min_slope) {
728+
# slope_value <- sword_slope
729+
# } else {
730+
# slope_value <- min_slope
731+
# }
732+
733+
# #reset any slope less than the minimum slope value to the slope value
734+
# data$slope[data$slope< min_slope]= slope_value
735+
# data$slope2[data$slope2< min_slope]= slope_value
736+
# # #return a '1' where we have masked to slope
737+
# # #the +() syntax will binarize
738+
# slope_flags=+(data$slope< min_slope)
739739

740-
741740
# print(slope_flags)
742-
### mixed slope toggle end
741+
### mixed slope toggle end----------------------
743742

744743

745-
# ### FIXED SLOPE TOGGLE 1/2/25
746-
# if (any(data$slope< min_slope,na.rm=TRUE)){
747-
# slope_value=sword_slope
744+
### FIXED SLOPE TOGGLE 1/2/25 ------------------
745+
#in this case, if we have low slopes, we want to set all slopes to a constant value equal to the
746+
#sword slope, which approximates the bed slope. This prevents behavior where HWS appaear to vary
747+
#out of step one another
748+
749+
750+
# if (sword_slope > min_slope) {
751+
slope_value = sword_slope
752+
# } else {
753+
# slope_value = min_slope
754+
# }
755+
756+
#dont write if the input is all NA, this will be confusing later
757+
if(all(is.na(data$slope))){
758+
# print('allna')
759+
length = dim(data$slope)
760+
if (level == "reach") {
761+
762+
slope_flags <- rep(1, times=length)
763+
} else {
764+
765+
slope_flags <- array(1, dim=length)
766+
}
767+
768+
769+
return(list(data=data, flags=slope_flags))}
770+
771+
if (any(data$slope< slope_value,na.rm=TRUE)){
772+
773+
# print(paste('low slope on',level))
774+
# print(slope_value)
748775

749-
# # Set slope and slope2
750-
# length = dim(data$slope)
776+
# Set slope and slope2
777+
length = dim(data$slope)
751778

752-
# if (level == "reach") {
753-
# data$slope <- rep(slope_value, times=length)
754-
# data$slope2 <- rep(slope_value, times=length)
755-
# slope_flags <- rep(1, times=length)
756-
# } else {
757-
# data$slope <- array(slope_value, dim=length)
758-
# data$slope2 <- array(slope_value, dim=length)
759-
# slope_flags <- array(1, dim=length)
760-
# }
779+
if (level == "reach") {
780+
data$slope <- rep(slope_value, times=length)
781+
data$slope2 <- rep(slope_value, times=length)
782+
slope_flags <- rep(1, times=length)
783+
} else {
784+
data$slope <- array(slope_value, dim=length)
785+
data$slope2 <- array(slope_value, dim=length)
786+
slope_flags <- array(1, dim=length)
787+
}
761788

762-
# } else {
763-
# length = dim(data$slope)
764-
# if (level == "reach") {
765-
# slope_flags <- rep(0, times=length)
766-
# } else {
767-
# slope_flags <- array(0, dim=length)
768-
# }
789+
790+
# print(data$slope)
791+
# bonk
769792

770-
# }
771-
#### fixed slope toggle end
793+
} else {
794+
length = dim(data$slope)
795+
if (level == "reach") {
796+
slope_flags <- rep(0, times=length)
797+
} else {
798+
slope_flags <- array(0, dim=length)
799+
}
800+
801+
802+
}
803+
### fixed slope toggle end------------------
772804
# if(!nrow(data$width>1)){
773805
# print('coming out of low slope diags')
774806
# print(data$slope)}
@@ -833,8 +865,12 @@ if (sword_slope > min_slope) {
833865
# ##end debugging toggle---------------
834866

835867

868+
# print('reach')
869+
# print(reach_list$slope)
870+
# print('node')
871+
# print(node_list$slope)
836872

837-
873+
# bonk
838874

839875
#output of diagnostics
840876
write_data(reach_list, node_list, reach_flags, node_flags, reach_outliers,

prediagnostics/config.R

Lines changed: 35 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -17,44 +17,44 @@
1717
# # wse_r_u_max = 0.5 ## deprecated in v002
1818
# )
1919

20-
# # Jan 13 2025 v "permissive" params
21-
# GLOBAL_PARAMS = list (
22-
# prior_width_min_m = 80 ,
23-
# prior_slope_min = 3.4e-5,
24-
# reach_length_min_m=7000,
25-
# cross_track_dist_min_m= 10000,
26-
# cross_track_dist_max_m= 60000,
27-
# ice_max = 0,
28-
# target_bit_reach= 507510784, #FUNCTIONALLY EQUIVALENT TO _q<=2
29-
# target_bit_node= 532680192 , #adds flags 9,10, 11, 23, and 24 to the reach
30-
# dark_max = 0.4,
31-
# obs_frac_min= 0.5,
32-
# xover_cal_q_max = 1,
33-
# Tukey_number = 1.5,
34-
# n_node_pix_min =10
35-
# # slope_r_u_max=10e-5 ## deprecated in v002
36-
# # wse_r_u_max = 0.5 ## deprecated in v002
37-
# )
38-
39-
# Jan 17 2025 v "strict" params
20+
# Jan 13 2025 v "permissive" params
4021
GLOBAL_PARAMS = list (
41-
prior_width_min_m = 80 ,#same as Kostas
42-
prior_slope_min = 1.7e-5,#same as Kostas
43-
reach_length_min_m=7000,#same as Kostas
44-
cross_track_dist_min_m= 15000,#same as Kostas
45-
cross_track_dist_max_m= 600000, #setting to high number to reflect no max in Kostas run
46-
ice_max = 0,#same as Kostas
47-
target_bit_reach= 168298510, #same as Kostas
48-
target_bit_node= 168298510, #same as Kostas
49-
dark_max = 0.1,#same as Kostas
50-
obs_frac_min= 0.01, #setting super low to recreate Kostas run, which didn't have this filter
51-
xover_cal_q_max = 1,#same as Kostas
52-
Tukey_number = 1.5,#same as Kostas
53-
n_node_pix_min =1 #setting super low to recreate Kostas run, which didn't have this filter
54-
# slope_r_u_max=10e-5 ## deprecated
55-
# wse_r_u_max = 0.5 ## deprecated
22+
prior_width_min_m = 80 ,
23+
prior_slope_min = 3.4e-5,
24+
reach_length_min_m=7000,
25+
cross_track_dist_min_m= 10000,
26+
cross_track_dist_max_m= 60000,
27+
ice_max = 0,
28+
target_bit_reach= 507510784, #FUNCTIONALLY EQUIVALENT TO _q<=2
29+
target_bit_node= 532680192 , #adds flags 9,10, 11, 23, and 24 to the reach
30+
dark_max = 0.4,
31+
obs_frac_min= 0.5,
32+
xover_cal_q_max = 1,
33+
Tukey_number = 1.5,
34+
n_node_pix_min =10
35+
# slope_r_u_max=10e-5 ## deprecated in v002
36+
# wse_r_u_max = 0.5 ## deprecated in v002
5637
)
5738

39+
# # Jan 17 2025 v "strict" params
40+
# GLOBAL_PARAMS = list (
41+
# prior_width_min_m = 80 ,#same as Kostas
42+
# prior_slope_min = 1.7e-5,#same as Kostas
43+
# reach_length_min_m=7000,#same as Kostas
44+
# cross_track_dist_min_m= 15000,#same as Kostas
45+
# cross_track_dist_max_m= 600000, #setting to high number to reflect no max in Kostas run
46+
# ice_max = 0,#same as Kostas
47+
# target_bit_reach= 168298510, #same as Kostas
48+
# target_bit_node= 168298510, #same as Kostas
49+
# dark_max = 0.1,#same as Kostas
50+
# obs_frac_min= 0.01, #setting super low to recreate Kostas run, which didn't have this filter
51+
# xover_cal_q_max = 1,#same as Kostas
52+
# Tukey_number = 1.5,#same as Kostas
53+
# n_node_pix_min =1 #setting super low to recreate Kostas run, which didn't have this filter
54+
# # slope_r_u_max=10e-5 ## deprecated
55+
# # wse_r_u_max = 0.5 ## deprecated
56+
# )
57+
5858
#v 0001 params, pre December 2024
5959
#GLOBAL_PARAMS = list (
6060
# wse_r_u_max = 0.5,

prediagnostics/input.R

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ get_data <- function(reach_files) {
3737
time_str = var.get.nc(r_grp, "time_str")
3838
close.nc(swot)
3939

40-
# ##-------------------------------------------------------
41-
# #debugging toggle for when patched sword is not avaailable
42-
# sword_base='/nas/cee-water/cjgleason/data/SWORD/SWORDv16/netcdf/'
43-
# bleh=reach_files$sword
44-
# split1=strsplit(bleh,'/')[[1]][11]
45-
# split2=paste(strsplit(split1,'_')[[1]][1:3],collapse="_")
46-
# split3=paste0(split2,'.nc')
47-
# reach_files$sword=paste0(sword_base,split3)
48-
# ##-------------------------------------------------------
40+
# ##-------------------------------------------------------
41+
# #debugging toggle for when patched sword is not avaailable
42+
# sword_base='/nas/cee-water/cjgleason/data/SWORD/SWORDv16/netcdf/'
43+
# bleh=reach_files$sword
44+
# split1=strsplit(bleh,'/')[[1]][11]
45+
# split2=paste(strsplit(split1,'_')[[1]][1:3],collapse="_")
46+
# split3=paste0(split2,'.nc')
47+
# reach_files$sword=paste0(sword_base,split3)
48+
# ##-------------------------------------------------------
4949

5050

5151

0 commit comments

Comments
 (0)