-
-
Save msakuta/23dea348208c9ecd3b01 to your computer and use it in GitHub Desktop.
An Octave function that reads and parses astorb.dat file that can be downloaded from ftp://ftp.lowell.edu/pub/elgb/astorb.html. Not tested for Matlab
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [astorb] = readastorb(file) | |
%READASTORB reads and parses astorb.dat file that can be downloaded from | |
% ftp://ftp.lowell.edu/pub/elgb/astorb.html | |
% | |
% [astorb] = readastorb(file) | |
% file File path | |
% astorb The structure array that contains following members | |
% | |
% num Returned asteroid number list | |
% names Returned asteroid name (if any) | |
% hmag H. magnitude (absolute magnitude) | |
% argument_of_perihelion | |
% Argument of perihelion of the orbit | |
% ascending_node | |
% Ascending node of the orbit | |
% inclination | |
% Inclination of the orbit | |
% eccentricity | |
% Eccentricity of the orbit | |
% semimajor_axis | |
% Semimajor axis length of the orbit [AU] | |
f = fopen(file, "r"); | |
names = []; | |
hmag = []; | |
argument_of_perihelion = []; | |
ascending_node = []; | |
inclination = []; | |
eccentricity = []; | |
semimajor_axis = []; | |
linecount = 1; | |
while !feof(f) | |
line = fgetl(f); | |
astorb(linecount).num = sscanf(line(1:6), "%d", 1); | |
astorb(linecount).name = line(8:25); | |
astorb(linecount).hmag = sscanf(line(43:47), "%f", 1); | |
astorb(linecount).argument_of_perihelion = sscanf(line(127:136), "%f", 1); | |
astorb(linecount).ascending_node = sscanf(line(138:147), "%f", 1); | |
astorb(linecount).inclination = sscanf(line(149:157), "%f", 1); | |
astorb(linecount).eccentricity = sscanf(line(159:168), "%f", 1); | |
astorb(linecount).semimajor_axis = sscanf(line(170:181), "%f", 1); | |
% astorb.dat contains 68000 lines which is too many for a small scale data processing | |
linecount = linecount + 1; | |
if 10000 < linecount | |
break; | |
end; | |
end; | |
fclose(f); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment