def compute_col_pos(xz,xy,col_pos_end, col_pos_interval, col_pos_number): ##DESCRIPTION: ##returns rounded values of cumulative displacements ##INPUT: ##xz; dataframe; horizontal linear displacements along the planes defined by xa-za ##xy; dataframe; horizontal linear displacements along the planes defined by xa-ya ##col_pos_end; string; right bound for generating dates ##col_pos_interval; string ; interval between two adjacent column position dates ##col_pos_number; integer; number of column position dates to plot ##OUTPUT: ##np.round(cs_x,4), np.round(cs_xz,4), np.round(cs_xy,4) #computing x from xz and xy x=pd.DataFrame(data=None,index=xz.index) num_nodes=len(xz.columns.tolist()) for n in np.arange(1,1+num_nodes): x[n]=gf.x_from_xzxy(seg_len, xz.loc[:,n].values, xy.loc[:,n].values) #getting dates for column positions colposdates=pd.date_range(end=col_pos_end, freq=col_pos_interval,periods=col_pos_number, name='ts',closed=None) #reversing column order revcols=xz.columns.tolist()[::-1] xz=xz[revcols] xy=xy[revcols] x=x[revcols] #getting cumulative displacements cs_x=pd.DataFrame() cs_xz=pd.DataFrame() cs_xy=pd.DataFrame() for i in colposdates: cs_x=cs_x.append(x[(x.index==i)].cumsum(axis=1),ignore_index=True) cs_xz=cs_xz.append(xz[(xz.index==i)].cumsum(axis=1),ignore_index=True) cs_xy=cs_xy.append(xy[(xy.index==i)].cumsum(axis=1),ignore_index=True) cs_x=cs_x.set_index(colposdates) cs_xz=cs_xz.set_index(colposdates) cs_xy=cs_xy.set_index(colposdates) #returning to original column order cols=cs_x.columns.tolist()[::-1] cs_xz=cs_xz[cols] cs_xy=cs_xy[cols] cs_x=cs_x[cols] #appending 0 values to bottom of column (last node) cs_x[num_nodes+1]=0 cs_xz[num_nodes+1]=0 cs_xy[num_nodes+1]=0 return np.round(cs_x,4), np.round(cs_xz,4), np.round(cs_xy,4)
def compute_col_pos(xz, xy, col_pos_end, col_pos_interval, col_pos_number, seg_len): #computing x from xz and xy x = pd.DataFrame(data=None, index=xz.index) num_nodes = len(xz.columns.tolist()) for n in np.arange(1, 1 + num_nodes): x[n] = gf.x_from_xzxy(seg_len, xz.loc[:, n].values, xy.loc[:, n].values) #getting dates for column positions colposdates = pd.date_range(end=col_pos_end, freq=col_pos_interval, periods=col_pos_number, name='ts', closed=None) #reversing column order revcols = xz.columns.tolist()[::-1] xz = xz[revcols] xy = xy[revcols] x = x[revcols] #getting cumulative displacements cs_x = pd.DataFrame() cs_xz = pd.DataFrame() cs_xy = pd.DataFrame() for i in colposdates: cs_x = cs_x.append(x[(x.index == i)].cumsum(axis=1), ignore_index=True) cs_xz = cs_xz.append(xz[(xz.index == i)].cumsum(axis=1), ignore_index=True) cs_xy = cs_xy.append(xy[(xy.index == i)].cumsum(axis=1), ignore_index=True) cs_x = cs_x.set_index(colposdates) cs_xz = cs_xz.set_index(colposdates) cs_xy = cs_xy.set_index(colposdates) #returning to original column order cols = cs_x.columns.tolist()[::-1] cs_xz = cs_xz[cols] cs_xy = cs_xy[cols] cs_x = cs_x[cols] #appending 0 values to bottom of column (last node) cs_x[num_nodes + 1] = 0 cs_xz[num_nodes + 1] = 0 cs_xy[num_nodes + 1] = 0 return np.round(cs_x, 4), np.round(cs_xz, 4), np.round(cs_xy, 4)