CDS data parsing
Posted: Mon Sep 05, 2016 1:30 pm
Hello,
A little code to explore CDS data parsing.
You can play with "regexp" to obtain informations of an object from CDS HTML page. To understand all patterns, you must look at the code of the HTML page.
It is necessary to test the size of some results because all informations are not given for all objects (try "VV_Cep" and "HD256128" ... I don't know why this last star).
Stephane
A little code to explore CDS data parsing.
You can play with "regexp" to obtain informations of an object from CDS HTML page. To understand all patterns, you must look at the code of the HTML page.
It is necessary to test the size of some results because all informations are not given for all objects (try "VV_Cep" and "HD256128" ... I don't know why this last star).
Stephane
Code: Select all
Name = 'VV_Cep'; % Name from FITS 1D - ISIS; works also with 'VV Cep' for example.
% URL with questions after ?
URL = sprintf('http://simbad.u-strasbg.fr/simbad/sim-basic?Ident=%s&submit=SIMBAD+search',Name);
Str = urlread(URL);
% coordinates :
Type = 'ICRS';
pattern = sprintf('%s.{1,150}TT.{1,5}(?<RA>\\d{2}\\s\\d{2}\\s\\d{2}\\.\\d*)\\s(?<DEC>[+-]\\d{2}\\s\\d{2}\\s\\d{2}\\.\\d*).*<A HREF',Type);
Coord = regexp(Str,pattern,'names');
% Spectral type :
Type = 'Spectral type:';
pattern = sprintf('%s.{1,150}TT.{1,5}(?<SpectralType>\\S{2,20}\\s\\S).*<SPAN',Type);
SpectralType = regexp(Str,pattern,'names');
%MagV :
Type = 'Fluxes';
pattern = sprintf('%s.{1,1200}TT>.V......(?<MagV>\\d{1,2}\\.\\d{2}).*<SPAN',Type);
MagV = regexp(Str,pattern,'names');
%Vr
Type = 'Radial velocity';
pattern = sprintf('%s.{1,150}km/s..(?<Vr>[+-]\\d{1,2}\\.\\d{1,2}).*<SPAN',Type);
Radial_Velocity = regexp(Str,pattern,'names');
% PRINT :
disp(Coord.RA);
disp(Coord.DEC);
disp(MagV.MagV);
if size(SpectralType) > 0
disp(SpectralType.SpectralType);
end
if size(Radial_Velocity) > 0
disp(Radial_Velocity.Vr);
end