[docs]defget_cdf_data(event_id,damagecdfrecs,recs,rec_idx_ptr,cdf_dtype):"""Get the cdf data produced by getmodel. Note that the input arrays are lists of cdf entries, namely the shape on axis=0 is the number of entries. Args: event_id (int): event_id damagecdfrecs (ndarray[damagecdfrec]): cdf record keys recs (ndarray[ProbMean]): cdf record values rec_idx_ptr (ndarray[int]): array with the indices of `rec` where each cdf record starts. cdf_dtype (np.dtype): cdf numpy dtype. Returns: data (ndarray[cdf_dtype]): cdf data extracted from recs/getmodel. """assertlen(damagecdfrecs)==len(rec_idx_ptr)-1,"Number of cdfrecs groups does not match number of cdf keys found"data=np.zeros(len(recs),dtype=cdf_dtype)Nbins=len(rec_idx_ptr)-1idx=0forgroup_idxinrange(Nbins):areaperil_id,vulnerability_id=damagecdfrecs[group_idx]forbin_index,recinenumerate(recs[rec_idx_ptr[group_idx]:rec_idx_ptr[group_idx+1]]):data[idx]["event_id"]=event_iddata[idx]["areaperil_id"]=areaperil_iddata[idx]["vulnerability_id"]=vulnerability_iddata[idx]["bin_index"]=bin_index+1data[idx]["prob_to"]=rec["prob_to"]data[idx]["bin_mean"]=rec["bin_mean"]idx+=1returndata