Saturday, June 30, 2012

主要的光纤连接器总结

做光学实验经常需要用到多种光纤连接器,我们实验室用到的主要有:
  • FC/PC
  • FC/APC
  • SC/PC
  • SC/APC
图示如下:
其中斜线前的部分描述的是连接器的物理连接部分,表明尾纤的连接器型号。FC是Ferrule Connector的缩写,是螺纹金属套的连接器。SC连接器是Square Connector(or Subscriber Connector or Standard Connector),是方形直插连接器。SC连接器所采用的插针与耦合套筒的结构尺寸与FC型完全相同(因此可以通过FC-SC适配器对接)。(BTW:这两种连接器都是由日本NTT公司研发,可见日本的光通信技术非常先进,特别是NTT,世界领先。) 斜线之后的部分表示光纤的实际连接部分,也就是光纤与光纤接触的部分,表明光纤接头截面工艺,即研磨方式。PC是Physic Contact的缩写,原意是物理接触的意思,插针体端面为物理端面;APC是Angled Physical Contact的缩写,插针体端面为角度物理端面。 不同的接头截面工艺图示如下:
针对这两种主要的连接器,有三种连接适配器(法兰盘):
  • FC-FC
  • SC-SC
  • SC-FC
图示如下:
更多的连接器见下图:
更多的连接适配器见下图:
图中的SM/MM表示single mode/multimode,而SX/DX则表示simplex/duplex,即是单根的还是两根一组的。 以前买过一批跳线跟法兰盘,当时查了一些资料,今天一个师弟要买激光器,问我选什么接头,居然连FC/PC、FC/APC都弄不清楚是什么东西了,总结一下,加深记忆。 更多详细信息参见:
  1. 维基-光纤连接器
  2. Fiber Optic Connector Tutorial

开始写blogger

    
  我相信,终有一天,大陆人民也可以自由使用Google的所有产品,因此我把我的所有博客转到blogger。
    

Using VIM to extract data from a text file

Yesterday, I helped one of my alumnus to deal with a text file. The task is to extract some data from the file. The file is as blow:
mbgstatus v3.4.0 (c) Meinberg 2001-2009

GPS168PCI 027110027620 (FW 1.09) at port 0xDC00/0xDFA0, irq 23
Normal Operation, 11 sats in view, 6 sats used
Osc type: TCXO LQ, DAC cal: +500, fine: +48
Date/time:  We, 2010-07-07  10:06:12.52 UTC
Signal: 100%  (GPS)
Status info: Antenna is connected
Status info: Time is synchronized
Status info: *** Receiver pos. not verified
Last sync:  We, 2010-07-07  10:06:01.00 UTC
Receiver Position:
  lat: +52.6201 lon: -1.1239 alt: 163m
  latitude:  N  52 deg 37 min 12.36 sec
  longitude: W   1 deg 07 min 25.87 sec

mbgstatus v3.4.0 (c) Meinberg 2001-2009

GPS168PCI 027110027620 (FW 1.09) at port 0xDC00/0xDFA0, irq 23
Normal Operation, 11 sats in view, 5 sats used
Osc type: TCXO LQ, DAC cal: +500, fine: +46
Date/time:  We, 2010-07-07  10:07:12.64 UTC
Signal: 100%  (GPS)
Status info: Antenna is connected
Status info: Time is synchronized
Status info: *** Receiver pos. not verified
Last sync:  We, 2010-07-07  10:07:01.00 UTC
Receiver Position:
  lat: +52.6201 lon: -1.1239 alt: 163m
  latitude:  N  52 deg 37 min 12.36 sec
  longitude: W   1 deg 07 min 25.87 sec

mbgstatus v3.4.0 (c) Meinberg 2001-2009

