memoryfolder

メモです

ChromeをSSD(2つ目のドライブ)にインストールして動作を早くする

具体的な方法はページの一番下の3. にあります。

1. 背景

HybridHDDをWindowsのブートドライブに使っていたんですが、ゲームをいくつか遊び始めたのでハイブリッドでは遅くて、ゲームをインストールするためのSSDを買いました。
Dドライブとしてフォーマットして、ひとまずSteamのライブラリのデフォルトフォルダはこっちに変えました。
ゲームを新しいディスクに移動するにはこれ
www.youtube.com





2. Chromeも早くしたい

さらに、普段Task ManagerでDiskのIOを使いまくっていそうなプログラムもSSDに移したいなと思い始めました(思いますよね)。
しかし、Chromeをアンインストールしてもう一度インストールしても、システムドライブのC:Users//AppData/Google/Chromeに勝手にインストールされて結局うまくいきません…


そこで、こんな記事を見つけました。

https://productforums.google.com/forum/?hl=ru#!topic/chrome/gegy49aC3m0

"Hell, you can even do this without uninstalling Chrome. Just close Chrome, and cut and paste the "Chrome" directory I mentioned anywhere you want on the D drive. Then use the Junction program to make a junction labeled "Chrome" that maps to where you just cut/pasted the Chrome directory."


つまり、C:Users//AppData/Google/ChromeをD:の好きなところに移して、

junction.exe "C:\Users\<username>\AppData\Local\Google\Chrome" "D:\Programs\chrome"

とすればOKってこと

3. 以下やり方


まず、最新のjunctionをダウンロードします。
Junction - Windows Sysinternals | Microsoft Docs
解凍したらjunction.exeをC:/Windows/system32にコピーします。

あとはC:\Users\\AppData\Local\Google\Chromeを普通にFile ExplorerでD:\Programs\にカット+ペーストして、
コマンドプロンプト

junction "C:\Users\<username>\AppData\Local\Google\Chrome" "D:\Programs\chrome"

と打つだけです。


Chromeの起動や動作が早くなりました!!!
忙しい時はタブが4−50個開いてたりするんで、これは助かります
slackやgitkrakenなど、起動に時間かかってたプログラムも同様に移動して、正常に動作しました。

Andor python wrapper

It is from ages ago, but I think this is for iXon EMCCD camera

iXon EMCCD Cameras | Ultimate Speed & Sensitivity - Andor - Oxford Instruments

The code below is also in my git repo for DMD fast feedback program used with quantum gas microscope.
GitHub - shinich1/DMDControl

I hope this helps someone working on hardware interface task in their PhD.

make sure you load from correct dll, especially look out for the ones with correct system bit (atmcd32d.dll or atmcd64.dll)!

from ctypes import *
import numpy as np
import matplotlib.pyplot as plt

DRV_SUCCESS = 20002
DRV_VXDNOTINSTALLED = 20003

dll = windll.LoadLibrary("C:/Program Files/Andor SOLIS/Drivers/atmcd32d.dll")
c_long_p=POINTER(c_long)
c_uint_p=POINTER(c_uint)
c_int_p=POINTER(c_int)
c_float_p=POINTER(c_float)
c_long_arr = c_long*262144
c_long_arrp = POINTER(c_long_arr)


dll.Initialize.argtypes=[c_char_p]
dll.Initialize.restype=c_uint
dll.GetAcquiredData.argtypes=[c_long_p,c_ulong]
dll.GetAcquiredData.restype=c_uint
dll.ShutDown.restype=c_uint
dll.GetNumberADChannels.argtypes=[c_int_p]
dll.GetNumberADChannels.restype=c_uint
dll.GetHSSpeed.restype=c_uint
dll.GetHSSpeed.argtypes=[c_int,c_int,c_int,c_float_p]
dll.GetDetector.restype=c_uint
dll.GetDetector.argtypes=[c_int_p,c_int_p]
#dll.GetNewData.argtypes = [c_long_arrp, c_int]
#dll.GetNewData.restype=c_uint
dll.WaitForAcquisition.restype=c_uint
dll.AbortAcquisition.restype=c_uint
dll.PrepareAcquisition.restype=c_uint
dll.SetShutter.restype=c_uint
dll.SetShutter.argtypes = [c_int, c_int,c_int,c_int]
dll.StartAcquisition.restype=c_uint
dll.SendSoftwareTrigger.restype=c_uint
dll.SetImage.restype=c_uint
dll.SetImage.argtypes = [c_int, c_int,c_int,c_int,c_int,c_int]
dll.GetAcquisitionTimings.argtypes=[c_float_p,c_float_p,c_float_p]
dll.GetAcquisitionTimings.restype=c_uint
dll.SetTriggerMode.restype=c_uint
dll.SetTriggerMode.argtypes=[c_int]

