In [1]:
# import numpy as np

# # !/usr/bin/env python3
# # -*- coding: utf-8 -*-
# """
# Created on 20181219

# @author: zhangji

# Trajection of a ellipse, Jeffery equation. 
# """

# %pylab inline
# pylab.rcParams['figure.figsize'] = (25, 11)
# fontsize = 40

# import numpy as np
# import scipy as sp
# from scipy.optimize import leastsq, curve_fit
# from scipy import interpolate
# from scipy.interpolate import interp1d
# from scipy.io import loadmat, savemat
# # import scipy.misc

# import matplotlib
# from matplotlib import pyplot as plt
# from matplotlib import animation, rc
# import matplotlib.ticker as mtick
# from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
# from mpl_toolkits.mplot3d import Axes3D, axes3d

# from sympy import symbols, simplify, series, exp
# from sympy.matrices import Matrix
# from sympy.solvers import solve

# from IPython.display import display, HTML
# from tqdm import tqdm_notebook as tqdm
# import pandas as pd
# import re
# from scanf import scanf
# import os
# import glob

# from codeStore import support_fun as spf
# from src.support_class import *
# from src import stokes_flow as sf

# rc('animation', html='html5')
# PWD = os.getcwd()
# font = {'size': 20}
# matplotlib.rc('font', **font)
# np.set_printoptions(linewidth=90, precision=5)

%load_ext autoreload
%autoreload 2

import os
import glob
import natsort 
import numpy as np
import scipy as sp
from scipy.optimize import leastsq, curve_fit
from scipy import interpolate, integrate
from scipy import spatial, signal
# from scipy.interpolate import interp1d
from scipy.io import loadmat, savemat
# import scipy.misc
# import importlib
from IPython.display import display, HTML
import pandas as pd
import pickle
import re
from scanf import scanf

import matplotlib
# matplotlib.use('agg')
from matplotlib import pyplot as plt
import matplotlib.colors as colors
from matplotlib import animation, rc
import matplotlib.ticker as mtick
from mpl_toolkits.axes_grid1.inset_locator import inset_axes, zoomed_inset_axes
from mpl_toolkits.mplot3d import Axes3D, axes3d
from mpl_toolkits.axes_grid1.axes_divider import make_axes_locatable
from mpl_toolkits.mplot3d.art3d import Line3DCollection
from matplotlib import cm

from tqdm.notebook import tqdm as tqdm_notebook
from tqdm import tqdm
from time import time
from src.support_class import *
from src import jeffery_model as jm
from codeStore import support_fun as spf
from codeStore import support_fun_table as spf_tb

# %matplotlib notebook
%matplotlib inline
rc('animation', html='html5')
fontsize = 40
PWD = os.getcwd()

In [2]:
fig = plt.figure(figsize=(2, 2))
fig.patch.set_facecolor('white')
ax0 = fig.add_subplot(1, 1, 1)



In [3]:
job_dir = 'ecoC01B05_wt0.1_psi-0a'
table_name = 'ecoC01B05_tao1_wm0.1'
t_headle = '(.*?).pickle'

In [4]:
t_dir = os.path.join(PWD, job_dir)

data = spf_tb.load_table_data_pickle_dir(t_dir, t_headle)
lst_eta = data.lst_eta
theta_max_fre = data.theta_max_fre
phi_max_fre = data.phi_max_fre
psi_max_fre = data.psi_max_fre
eta_max_fre = data.eta_max_fre
data_idx = data.data_idx.fillna(-1).astype(int)




In [13]:
# sort all frequrents
with np.printoptions(precision=10, suppress=True, threshold=1e10):
    print(np.flipud(np.sort(data.theta_max_fre.values.flatten())))


