Esempio n. 1
0
def create_ei(i):

    from_pos = pos_array[i]
    to_pos = pos_array[i+1]

    # initiate DeepGraph
    g = dg.DeepGraph(v)

    # create edges
    g.create_edges(connectors=corr, step_size=step_size,
                   from_pos=from_pos, to_pos=to_pos)

    # store edge table
    g.e.to_pickle('tmp/correlations/{}.pickle'.format(str(i).zfill(3)))
Esempio n. 2
0
# alternative representation of e
e['type'] = 0
e['weight'] = 0
for layer in layer_names:
    where = e[layer].notnull()
    e.loc[where, 'type'] = layer
    e.loc[where, 'weight'] = e.loc[where, layer]
e = e[['type', 'weight']]

# ## DeepGraph's Supra-Graph Representation of a MLN, $G = (V, E)$

# Above, we have processed the downloaded data into a node table ``v`` and an edge table ``e``, that correspond to the supra-graph representation of a multilayer network. This is the preferred representation of a MLN by a deep graph, since all other representations are entailed in the supra-graph's partition lattice, as we will demonstrate below.

# In[5]:

g = dg.DeepGraph(v, e)
print(g)

# Let's have a look at the node table first

# In[6]:

print(g.v)

# As you can see, there are 790 nodes in total. Each of the 10 layers,

# In[7]:

print(g.v.layer.unique())

# is comprised of 79 nodes. Every node has a feature of type ``V_N``, indicating the individual the node belongs to, and a feature of type ``layer``, corresponding to the layer the node belongs to. Each of the 790 nodes corresponds to a node-layer of the MLN representation of this data.
Esempio n. 3
0
v = pd.read_hdf(
    os.path.join(cwd, 'v.h5'),
    columns=['t', 'dtime', 'lat', 'lon', 'maxFRP', 'neigh_int', 'gl', 'cp'])

# feature functions, will be applied on each component
feature_funcs = {
    't': ['min', 'max'],
    'dtime': ['min', 'max'],
    'lat': ['mean'],
    'lon': ['mean'],
    'maxFRP': ['mean', 'sum'],
    'neigh_int': ['min'],
}

# create spatiotemporal components
g = dg.DeepGraph(v)
cp, gv = g.partition_nodes('cp', feature_funcs, return_gv=True)

# rename neighbor column
cp.loc[:, 'neigh_min'] = cp['neigh_int_min'].apply(lambda x: ndict[x])

# compute lifetime
cp.loc[:, 'duration'] = cp['t_max'] - cp['t_min'] + 1

# compute area
cp.loc[:, 'unique_gls'] = gv['gl'].nunique()
cp.loc[:, 'area'] = cp['unique_gls'] * 0.92662543305**2  # page 50 manual

# compute expansion (km^2 day^-1)
cp.loc[:, 'expansion'] = cp['area'] / cp['duration']
Esempio n. 4
0
e['weight'] = 0
for layer in layer_names:
    where = e[layer].notnull()
    e.loc[where, 'type'] = layer
    e.loc[where, 'weight'] = e.loc[where, layer]
e = e[['type', 'weight']]

# ## DeepGraph's Supra-Graph Representation of a MLN, $G = (V, E)$

# Above, we have preprocessed the downloaded data into a node table v
# and an edge table e, that correspond to the supra-graph representation
# of a multilayer network. This is the preferred representation of a MLN
# by a deep graph, since - as we will demonstrate below - all other
# representations are entailed in the supra-graph's partition lattice.

g = dg.DeepGraph(v, e)

# ======================================================================
# plot circular
# scale factor (resolution of the plot)
scale_factor = 1

# create graph_tool graph object
gtg = g.return_gt_graph(features=True, relations=True)
gtg.set_directed(False)

# build tree
t = gt.Graph()

# add nodes
nodes_by_layer = {}
Esempio n. 5
0
v.rename(columns={
    'pcp': 'r',
    'latitude': 'lat',
    'longitude': 'lon',
    'time': 'dtime',
    'itime': 'time'
},
         inplace=True)

# In[3]:

print(v)

# In[4]:

g = dg.DeepGraph(v)

# ### Plot the Data

# In[ ]:

# configure map projection
kwds_basemap = {
    'llcrnrlon': v.lon.min() - 1,
    'urcrnrlon': v.lon.max() + 1,
    'llcrnrlat': v.lat.min() - 1,
    'urcrnrlat': v.lat.max() + 1,
    'resolution': 'i'
}

# configure scatter plots
Esempio n. 6
0
def create(vector):

    #       vector=vector.sort_values('PCA', ascending=False)
    vector = vector.iloc[0:500, :]
    #       vector=vector.reset_index()
    g = dg.DeepGraph(vector)

    #       plt.plot(vector,"b")
    #       plt.show()

    def x_dist(PCA_s, PCA_t):
        dx = PCA_t - PCA_s
        return dx
#       def x_dist(Sum_s, Sum_t):
#           dx = Sum_t - Sum_s
#           return dx
#

    g.create_edges(connectors=x_dist)

    #       print(g)

    def x_dist_selector(dx, sources, targets):
        dxa = np.abs(dx)
        sources = sources[dxa <= 100]
        targets = targets[dxa <= 100]
        return sources, targets

    g.create_edges(connectors=x_dist, selectors=x_dist_selector)
    #       print(g)
    #       print(g.e)

    #       g.v.sort_values('Wavelength', inplace=True)
    #       print(g.v)
    #       g.create_edges_ft(ft_feature=('PCA', 100))
    #       print(g)

    #       def y_dist(Sum_s, Sum_t):
    #           dy = Sum_t - Sum_s
    #           return dy
    #
    #       def y_dist_selector(dy, sources, targets):
    #           dya = np.abs(dy)
    #           sources = sources[dya <= 100]
    #           targets = targets[dya <= 100]
    #           return sources, targets
    #
    #       g.create_edges_ft(ft_feature=('Wavelength',100),
    #                         connectors=y_dist,
    #                         selectors=y_dist_selector)

    gtd = g.return_gt_graph()
    return gtd


#guess=pd.read_csv("Numune/Ff.csv",sep=",",index_col=0,usecols=["Wavelength","Sum"])
#guess=guess[221.22:576.74]

#ggg=pd.DataFrame(data=guess,index=(xx in range(600)))
#print(create(guess))/
#v = pd.DataFrame({'time': [-3.6,-1.1,1.4,4., 6.3],'x': [-3.,3.,1.,12.,7.]})
#g = dg.DeepGraph(guess)
#print(g.v)
#g.create_edges_ft(ft_feature=('Wavelength', 5))
#print(g.e)