dll.SetExposureTime.argtypes=[c_float]
dll.SetExposureTime.restype=c_uint
dll.GetFastestRecommendedVSSpeed.argtypes=[c_int_p,c_float_p]
dll.GetFastestRecommendedVSSpeed.restype=c_uint
dll.GetNewData.argtypes=[c_long_p,c_long]
dll.GetNewData.restype=c_uint
cdll.msvcrt.malloc.restype=c_long_p

dll.SetAcquisitionMode.restype=c_uint
dll.SetAcquisitionMode.argtypes=[c_int]
dll.IsTriggerModeAvailable.argtypes=[c_int]
dll.IsTriggerModeAvailable.restype=c_uint

dll.SetExposureTime.restype=c_uint
dll.SetExposureTime.argtypes=[c_float]
dll.SetVSSpeed.restype=c_uint
dll.SetVSSpeed.argtypes=[c_int]
dll.GetNumberVSSpeeds.restype=c_uint
dll.GetNumberVSSpeeds.argtypes=[c_int_p]

##
dll.SetEMGainMode.restypes=c_uint
dll.SetEMGainMode.argtypes=[c_int]
dll.SetEMCCDGain.restypes=c_uint
dll.SetEMCCDGain.argtypes=[c_int]
dll.GetEMCCDGain.restypes=c_uint
dll.GetEMCCDGain.argtypes=[c_int_p]

dll.SetTemperature.argtypes=[c_int]
dll.SetTemperature.restype=c_int
dll.GetTemperature.argtypes=[c_int_p]
dll.GetTemperature.restype=c_int
dll.IsCoolerOn.argtypes=[c_int_p]
dll.CoolerON.restype=c_int
dll.CoolerOFF.restype=c_int

dll.GetBaselineClamp.restypes=c_int
dll.GetBaselineClamp.argtypes=[c_int_p]
dll.SetBaselineClamp.restypes=c_uint
dll.SetBaselineClamp.argtypes=[c_int]
dll.SetBaselineOffset.restypes=c_int
dll.SetBaselineOffset.argtypes=[c_int]

dll.AbortAcquisition.restypes=c_int

dll.GetBackground.argtypes=[c_long_p,c_long]
dll.GetBackground.restype=c_uint