[0.068254267  0.0586605145 0.0206826103 0.0206797877 0.0206625628
 0.0206536615 0.0206417512 0.0206393922 0.0206219575 0.0206198636
 0.0206124589 0.0206093356 0.0206058682 0.0205954394 0.0205927342
 0.0205905679 0.0205809703 0.02057499   0.0205729064 0.0205595241
 0.0205586433 0.0205533853 0.0205480273 0.0205359495 0.0205337571
 0.0205336987 0.0205332124 0.0205232614 0.0205208279 0.0205145767
 0.0205113985 0.0205103503 0.0205097386 0.0205087672 0.0205078573
 0.0205051652 0.020503653  0.0204994398 0.0204990942 0.0204990712
 0.0204990296 0.0204936705 0.0204902889 0.020490214  0.0204798011
 0.0204792385 0.0204738972 0.0204695026 0.0204677492 0.0204657886
 0.0204649897 0.0204626234 0.0204549791 0.0204528295 0.0204476276
 0.0204472433 0.0204445706 0.0204443395 0.0204439012 0.0204436152
 0.0204418228 0.0204416308 0.0204404514 0.0204362001 0.020435965
 0.0204333201 0.0204319713 0.0204273595 0.020421091  0.0204201072
 0.0204190146 0.0204189978 0.0204186863 0.0204183902 0.0204116977
 0.020408393  0.0204082305 0.0204074535 0.0204057507 0.0204023901
 0.0203994237 0.0203993824 0.0203974679 0.0203973017 0.0203971328
 0.0203923751 0.0203923481 0.0203894587 0.0203888969 0.0203848292
 0.0203847344 0.0203842713 0.0203836505 0.0203828333 0.0203824205
 0.0203751733 0.0203748102 0.0203735855 0.0203731359 0.0203713169
 0.0203682913 0.0203655132 0.0203640063 0.0203625283 0.0203607419
 0.0203591435 0.0203569658 0.0203499291 0.0203499261 0.0203491416
 0.0203490075 0.0203478871 0.0203432204 0.0203384374 0.0203368099
 0.0203365098 0.0203349293 0.0203347    0.0203339149 0.0203325868
 0.0203296881 0.0203289734 0.0203242205 0.0203216327 0.0203214225
 0.0203191588 0.020317703  0.0203100145 0.020309003  0.0203065581
 0.0203064214 0.020305584  0.0203040823 0.0203015317 0.0202942846
 0.020285742  0.0202688799 0.0202669935 0.0202668959 0.0202654509
 0.0202586526 0.0202366704 0.0202194698 0.020120812  0.0201050334
 0.0200775362 0.0200681531 0.0200053123 0.0199872292 0.0199841297
 0.0199541749 0.0199313536 0.0199069735 0.0198864165 0.0198073898
 0.0197892373 0.0197838073 0.0197434923 0.019670487  0.0196587568
 0.019005542  0.0190055291 0.0190046669 0.0190037449 0.0190033781
 0.0190031865 0.0190030272 0.0190029852 0.0190028399 0.0190028224
 0.019002653  0.0190025465 0.0190024944 0.0190024784 0.0190024718
 0.0190024279 0.0190023688 0.0190023666 0.0190023341 0.019002179
 0.019002173  0.0190021598 0.0190020976 0.0190019362 0.0190017516
 0.0190016867 0.0190016827 0.0190016032 0.0190015796 0.0190015705
 0.0190015503 0.0190015209 0.0190014378 0.0190014271 0.019001411
 0.0190013643 0.0190013612 0.0190013352 0.0190013288 0.0190013244
 0.0190013126 0.0190013073 0.0190012999 0.019001297  0.0190012583
 0.0190012124 0.0190012115 0.0190011791 0.019001136  0.0190011263
 0.0190010971 0.0190010539 0.0190010459 0.0190010398 0.0190010117
 0.0190009213 0.0190008715 0.019000849  0.0190008345 0.0190008309
 0.0190008288 0.0190008046 0.0190007714 0.0190007639 0.0190007318
 0.0190007182 0.0190007177 0.0190006471 0.0190006403 0.0190006313
 0.0190006291 0.0190006034 0.0190005975 0.0190005959 0.0190005689
 0.0190005579 0.0190005377 0.0190005364 0.0190005214 0.0190005172
 0.0190005117 0.0190005048 0.0190004873 0.0190004724 0.0190004453
 0.0190004327 0.0190004257 0.0190004139 0.0190003803 0.0190003531
 0.0190002813 0.0190002584 0.0190002341 0.0190001822 0.0190001691
 0.0190001682 0.0190001611 0.0190000643 0.01900004   0.0190000154
 0.0190000024 0.018999989  0.0189999745 0.0189999501 0.0189999419
 0.0189999138 0.0189998959 0.0189998624 0.0189998322 0.018999831
 0.018999819  0.018999802  0.0189997833 0.0189997771 0.0189997758
 0.0189997646 0.0189997493 0.0189997472 0.0189997314 0.0189997259
 0.0189997157 0.0189997091 0.0189997059 0.0189997028 0.0189997002
 0.0189996962 0.0189996929 0.0189996885 0.0189996793 0.0189996625
 0.0189996577 0.0189996532 0.0189996456 0.018999626  0.0189995947
 0.0189995925 0.018999559  0.0189995494 0.0189995343 0.0189995142
 0.0189994768 0.0189994711 0.018999455  0.0189994173 0.0189993973
 0.0189993882 0.0189993846 0.0189993831 0.0189993781 0.0189993487
 0.0189993475 0.0189993349 0.0189993069 0.0189993025 0.0189992941
 0.0189992886 0.0189992817 0.0189992732 0.0189992707 0.0189992468
 0.0189992441 0.0189992415 0.018999232  0.0189992315 0.0189992264
 0.0189992222 0.0189992122 0.0189991732 0.0189991639 0.0189991631
 0.0189991427 0.0189991426 0.018999137  0.0189991262 0.0189991182
 0.0189990937 0.0189990924 0.018999091  0.018999079  0.0189990753
 0.0189990738 0.0189990435 0.0189990381 0.0189990357 0.0189990335
 0.0189990175 0.0189990043 0.0189989824 0.0189989699 0.0189989579
 0.0189989261 0.0189989221 0.0189988936 0.0189988907 0.0189988899
 0.0189988647 0.0189988533 0.0189988499 0.018998843  0.0189988283
 0.0189988251 0.0189988216 0.0189988175 0.0189988152 0.0189987997
 0.0189987986 0.0189987908 0.0189987608 0.0189987572 0.018998754
 0.0189987473 0.0189987206 0.0189987187 0.0189987182 0.0189987067
 0.0189986916 0.0189986914 0.0189986913 0.0189986887 0.0189986789
 0.0189986768 0.0189986762 0.0189986734 0.0189986578 0.0189986561
 0.0189986542 0.0189986513 0.0189986451 0.0189986406 0.0189986405
 0.0189986391 0.0189986363 0.0189986145 0.0189986069 0.0189986059
 0.0189985829 0.0189985821 0.0189985821 0.0189985821 0.0189985821
 0.0189985821 0.0189985821 0.0189985821 0.0189985821 0.0189985821
 0.0189985821 0.0189985821 0.0189985821 0.0189985821 0.0189985821
 0.0189985821 0.0189985821 0.0189985821 0.0189985821 0.0189985821
 0.0189985821 0.0189985821 0.0189985821 0.0189985821 0.0189985821
 0.0189985736 0.0189985713 0.0189985654 0.0189985642 0.0189985635
 0.0189985523 0.0189985406 0.0189985403 0.0189985321 0.0189985132
 0.0189985084 0.0189985039 0.0189984845 0.0189984816 0.0189984637
 0.0189984452 0.0189984383 0.0189984379 0.0189984356 0.0189984288
 0.0189984276 0.0189984254 0.0189984127 0.0189984041 0.0189984035
 0.0189984015 0.0189983971 0.0189983903 0.0189983868 0.0189983784
 0.0189983768 0.0189983753 0.0189983744 0.0189983647 0.0189983645
 0.0189983626 0.0189983546 0.0189983543 0.0189983536 0.0189983506
 0.0189983487 0.0189983264 0.0189983262 0.0189983227 0.0189983163
 0.0189983114 0.0189983097 0.0189983068 0.0189983066 0.0189982979
 0.0189982943 0.0189982906 0.0189982855 0.0189982839 0.0189982668
 0.0189982648 0.0189982635 0.0189982628 0.0189982625 0.0189982592
 0.0189982534 0.0189982524 0.0189982395 0.0189982382 0.0189982314
 0.0189982188 0.0189982089 0.0189982079 0.018998163  0.0189981555
 0.0189981499 0.0189981434 0.0189981348 0.0189981316 0.0189981261
 0.0189981074 0.0189981057 0.0189981042 0.0189981017 0.0189980918
 0.0189980893 0.0189980871 0.018998077  0.0189980722 0.0189980692
 0.0189980611 0.0189980543 0.0189980507 0.0189980495 0.0189980402
 0.0189980329 0.0189980204 0.0189980116 0.0189979771 0.018997977
 0.0189979587 0.018997956  0.0189979377 0.018997937  0.018997928
 0.0189979209 0.0189979157 0.0189979088 0.0189979068 0.018997905
 0.018997904  0.0189978985 0.0189978933 0.0189978933 0.0189978841
 0.0189978828 0.0189978823 0.0189978792 0.0189978749 0.0189978712
 0.0189978707 0.0189978598 0.0189978522 0.0189978503 0.0189978351
 0.0189978266 0.0189978249 0.0189978189 0.0189978109 0.0189977928
 0.0189977831 0.0189977816 0.0189977785 0.018997777  0.0189977744
 0.0189977738 0.0189977736 0.0189977665 0.0189977594 0.0189977493
 0.0189977415 0.0189977371 0.0189977226 0.0189977214 0.0189977106
 0.0189977097 0.0189976937 0.0189976928 0.0189976683 0.0189976626
 0.0189976485 0.0189976466 0.0189976218 0.018997615  0.0189976107
 0.0189976073 0.0189976033 0.0189975948 0.0189975714 0.0189975685
 0.0189975633 0.018997553  0.0189975404 0.0189975344 0.0189975328
 0.0189975238 0.0189975172 0.018997512  0.0189975107 0.0189975064
 0.0189975024 0.0189974929 0.0189974801 0.0189974791 0.0189974782
 0.0189974616 0.0189974582 0.0189974448 0.0189974401 0.0189974347
 0.018997433  0.0189974329 0.0189974305 0.0189974115 0.0189974062
 0.0189974045 0.0189974041 0.0189974031 0.0189973989 0.0189973873
 0.0189973836 0.0189973725 0.0189973685 0.0189973662 0.0189973636
 0.0189973556 0.0189973388 0.018997327  0.0189973183 0.0189973061
 0.0189973036 0.0189973025 0.0189972936 0.0189972897 0.0189972889
 0.0189972858 0.0189972812 0.0189972792 0.0189972634 0.0189972634
 0.018997237  0.0189972231 0.0189972227 0.0189972131 0.0189971982
 0.0189971859 0.0189971857 0.0189971753 0.0189971701 0.0189971443
 0.0189971216 0.0189971076 0.0189971043 0.0189970826 0.0189970686
 0.0189970654 0.0189970562 0.0189970239 0.0189970222 0.0189970203
 0.0189970089 0.0189970079 0.0189970068 0.0189970016 0.0189969658
 0.0189969607 0.0189969509 0.0189969376 0.0189969376 0.0189969322
 0.0189969305 0.0189969195 0.018996901  0.0189969003 0.0189968918
 0.0189968651 0.0189968651 0.0189968634 0.0189968583 0.0189968562
 0.018996843  0.0189967909 0.0189967764 0.0189967588 0.0189967562
 0.0189967456 0.0189967355 0.0189967204 0.0189967193 0.0189967167
 0.018996713  0.0189966785 0.0189966511 0.0189966453 0.0189966364
 0.0189966206 0.0189965607 0.0189964746 0.0189964482 0.018996428
 0.0189964041 0.0189962434 0.016999276  0.0169968398 0.0160062452
 0.0160062087 0.0160052584 0.0160051508 0.0160050928 0.0160050489
 0.0160049108 0.0160048603 0.0160048061 0.016004596  0.0160044485
 0.0160044016 0.01600439   0.0160043378 0.0160041577 0.0160040046
 0.0160039601 0.0160039559 0.0160035795 0.01600357   0.01600353
 0.0160034589 0.0160034223 0.0160033389 0.0160032735 0.0160032254
 0.0160031678 0.0160031671 0.0160030978 0.0160030864 0.0160030753
 0.0160029835 0.0160029221 0.0160028605 0.0160027318 0.0160026995
 0.0160026816 0.0160025831 0.0160025766 0.0160025443 0.0160025244
 0.0160025242 0.0160024888 0.0160024771 0.0160023694 0.0160023076
 0.0160022587 0.0160021982 0.0160021653 0.0160021508 0.0160021331
 0.0160021029 0.0160020724 0.016002039  0.0160019949 0.016001896
 0.0160018868 0.0160018822 0.0160018676 0.0160018434 0.0160018376
 0.0160018161 0.0160018022 0.0160017861 0.0160017726 0.016001755
 0.0160016971 0.01600167   0.0160016561 0.0160016546 0.0160016478
 0.016001643  0.0160016377 0.0160015946 0.0160015004 0.0160014421
 0.0160014385 0.0160014268 0.0160014113 0.0160013112 0.0160012539
 0.0160012453 0.0160012253 0.0160012232 0.0160012229 0.0160012193
 0.0160011875 0.0160011765 0.0160011612 0.0160011594 0.0160011432
 0.0160011156 0.016001108  0.0160010861 0.0160010736 0.0160010546
 0.0160010208 0.0160010092 0.0160009856 0.0160009581 0.0160009517
 0.0160009433 0.0160009346 0.0160009183 0.0160008271 0.0160007825
 0.0160007725 0.0160007561 0.0160007533 0.0160007413 0.0160007238
 0.0160006988 0.0160006734 0.0160006689 0.0160006679 0.0160006601
 0.0160006532 0.0160006459 0.0160006389 0.0160005975 0.0160005911
 0.0160005903 0.0160005633 0.0160005437 0.0160005409 0.0160005377
 0.016000512  0.0160005069 0.0160004906 0.0160004811 0.0160004447
 0.0160004271 0.016000388  0.016000355  0.0160003291 0.0160002858
 0.0160002748 0.0160002745 0.0160002673 0.0160002499 0.0160002467
 0.0160002372 0.0160001877 0.0160001743 0.0160001613 0.0160001479
 0.0160001337 0.0160001242 0.0160001206 0.0160001041 0.0160000891
 0.0160000816 0.0160000452 0.0160000366 0.0160000319 0.0159999687
 0.0159999448 0.0159999232 0.0159998861 0.0159998801 0.0159998546
 0.0159998168 0.0159998073 0.0159997887 0.0159997801 0.0159997735
 0.0159997409 0.0159997283 0.015999698  0.0159996976 0.0159996863
 0.0159996744 0.0159996613 0.0159996317 0.0159996317 0.0159996317
 0.0159996317 0.0159996317 0.0159996317 0.0159996317 0.0159996317
 0.0159996317 0.0159996317 0.0159996317 0.0159996317 0.0159996317
 0.0159996317 0.0159996317 0.0159996317 0.0159996317 0.0159996317
 0.0159996317 0.0159996317 0.0159996317 0.0159996066 0.0159996031
 0.0159995946 0.0159995943 0.0159995668 0.0159995623 0.0159995235
 0.0159995002 0.015999482  0.0159994818 0.0159994783 0.0159994629
 0.0159994614 0.0159994589 0.0159994524 0.0159994404 0.0159993947
 0.0159993814 0.0159993773 0.0159993455 0.0159993178 0.0159993116
 0.0159992917 0.0159992245 0.0159991897 0.0159991559 0.0159991455
 0.0159991251 0.0159990657 0.0159990593 0.015999041  0.0159990264
 0.0159990198 0.0159990083 0.015999005  0.0159989841 0.0159989732
 0.0159989451 0.0159989281 0.0159989141 0.0159988961 0.0159988875
 0.0159988774 0.0159988637 0.0159988618 0.0159988542 0.0159988263
 0.0159987979 0.0159987769 0.0159987685 0.0159987488 0.0159987184
 0.0159987168 0.0159987054 0.0159986756 0.0159986749 0.0159986715
 0.0159986611 0.0159986341 0.0159986064 0.0159985894 0.015998532
 0.0159985305 0.0159985135 0.0159984981 0.0159984957 0.0159984893
 0.0159984779 0.0159984613 0.0159984478 0.015998437  0.0159984349
 0.0159984293 0.0159984193 0.0159984043 0.0159983852 0.0159983814
 0.0159983637 0.015998355  0.0159983514 0.0159983221 0.0159983129
 0.0159982692 0.015998246  0.0159982319 0.0159981803 0.015998177
 0.0159981711 0.0159981608 0.0159981551 0.0159981516 0.015998135
 0.0159981224 0.0159981134 0.0159981042 0.0159981    0.0159980964
 0.0159980947 0.0159980838 0.0159980734 0.0159980729 0.0159980332
 0.0159980305 0.0159979989 0.0159979755 0.0159979225 0.015997868
 0.0159978467 0.015997809  0.0159978036 0.0159978013 0.015997797
 0.0159976911 0.0159976881 0.015997687  0.0159976679 0.015997643
 0.015997617  0.0159975941 0.0159975528 0.0159974914 0.0159974373
 0.015997428  0.0159974087 0.0159973511 0.0159973465 0.0159973217
 0.0159973202 0.0159973095 0.0159972297 0.0159972211 0.0159971882
 0.0159971662 0.0159971605 0.0159971342 0.0159971153 0.0159970961
 0.0159970875 0.015997058  0.0159970303 0.0159969493 0.0159969212
 0.0159968589 0.0159968522 0.0159967387 0.0159967275 0.0159967028
 0.0159966582 0.0159965893 0.0159965118 0.0159964607 0.0159962407]

In [45]:
# put images with same frequence into a subdirect
check_fre_list = [0.0160, 0.0170, 0.0190]
atol_fre_list =  [0.0002, 0.0002, 0.0002]
Table_t_range = np.array((4500, np.inf))

def sub_seperate_0(i1, type_fre, iidx, Table_t_range):
    t1 = np.zeros_like(iidx[0])
    return t1

def sub_seperate_2(i1, type_fre, iidx, Table_t_range):
    theta = type_fre.index.values[iidx[0]]
    phi = type_fre.columns.values[iidx[1]]
    theta_phi_list = np.vstack((theta, phi)).T
    tuse = []
    for theta, phi in tqdm_notebook(theta_phi_list, desc='No. %d  ' % i1):
        tpick, _ = spf_tb.load_table_date_pickle(job_dir, theta, phi)
        Table_t = tpick['Table_t']
        Table_theta = tpick['Table_theta']
        Table_phi = tpick['Table_phi']
        Table_psi = tpick['Table_psi']
        
        idx = np.logical_and(Table_t >= Table_t_range[0], Table_t <= Table_t_range[1])
        tuse.append(np.max(Table_theta[idx]))
    tuse = np.hstack(tuse)
    t1 = np.ones_like(tuse)
    t1[tuse >1.9] = 0
    t1[tuse < 1.844] = 2
    return t1

