%% ap_update.m is a program to update the IRI ap.dat file with
%% the latest AP and F10.7 values for the year given by the user. 
%% This is so that I don't have to wait for the NSSDC to do them, 
%% as this only seems to occur twice a year. It is suggested that 
%% a copy of ap.dat is made before this program is run.
%%
%% Author: Phillip A. Webb
%% Last updated: Jan 21, 2004
%%

clear all
close all

%year=input('Input year to update ap.dat file to? ');
year=2003

%Load in existing ap.dat file to determine what final date that
%data is available to.
z=1;
fid=fopen('ap.dat');
while z 
 datai=fgetl(fid);
 if datai<0
  z=0;
 else
  yris=datai(2:3);
  mnis=datai(5:6);
  dyis=datai(8:9);
 end  
end 
fclose(fid);

%Convert final date to intgers
yri=str2num(yris);
mni=str2num(mnis);
dyi=str2num(dyis);

%Load in the ap data for the year requested by the user, as well
%as the F107 data set
cd ..
cd data/ap3hour/
eval(['load a',int2str(year),'.txt -ascii'])
eval(['apup=a',int2str(year),';'])
cd ..
cd f107day
load f107day.txt -ascii
cd ..
cd ..
cd iri2000


