% [IDs,obs] = readMPC(filename) % By Jeremy Kubica, 2004 % % Reads a set of astronomical observations (in MPC % format) and places them in Matlab arrays. % % Input: % filename - The name of the observation file % to read. % % Output: % IDs - A matrix with one row for each observation. % Each row contains 6 entries the characters % of the observation's ID in ASCII. % % obs - A matrix of observations with one row for % each observation. The row contains: % [time_stamp, ra, dec, brightness] function [IDs,obs] = readMPC(filename) IDs = []; obs = []; count = 0; fid = fopen(filename); if fid == -1 disp(strcat('ERROR: File [',filename,'] not found. Aborting. ')); else line = fgetl(fid); while isstr(line) & (length(line) > 10) count = count + 1; line = fgetl(fid); end fclose(fid); IDs = zeros(count,6); obs = zeros(count,4); count = 0; fid = fopen(filename); line = fgetl(fid); while isstr(line) & (length(line) > 10) count = count + 1; ID = line(6:11); yr = str2num(line(16:19)); mth = str2num(line(21:22)); day = str2num(line(24:31)); dat = datenum(yr,mth,0)+day; rah = str2num(line(33:34)); ram = str2num(line(36:37)); ras = str2num(line(39:43)); ra = rah + ram / 60.0 + ras / 3600.0; dech = str2num(line(46:47)); decm = str2num(line(49:50)); decs = str2num(line(52:55)); dec = dech + decm / 60.0 + decs / 3600.0; if(line(45) == '-') dec = dec * -1; end bright = str2num(line(66:69)); IDs(count,:) = ID; obs(count,:) = [dat ra dec bright]; line = fgetl(fid); end fclose(fid); end