• 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


顯示具有 ipython notebook 標籤的文章。 顯示所有文章
顯示具有 ipython notebook 標籤的文章。 顯示所有文章

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年3月8日 星期三

python opencv in MAC 視窗問題

我在mac 裡編譯python只要用到視窗跳出在關閉時都會怪怪的。
opencv的imshow()這邊就會碰到..
網路上看了以後,不知道為什麼很少人有這問題,好像多是windows系統,所以沒這問題。
osx系統的我看提問,最後也是無疾而終

我目前想到的方法:
  • 就是不用imshow 改用 skimage 裡的io.imshow()
%matplotlib

import matplotlib.pyplot as plt
from skimage import io
import cv2
import numpy as np 
#載入影像 
img = cv2.imread('Li.png')    
io.imshow(img)
plt.show()

magic 函數 %matplotlib 後面不加任何東西就是default視窗,這是可以被關閉的
或是要用notebook的特色 就 %matplotlib notebook即可。


不過pyQ我還是無法解決視窗問題=="
這封郵件來自 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

安裝jupyter notebook extension

原本的jupyter notebook其實就滿方便的,不過仍有些東西需要改進,於是就有提供立三方文檔,提供作為外掛.
以下是安裝連結:

基本上依照pip安裝即可(conda的安裝方式是linux才能所以不用參考)

安裝好後,瀏覽器重新整理或terminal重新開啟,只要在nbextension那標籤頁開啟後能看到下圖就代表成功

我主要是要能用codefolding,滿好用的.(只是快捷鍵好像無法用?)
其實還有滿多的可以嘗試看看,另外只要點擊有興趣的外掛,往下看就可以看到介紹.

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

2017年2月12日 星期日

引入js語法

這東西花了我三天去解決,自己解決出來就是爽,可是有點太耗時間,連續三天都兩點才睡...
故事:
  • 一開始是想說找看看jupyter notebook有沒有辦法跳出視窗或是inline,然後依照點選的資料夾去給定路徑,之後依照那路徑去跑資料夾內的東西做資料處理.(同 matlab的 guigetdir).  -----答案是沒有 所以只好另尋方法。
  • 那就自己做個視窗,寫個function就好摟?的確是能這樣做沒錯,上網找到gui套件都試過,pyqt ,pyqt4, wxpython, easygui, tkinter都try,在windows上測試過是沒問題,但在mac上擾人的python launcher就會跳出來當視窗,跳出來當預設對話窗是沒問題,但是就在於點完資料夾後,視窗不會消失,變成要去 force quit pytho launcher 然後還crash....上網找了好兩天也去求助stack overflow 真是沒解-----最後也只好放棄。
  • 最後想到jupyter notebook 是用瀏覽器做編譯,而瀏覽器通常在存檔或取檔的時候也會開視窗,那不如找看看有沒有辦法讓瀏覽器開視窗-----這方法最後可行,不過也遇到問題。
  • 瀏覽器有個限制,就是基於隱私權, 無法取得絕對路徑......-----真是沒步了,只好妥協...我至少做到的功能是讓使用者先依照我指示的路徑放置資料夾,然後透過程式能夠點選他的資料夾(目的是讓電腦能取得資料夾名稱),這樣就能設置完整的路徑了。   
要用瀏覽器功能,自然就是要用網頁語法,jupyter notebook 被稱之為膠水語言,就厲害在他也能夠導入網頁語言然後一併使用!

JavaScript & Html5
jupyter notebook 的magic功能裡就有支援:
%% javascript
%% html
特色在於他們只運作在有寫magic的cell裡面,到下個cell就沒用了。
不過好處是他們看來比較簡潔,不需要去寫script 的框架.所以有好有壞啦

因為我之後需要用 %run 導入,magic的限制cell裡才能使用的功能對我來說就很不便.
所以只好再找其他方式:
from IPython.display import HTML
這是ipython裡的寫法,雖是舊式寫法,但是能滿足我的需求。
因為我暫時沒打算再去學js語法,所以找資料夾的寫法就直接上網找了下:

from IPython.display import HTML
input_form = """
<div >
<span style="color:#DC143C;">[ REMINDER ] </span>Make sure your folfer is placed under: 
/Users/bobobo746/Desktop/stuff/python/LEARNING/
</div>     
<input type="file" id="FileUpload" 
onchange="selectFolder(event)" 
webkitdirectory mozdirectory msdirectory odirectory directory multiple />
"""

input_form2 = """
<script type="text/javascript">
function selectFolder(e) {
  var theFiles = e.target.files;
  var relativePath = theFiles[0].webkitRelativePath;
  var folder = relativePath.split("/");
  //alert(folder[0]);
  var var_name = 'folder_name';
  var var_id = folder[0];
  var command = var_name + " = '" + var_id + "'";
  IPython.notebook.kernel.execute(command);
  }

</script>
"""
fileloc= HTML(input_form+input_form2 )
裡面特別要說的地方:
  1.  <div> ...</div> 中間插入的就是我要標注的文字
  2.  另外標註的顏色可以在那文字的前後補:span
<div >
<span style="color:#DC143C;">[ REMINDER ] </span>Make sure your folfer is placed under: 
/Users/bobobo746/Desktop/stuff/python/LEARNING/
</div>
  1. 針對我上面語法,大致上是說我找到的folder ,會再到下一層去找所有的文件名稱,把他們都轉成string 存到 folder這個array裡面,folder[0]就是我一開始點選的資料夾名稱存放處。(alert會跳出警語視窗,這我現在不需要,所以註解掉)

再來最重的地方是要如何將js語法裡的資料拿到python用?
ipython notebook 提供了一個方式:

IPython.notebook.kernel.execute(command)

我把要在python呈現的東西放到command裡面去就能夠共用了。

  var var_name = 'folder_name';
  var var_id = folder[0];
  var command = var_name + " = '" + var_id + "'";
  IPython.notebook.kernel.execute(command);

因為要呈現:
var_name      =  '     string     ' ;
要有等號的形式出現所以要這樣表示:
var_name + "  =  ' " + var_id + " ' "; 
把    =  ' " + var_id + " '  本身當成一個字串,即 字串+字串

所以在他的規則裡,要注意的地方:
  • 我要先自己寫個變數 var var_name,這變數名稱是之後python要去讀的名稱。 
  • var var_id 這個變數是之後python會讀到的資訊
  • 再設個變數 var command  用=把上面兩個變數建立關係
  • 最後再丟到IPython.notebook.kernel.execute(command)


運行結果:


可以參考:

這封郵件來自 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