clear all
close all;clc
path_in='C:\Users\Administrator\Desktop\';
name_fgm='c1_cp_fgm_spin_20010907_v01';
path_fgm=sprintf('%s%s',path_in,name_fgm);
info=cdfinfo(path_fgm);
varname=info.Variables;
t1=cdfread(path_fgm,'Variables',varname{1});%the Epoch
fgm1=cdfread(path_fgm,'Variables',varname{3});%the data of fgm
%***********deal with the .. bad data
for i=1:length(fgm1)
FGM1(i,:)=fgm1{i};
T_fgm1(i)=todatenum(t1{i});%the datenum of time HH:MM:SS
T1{i}=datestr(T_fgm1(i),13);
end
i=find(abs(FGM1)>1e+030);
FGM1(i)=NaN;
Ts=datenum( '07-Sep-2001 19:00:00' );
Ts1=datenum( '07-Sep-2001 19:00:04' );
Tb=Ts1-Ts;
Tn=datenum( '07-Sep-2001 21:30:00' );
Tx=Ts:Tb:Tn;
Bx1=interp1(T_fgm1,FGM1(:,1),Tx);
By1=interp1(T_fgm1,FGM1(:,2),Tx);
Bz1=interp1(T_fgm1,FGM1(:,3),Tx);
load ('bx.mat')
for i=1:2251
A=[ 1,0,0;
0,cos(bx(i)*pi/180),sin(bx(i)*pi/180);
0,-sin(bx(i)*pi/180),cos(bx(i)*pi/180)];
B=[Bx1(i),By1(i),Bz1(i)];
GSMB1{i}= (B * A);
GSMBx1(i)=GSMB1{i}(1);
GSMBy1(i)=GSMB1{i}(2);
GSMBz1(i)=GSMB1{i}(3);
GSMBt1(i)=(GSMBx1(i)^2+GSMBy1(i)^2+GSMBz1(i)^2)^0.5;
end
j=1;
ge=0;
for i=1:2250
if GSMBx1(i)*GSMBx1(i+1)<0
a(j)=i;
j=j+1;
ge=ge+1;
end
end
ca=1/(GSMBx1(a(2))-GSMBx1(a(2)+1))*GSMBx1(a(2));
chuanx1=a(2)+ca;
subplot(4,1,1);
plot(Tx(2:2251),GSMBx1(2:2251),'-r')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
grid on;
hold on;
subplot(4,1,2);
plot(Tx(2:2251),GSMBy1(2:2251),'-r' )
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
grid on
hold on;
subplot(4,1,3);
plot(Tx(2:2251),GSMBz1(2:2251),'-r')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
grid on
hold on;
subplot(4,1,4);
plot(Tx(2:2251),GSMBt1(2:2251),'-r')
axis([Tx(2),Tx(2251),0, 20])
datetick('x');
grid on
hold on;
path_in='C:\Users\Administrator\Desktop\';
name_fgm='c2_cp_fgm_spin_20010907_v01';
path_fgm=sprintf('%s%s',path_in,name_fgm);
info=cdfinfo(path_fgm);
varname=info.Variables;
t2=cdfread(path_fgm,'Variables',varname{1});%the Epoch
fgm2=cdfread(path_fgm,'Variables',varname{3});%the data of fgm
%***********deal with the .. bad data
for i=1:length(fgm2)
FGM2(i,:)=fgm2{i};
T_fgm2(i)=todatenum(t2{i});%the datenum of time HH:MM:SS
T2{i}=datestr(T_fgm2(i),13);
end
i=find(abs(FGM2)>1e+030);
FGM2(i)=NaN;
Ts=datenum( '07-Sep-2001 19:00:00' );
Ts1=datenum( '07-Sep-2001 19:00:04' );
Tb=Ts1-Ts;
Tn=datenum( '07-Sep-2001 21:30:00' );
Tx=Ts:Tb:Tn;
Bx2=interp1(T_fgm2,FGM2(:,1),Tx);
By2=interp1(T_fgm2,FGM2(:,2),Tx);
Bz2=interp1(T_fgm2,FGM2(:,3),Tx);
load ('bx.mat')
for i=1:2251
A=[ 1,0,0;
0,cos(bx(i)*pi/180),sin(bx(i)*pi/180);
0,-sin(bx(i)*pi/180),cos(bx(i)*pi/180)];
B=[Bx2(i),By2(i),Bz2(i)];
GSMB2{i}= (B * A);
GSMBx2(i)=GSMB2{i}(1);
GSMBy2(i)=GSMB2{i}(2);
GSMBz2(i)=GSMB2{i}(3);
GSMBt2(i)=(GSMBx2(i)^2+GSMBy2(i)^2+GSMBz2(i)^2)^0.5;
end
subplot(4,1,1);
plot(Tx(2:2251),GSMBx2(2:2251),'--b')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,2);
plot(Tx(2:2251),GSMBy2(2:2251),'--b' )
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,3);
plot(Tx(2:2251),GSMBz2(2:2251),'--b')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,4);
plot(Tx(2:2251),GSMBt2(2:2251),'--b')
axis([Tx(2),Tx(2251),0, 20])
datetick('x');
hold on;
path_in='C:\Users\Administrator\Desktop\';
name_fgm='c3_cp_fgm_spin_20010907_v01';
path_fgm=sprintf('%s%s',path_in,name_fgm);
info=cdfinfo(path_fgm);
varname=info.Variables;
t3=cdfread(path_fgm,'Variables',varname{1});%the Epoch
fgm3=cdfread(path_fgm,'Variables',varname{3});%the data of fgm
%***********deal with the .. bad data
for i=1:length(fgm3)
FGM3(i,:)=fgm3{i};
T_fgm3(i)=todatenum(t3{i});%the datenum of time HH:MM:SS
T3{i}=datestr(T_fgm3(i),13);
end
i=find(abs(FGM3)>1e+030);
FGM3(i)=NaN;
Ts=datenum( '07-Sep-2001 19:00:00' );
Ts1=datenum( '07-Sep-2001 19:00:04' );
Tb=Ts1-Ts;
Tn=datenum( '07-Sep-2001 21:30:00' );
Tx=Ts:Tb:Tn;
Bx3=interp1(T_fgm3,FGM3(:,1),Tx);
By3=interp1(T_fgm3,FGM3(:,2),Tx);
Bz3=interp1(T_fgm3,FGM3(:,3),Tx);
load ('bx.mat')
for i=1:2251
A=[ 1,0,0;
0,cos(bx(i)*pi/180),sin(bx(i)*pi/180);
0,-sin(bx(i)*pi/180),cos(bx(i)*pi/180)];
B=[Bx3(i),By3(i),Bz3(i)];
GSMB3{i}= (B * A);
GSMBx3(i)=GSMB3{i}(1);
GSMBy3(i)=GSMB3{i}(2);
GSMBz3(i)=GSMB3{i}(3);
GSMBt3(i)=(GSMBx3(i)^2+GSMBy3(i)^2+GSMBz3(i)^2)^0.5;
end
subplot(4,1,1);
plot(Tx(2:2251),GSMBx3(2:2251),'-.g')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,2);
plot(Tx(2:2251),GSMBy3(2:2251),'-.g' )
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,3);
plot(Tx(2:2251),GSMBz3(2:2251),'-.g')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,4);
plot(Tx(2:2251),GSMBt3(2:2251),'-.g')
axis([Tx(2),Tx(2251),0, 20])
datetick('x');
hold on;
path_in='C:\Users\Administrator\Desktop\';
name_fgm='c4_cp_fgm_spin_20010907_v01';
path_fgm=sprintf('%s%s',path_in,name_fgm);
info=cdfinfo(path_fgm);
varname=info.Variables;
t4=cdfread(path_fgm,'Variables',varname{1});%the Epoch
fgm4=cdfread(path_fgm,'Variables',varname{3});%the data of fgm
%***********deal with the .. bad data
for i=1:length(fgm4)
FGM4(i,:)=fgm4{i};
T_fgm4(i)=todatenum(t4{i});%the datenum of time HH:MM:SS
T4{i}=datestr(T_fgm4(i),13);
end
i=find(abs(FGM4)>1e+030);
FGM4(i)=NaN;
Ts=datenum( '07-Sep-2001 19:00:00' );
Ts1=datenum( '07-Sep-2001 19:00:04' );
Tb=Ts1-Ts;
Tn=datenum( '07-Sep-2001 21:30:00' );
Tx=Ts:Tb:Tn;
Bx4=interp1(T_fgm4,FGM4(:,1),Tx);
By4=interp1(T_fgm4,FGM4(:,2),Tx);
Bz4=interp1(T_fgm4,FGM4(:,3),Tx);
load ('bx.mat')
for i=1:2251
A=[ 1,0,0;
0,cos(bx(i)*pi/180),sin(bx(i)*pi/180);
0,-sin(bx(i)*pi/180),cos(bx(i)*pi/180)];
B=[Bx4(i),By4(i),Bz4(i)];
GSMB4{i}= (B * A);
GSMBx4(i)=GSMB4{i}(1);
GSMBy4(i)=GSMB4{i}(2);
GSMBz4(i)=GSMB4{i}(3);
GSMBt4(i)=(GSMBx4(i)^2+GSMBy4(i)^2+GSMBz4(i)^2)^0.5;
end
subplot(4,1,1);
plot(Tx(2:2251),GSMBx4(2:2251),':k')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,2);
plot(Tx(2:2251),GSMBy4(2:2251),':k' )
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,3);
plot(Tx(2:2251),GSMBz4(2:2251),':k')
axis([Tx(2),Tx(2251),-20, 20])
datetick('x');
hold on;
subplot(4,1,4);
plot(Tx(2:2251),GSMBt4(2:2251),':k')
axis([Tx(2),Tx(2251),0, 20])
datetick('x');
hold on;
legend('C1','C2','C3','C4',1)