# def sub_seperate_2(i1, type_fre, iidx, Table_t_range):
#     theta = type_fre.index.values[iidx[0]]
#     phi = type_fre.columns.values[iidx[1]]
#     theta_phi_list = np.vstack((theta, phi)).T
#     tuse = []
#     for theta, phi in tqdm_notebook(theta_phi_list, desc='No. %d  ' % i1):
#         tpick, _ = spf_tb.load_table_date_pickle(job_dir, theta, phi)
#         Table_t = tpick['Table_t']
#         Table_theta = tpick['Table_theta']
#         Table_phi = tpick['Table_phi']
#         Table_psi = tpick['Table_psi']
        
#         idx = np.logical_and(Table_t >= Table_t_range[0], Table_t <= Table_t_range[1])
#         tuse.append(np.max(Table_phi[idx]))
#     tuse = np.hstack(tuse)
#     t1 = np.ones_like(tuse)
#     t1[tuse < 4] = 0
#     t1[tuse > 5.1] = 2
#     return t1
    
sub_seperate = {0: sub_seperate_0, 
                1: sub_seperate_0, 
                2: sub_seperate_2, 
                3: sub_seperate_0, }

tfre = theta_max_fre.copy()
type_fre = tfre.copy()
type_fre.iloc[:, :] = -1
i0 = 0
process_total = 0
for i1, (check_fre, atol_fre) in enumerate(zip(check_fre_list[:], atol_fre_list)):
    use_idx = np.isclose(tfre, check_fre, rtol=0, atol=atol_fre)
    iidx = np.where(use_idx)
    process_total = process_total + np.sum(use_idx)
    t1 = sub_seperate[i1](i1, type_fre, iidx, Table_t_range)
    type_fre.iloc[use_idx] = i0 + t1
    i0 = i0 + 1 + np.max(t1)
    print(i0, np.sum(use_idx))