GPS168PCI 027110027620 (FW 1.09) at port 0xDC00/0xDFA0, irq 23
Normal Operation, 10 sats in view, 5 sats used
Osc type: TCXO LQ, DAC cal: +500, fine: +47
Date/time: We, 2010-07-07 11:02:18.44 UTC
Signal: 100% (GPS)
Status info: Antenna is connected
Status info: Time is synchronized
Status info: Receiver position has been verified
Last sync: We, 2010-07-07 11:02:01.00 UTC
Receiver Position:
lat: +52.6202 lon: -1.1241 alt: 147m
latitude: N 52 deg 37 min 12.56 sec
longitude: W 1 deg 07 min 26.85 sec
There are so so many segments of this kid of paragraphs. The data to extract is the numbers after lat and lon marks in each paragraph which means the latitude and longitude of something which come from a GPS device. One more thing is that only data that has been verified is useful, that is to say, only data in the paragraph the contains "Status info: Receiver position has been verified" is useful. The target file is to be like this:
+52.6202 -1.1241
+52.6202 -1.1241
+52.6202 -1.1241
Of course,actual data are different. At first he want to extract the data using Matlab, I don't know how to use Matlab to do this kind of stuff. Since real time process is not needed, I thought extract data use some other tools will be better. At last I thought VIM is a good candidate cause I don't need to write any language to do this, another reason I chose VIM is because I am learning VIM so I want to use it as much as I can. My strategy was quite simple, that it to delete all the stuffs that I don't need. I first deal with a single paragraph, then repeat the operation using macro. Operation is as below:
  1. Search "has been verified" using /has been verified, delete this line
  2. Start record a macro and delete two lines from here"
  3. Move to the next line
  4. Delete to the next match of line contains "has been verified" (shift V, n, d) and stop record the macro
  5. Repete this operation use the macro recorded
  6. Using block mode to delete all the columns that are not needed
That's all, I think there must be a better way to do this, someone knows?

A python clip to delete subdirectories

I wrote a short python program to delete all subdirectories with a particular name in a directory. I worte this in order to delete all the Debug directories that visual studio 2005 generated automatically for me when I was trying to back up the whole workspace on dropbox. It was a huge directory, after check all the files and subdirectories in the directory, I found out there are many useless craps that I don't have to back up together with the source files. So I wrote this code clip. But after I finished it, I  found out that by just search the subdirectorie with the name of which I want to delete, I can delete them all together. How stupid I am.  Any way, I put the code here in case someone may need it.
import shutil, os, re

NAME = "Debug"

matchpaths = []

current = os.walk(".")
for (path, dirs, files) in current:
#    print "path", path
#    print "dirs", dirs
#    print "files", files
#    print "----"

    for di in dirs:
        if di == NAME:
            matchpaths = matchpaths + [path + "\\" + di]

#print "mathpaths: ", matchpaths

#for path in matchpaths:
#    print path

for path in matchpaths:
    shutil.rmtree(path, True)
print len(matchpaths), "directories removed!"

Thursday, June 28, 2012

我读三国演义-章回体总结1-10回

第一回 宴桃园豪杰三结义 斩黄巾英雄首立功
灵帝在位,宠信宦官,十常侍当权,灵帝居然呼太监张让为“阿父”。40万余人相附跟张角发动了黄巾军起义,开创了汉末了乱世。刘关张结拜为兄弟、曹操及董卓现身。刘备一开始投刘焉,后来去老师卢植那里助战。卢植派他去打仗,不想自己却因为没钱贿赂朝庭官员被捉。刘备等救了董卓一命却因为地位太低被鄙视。
    
名句
    滚滚长江东逝水,浪花淘尽英雄。是非成败转头空。
    青山依旧在,几度夕阳红。
    白发渔樵江渚上,惯看秋月春风。一壶浊酒喜相逢。
    古今多少事,都付笑谈中。
             ——调寄《临江仙》
    
    苍天已死,黄天当立;岁在甲子,天下大吉。
    
    子治世之能臣,乱世之奸雄也。
    
第二回 张翼德怒鞭督邮 何国舅谋诛宦竖
刘备投朱儁,赢了几仗。黄巾最终被大家一起消灭,刘备因为没钱贿赂被督邮欺负,张飞看不下去怒鞭之,之后刘备离职,后投奔刘虞因打另一拨反贼有功再次当官。孙坚登场,打反贼有功当上小官。灵帝病死,何进立外甥刘协为新任皇帝。袁绍登场,一出场就出了一个馊主意,让何进请外援来解决宦官问题,遭曹操鄙视。
    
名句
    (刘备)与关、张食则同桌,寝则同床。
    
第三回 议温明董卓叱丁原 馈金珠李肃说吕布
何太后听太监的话召哥哥何进进宫欲帮他们说情,何进太笨被太监干死。袁绍、袁术等人因此杀死所有太监(可怜有些有没胡子的也被当太监干死了)。少帝刘协被太监挟持,太监被打死之后又碰到董卓。董卓因为看陈留王更聪明想废少帝而立陈留王为新任皇帝(不明白他是怎么想的,笨的皇帝不是更好控制吗?)。吕布作为丁原的保镖登场,后来因为一匹马就出卖了主子,卖主求荣认董卓为义父。
    
故事
    李儒居然是董卓的女婿。
    
第四回 废汉帝陈留践位 谋董贼孟德献刀
董卓废少帝立陈留王,少帝因写诗明志一家都被董卓害死。王允召旧臣密谋弄死董卓,曹操欲借献刀杀董卓没有成功只能跑路。陈宫登场,义释曹操并跟随他准备与之干一番大事。曹操误会杀吕伯奢一家导致陈宫离之而去。
    
