[docs]deflossfactors_tobin(stack,file_in,file_out,file_type):ifstr(file_in)=="-":plafactors=read_lossfactors(ignore_file_type=set(["bin"]),use_stdin=True)else:lossfactors_fp=Path(file_in)plafactors=read_lossfactors(run_dir=lossfactors_fp.parent,ignore_file_type=set(["bin"]),filename=lossfactors_fp.name)# Write the 4-byte zero headernp.array([0],dtype="i4").tofile(file_out)current_event_id=-1counter=0factors=[]fork,vinplafactors.items():ifk[0]!=current_event_id:ifcurrent_event_id!=-1:np.array([current_event_id],dtype=np.int32).tofile(file_out)np.array([counter],dtype=np.int32).tofile(file_out)forafinfactors:np.array(af,dtype=amp_factor_dtype).tofile(file_out)current_event_id=k[0]counter=0factors=[]factors.append((k[1],v))counter+=1ifcurrent_event_id!=-1:np.array([current_event_id],dtype=np.int32).tofile(file_out)np.array([counter],dtype=np.int32).tofile(file_out)forafinfactors:np.array(af,dtype=amp_factor_dtype).tofile(file_out)