# plot one of the remaind cases
if np.any(type_fre.values == -1):
    for i3, i4 in np.vstack(np.where(type_fre.values == -1)).T:
        type_fre.iloc[i3].iloc[i4] = i0

assert np.all(type_fre.values >= 0)
type_fre2 = type_fre.copy()
type_fre2.iloc[type_fre.values == 0] = 0
type_fre2.iloc[type_fre.values == 1] = 4
type_fre2.iloc[type_fre.values == 2] = 3
type_fre2.iloc[type_fre.values == 3] = 3
type_fre2.iloc[type_fre.values == 4] = 2
type_fre2.iloc[type_fre.values == 5] = 1
spf_tb.show_traj_phase_map_type(type_fre2)
# spf_tb.save_separate_angleList_fft(job_dir, tfre, check_fre_list, atol_fre_list)


1 346
2 2
5.0 527
Out[45]:
True

In [55]:
t1 = []
for i0 in np.arange(type_fre2.values.max() + 1):
    t1.append(np.isclose(type_fre2.values, i0).sum())

print(np.sum(t1))
print(t1)
print(t1 / np.sum(t1))


1035
[346, 160, 265, 262, 2]
[0.33429952 0.15458937 0.25603865 0.2531401  0.00193237]

In [56]:
fast_mode1 = 0
figsize = np.array((16, 9)) * 0.5
dpi = 200

