pro euv_sinfit_na ;;;へこんだとこはよけてsin fit ver 2020 Jan 17 revised pot_na_kodaiwinpc set_erg_var_label ;uのサインカーブ get_data,'spinphase',data=spin_data,dlim=dlim n_spin=n_elements(spin_data.x) fit_curve=fltarr(n_spin) avrg_volt=fltarr(n_spin) sinfit_volt=fltarr(n_spin) despun_voltx=fltarr(n_spin) despun_volty=fltarr(n_spin) for ispecies=0,1 do begin if ispecies eq 0 then begin get_data,'E_u_d',data=volt_data,dlim=dlim dphi = 21.9 * !pi/180.0 endif if ispecies eq 1 then begin get_data,'E_v_d',data=volt_data,dlim=dlim dphi = (21.9 + 90.0) * !pi/180.0 endif ;; for calculation f Ex,Ey in DSI ;;;; cosdphi = cos( dphi) sindphi = sin( dphi) for i=0ul,n_spin,1 do begin judg=spin_data.y[i+1]-spin_data.y[i] if judg le 0 then begin start_buffer=i+1 break endif endfor for j=start_buffer, n_spin-2,1 do begin judg=spin_data.y[j+1]-spin_data.y[j] if judg le 0 then begin end_buffer=j ;;;; average ;;;;;;;;;;;;;;;; kosu = 0 a0u = 0.0 for k=start_buffer,end_buffer do begin a0u=a0u+volt_data.y[k] kosu = kosu +1 endfor ;;k a0u = a0u/kosu a0old = a0u ;;; sin fit ;;;;;;;;;;;;;;;; a1old=0.0 b1old=0.0 ;;;; ここがi_fit_kai=0,0 ならば単にサインフィット、 0,1 だと凹み除け操作1回、 0,2 は2回;;;;;;; for i_fit_kai=0,0 do begin ;;a0u=0.0 a1u=0.0 b1u=0.0 cc=0.0 ss=0.0 cs=0.0 kosu = 0 for k=start_buffer,end_buffer do begin angrad = spin_data.y[k] * !pi/180.0 co = cos(angrad) si = sin(angrad) y_model = a1old * co + b1old * si hekomiyoke = y_model * ( volt_data.y[k] - a0old - y_model ) hekomiyoke = hekomiyoke/(a1old*a1old + b1old*b1old) if i_fit_kai eq 0 or hekomiyoke gt -0.1 then begin ;; a0u=a0u+volt_data.y[k] a1u=a1u+(volt_data.y[k] - a0old) *co b1u=b1u+(volt_data.y[k] - a0old) *si cc = cc + co*co ss = ss + si*si cs = cs + co*si kosu = kosu +1 endif endfor ;;k if kosu gt 0 then begin ;; a0u = a0u/ kosu a1u = a1u/ kosu b1u = b1u/ kosu cc = cc/kosu ss = ss/kosu cs = cs/kosu d = cc * ss - cs * cs a0old = a0u a1old = ( ss * a1u - cs * b1u )/d b1old = (-cs * a1u + cc * b1u )/d endif ;;kosu>0 endfor ;; i_fit_kai ;;; best-fit curve ;;;; for k= start_buffer,end_buffer do begin angrad = spin_data.y[k] * !pi/180.0 fit_curve[k]=a1old * cos(angrad) + b1old * sin(angrad) endfor avrg_volt[start_buffer:end_buffer] = a0old ;; despun E field ;;;;;;; dvxdsi = a1old * cosdphi - b1old * sindphi dvydsi = a1old * sindphi + b1old * cosdphi despun_voltx[start_buffer:end_buffer] = dvxdsi despun_volty[start_buffer:end_buffer] = dvydsi start_buffer=end_buffer+1l endif endfor ;;j sinfit_volt = avrg_volt + fit_curve fit_curve_half= fit_curve/2. if ispecies eq 0 then begin store_data,'sinecurve_of_Eud',data={x:volt_data.x,y:sinfit_volt} options,'sinecurve_of_Eud',colors='red',thick=1 store_data,'Eud_and_sinecurve',data=['E_u_d','sinecurve_of_Eud'] store_data,'half_sin_Eud',data={x:volt_data.x,y:fit_curve_half} options,'half_sin_Eud',colors='red',thick=1 store_data,'despun_Eudx',data={x:volt_data.x,y:despun_voltx} options,'despun_Eudx',colors='red',thick=1 store_data,'despun_Eudy',data={x:volt_data.x,y:despun_volty} options,'despun_Eudy',colors='red',thick=1 endif if ispecies eq 1 then begin store_data,'sinecurve_of_Evd',data={x:volt_data.x,y:sinfit_volt} options,'sinecurve_of_Evd',colors='blue',thick=1 store_data,'Evd_and_sinecurve',data=['E_v_d','sinecurve_of_Evd'] store_data,'half_sin_Evd',data={x:volt_data.x,y:fit_curve_half} options,'half_sin_Evd',colors='blue',thick=1 store_data,'despun_Evdx',data={x:volt_data.x,y:despun_voltx} options,'despun_Evdx',colors='blue',thick=1 store_data,'despun_Evdy',data={x:volt_data.x,y:despun_volty} options,'despun_Evdy',colors='blue',thick=1 endif endfor ;; ispecies store_data,'despun_Edx',data=['despun_Eudx','despun_Evdx'] store_data,'despun_Edy',data=['despun_Eudy','despun_Evdy'] ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; get_data,'spinphase',data=spin_data,dlim=dlim get_data,'erg_pwe_efd_l1p_Vu1_waveform_8HZ',data=u1_wavefrm_data get_data,'erg_pwe_efd_l1p_Vu2_waveform_8HZ',data=u2_wavefrm_data get_data,'erg_pwe_efd_l1p_Vv1_waveform_8HZ',data=v1_wavefrm_data get_data,'erg_pwe_efd_l1p_Vv2_waveform_8HZ',data=v2_wavefrm_data n_spin=n_elements(spin_data.x) sum_hib_u1=fltarr(n_spin) sum_hib_u2=fltarr(n_spin) sum_hib_v1=fltarr(n_spin) sum_hib_v2=fltarr(n_spin) ;;;;;;;;;;;;;;;;;;1スピン目の始まりと終わり確認;;;;;;;;;;;;;;;;;;;;;;;;;;;; for i=0,n_spin, 1 do begin judg=spin_data.y[i+1]-spin_data.y[i] if judg le 0 then begin start_buffer=i+1 break endif endfor for j=start_buffer,n_spin-2,1 do begin judg=spin_data.y[j+1]-spin_data.y[j] if judg le 0 then begin end_buffer=j sum_yui_u1=0 sum_yui_u2=0 sum_yui_v1=0 sum_yui_v2=0 kosu = 0 for i=start_buffer,end_buffer do begin sum_yui_u1=u1_wavefrm_data.y[i]+sum_yui_u1 sum_yui_u2=u2_wavefrm_data.y[i]+sum_yui_u2 sum_yui_v1=v1_wavefrm_data.y[i]+sum_yui_v1 sum_yui_v2=v2_wavefrm_data.y[i]+sum_yui_v2 kosu = kosu+1 endfor if kosu gt 0 then begin sum_yui_u1=sum_yui_u1/kosu sum_yui_u2=sum_yui_u2/kosu sum_yui_v1=sum_yui_v1/kosu sum_yui_v2=sum_yui_v2/kosu endif ;; kosu>0 sum_hib_u1[start_buffer:end_buffer]=sum_yui_u1 sum_hib_u2[start_buffer:end_buffer]=sum_yui_u2 sum_hib_v1[start_buffer:end_buffer]=sum_yui_v1 sum_hib_v2[start_buffer:end_buffer]=sum_yui_v2 start_buffer=end_buffer+1l endif endfor ;;j store_data,'u1_heikin',data={x:u1_wavefrm_data.x,y:sum_hib_u1} store_data,'u2_heikin',data={x:u2_wavefrm_data.x,y:sum_hib_u2} store_data,'v1_heikin',data={x:v1_wavefrm_data.x,y:sum_hib_v1} store_data,'v2_heikin',data={x:v2_wavefrm_data.x,y:sum_hib_v2} ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; add_data,'u1_heikin','half_sin_Eud',newname='sift_half_sin_eud' dif_data,'u2_heikin','half_sin_Eud',newname='sift_half_sin_eud2' options,'sift_half_sin_eud',colors='red',thick=2 options,'sift_half_sin_eud2',colors='red',thick=2 store_data,'u1_fit_sin',data=['erg_pwe_efd_l1p_Vu1_waveform_8HZ','sift_half_sin_eud'] store_data,'u2_fit_sin',data=['erg_pwe_efd_l1p_Vu2_waveform_8HZ','sift_half_sin_eud2'] ;;;; 各プローブ電位波形平均に v1-v2の1スピcwdン分の振幅/2を足し引き add_data,'v1_heikin','half_sin_Evd',newname='sift_half_sin_evd' dif_data,'v2_heikin','half_sin_Evd',newname='sift_half_sin_evd2' options,'sift_half_sin_evd',colors='blue',thick=2 options,'sift_half_sin_evd2',colors='blue',thick=2 store_data,'v1_fit_sin',data=['erg_pwe_efd_l1p_Vv1_waveform_8HZ','sift_half_sin_evd'] store_data,'v2_fit_sin',data=['erg_pwe_efd_l1p_Vv2_waveform_8HZ','sift_half_sin_evd2'] tplot_options,'region',[0.15,0,0.94,1];体裁整う[左端からの距離,下からの距離,よこ,分からないからそのまま] tplot,['Eud_and_sinecurve','u1ant_and_mag','u1_fit_sin','u2_fit_sin','Evd_and_sinecurve','v1ant_and_mag','v1_fit_sin','u2_fit_sin','mag_dsi_th'] ;tplot,['v1_fit_sin','v1ant_and_mag','u1_fit_sin','u1ant_and_mag','v2_fit_sin','v2ant_and_mag','u2_fit_sin','u2ant_and_mag','mag_dsi_mag','mag_dsi_th'] ;tplot,['Eud_and_sinecurve','u1ant_and_mag','u1_fit_sin','u2_fit_sin'] ;tplot,['Evd_and_sinecurve','v1ant_and_mag','v1_fit_sin','v2_fit_sin','Eud_and_sinecurve','u1ant_and_mag','u1_fit_sin','u2_fit_sin','despun_Edx','despun_Edy'] ;tplot,['Evd_and_sinecurve','v1ant_and_mag','v1_fit_sin','v2_fit_sin'] ;tplot,['v1_fit_sin','u1_fit_sin','u1ant_and_mag','v2_fit_sin','u2_fit_sin'] ;tplot,['v1_fit_sin','v1ant_and_mag','u1_fit_sin','v2_fit_sin','u2_fit_sin','mag_dsi_mag','mag_dsi_th'] end この内容を euv_sinfit_na.pro という名前でIDLWorkspaceに保存、IDLでコンパイルして使う

i_fit_kai=0,0 ならば単にサインフィット、 0,1 だと凹み除け操作1回、 0,2 は2回

書き換えてコンパイルして使う