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


2017年2月28日 星期二

Machine learning

Machine learning

coursera 筆記 ,check this out :

https://www.evernote.com/shard/s675/sh/2cb1f99c-42d5-475f-b509-8e94ef45237e/1002062bec10cdced4bef47323466939

2017年2月23日 星期四

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

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 進度條心得

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 extension

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

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

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

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

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

2017年2月12日 星期日

引入js語法

引入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

2017年2月8日 星期三

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

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

2017年2月6日 星期一

python pandas 轉list 或 array

python pandas 轉list 或 array

網路上很多人推崇pandas,但我覺得他還是有它不方便的地方,先前要從txt檔轉pickle檔pandas就沒有什麼方法可以直接查找,還是要做一次轉手.
今天在畫圖的時候,發現pandas 在cuffkinks上面是非常好用沒錯,但是如果我要用plotly而不是cufflinks的話就不是那麼方便了
至少就我目前還不會啦...
所以我只能將pandas 轉 array (順便也附帶如果要轉list的方法)

df = pd.DataFrame(np.random.randn(50,1))


# 轉array:
df[0].as_matrix()
   
# 轉list:
df['0'].values.tolist()

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

python Pandas資料的刪除

python Pandas資料的刪除

資料的刪除基本上都是和網路上大家提到的方法一樣, 都是用drop的方式
但是我到的問題是:

假設我今天是有一堆數據依序讀出來然後存成了packle檔,(之後會再補上完整程式碼)
但是我必須要刪掉其中一行的數據,該怎辦?
一般是直接刪掉沒問題,但是我因為行沒有命名,主要是因為我存了一堆數據沒有必要去餵牠們命名,他們就只是我要做資料分析的訊號數據而已,如:


當刪除第2行的時候,之後就會變成 0 ,1,3 這並不是我要的
查了文檔發現並沒有針對columns做重新default的設定 只有index
所以我換了方向,只好先將原本的dataframe做轉置,然後再利用set_index的方式把 0,1,3變成 0,1,2

只是記得要再轉置回來 


原始碼:

import pandas as pd
import numpy as np
d = pd.DataFrame(np.random.rand(3,4)*10)
 
d
 
r=d.T
 
rr =r.drop([1],axis= 0)
 
rr
 
rrr =rr.reset_index(drop= True)
# drop= true will reset the index order as default
 
rrr
 
rrr.T
 
rrr.iloc[2]

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