名句
    宁教我负天下人,休教天下人负我。
    
第五回 发矫诏诸镇应曹公 破关兵三英战吕布
曹操回家变卖家产招兵买马起义,众多武将来投-乐进、李典、夏侯惇、夏侯渊、曹仁、曹洪等,曹操一开始就有如此多的大将,非常厉害。袁绍结连曹操一起号称奉天子密诏,招大家一起造反,有十八路诸侯响应:袁术、韩馥、孔伷、刘岱、王匡、张邈、乔瑁、袁遣、鲍信、孔融、张超、陶谦、马腾、公孙瓒、张杨、孙坚、袁绍,加上曹操刚好十八路。公孙瓒路上碰到刘备所以就带他一起来会盟。孙坚带四员大将:程普、黄盖、韩当与祖茂,董卓派华雄迎敌,祖茂中李肃之计阵亡。关羽温酒斩华雄,刘关张三英战吕布。

第六回 焚金阙董卓行凶 匿玉玺孙坚背约
董卓迁都长安,通过给有钱人安罪名弄死之后抄家、盗墓等方法赚了很多钱,薄熙来唱红打黑是不是就跟他学的啊?曹操劝大家追没人听,自己去追结果被吕布杀的大败,幸亏曹洪救了他一条狗命。孙坚捡了传国玉玺,被袁绍发现了,自此决裂,袁绍写信给刘表让他阻击孙坚。孙坚回江东路过荆州跟刘表打了一驾,自此两家结怨。
    
故事
    这个玉玺大有来头,它由和氏碧做成,李斯刻“受命于天,既寿永昌”于上。秦始皇游洞庭湖里风浪大作于是把玉玺投进湖里风浪立刻就停了,后来又有人送了回来。 王莽篡逆的时候,孝元皇太后用玉玺打人,崩掉了一个角,后来用金子补了起来。
    
第七回 袁绍磐河战公孙 孙坚跨江击刘表
袁绍利用公孙瓒,约好一起打韩馥,料到韩馥肯定会请他帮忙,于是乘机夺了人家的冀州。公孙瓒咽不下这口气,于是两家打了起来,公孙瓒幸亏有刘关张与赵云救命才没被打死。孙坚去找刘表报仇结果被用计杀死。
    
故事
    赵云这么厉害的人居然是自己冒出来帮公孙瓒的,开始还是袁绍的人,因为看袁绍不爽所以投公孙瓒。
    
第八回 王司徒巧使连环计 董太师大闹凤仪亭
王允先将貂蝉送给吕布,之后又送给董卓让他们反目,结果他们真的就反目了。貂蝉挺聪明的,把董卓跟吕布玩的团团转。

第九回 除凶暴吕布助司徒 犯长安李傕听贾诩
王允设计说皇帝要禅让,骗董卓到宫殿,吕布亲手杀手董卓。李傕、郭汜、张济、樊稠逃到西凉求王允赦免,王允不同意,于是他们听贾诩的建议起兵造反,用计拖住吕布之后攻打长安,逼死王允,要挟皇帝。
    
故事
    没想到吕布居然会考虑董卓跟他的父子关系,幸亏有王允提醒他姓吕,董卓姓董,当初杀丁原的时候为什么没有想过这个问题呢。
    蔡邕因为当初受董卓提拔而哭之,虽然多人求王允留他的双手让他可以写完汉史,但还是被王允定死罪,他的理由是当初汉武帝不杀司马迁,之后司马迁就在史书中贬之。
    
第十回 勤王室马腾举义 报父仇曹操兴师
李傕、郭汜入主长安,专权更甚董卓。马腾与韩遂兴兵勤王,李傕、郭汜用贾诩之计待他们粮尽追赶。樊稠因为有点良知没有死命追赶被贾诩设计干掉。李郭命曹操出兵镇压反贼,之后曹操干掉反贼之后收了反贼的精锐组成青州兵,又得了很多文官武将,文有荀彧、荀攸、陈昱、郭嘉等,武有于禁、典韦等,实力大增。曹操腾达了之后不忘家中父母,命人去取父亲来享福,路过徐州里徐州太守陶谦想结好曹操,派张闿护送,没想到张闿为了些许钱财杀了曹操的老爸。于是曹操以此为名出师打徐州,一路屠城盗墓来到徐州找陶谦打架。
    
故事
    荀彧是荀攸的叔叔。
    典韦投奔曹操的时候,忽然起大风,众军士一起都扶不住大旗,典韦一人扶之岿然不动。