class Andor(object):
    def __init__(self, **kwargs):
        path = "."
        c_s             =   c_char_p(path)
        self._iAD       =   c_int(0)
        self._nAD       =   c_int(0)
        self._nAD_p     =   c_int_p(self._nAD)
        self._HSS       =   c_float(0)
        self._HSS_p     =   c_float_p(self._HSS)
        self._giSize    =   c_int(992*992)
        self._extime    =   c_float(0.1)
        self._extime_p  =   c_float_p(self._extime)
        self._acc       =   c_float(0)
        self._acc_p     =   c_float_p(self._acc)
        self._kin       =   c_float(0)
        self._kin_p     =   c_float_p(self._kin)
        self._trgmode   =   c_int(10)   # trgmode10 : Software Trigger
        self._acqmode   =   c_int(1)    # acqmode=1  : Single Shot
        self._VSSpeed   =   c_int(0)
        self._EMGmode   =   c_int(2)
        self._EMGmode_p =   c_int_p(self._EMGmode)
        self._EMGain    =   c_int(10)
        self._EMGain_p  =   c_int_p(self._EMGain)
        self._gblXpixels = c_int(992)
        self._gblYpixels = c_int(992)
        self._image = np.zeros((992,992),dtype=int)
        
        self._camtemperature    = c_int(0)
        self._camtemperature_p  = c_int_p(self._camtemperature)
        self._coolerstate       = c_int(1)
        self._coolerstate_p     = c_int_p(self._coolerstate)
        self._setpoint          = -70

        self._clampstate    = c_int(0)
        self._clampstate_p  = c_int_p(self._clampstate)


        """initialize"""
        err=dll.Initialize(c_s)
        if err==DRV_SUCCESS:
            print "initialization success"
        else:
            print "initialization error %d"%(err)
            

        """PrepareAcquisition"""
        err=dll.PrepareAcquisition()
        if err==DRV_SUCCESS:
            print "PrepareAcquisition success"
        else:
            print "PrepareAcquisition error %d"%(err)
        

        """SetShutter"""
        err=dll.SetShutter(c_int(1),c_int(1),c_int(0),c_int(0))
        if err==DRV_SUCCESS:
            print "SetShutter success"
        else:
            print "SetShutter ERROR %d"%(err)
            

        """getADnumber"""
        err=dll.GetNumberADChannels(self._nAD_p)
        print "nAD %d"%(self._nAD.value)
        

        """getHSSpeed"""
        err=dll.GetHSSpeed(self._iAD,c_int(0),c_int(1),self._HSS_p)
        print "HSSpeed %f"%(self._HSS.value)
        

        """SetAcquisitionMode"""
        err=dll.SetAcquisitionMode(self._acqmode)
        if err==DRV_SUCCESS:
            print "Set to acquire Single Shot mode"
        else:
            print "SetAcquisitionMode error %d"%(err)

        """SetTriggerMode"""
        err=dll.SetTriggerMode(self._trgmode)
        if err==DRV_SUCCESS:
            print "set to Sofware trigger mode"
        else:
            print "triggermode ERROR %d"%(err)

        """SetImage"""
        err=dll.SetImage(c_int(1),c_int(1),c_int(1),self._gblXpixels,c_int(1),self._gblYpixels);
        if err==DRV_SUCCESS:
            print "SetImage success"
        else:
            print "SetImage ERROR %d"%(err)

        """Set Cooler"""
        err=dll.CoolerON()
        err=dll.SetTemperature(self._setpoint)
        dll.GetTemperature(self._camtemperature_p)
        if err==DRV_SUCCESS:
            print "Set Temperature success"
        else:
            print "SetTemperature ERROR %d"%(err)

        """SetExposureTime"""
        err=dll.SetExposureTime(self._extime)
        if err==DRV_SUCCESS:
            print "SetExposureTime success"
        else:
            print "SetExposure ERROR %d"%(err)

        """SetVSSpeed"""
        dll.GetNumberVSSpeeds(c_int_p(self._VSSpeed))
        err=dll.SetVSSpeed(c_int(self._VSSpeed.value-2))
        if err==DRV_SUCCESS:
            print "setVS success %d"%(self._VSSpeed.value)
        else:
            print "setVS ERROR %d"%(err)

        """SetEMGainMode"""
        err=dll.SetEMGainMode(self._EMGmode)
        if err==DRV_SUCCESS:
            print "SetEMGainMode liner"
        else:
            print "SetEMGainMode ERROR %d"%(err)

        """SetEMCCDGain"""
        err=dll.SetEMCCDGain(self._EMGain)
        if err==DRV_SUCCESS:
            print "SetEMCCDGain %d"%(self._EMGain.value)
        else:
            print "SetEMCCDGain ERROR %d"%(err)

        """GetAcquisitionTimings"""
        dll.GetAcquisitionTimings(self._extime_p,self._acc_p,self._kin_p);
        print "Exposure time %f s"%(self._extime.value)
        print "Accumulate %f"%(self._acc.value)
        print "Kinetic %f"%(self._kin.value)
        
        """SetBaselineClamp"""
        err=dll.SetBaselineClamp(self._clampstate)
        if err==DRV_SUCCESS:
            print "SetBaselineClamp success"
        else:
            print "SetBaselineClamp ERROR %d"%(err)

        #"""StartAcquisition"""
        #err=dll.StartAcquisition()
        #if err==DRV_SUCCESS:
        #    print "startAcquisition success"
        #else:
        #    print "startAcquisition error"

    def shutdown(self):
        """AbortAcquisition"""
        err = dll.AbortAcquisition()
        """shutdown"""
        err = dll.ShutDown()
        if err==DRV_SUCCESS:
        	print "shutdown success"
        else:
        	print "shutdown error"

    @property
    def exposuretime(self):
        return self._extime.value
    @exposuretime.setter
    def exposuretime(self,value):
        err=dll.SetExposureTime(c_float(value))
        if err==DRV_SUCCESS:
            self._extime=c_float(value)
        else:
            print "SetExposure ERROR %d"%(err)

    @property
    def setpoint(self):
        return self._setpoint
    @setpoint.setter
    def setpoint(self, value):
        err=dll.SetTemperature(c_int(value))
        if err==DRV_SUCCESS:
            self._setpoint=value
        else:
            print "Set setpoint ERROR %d"%(err)

    @property
    def cooler(self):
        dll.IsCoolerOn(self._coolerstate_p)
        return self._coolerstate.value
    @cooler.setter
    def cooler(self,state):
        if state:
            dll.CoolerON()
        else:
            dll.CoolerOFF()

    def readtemp(self):
        dll.AbortAcquisition()
        err=dll.GetTemperature(self._camtemperature_p)
        print err
        return {"temperature":self._camtemperature.value}

    @property
    def emgain(self):
        err=dll.GetEMCCDGain(self._EMGain_p)
        print err
        return self._EMGain.value
    @emgain.setter
    def emgain(self,value):
        err=dll.SetEMCCDGain(c_int(value))
        if err==DRV_SUCCESS:
            self._EMGain=c_int(value)
        else:
            print err

    @property
    def extime(self):
        err=dll.GetAcquisitionTimings(self._extime_p,self._acc_p,self._kin_p)
        #print err
        return self._extime.value
    @extime.setter
    def extime(self,value):
        err=dll.SetExposureTime(c_float(value))
        if err==DRV_SUCCESS:
            self._extime=c_float(value)
        else:
            print err
                                      
                
    def getimage(self):
        err=dll.StartAcquisition()
        if err==DRV_SUCCESS:
            dll.SendSoftwareTrigger()
            dll.WaitForAcquisition()
            dll.GetNewData(self._image.ctypes.data_as(c_long_p),self._giSize)
        else:
            print "startAcquisition error"

    def showimages(self,klen):
        for i in xrange(klen):
            self.getimage()
            plt.figure()
            plt.gray()
            plt.imshow(self._image)
            plt.colorbar()
        #plt.ion()
        plt.show()

    def settings(self):
        dll.AbortAcquisition()
        err=dll.GetTemperature(self._camtemperature_p)
        return {"iAD":self._iAD.value,"nAD":self._nAD.value,"HSS":self._HSS.value,
                "VSS":self._VSSpeed.value,"ExTime":self.extime,
                "TRG":self._trgmode.value,"ACQmode":self._acqmode.value,
                "EMGmode":self._EMGmode.value,"EMgain":self._EMGain.value,
                "temp":self._camtemperature.value}

