• 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


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

2017年2月6日 星期一

python 正則表達式

再不寫真的不行了, 不然每次寫都要重看一次.....記憶力真的很不好 

import re
 
method = r'.*\.txt$'
line = 'ixensor12345.txt'
answer = re.search(method,filename)
 
if bool(answer):
    print answer.group() + '   has read'
else:
    print "There has no such file named with .txt"

在搜尋條件前加上r主要是表示正式正則表達式用的 
主要是條件的設定, 因為我要找的是.txt檔. 所以我需要設定在結尾是.txt 
所以就要在最後加上$代表我前面key的東西是要做為結尾的 
而\. 是因為加反斜線要把點給取消字元符作為純點的符號,不然點在正則表達式有別的意義在 
.就是匹配點之前的任意字元,而*就是要匹配的字元可以0個到多個 
r'x.*\.txt$' 如果加上x那他只會匹配i到.txt之間的字串 
最後用group()把配到的東西全印出來
這封郵件來自 Evernote。Evernote 是您專屬的工作空間,免費下載 Evernote

python讀檔

我上週真正開始測試python的程式碼,目前最先碰到的是讀檔的部分.
幾乎要用的每個步驟都要查找,不過也總算讓我解決了問題. 之後的文章要來處理如何精熟畫圖以及python的分析模式


狀況:
我現在有三份文字檔,裡面都記錄我的rgb訊號,分別放在不同的資料夾中,必須要將他們依序讀出並且轉成我得的資訊並畫圖
問題:
1. 因為python本身讀檔方式是看.py檔在哪,就讀去同層裡的檔案,但是我必須要分別在不同資料夾中讀取,所以勢必要去告訴電腦路徑的修改
2. 因為每個檔案名稱都不同,只有附檔名是一樣的,所以要學會模糊比對(這邊學到的是正則表達式)
3. 文字檔裡面如何去篩選我要的資訊並把他們轉成字串
4. 如何做到像matlab一樣hold on 畫圖
?
import os
import re
import numpy as np
for i in range (0,3):
    path = "/Users/bobobo746/Desktop/signal_test/" + "%s" %i
    # 先設置我之後要讀的路徑位置. 而i就是照片裡的資料夾名稱0,1,2
    retval = os.getcwd()
    # os.gercwd 是要先找出當前的路徑
    print "Current root: " ,retval
    os.chdir( path )
    #chdir :change Directory
    retval = os.getcwd()
    print "Successfully change root:  %s" % retval

再來就是要如何在資料夾中找到我需要的檔案呢? 就要利用os.walk來遍歷資料夾內所有的檔案
裡面提到walk會帶出一個我當下位置所包含的東西(list),當中包含了root(根目錄),dirs(資料夾)還有files(檔案),把他們print出來確認:



for root, dirs, files in os.walk(retval):
    print "root: "+(root)
    print "dirname: %s" %(dirs)
    print"filesnames: %s " %(files)

做模糊比對,至於正則表達式的原理我之後再補上免得久了又忘掉:

s = r'\.txt'
# \. 反斜線是要取消.(點)在正則表達式的特殊含義,回歸成單純反斜線的符號
for ii in range(len(files)):  
# Use len() to get how many files in folder
    t = re.search(s,files[ii])
    if bool(t):
        print  "File:%s" %files[ii] +" is read"

下面是開始讀取訊號的部分:

       filename = files[ii]
            pos = []
            with open(filename, 'r') as file_to_read:
                lines = file_to_read.readlines()
                #readlines是讀取每行
            p_tmp = [str(i) for i in lines]
            # 讀到的都當成list格式放在p_temp
            wow = np.append(pos,p_tmp)
            # 再把他們集結
            wow = np.array(wow)
            # 轉成陣列,因為每行讀去問題,\n的字樣會出現之後便成字串會消不掉
            #,所以要先轉成陣列再利用rsrip消除 最right的: \n
            len (wow)
            wow_no_slash =[]
            for i in range(0,24000,1):
                temp = wow[i].rstrip()
            #strip是消除空白或是\n等符號,r是右邊 ,l就是左邊
                wow_no_slash = np.append(wow_no_slash,temp)
            wow_no_slash
 
            print wow_no_slash[51]
 
            find_R = 'Reaction_R:'
            find_G = 'Reaction_G:'
 
            l_list = wow_no_slash.tolist()   
            # index is a function in list , so numpy.array needs to Transform to l_list
            l_list.index(find_R)
            l_list.index(find_G)
            #print l_list[52]
            #print l_list[2888]
            Signal_R = l_list[52:l_list.index(find_G)-1]
            print Signal_R
            len(Signal_R)
 
            import matplotlib.pyplot as plt
            plt.plot(Signal_R, 'r')
           
# End read signal

    parent_path = os.path.abspath(".."
    # Back to upper layer folder
    print parent_path
plt.show()
# plt在最後放 =hold on

以下是完整原始碼:

import os
import re
import numpy as np
for i in range (0,3):
    path = "/Users/bobobo746/Desktop/signal_test/" + "%s" %i     #i in here is named as file name
    retval = os.getcwd()
    print "Current root: " ,retval
    os.chdir( path )
    retval = os.getcwd()
    print "Successfully change root:  %s" % retval

    for root, dirs, files in os.walk(retval):
        print "root: "+(root)
        print "dirname: %s" %(dirs)
        print"filesnames: %s " %(files)

    s = r'\.txt'
    for ii in range(len(files)):   # Use len() to get how many files in folder
        t = re.search(s,files[ii])
        if bool(t):
            print  "File:%s" %files[ii] +" is read"
# Start to read signal:
            filename = files[ii]
            pos = []
            with open(filename, 'r') as file_to_read:
                lines = file_to_read.readlines()

            p_tmp = [str(i) for i in lines]
            wow = np.append(pos,p_tmp)
            wow = np.array(wow)

            len (wow)
            wow_no_slash =[]
            for i in range(0,24000,1):
                temp = wow[i].rstrip()
                wow_no_slash = np.append(wow_no_slash,temp)
            wow_no_slash

            print wow_no_slash[51]

            find_R = 'Reaction_R:'
            find_G = 'Reaction_G:'

            l_list = wow_no_slash.tolist()    # index is a function in list , so numpy.array needs to Transform to l_list
            l_list.index(find_R)
            l_list.index(find_G)
            #print l_list[52]
            #print l_list[2888]
            Signal_R = l_list[52:l_list.index(find_G)-1]
            print Signal_R
            len(Signal_R)

            import matplotlib.pyplot as plt
            plt.plot(Signal_R, 'r')
            #plt.show()
# End read signal
            print "\n"
        else:
            print "nothing"
    parent_path = os.path.abspath("..")   # Back to upper layer folder
    print parent_path
plt.show()





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