Beispiel #1
0
base = '/data/alstottj/Langley/'
from numpy import asarray, isnan, median, unique
from scipy.stats import skew, kruskal, ks_2samp

#from rpy2 import robjects
from rpy2.robjects.packages import importr
from rpy2.robjects.vectors import FloatVector
stats = importr('stats')

import database as db
from Helix_database import Session, database_url
session = Session()
db.create_database(database_url)

import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
plots = PdfPages(base+'Langley_distributions.pdf')

import powerlaw

dependents = ['Number_of_Children', 'Parent_Child_Registration_Interval_Corrected', 'Distance_from_Parent', 'Has_Children', 'Has_Parent']
independents = ['Age', 'Gender', 'Relationship_with_Parent', 'Heard_Through_Medium', 'Same_Age_as_Parent',\
        'Same_City_as_Parent', 'Same_Country_as_Parent', 'Same_Gender_as_Parent', 'Same_Relationship_to_Parent_as_They_Had_to_Their_Parent',\
        'Heard_Through_Same_Medium_as_Parent', 'Has_Parent']


#robjects.r("data<-read.table('%s')"%(base+'LangleyRtable'))
#robjects.r("attach(data)")

for d in dependents:
    print d
Beispiel #2
0
from avalanchetoolbox import avalanches
from avalanchetoolbox import database as db
import h5py
import os

#import BCNI_database as db
#cluster=False

from Helix_database import Session, database_url
session = Session()
cluster=True
analyses_directory = '/home/alstottj/biowulf/analyses/'
swarms_directory = '/home/alstottj/biowulf/swarms/'
python_location= '/usr/local/Python/2.7.2/bin/python'

time_scales = [1, 2, 3, 4, 5, 6, 7, 8, 16, 32]
threshold_mode = 'SD'
threshold_levels = [3]
threshold_directions = ['both']
#bins = [1]
#percentiles =[99]
given_xmin_xmax = [(None, None), (1, None), (1, 'channels'), (1,102)]
event_signals = ['amplitude', 'displacement']
event_detections = ['local_extrema', 'local', 'excursion_extrema']
cascade_methods = ['grid']
spatial_samples = [('all', 'all')]
temporal_samples = [('all', 'all')]


visits = [2, 3]
tasks = ['rest']
base = '/data/alstottj/Langley/'

import pickle
G = pickle.load(open(base+'Network_parents.p'))

import database as db
from Helix_database import Session, database_url
session = Session()
db.create_database(database_url)

for n_id in G.node:
    n = G.node[n_id]
    p = db.LangleyParticipant()
    p.node_id = n['node_id']
    p.Age = n['age']
    p.City = n['city']
    p.Country = n['country']
    p.Depth_in_Invite_Chain = n['depth']
    p.Gender = n['gender']
    p.Number_of_Children = n['sigma']
    p.Has_Children = (G.out_degree()[n_id]>0)
    p.Relationship_with_Parent = n['source_from']
    p.Heard_Through_Medium = n['source_through']
    p.Join_Time = n['join_time']
    p.Latitude = n['lat']
    p.Longitude = n['lng']
    p.Has_Parent = False
    if 'parent_id' in n.keys():
        p.Has_Parent = True
        p.parent_id = n['parent_id']
        p.Parent_Child_Registration_Interval = n['wait_time']