インフォグラフィックを作る

あるプレゼンのために、量子物理が貢献しそうな身近な例をまとめてインフォグラフィックを作った。

いろいろ調べた結果、無料でいいのを作ろうとしたら以下の組み合わせが最高だった。
Make Free Infographics, Reports & Charts Online | Visme
インフォグラフィックを作り、無料のベクター素材は
KissPNG - HD png images and illustrations. Free unlimited download.
Millions of PNG Images, Backgrounds and Vectors for Free Download | Pngtree


から取ってくる。こんなのができました。

f:id:sunakku:20190226064000p:plain
Quantum physics infographics, application of quantum tech in everyday life

how to use a specific pull request of a python library

I want to use qutip's pull request #815. Recently I git checkout this as explained in
how to checkout to a specific pull request - memoryfolder

Now I'd like to actually use this. First, I need to uninstall the module

C:\>conda uninstall qutip
...

Then,

C:\>cd code/qutip

C:\code\qutip>python setup.py install
...

I'm ready to use it!

Returning Macbook Pro bought at apple store

Apple has very flexible return policy.
I bought MacBook Pro 2018 with 512GB storage, but thought I'd want 16 gigs of RAM instead of default 8. I returned and got full refund, no questions asked.

The beats solo 3, that came for free with the mac, was without the box, they just took it as it is and did full refund.
It may depend on the condition and not applicable to all cases, but until 14 days after purchase you can expect full refund.

