1010 "n_contacts" : "balanced.sum" ,
1111 "contact_freq" : "balanced.avg" ,
1212 "smooth_suffix" : ".smoothed" ,
13+ "n_pixels_tot" : "n_elem" ,
14+ "n_contacts_raw" : "count.sum" ,
15+ "contact_freq_raw" : "count.avg" ,
1316}
1417
1518
@@ -182,6 +185,8 @@ def _smooth_cvd_group(cvd, sigma_log10, window_sigma, points_per_sigma, cols=Non
182185 {
183186 cols ["n_pixels" ]: "sum" ,
184187 cols ["n_contacts" ]: "sum" ,
188+ cols ["n_pixels_tot" ]: "sum" ,
189+ cols ["n_contacts_raw" ]: "sum" ,
185190 }
186191 )
187192 .reset_index ()
@@ -198,6 +203,18 @@ def _smooth_cvd_group(cvd, sigma_log10, window_sigma, points_per_sigma, cols=Non
198203 points_per_sigma = points_per_sigma ,
199204 )
200205
206+ smoothed_raw_sum , smoothed_n_elem = log_smooth (
207+ cvd_smoothed [cols ["dist" ]].values .astype (np .float64 ),
208+ [
209+ cvd_smoothed [cols ["n_contacts_raw" ]].values .astype (np .float64 ),
210+ cvd_smoothed [cols ["n_pixels_tot" ]].values .astype (np .float64 ),
211+ ],
212+ sigma_log10 = sigma_log10 ,
213+ window_sigma = window_sigma ,
214+ points_per_sigma = points_per_sigma ,
215+ )
216+
217+
201218 # cvd_smoothed[cols["contact_freq"]] = cvd_smoothed[cols["n_contacts"]] / cvd_smoothed[cols["n_pixels"]]
202219
203220 cvd_smoothed [cols ["n_pixels" ] + cols ["smooth_suffix" ]] = smoothed_n_valid
@@ -207,6 +224,13 @@ def _smooth_cvd_group(cvd, sigma_log10, window_sigma, points_per_sigma, cols=Non
207224 / cvd_smoothed [cols ["n_pixels" ] + cols ["smooth_suffix" ]]
208225 )
209226
227+ cvd_smoothed [cols ["n_pixels_tot" ] + cols ["smooth_suffix" ]] = smoothed_n_elem
228+ cvd_smoothed [cols ["n_contacts_raw" ] + cols ["smooth_suffix" ]] = smoothed_raw_sum
229+ cvd_smoothed [cols ["contact_freq_raw" ] + cols ["smooth_suffix" ]] = (
230+ cvd_smoothed [cols ["n_contacts_raw" ] + cols ["smooth_suffix" ]]
231+ / cvd_smoothed [cols ["n_pixels_tot" ] + cols ["smooth_suffix" ]]
232+ )
233+
210234 return cvd_smoothed
211235
212236
@@ -291,7 +315,7 @@ def agg_smooth_cvd(
291315 )
292316
293317 cvd_smoothed .drop (
294- [cols ["n_pixels" ], cols ["n_contacts" ]], axis = "columns" , inplace = True
318+ [cols ["n_pixels" ], cols ["n_contacts" ], cols [ "n_pixels_tot" ], cols [ "n_contacts_raw" ] ], axis = "columns" , inplace = True
295319 )
296320
297321 # cvd = cvd.drop(cols["contact_freq"], axis='columns', errors='ignore')
0 commit comments