tipical_th_ph_list = []
for i0 in np.arange(type_fre2.values.max() + 1)[:]:
    iidx = np.where(np.isclose(type_fre2.values, i0))
    spf_tb.phase_map_show_idx(type_fre2, tipical_th_ph_list, iidx, job_dir, table_name, fast_mode=fast_mode1, )


-ini_theta 0.000000 -ini_phi 1.714000
-ini_theta 0.000000 -ini_phi 0.000000 -ini_psi 3.141593
/anaconda3/envs/py35/lib/python3.5/site-packages/matplotlib/figure.py:2369: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  warnings.warn("This figure includes Axes that are not compatible "
-ini_theta 0.143000 -ini_phi 1.856000
-ini_theta 0.142800 -ini_phi 1.856396 -ini_psi 0.000000
-ini_theta 0.000000 -ini_phi 0.000000
-ini_theta 0.000000 -ini_phi 0.000000 -ini_psi 0.000000
-ini_theta 0.143000 -ini_phi 0.143000
-ini_theta 0.142800 -ini_phi 0.142800 -ini_psi 0.000000
-ini_theta 1.999000 -ini_phi 6.140000
-ini_theta 1.999195 -ini_phi 6.140386 -ini_psi 0.000000

In [54]:
Table_t_range1 = np.array((9000, np.inf))
Table_t_range2 = np.array((9000, np.inf))
nshow = np.inf
# nshow = 2
fast_mode2 = True
figsize = np.array((16, 9)) * 0.5
dpi = 200

i0 = 3
iidx = np.where(np.isclose(type_fre2.values, i0))
spf_tb.phase_map_show_idx_list(type_fre2, iidx, job_dir, nshow=nshow, figsize=figsize, dpi=dpi, 
                               Table_t_range1=Table_t_range1, Table_t_range2=Table_t_range2, fast_mode=fast_mode2, )


Out[54]:
True

In [48]:
Table_t_range1 = np.array((4500, 6000))
Table_t_range2 = np.array((4500, 6000))
nshow = np.inf
# nshow = 2
fast_mode2 = True
figsize = np.array((16, 9)) * 0.5
dpi = 100

for i0 in np.arange(type_fre2.values.max() + 1)[:]:
    iidx = np.where(np.isclose(type_fre2.values, i0))
    spf_tb.phase_map_show_idx_list(type_fre2, iidx, job_dir, nshow=nshow, figsize=figsize, dpi=dpi, 
                                   Table_t_range1=Table_t_range1, Table_t_range2=Table_t_range2, fast_mode=fast_mode2, )



In [33]:
# for i0 in np.arange(type_fre2.values.max() + 1)[:]:
i0 = 2
Table_t_range = (4500, np.inf)

iidx = np.where(np.isclose(type_fre2.values, i0))
theta = type_fre.index.values[iidx[0]]
phi = type_fre.columns.values[iidx[1]]
theta_phi_list = np.vstack((theta, phi)).T

t1 = []
for theta, phi in theta_phi_list:
    tpick, _ = spf_tb.load_table_date_pickle(job_dir, theta, phi)
    Table_t = tpick['Table_t']
    idx = np.logical_and(Table_t >= Table_t_range[0], Table_t <= Table_t_range[1])
    Table_theta = tpick['Table_theta'][idx]
    Table_phi = tpick['Table_phi'][idx]
    Table_psi = tpick['Table_psi'][idx]
    t2 = (np.max(Table_theta), np.min(Table_theta), np.mean(Table_theta), 
          np.max(Table_phi), np.min(Table_phi), np.mean(Table_phi), 
          np.max(Table_psi), np.min(Table_psi), np.mean(Table_psi), )
    t1.append(t2)

In [35]:
figsize = np.array((16, 9))
dpi = 50

t1 = np.vstack(t1)
t1[t1[:, 0] > 1.9, :] = np.nan 
fig, axs = plt.subplots(3, 3, figsize=figsize, dpi=dpi)
for i0, axi in enumerate(axs.ravel()):
    axi.plot(t1[:, i0], '.')



In [5]:
tipical_th_ph_list = [[0.   , 1.714],
                      [0.000, 0.   ],
                      [0.000, 0.   ],
                      [0.143, 0.143],
                      [1.999, 6.140]]

tipical_th_ph_use_idx = [0, 2, 3, 4, ]
Table_t_range = np.array((4500, np.inf))
figsize = np.array((16, 9)) * 0.7
dpi = 200

tipical_th_ph_list_use = np.array(tipical_th_ph_list)[tipical_th_ph_use_idx]
label_list = np.arange(len(tipical_th_ph_list))[tipical_th_ph_use_idx]
spf_tb.show_table_theta_phi_psi_fft_list(tipical_th_ph_list_use, job_dir, label_list=label_list, figsize=figsize, dpi=dpi, 
                                         use_welch=False)
spf_tb.show_table_theta_phi_psi_fft_list(tipical_th_ph_list_use, job_dir, label_list=label_list, figsize=figsize, dpi=dpi, 
                                         use_welch=True)
spf_tb.show_table_result_list(tipical_th_ph_list_use, job_dir, label_list=label_list, Table_t_range=Table_t_range,
                              figsize=figsize, dpi=dpi)


Out[5]:
True

In [59]:
psi_lim_fct = 20
resampling_fct = 10
figsize = np.array((16, 9)) * 0.7
dpi = 200

# case_path_list = separate_fre_path_v2(type_fre2)
# color_list =     [np.array(plt.get_cmap('tab20', len(check_fre_list))(i0)[:3]).reshape((1, 3)) 
#                   for i0 in np.arange(type_fre2.values.max() + 1)]
for idx, psi_lim1 in enumerate(np.linspace(0, 2 * np.pi, psi_lim_fct * 16, endpoint=False)[::psi_lim_fct]):
    psi_lim = (psi_lim1, psi_lim1 + 2 * np.pi / (psi_lim_fct * 16))
    # create fig
    desc = '$\\psi \\in [%.3f \\pi, %.3f \\pi)$' % ((psi_lim[0] / np.pi), (psi_lim[1] / np.pi))
    fig, ax1 = plt.subplots(1, 1, figsize=figsize, dpi=dpi, subplot_kw=dict(polar=True))
    n_xticks = 32
    xticks = np.arange(n_xticks)
    ax1.set_xticks(xticks / n_xticks * 2 * np.pi)
    ax1.set_xticklabels(['$\dfrac{%d}{%d}2\pi$' % (i0, n_xticks) for i0 in xticks])
    ax1.set_yticklabels([])
    ax1.set_ylim(0, np.pi)
    fig.suptitle(desc)
    fig.tight_layout(rect=[0, 0, 1, 0.95])
    
    for i0 in np.arange(type_fre2.values.max() + 1):
        # get case_path
        iidx = np.where(np.isclose(type_fre2.values, i0))
        theta = type_fre2.index.values[iidx[0]]
        phi = type_fre2.columns.values[iidx[1]]
        theta_phi_list = np.vstack((theta, phi)).T
        case_path = []
        for theta, phi in theta_phi_list[:]:
            t_headle = 'th%5.3f_ph%5.3f_(.*?).pickle' % (theta, phi)
            filename = [filename for filename in os.listdir(job_dir)
                        if re.match(t_headle, filename) is not None][0]
            case_path.append(os.path.join(PWD, job_dir, filename))
            
        thandle = ''
        color = np.array(plt.get_cmap('tab20', int(type_fre2.values.max() + 1))(int(i0))[:3]).reshape((1, 3)) 
#         print(int(type_fre2.values.max()), i0, color)
        spf_tb.draw_phase_map_theta(case_path, color, psi_lim, axs=[ax1, ], thandle=thandle, 
                                    resampling=True, resampling_fct=resampling_fct)
    tdir = os.path.join(PWD, job_dir, 'phase_mape_fre')
    if not os.path.exists(tdir):
        os.makedirs(tdir)
    figname = os.path.join(tdir, '%04d.png' % (idx))
    fig.savefig(os.path.join(tdir, figname))
    print('save to %s' % figname)
    plt.close(fig)






save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0000.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0001.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0002.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0003.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0004.png



save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0005.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0006.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0007.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0008.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0009.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0010.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0011.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0012.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0013.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0014.png




save to /home/zhangji/stokes_flow_master/head_Force/do_calculate_table/ecoC01B05_wt0.1_psi-0a/phase_mape_fre/0015.png

In [ ]: