% OMNI2-binŠŠridatan luku (tuntidata).

% Load variable "data".

file = 'omni2_2005.mat';
fprintf(' %s\n',file); load(file);

% Extract some variables.
% Poista kommenttimerkki (%) tarvittavien muuttujien edestŠ.
% Tarkasta indeksšinti OMNI2-formaatista:
% http://omniweb.gsfc.nasa.gov/html/ow_data.html

% year = data(:,1);
% day = data(:,2);   % decimal day
% hour = data(:,3);   % UT hour
% data(:,4);   % Bartels rotation number
% spacecraft = data(:,5);   % IMF spacecraft number
% plasma_spacecraft = data(:,6);   % plasma spacecraft number
% points = data(:,7);   % points in IMF averages
% plasma_points = data(:,8);   % points in plasma averages
% data(:,9);   % average of the magnitude of the magnetic field [nT]
% data(:,10);   % magnitude of the average field vector [nT]
% lat = data(:,11);   % latitude of the average field vector [GSE deg]
% long = data(:,12);   % longitude of the average field vector [GSE deg]
bx_gsm = data(:,13); bx_gse = bx_gsm;  % IMF BX_GSM (=BX_GSE) [nT]
by_gse = data(:,14);   % IMF BY_GSE
bz_gse = data(:,15);   % IMF BZ_GSE
by_gsm = data(:,16);   % IMF BY_GSM
bz_gsm = data(:,17);   % IMF BZ_GSM
% data(:,18);   % standard deviation in average magnitude [nT]
% data(:,19);   % standard deviation in field vector [nT]
% data(:,20);   % standard deviation in BX_GSE [nT]
% data(:,21);   % standard deviation in BY_GSE [nT]
% data(:,22);   % standard deviation in BZ_GSE [nT]
% data(:,23);   % proton temperature [K]
dens = data(:,24);   % proton density [1/cm^3]
vel = data(:,25);   % plasma speed [1/cm^3]
% data(:,26);   % bulk flow longitude [GSE deg]
% data(:,27);   % bulk flow latitude [GSE deg]
nanp = data(:,28);   % Na/Np (alpha/proton ratio)
% data(:,29);   % flow pressure [nPa]
% data(:,30);   % sigma-T [K]
% data(:,31);   % sigma-N [1/cm^3]
% data(:,32);   % sigma-V [km/s]
% data(:,33);   % sigma-phi-V [degrees]
% data(:,34);   % sigma-theta-V [degrees]
% data(:,35);   % sigma-ratio
% data(:,36);   % electric field V(km/s) * Bz (nT; GSM) * 10**-3.
% data(:,37);   % plasma beta [(T*4.16/10**5) + 5.34] * Np / B**2
% data(:,38);   % AlfvŽn mach number Ma = (V * Np**0.5) / 20 * B
kp = data(:,39);   % Kp-index
% data(:,40);   % sunspot number
dst = data(:,41);   % Dst-index [nT]
ae = data(:,42);   % AE-index [nT]
% data(:,43:48);   % proton fluxes
% data(:,49);   % flag

clear data;

% Mark missing values as NaN.
% Tarkasta puuttuvan datan merkinnŠt OMNI2-formaatista:
% http://omniweb.gsfc.nasa.gov/html/ow_data.html

bx_gse(bx_gse>=990) = NaN;
by_gse(by_gse>=990) = NaN;
bz_gse(bz_gse>=990) = NaN;
bx_gsm(bx_gsm>=990) = NaN;
by_gsm(by_gsm>=990) = NaN;
bz_gsm(bz_gsm>=990) = NaN;
dens(dens>=990) = NaN;
vel(vel>=9990) = NaN;
nanp(nanp>=9.9) = NaN;
kp(kp==99) = NaN;
ae(ae>=9999) = NaN;
dst(dst>=99990) = NaN;