One point to note is, if you buy from apple stores you have to return to one of their stores, whereas if you buy from apple.com you can either ship it or bring to stores.
I should have bought online (I had to go to reading just for this..)

一時帰国持ち物リスト

年に4-5回日本に帰ってます。必要な持ち物たまに忘れてつらいのでメモ

  1. Mac電源アダプタの、コンセント部分(ヨーロッパ版と日本版両方)
  2. ゼムクリップ1個財布とかに入れとく(Sim入れ替えるため)
  3. 使い捨て歯ブラシ
  4. マスクとトローチ
  5. 頭痛薬とベンザブロック
  6. to be added

Boseノイズキャンセリングヘッドホンほしい。


Todo

  1. Registered traveller登録して空港で列に並ばなくてもいいようにする - done!

Registered Traveller: faster entry through the UK border - GOV.UK

bloch sphere drawing

bored from talks.

import numpy as np
from qutip import *

if __name__ = '__main__':

	dist2d = np.random.normal(scale=0.1,size=(2,500))
	plt.hist(dist2d[1,:])

	b = Bloch()
	# T
	theta = np.pi/4 + dist2d[1,:]/10
	phi = np.pi*0 + dist2d[0,:]*2
	x = np.sin(theta)*np.cos(phi)
	y = np.sin(theta)*np.sin(phi)
	z = np.cos(theta)
	theta = np.pi/3 + dist2d[1,:]
	phi = np.pi*0 + dist2d[0,:]/10
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))

	# e
	theta = np.pi*0.36 + 0.2*np.cos(dist2d[1,:]*2.5*np.pi-np.pi/2)
	phi = np.pi*0.15 + 0.2*np.sin(dist2d[1,:]*2.5*np.pi-np.pi/2)
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.35 + dist2d[1,:]/10
	phi = np.pi*0.15 + dist2d[0,:]
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))

	#a
	theta = np.pi*0.36 + 0.2*np.cos(dist2d[1,:]*2.5*np.pi-np.pi/3)
	phi = np.pi*0.3 + 0.2*np.sin(dist2d[1,:]*2.5*np.pi-np.pi/3)
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.36 + dist2d[1,:]*0.9
	phi = np.pi*0.34 + dist2d[1,:]*0.4+dist2d[0,:]*0.2
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))

	# m
	theta = np.pi*0.36 + dist2d[1,:]*0.8
	phi = np.pi*0.4 + dist2d[0,:]*0.1
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.32 + 0.06*np.cos(dist2d[1,:]*2.*np.pi-np.pi)
	phi = np.pi*0.43 + 0.06*np.sin(dist2d[1,:]*2.*np.pi-np.pi)
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.36 + dist2d[1,:]*0.8
	phi = np.pi*0.45 + dist2d[0,:]*0.1
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.32 + 0.06*np.cos(dist2d[1,:]*2.*np.pi-np.pi)
	phi = np.pi*0.47 + 0.06*np.sin(dist2d[1,:]*2.*np.pi-np.pi)
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))
	theta = np.pi*0.36 + dist2d[1,:]*0.8
	phi = np.pi*0.49 + dist2d[0,:]*0.1
	x = np.concatenate((x,np.sin(theta)*np.cos(phi)))
	y = np.concatenate((y,np.sin(theta)*np.sin(phi)))
	z = np.concatenate((z,np.cos(theta)))

	vec = [x,y,z]
	b.add_points(vec)
	b.point_size = [1,1,1,1]
	b.point_color = ['r']
	b.show()

f:id:sunakku:20181006195128p:plain