• Twitter
  • Facebook
  • Google+
  • Instagram
  • Youtube

About me

Let me introduce myself


A bit about me

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

I have more than 5 years’ experience related to manufacturing of optical design ,Camera Module and also have some experience on coding . Having years of RD experience that cooperated with international ODM/OEM partners and optics-mechanical products development/DataAnalysis/research/process.

Profile

Deepak Bhagya

Personal info

Deepak Bhagya

If I have seen further than others, it is by standing upon the shoulders of giants.

Birthday: 21 Dec 1984
Phone number: +886
Website: https://bobobo746.blogspot.com
E-mail: 2dkjd1k@gmail.com

RESUME

Know more about my past


Employment

  • 2016-future

    https://www.ixensor.com/ix_web/ @ Optical-Software Programmer

    Optical-Signal algorithm and analysis: 1). Using smart phone’s front camera as optical-analysis device to observe color signal change. 2). Color signal change is based on the blood reacts with strips. 3.) By those signal change, trying to figure out a curve line to represent the bio-reacts on strips and use those feature to construct a measurement system. 4.) Trying to improve the bias, accuracy and precision. 5.) Issues fixed. Image process algorithm: 1.) Image Recognition: Analysis the image to make sure whether the optical device’s uniformity is qualified or not. Experiment Data Build: 1.) Using SQL to build Database for Experiment data. 2.) Producing API for co-workers to access and get some data source, reducing the data collecting time. 3.) Maintaining data base and trying to improve data schemas.

  • 2013-2016

    http://www.primax.com.tw/ @ Sr.Optical and Software Engineer

    1). Camera lens optical specifications define and analysis optical issue, likes the Flare, MTF(SFR), Alignment, Optical Center, and NG-sample analysis. 3). Lens focusing image recognition: Programming an application for machine to recognize the image and focus lens. 4). Con-call and report to customer, and vendor management.

  • 2010-2013

    www.Ledlink.com @ Optical Engineer

    1/ LED lighting lens module development, LED module development of TV backlight, new module development and spec. define. 2/ Optical design of LED lighting lens, jigs design, and solve process problems. 3/ Precision process development, new film materials analysis. 4/ New patent application . 5/ Optical simulation analysis

Education

  • 2006-2009

    University of NCUE @ graduated

    bachelor of science (physics)

  • *********.

Skills & My Love

Engineer
80%
software
WorkOut
91%
Fitting
Coding
95%
Python

Portfolio

My latest projects


顯示具有 ipynb 標籤的文章。 顯示所有文章
顯示具有 ipynb 標籤的文章。 顯示所有文章

2017年3月10日 星期五

Demo_Pandas plot


%matplotlib
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
Plot
# simple plot
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df.plot()
plt.figure();
df['A'].plot()
plt.figure();
df['A'].cumsum().plot()

# subplots 提供了多張圖示出現在一畫面的方式
df.plot(subplots=True, alpha =0.5,figsize=(6, 6))

# kde: density plots
df['A'].plot(kind='kde')
Bar plot
# 看DataFrame橫向: 另外也展示了堆疊的方式(stack)
df = pd.DataFrame(np.random.rand(10, 4), columns=['A', 'B', 'C', 'D'])
df.plot(kind='bar',alpha =0.8)
df.plot(kind='bar', stacked=True)

# 橫向bar堆疊(barh)
df.plot(kind='barh',alpha =0.8, stacked=True)
Histgram plot
# 看DataFrame縱向: A,B,C,D 的高斯分佈
df = pd.DataFrame(np.random.randn(100, 4), columns=['A', 'B', 'C', 'D'])
df.plot(kind='hist',alpha= 0.8)
df.plot(kind='hist',alpha= 0.5, stacked=True,bins= 50)
plt.figure()
df['A'].plot(kind='hist',bins= 10)

# df.diff().hist 提供了多張圖示出現在一畫面的方式
df.diff().hist(color='k', alpha=0.5, bins=30)

# subplots 提供了多張圖示出現在一畫面的方式
df.plot(kind='hist',subplots=True, alpha =0.5,figsize=(6,8),color='k',bins=30)
Area plot
# 都要是正數範圍;stack 可以改為透明
df = pd.DataFrame(np.random.rand(10, 4), columns=['A', 'B', 'C', 'D'])
df.plot(kind='area',alpha=0.5)
df.plot(kind='area', stacked=False)
Scatter plot
# simple scatter plot
df = pd.DataFrame(np.random.rand(50, 6), columns=['A', 'B', 'C', 'D','E','F'])
df.plot(kind='scatter', x='A', y='B')

# a3 為 A,B,C 對應E,F,G散佈圖
a1 = df.plot(kind='scatter', x='A', y='B',color='DarkBlue', label='Group 1')
a2 = df.plot(kind='scatter',x='C',y='D',color='DarkGreen', label='Group 2',ax = a1 )
a3 = df.plot(kind='scatter',x='E',y='F',color='k', label='Group 3',alpha =0.6 ,ax = a2 )

# s為圓點大小;c代表顏色用C的資料點代表顏色強度;colormap沒寫則預設黑色
df.plot(kind='scatter', x='A', y='B',c='C', colormap='OrRd', s=60)

# s為圓點大小,用C資料來改變點大小
df.plot(kind='scatter', x='A', y='B',c='k', s=df['C']*200)

# 六角形
df.plot(kind='hexbin', x='A', y='B', gridsize=15)

                                                                       Other Example(共用)
scatter_matrix: 展示了matrix的比較圖. 
e.g: A資料自己的常態分佈圖或是A,B . A,C . A,D 的散佈圖
from pandas.tools.plotting import scatter_matrix
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
scatter_matrix(df, alpha=0.2, figsize=(6, 6), diagonal='kde')

增加右邊y軸數值
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df.A.plot(c='r')
df.B.plot(secondary_y=True, style='g')

增加右邊y軸數值與標籤
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()
ax = df.plot(secondary_y=['A', 'B'])
ax.set_ylabel('CD scale')
ax.right_ax.set_ylabel('AB scale')

針對各資料設定顏色
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()
with pd.plot_params.use('x_compat',True):
  df.A.plot(c='k')
  df.B.plot(c='m')
  df.C.plot(c='y')
  df.D.plot(c='grey')
  
提供了多張圖示出現在一畫面的方式
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()
df.plot(subplots=True, figsize=(6, 6));

df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()
# subplot 排列方法 :layout=(2, 3)->(raw,column):
df.plot(subplots=True, layout=(2, 3), figsize=(6, 6), sharex=False);
# subplot 排列方法 :指定哪個raw哪個column放哪個資料:
fig, axes = plt.subplots(nrows=2, ncols=2)
df['A'].plot(ax=axes[0,0],c='k') ; axes[0,0].set_title('A');
df['B'].plot(ax=axes[0,1],c='k',alpha =0.7); axes[0,1].set_title('B');
df['C'].plot(ax=axes[1,0],c='k',alpha= 0.4); axes[1,0].set_title('C');
df['D'].plot(ax=axes[1,1],c='k',alpha= 0.1); axes[1,1].set_title('D');

subplot ,增加cv bias mean等的資訊在table欄位
from pandas.tools.plotting import table
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()

fig,ax = plt.subplots(1, 1)
# describe():會幫忙算出cv bias mean...
# table 用來顯示欄位用的
table(ax, np.round(df.describe(), 2),loc='upper left', colWidths=[0.1, 0.1, 0.1,0.1])
df.plot(ax=ax,figsize=(10, 10))
 colormap
from pandas.tools.plotting import table
df = pd.DataFrame(np.random.randn(1000, 4), columns=['A', 'B', 'C', 'D'])
df= df.cumsum()
df.plot(colormap='Greens')










這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

2017年2月23日 星期四

python 生成器,迭代器 ;yield,return

生成器 與 迭代器, 有點難懂。看了很多次還不是很完全理解,可能是剛開始碰的例子不多,之後如果有更深體會再跟新記錄。

迭代器:  
my_list = [x*x for x in range(4)]
生成器:
my_generator = (x*x for x in range(4))
基本上是分小括號和中括號做區分。
不過如果寫在函數裡面就不用這樣分法
如果需要回傳值,return  是for 迭代器 。 yield則是for 生成器。
例子:

 def createGenerator() :
  mylist = ['a','b','c']
  em= []
  for i in range(len(mylist)) :
  empty= mylist[i]
  em.append(empty)
  return em
mygenerator = createGenerator() # create a generator
print(mygenerator) # mygenerator is an object!
回傳: ['a', 'b', 'c']

for url in createGenerator():
  pass
  print (url)
回傳:
a
b
c

 def createGenerator() :
  mylist = ['a','b','c']
  em= []
  for i in range(len(mylist)) :
  empty= mylist[i]
  em.append(empty)
  yield em
mygenerator = createGenerator() # create a generator
print(mygenerator) # mygenerator is an object!
回傳:  <generator object createGenerator at 0x05E08328>

for url in createGenerator():
  pass
  print (url)
回傳: ['a', 'b', 'c']

*  第一個例子是迭代器的結果,
用  url 進入函數 createGenerator(),由於函數裡的回傳值是return,所以吐回給url的訊息是迭代器的結果,
告訴我們依序進入mylist時得到的值。

若第一個例子直接跑函數:
createGenerator()
回傳: ['a', 'b', 'c']

*  第二個例子則是生成器的結果
碰到yield其實會終止,並跳出迴圈,下次進入時再從終止的位置繼續。
不過這個範例,我把它放到迴圈之外,所以看不出來,因為是要呈現生成器吐出的東西,
也就是說用生成器利用 for in 完成迭代器的出值方式。





這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

簡潔語法 筆記

網路上看到 python 簡潔語法筆記,覺得滿實用的。先記錄下,之後用到時可以直接來查找:

這邊寫幾個我目前覺得會遇到的:

combine兩個list :

sorting ,依照字串長度:

尋找字串,有找到回傳在list裡的位置,沒找到則回傳-1 :

dict的key找法: 

合併list 成dict的方式:
這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

2017年2月21日 星期二

Python 進度條心得

這也花超久的時間去了解,總之解決了。
原因是這樣的:

假設我現在有個資料夾,裡面有放數支手機資料夾,每隻手機資料夾裡面都還有好幾個不等的數據資料夾,在裡面又都各有個txt文檔。
當數量眾多時,有時在讀檔不確定是當機了還是還在處理數據,這時就會希望能夠有個進度條來顯示目前進度.
網路上很多基本的進度條code供參考,其實那也可以,但是看到jupyter notebook 有個互動式的進度條,覺得很酷,想拿來嘗試。
找到網路上有個人分享他寫的方式:


結果如以下的圖示:

由於他是寫成function,所以要套用我的狀況,就勢必要做修改。本來嘗試幾天有點想放棄,覺得其實也沒必要這樣麻煩,但又覺得不想放棄,所以終於讓我想到怎修改了(其實好像是自己腦筋差)
以下是我的改法,由於完整碼滿多的,所以只付上progress的部分,待我把我目標的code完成,會再一併放到github上分享:

# 進度條寫法:
import sys
from time import sleep
import re
def progress(No_folder,every =1, size=None):
  from ipywidgets import IntProgress, HTML, VBox
  from IPython.display import display
  progress = IntProgress(min=0, max=len(M_filefolder))
  label = HTML()
  box = VBox(children=[label, progress])
  display(box)
  try:
  for index, record in enumerate(M_filefolder, 1):
  #print ( index )   
  if index % every == 0:
  path_with_M_Lipid = path_with_phoneNumber +'/'+ M_filefolder[index-1]    
  temp = os.getcwd()    
  os.chdir( path_with_M_Lipid )
  path_forProgress = os.getcwd()
  for root, dirs, files in os.walk(path_forProgress):
  dirs
  files
  break
  method = r'.*\.txt$' # 用來確認檔案裡有txt
  count = 0
  countError = 0
  list_item =[]
  for item in os.listdir(path_forProgress): # 刪除刪除隱藏檔
  if not item.startswith('.') :
  list_item.append(item)

  for ii in range(len(list_item)): # Use len() to get how many files in folder
  filename = list_item[ii]
  #print filename
  answer = re.search(method,filename)
  if bool(answer):
  print answer.group ()
  count = count +1
  txtfile=(filename)
  if count == 0 :
  countError = countError+1
  if countError != 0:
  print 'Folder:[ '+'{}'.format(M_filefolder[index-1])+' ]'+' without txt file'   
  os.chdir(path_with_phoneNumber)
  os.chdir(path_)

  sleep(0.1) 
  progress.value = index
  label.value = '{index} / {size}'.format(
  index=index,
  size=len(M_filefolder)
  ) 

  yield record #回傳給url index為順序編號 record為物件內容
  except:
  progress.bar_style = 'danger'
  raise
  else:
  progress.bar_style = 'success'
  progress.value = index
  label.value = str(index )


這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

2017年2月8日 星期三

Python 如何讀.ipynb到另個.ipynb裡?

又是個惱人的東西,每次一想到新的東西想嘗試,就搞老半天
今天想到說之後要寫class,裡面會有一堆function,那一堆的函式基本上就要分開存取才比較方便.於是嘗試該怎樣import 我的函式到我目前的文檔
網路上找到大多是說要建兩個.py檔 :  __init__.py 和  filename.py
然後filename裡放入你的函式,之後在你的文檔中import進去.
遇到問題:
  1.  我因為是用jupyter notebook寫,所以檔案出來格式是  .ipynb
  2.  如果我把.ipynb 轉成.py檔,會變成 json格式 
  3.  解決二的方式為 在.py檔寫入我的函式,但很不智能
  4. import 裡面放的是定義倒沒問題,但如果我import 的是另外一群要import的函式時就會出問題了,說我哪些東西沒定義.

找了老半天終於看到magic的方法了,首先先使用:

%magic #查找是否有支援的功能

發現 %run 可以實現
%run filename  or  %run filename.ipynb

以下是實作:
  1.     首先建立個U.ipynb 檔:
import pandas as pd
import numpy as np

a= pd.DataFrame(np.random.rand(10,3),columns =['R','G','B'])
b= pd.DataFrame(np.random.rand(10,3)+1,columns =['R','G','B'])
d= pd.DataFrame(np.random.rand(10,3)*2,columns =['R','G','B'])
e= pd.DataFrame(np.random.rand(10,3)*3,columns =['R','G','B'])

  1.    (這步驟要不要都可,只是想確認增加路徑是否可行)再來把它存放到Test_Folder裡面:
  1.      新創個ipynb檔:
%run Test_Folder/U.ipynb   

a
代表我的U.ipynb有被導入,且也幫我跑了 a,b,c,d 四個dataframe ,我直接運行就可以了.

結論: 
  1. 之後我可以把function給分門別類的另外存取了.
  2. 以後也可以把需要import的一次都寫好,再一次import就好
  3. 之後搭配class應用




這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

Services

What can I do


Branding

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

Web Design

Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Donec sit amet venenatis ligula. Aenean sed augue scelerisque.

Graphic Design

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

Development

Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident.

Photography

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod. Donec sit amet venenatis ligula. Aenean sed augue scelerisque, dapibus risus sit amet.

User Experience

Quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Donec sit amet venenatis ligula. Aenean sed augue scelerisque, dapibus risus sit amet.

Contact

Get in touch with me


Adress/Street

12 Street West Victoria 1234 Australia

Phone number

+(12) 3456 789

Website

www.johnsmith.com