pro rbsp_efw_spinfit_vxb_subtract_crib,probe,no_spice_load=no_spice_load,noplot=noplot,ql=ql,qa=qa,hiresl3=hiresl3
tr = timerange()
date = strmid(time_string(tr[0]),0,10)
rbspx = 'rbsp'+probe
if ~keyword_set(no_spice_load) then rbsp_load_spice_kernels
rbsp_load_state,probe=probe,/no_spice_load,datatype=['spinper','spinphase','mat_dsc','Lvec']
rbsp_efw_position_velocity_crib,/no_spice_load,/noplot
if ~keyword_set(noplot) then begin
rbsp_load_eclipse_predict,probe,date
get_data,'rbsp'+probe+'_umbra',data=eu
get_data,'rbsp'+probe+'_penumbra',data=ep
endif
if ~keyword_set(qa) then rbsp_load_efw_waveform, probe=probe, datatype = 'esvy', coord = 'uvw',/noclean
if keyword_set(qa) then rbsp_load_efw_waveform, probe=probe, datatype = 'esvy', coord = 'uvw',/noclean,/qa
if keyword_set(ql) then begin
rbsp_load_emfisis,probe=probe,/quicklook
if ~tdexists(rbspx+'_emfisis_quicklook_Mag',tr[0],tr[1]) then begin
print,'******NO QL MAG DATA TO LOAD.....rbsp_efw_DCfield_removal_crib.pro*******'
return
endif
endif else begin
if keyword_set(hiresl3) then type = 'hires' else type = '1sec'
rbsp_load_emfisis,probe=probe,coord='gse',cadence=type,level='l3'
if ~tdexists(rbspx+'_emfisis_l3_'+type+'_gse_Mag',tr[0],tr[1]) then begin
print,'******NO L3 MAG DATA TO LOAD.....rbsp_efw_DCfield_removal_crib.pro*******'
return
endif
endelse
rbsp_spinfit, rbspx + '_efw_esvy', plane_dim = 0
store_data,[rbspx+'_efw_esvy',rbspx+'_efw_esvy_spinfit_e12_a',$
rbspx+'_efw_esvy_spinfit_e12_b',rbspx+'_efw_esvy_spinfit_e12_c'],/delete
if ~tdexists(rbspx + '_efw_esvy_spinfit',tr[0],tr[1]) then begin
print,"CAN'T SPINFIT THE DATA....RETURNING"
return
endif
rbsp_cotrans, rbspx + '_efw_esvy_spinfit', rbspx + '_sfit12_mgse', /dsc2mgse
rbsp_corotation_efield,probe,date,/no_spice_load
message,"Rotating emfisis data...",/continue
if keyword_set(ql) then begin
t0 = time_double(date)
t1 = t0 + 86400.
ttst = tnames(rbspx+'_emfisis_quicklook_Mag',cnt)
if cnt eq 1 then time_clip,rbspx+'_emfisis_quicklook_Mag',t0,t1,replace=1,error=error
ttst = tnames(rbspx+'_emfisis_quicklook_Magnitude',cnt)
if cnt eq 1 then time_clip,rbspx+'_emfisis_quicklook_Magnitude',t0,t1,replace=1,error=error
get_data,rbspx +'_emfisis_quicklook_Mag',data=datt
data_att = {coord_sys:'uvw'}
dlim = {data_att:data_att}
store_data,rbspx +'_emfisis_quicklook_Mag',data=datt,dlimits=dlim
if tdexists(rbspx +'_emfisis_quicklook_Mag',tr[0],tr[1]) then begin
rbsp_decimate,rbspx +'_emfisis_quicklook_Mag', upper = 2
rbsp_spinfit,rbspx +'_emfisis_quicklook_Mag', plane_dim = 0
rbsp_cotrans,rbspx +'_emfisis_quicklook_Mag_spinfit', rbspx + '_mag_mgse', /dsc2mgse
endif
endif else begin
t0 = time_double(date)
t1 = t0 + 86400.
ttst = tnames(rbspx+'_emfisis_l3_'+type+'_gse_Mag',cnt)
if cnt eq 1 then time_clip,rbspx+'_emfisis_l3_'+type+'_gse_Mag',t0,t1,replace=1,error=error
ttst = tnames(rbspx+'_emfisis_l3_'+type+'_gse_Magnitude',cnt)
if cnt eq 1 then time_clip,rbspx+'_emfisis_l3_'+type+'_gse_Magnitude',t0,t1,replace=1,error=error
get_data,rbspx+'_emfisis_l3_'+type+'_gse_Mag',data=tmpp
if is_struct(tmpp) then begin
tinterpol_mxn,rbspx+'_spinaxis_direction_gse',tmpp.x
get_data,rbspx+'_spinaxis_direction_gse_interp',data=wsc_GSE_tmp
wsc_GSE_tmp = wsc_GSE_tmp.y
message,"Rotating emfisis l3 data, npoints:"+string(n_elements(tmpp.x)),/continue
rbsp_gse2mgse,rbspx+'_emfisis_l3_'+type+'_gse_Mag',wsc_GSE_tmp,newname=rbspx+'_mag_mgse'
endif
endelse
message,"Done rotating emfisis data...",/continue
dif_data,rbspx+'_state_vel_mgse',rbspx+'_state_vel_coro_mgse',newname='vel_total'
if tdexists('vel_total',tr[0],tr[1]) and $
tdexists(rbspx + '_mag_mgse',tr[0],tr[1]) and $
tdexists(rbspx+'_sfit12_mgse',tr[0],tr[1]) then $
rbsp_vxb_subtract,'vel_total',rbspx + '_mag_mgse',rbspx+'_sfit12_mgse'
store_data,'vel_total',/delete
join_vec,['vxb_x','vxb_y','vxb_z'],rbspx+'_vscxb'
store_data,['vxb_x','vxb_y','vxb_z'],/delete
copy_data,'Esvy_mgse_vxb_removed',rbspx+'_efw_esvy_mgse_vxb_removed_spinfit'
get_data,rbspx+'_efw_esvy_mgse_vxb_removed_spinfit', data = d
if is_struct(d) then begin
d.y[*, 1] *= 0.947d
d.y[*, 2] *= 0.947d
store_data,rbspx+'_efw_esvy_mgse_vxb_removed_spinfit', data = d
endif
add_data,rbspx+'_efw_esvy_mgse_vxb_removed_spinfit',rbspx+'_E_coro_mgse',newname=rbspx+'_efw_esvy_mgse_vxb_removed_spinfit'
options,rbspx + '_mag_mgse','ytitle','Bfield MGSE!C[nT]'
options,rbspx + '_mag_mgse','ysubtitle',''
options,rbspx+'_efw_esvy_mgse_vxb_removed_spinfit','colors',[4,1,2]
if ~keyword_set(noplot) then begin
tplot,[rbspx+'_efw_esvy_mgse_vxb_removed_spinfit']
if is_struct(eu) then timebar,eu.x,color=50
if is_struct(eu) then timebar,eu.x + eu.y,color=50
if is_struct(ep) then timebar,ep.x,color=80
if is_struct(ep) then timebar,ep.x + ep.y,color=80
endif
message,"Done with rbsp_efw_spinfit_vxb_crib...",/continue
store_data,['vxbmag','Esvy_mgse_vxb_removed','bfield_data_gei',$
rbspx+'_state_vel_coro_gei',rbspx+'_E_coro_gei',$
rbspx+'_emfisis_l3_'+type+'_gse_delta',rbspx+'_emfisis_l3_'+type+'_gse_lambda',$
rbspx+'_emfisis_l3_4sec_gse_rms',rbspx+'_emfisis_l3_4sec_gse_coordinates',$
rbspx+'_state_pos_gei',rbspx+'_efw_esvy_ccsds_data_BEB_config',$
rbspx+'_efw_esvy_ccsds_data_DFB_config',$
'bfield_data',rbspx+'_sfit12_mgse'],/delete
end