[docs]defsummarycalc_tobin(stack,file_in,file_out,file_type,max_sample_index,summary_set_id):headers=TOOL_INFO[file_type]["headers"]dtype=TOOL_INFO[file_type]["dtype"]data=read_csv_as_ndarray(stack,file_in,headers,dtype)stream_agg_type=1stream_info=(SUMMARY_STREAM_ID<<24|stream_agg_type)# Write stream info bytenp.array([stream_info],dtype="i4").tofile(file_out)# Write sample len bytenp.array([max_sample_index],dtype="i4").tofile(file_out)# Write summary set id bytenp.array([summary_set_id],dtype="i4").tofile(file_out)curr_event_id=-1curr_summary_id=-1curr_expval=-1sidx_losses=[]sidx_loss_dtype=np.dtype([("sidx",oasis_int),("loss",oasis_float)])forrowindata:event_id=row["EventId"]summary_id=row["SummaryId"]sidx=row["SampleId"]loss=row["Loss"]expval=row["ImpactedExposure"]if(event_id!=curr_event_id)or(summary_id!=curr_summary_id)or(expval!=curr_expval):ifcurr_event_id!=-1:sidx_losses.append((0,0))np.array([curr_event_id,curr_summary_id],dtype=oasis_int).tofile(file_out)np.array([curr_expval],dtype=oasis_float).tofile(file_out)np.array(sidx_losses,dtype=sidx_loss_dtype).tofile(file_out)curr_event_id=event_idcurr_summary_id=summary_idcurr_expval=expvalsidx_losses=[]ifsidx<=max_sample_index:sidx_losses.append((sidx,loss))ifcurr_event_id!=-1:sidx_losses.append((0,0))np.array([curr_event_id,curr_summary_id],dtype=oasis_int).tofile(file_out)np.array([curr_expval],dtype=oasis_float).tofile(file_out)np.array(sidx_losses,dtype=sidx_loss_dtype).tofile(file_out)