@@ -126,6 +126,30 @@ def clean_df(in_df):
126
126
return out_df
127
127
128
128
129
+ def set_gate_fraction (dts , op_var = "height" , ubound = 10 , lbound = 0 ):
130
+ # Filter rows where height is not 10 or 0
131
+ fraction_mask = (dts [op_var ] != ubound ) & (dts [op_var ] != lbound )
132
+
133
+ # Apply the mask to filter the DataFrame
134
+ filtered_dts = dts [fraction_mask ]
135
+
136
+ # Group the filtered DataFrame by month
137
+ for month , group in filtered_dts .groupby (filtered_dts .index .to_period ("M" )):
138
+ # Calculate the fraction
139
+ fraction = group [op_var ].iloc [0 ] / ubound
140
+
141
+ # Get the first fraction of the month
142
+ fraction_point = int (len (group ) * fraction )
143
+ first_indices = group .index [:fraction_point ]
144
+ second_indices = group .index [fraction_point :]
145
+
146
+ # Set the first half to lbound and the second half to ubound
147
+ dts .loc [first_indices , op_var ] = lbound
148
+ dts .loc [second_indices , op_var ] = ubound
149
+
150
+ return dts
151
+
152
+
129
153
@click .command ()
130
154
@click .argument ("config_yaml" , type = click .Path (exists = True ))
131
155
@click .option (
@@ -271,6 +295,9 @@ def create_schism_bc(config_yaml, kwargs={}):
271
295
source_file , v , name , dt , p = p , interp = interp
272
296
)
273
297
dts = eval (formula ).to_frame (name ).reindex (df_rng )
298
+ if boundary_kind == "dcc_gate" :
299
+ # Need to make any Percentage between 0 and 100 and convert them to days of month open
300
+ dts = set_gate_fraction (dts .ffill (), "height" )
274
301
if interp :
275
302
dfi = ts_gaussian_filter (dts , sigma = 100 )
276
303
else :
0 commit comments