from sys import argv import pandas as pd import numpy as np from os import path import MoNeT_MGDrivE as monet import matplotlib.pyplot as plt from deap import base, creator, algorithms, tools import pickle as pkl import TRP_gaFun as ga import TRP_aux as aux import TRP_fun as fun from PIL import Image if monet.isNotebook(): (EXP_FNAME, TRAPS_NUM) = ('SQR_01-150-HOM', 1) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths('lab') else: (EXP_FNAME, TRAPS_NUM) = (argv[1], int(argv[2])) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths(argv[3]) (kPars, GENS) = (aux.KPARS, 1000) print('* Optimizing: {} (traps={})'.format(EXP_FNAME, TRAPS_NUM)) bgImg = '{}_BF.png'.format(EXP_FNAME) ############################################################################### # Read migration matrix and pop sites ############################################################################### pthBase = path.join(PT_DTA, EXP_FNAME) migMat = np.genfromtxt(pthBase+'_MX.csv', delimiter=',') sites = np.genfromtxt(pthBase+'_XY.csv', delimiter=',') # Sites and landscape shapes -------------------------------------------------- sitesNum = sites.shape[0] if sites.shape[1] > 2:
from os import path from sys import argv import networkx as nx # import cdlib.algorithms as cd import MoNeT_MGDrivE as monet import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import normalize from sklearn.cluster import AgglomerativeClustering import TRP_aux as aux import TRP_fun as fun from scipy.interpolate import interp1d if monet.isNotebook(): (EXP_FNAME, TRAPS_NUM) = ('UNIF_MD-200-HET', 1) (PT_DTA, PT_IMG) = aux.selectPaths('lab') else: (EXP_FNAME, TRAPS_NUM) = (argv[1], 1) (PT_DTA, PT_IMG) = aux.selectPaths(argv[2]) kPars = aux.KPARS (LAY_TRAP, STEPS, delta) = (False, 120, 0.01) ############################################################################### # Read migration matrix and pop sites ############################################################################### pth = path.join(PT_DTA, EXP_FNAME) migMat = np.genfromtxt(pth + '_MX.csv', delimiter=',') sites = np.genfromtxt(pth + '_XY.csv', delimiter=',') sitesNum = sites.shape[0] pTypes = None if sites.shape[1] > 2: pTypes = sites[:, 2]
from os import path from sys import argv import networkx as nx # import cdlib.algorithms as cd import MoNeT_MGDrivE as monet import matplotlib.pyplot as plt import seaborn as sns from sklearn.preprocessing import normalize from sklearn.cluster import AgglomerativeClustering import TRP_aux as aux import TRP_fun as fun from scipy.interpolate import interp1d if monet.isNotebook(): (EXP_FNAME, TRAPS_NUM) = ('LRG_01-350-HOM', 1) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths('lab') else: (EXP_FNAME, TRAPS_NUM) = (argv[1], 1) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths(argv[2]) kPars = aux.KPARS (LAY_TRAP, STEPS) = (False, 120) print('* Generating base plot: {}'.format(EXP_FNAME)) ############################################################################### # Read migration matrix and pop sites ############################################################################### pth = path.join(PT_DTA, EXP_FNAME) migMat = np.genfromtxt(pth + '_MX.csv', delimiter=',') sites = np.genfromtxt(pth + '_XY.csv', delimiter=',') sitesNum = sites.shape[0] pTypes = None if sites.shape[1] > 2:
import math import random import numpy as np from os import path import pandas as pd import numpy.random as rand import MoNeT_MGDrivE as monet import matplotlib.pyplot as plt from sklearn.preprocessing import normalize import TRP_aux as aux (LND, MOD) = ('Donut', 'HET') if monet.isNotebook(): (POINTS, EXP_FNAME) = (400, 'MOV_01') (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths('lab') else: POINTS = argv[1] (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths(argv[2]) ############################################################################### # Constants ############################################################################### sca = 10 (xRan, yRan) = ((-1280 / sca, 1280 / sca), (-720 / sca, 720 / sca)) # (xRan, yRan) = ((-10, 10), (-10, 10)) if MOD == 'HOM': PTS_TMAT = np.asarray([[1 / 3, 1 / 3, 1 / 3], [1 / 3, 1 / 3, 1 / 3], [1 / 3, 1 / 3, 1 / 3]]) else: PTS_TMAT = np.asarray([[0.005, 0.975, 0.020], [0.020, 0.005, 0.975], [0.975, 0.020, 0.005]]) PTYPE_PROB = [.1, .6, .3]
(fig, ax) = plt.subplots(figsize=(15, 15)) plt.imshow(tauN, vmax=1e-1, cmap='Purples', interpolation='nearest') fig.savefig(path.join(PT_IMG, EXP_FNAME + '_trapsMatrix.png'), dpi=500, bbox_inches='tight') ############################################################################### # Plot landscape ############################################################################### BBN = tauN[:sitesNum, :sitesNum] BQN = tauN[:sitesNum, sitesNum:] (LW, ALPHA, SCA) = (.125, .2, 50) (fig, ax) = plt.subplots(figsize=(15, 15)) (fig, ax) = aux.plotNetwork(fig, ax, BQN * SCA, traps, sites, [0], c='#f72585', lw=LW * 2.5, alpha=.75) (fig, ax) = aux.plotNetwork(fig, ax, BBN * SCA, sites, sites, [0], c='#2B62F7', lw=LW, alpha=ALPHA) plt.scatter(sites.T[0], sites.T[1], marker='^', color='#03045eDB',
from sys import argv import pandas as pd import numpy as np from os import path import MoNeT_MGDrivE as monet import matplotlib.pyplot as plt from deap import base, creator, algorithms, tools import pickle as pkl import TRP_gaFun as ga import TRP_aux as aux import TRP_fun as fun from PIL import Image if monet.isNotebook(): (EXP_FNAME, TRAPS_NUM) = ('MOV_01-400-HOM', 10) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths('lab') else: (EXP_FNAME, TRAPS_NUM) = (argv[1], int(argv[2])) (PT_DTA, PT_GA, PT_IMG) = aux.selectPaths(argv[3]) kPars = aux.KPARS print('* Plotting: {} (traps={})'.format(EXP_FNAME, TRAPS_NUM)) bgImg = '{}_BF.png'.format(EXP_FNAME) pklPath = path.join(PT_GA, '{}_{}_GA'.format(EXP_FNAME, str(TRAPS_NUM).zfill(2))) ############################################################################### # Read migration matrix and pop sites ############################################################################### pthBase = path.join(PT_DTA, EXP_FNAME) migMat = np.genfromtxt(pthBase + '_MX.csv', delimiter=',') sites = np.genfromtxt(pthBase + '_XY.csv', delimiter=',') # Sites and landscape shapes --------------------------------------------------