-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqueryVizieR.m
executable file
·321 lines (315 loc) · 18.7 KB
/
queryVizieR.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
classdef queryVizieR
% query gaia Dr1,URAT1 with VizieR
% see http://cdsarc.u-strasbg.fr/doc/asu-summary.htx
% and http://cds.u-strasbg.fr/doc/asu.html
% for details , now it's a easy mode
% only support for a box region !
% fisrt version 2017/3/20 by lifan@pmo.ac.cn
% useage:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_urat1();
% disp(t.fields)
% summary(t.data);
properties
center
box
url
data
originSrc
source
hostname
end
methods % constructor methods
function self = queryVizieR(ra,dec,boxx,boxy)
% Input:
% ra : RA of the center, unit: deg;
% dec : DEC of the center, unit: deg;
% boxx: a rectangular box in the tangential projection centered on the given position
% boxy: where boxx and boxy are expressed in decimal arc minutes.
self.center.ra=ra;
self.center.dec=dec;
self.box.x=boxx;
self.box.y=boxy;
self.url = nan;
self.data = nan;
self.source = nan;
self.hostname='http://vizier.u-strasbg.fr/';
% self.hostname='http://vizier.cfa.harvard.edu/';
end
end
properties (Dependent)
fields
queryUrl
starNo
end
% methods of properties !
methods
function tt=get.fields(self)
% returns list of available properties for all epochs
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_urat1();
% disp(t.fields)
try
tt=self.data.Properties.VariableNames;
catch
tt=[];
end
end
function tt=get.starNo(self)
% returns total number of stars that have been returned
try
tt=size(self.data,1);
catch
tt=0;
end
end
function tt=get.queryUrl(self)
% returns URL that has been used in calling VizieR
try
tt=self.url;
catch
tt=[];
end
end
function tt=getitem(self,key,k)
%
% provides access to query data
%
% Parameters
% ----------
% key : str/int
% epoch index or property key
%
% Returns
% -------
% query data according to key
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_urat1();
% disp(t.fields)
% myNeed=t.getitem({'RA','DEC','Jmag'});
%
if isempty(self.data)
disp('queryVizieR ERROR: run get_gaia or get_urat1 first');
tt=nan;
else
if nargin>2&&max(k)<=self.starNo&&min(k)>0
tt=self.data{k,key};
elseif nargin>2&&(max(k)>self.starNo||min(k)<0)&&k~=':'
error('out of index')
else
tt=self.data{:,key};
end
end
end
end
% the main query function !
methods
function self=get_urat1(self)
% A easist mode query urat1 online
% example url is
% http://vizier.u-strasbg.fr/viz-bin/asu-txt?-source=I/329/urat1&-c.ra=10.6847&-c.dec=41.2687&-c.bm=4/2
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_urat1();
% disp(t.fields)
% summary(t.data)
self.source='I/329/urat1';
tmpurl=strcat(self.hostname,'viz-bin/asu-txt?',...
'-source=',self.source,sprintf('&-c.ra=%f&-c.dec=%f',self.center.ra,self.center.dec),...
sprintf('&-c.bm=%f/%f',self.box.x,self.box.y));
self.url=tmpurl;
% disp(self.url);
woption=weboptions('UserAgent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36',...
'Timeout',30,'RequestMethod','get');
src=webread(self.url,woption);
self.originSrc=src;
fieldnames={'URAT1','RA','DE','Ep',...
'fmag','e_fmag','pmRA','pmDE','Jmag','Hmag','Kmag','Bmag','Vmag','gmag',...
'rmag','imag'};
% get posizition of data in origin source file
pos1=regexp(src,'------\n\d','ONCE','end');
pos2=regexp(src,'\n#END#','ONCE','start');
% from uiimport
% read fixed width text
formatSpec = '%10s%12s%12s%9s%7s%7s%7s%7s%7s%7s%7s%7s%7s%7s%7s%[^\n\r]';
try
C= textscan(src(pos1:pos2),formatSpec, 'Delimiter', '', 'WhiteSpace', '', 'ReturnOnError', false);
catch
error('check source file %s\n',src);
end
for k=2:length(C)
C{k}=cell2mat(cellfun(@str2double,C{k},'UniformOutput', false));
end
self.data=table(C{1:end},'VariableNames',fieldnames);
% add unit and comments
self.data.Properties.VariableDescriptions{1} = 'URAT1 recommended identifier (ZZZ-NNNNNN)';
self.data.Properties.VariableUnits{2} = 'deg';self.data.Properties.VariableDescriptions{2}='Right ascension on ICRS, at "Epoch"';
self.data.Properties.VariableUnits{3} = 'deg';self.data.Properties.VariableDescriptions{3}='Declination on ICRS, at "Epoch"';
self.data.Properties.VariableUnits{4} = 'yr';self.data.Properties.VariableDescriptions{4}='Mean URAT observation epoch';
self.data.Properties.VariableUnits{5} = 'mag';self.data.Properties.VariableDescriptions{5}='mean URAT model fit magnitude';
self.data.Properties.VariableUnits{6} = 'mag';self.data.Properties.VariableDescriptions{6}='URAT photometry error';
self.data.Properties.VariableUnits{7} = 'mas/yr';self.data.Properties.VariableDescriptions{7}='Proper motion RA*cosDec (from 2MASS)';
self.data.Properties.VariableUnits{8} = 'mas/yr';self.data.Properties.VariableDescriptions{8}='Proper motion in Declination ';
self.data.Properties.VariableUnits{9} = 'mag';self.data.Properties.VariableDescriptions{9}='2MASS J-band magnitude';
self.data.Properties.VariableUnits{10} = 'mag';self.data.Properties.VariableDescriptions{10}='2MASS H-band magnitude';
self.data.Properties.VariableUnits{11} = 'mag';self.data.Properties.VariableDescriptions{11}='2MASS Ks-band magnitude';
self.data.Properties.VariableUnits{12} = 'mag';self.data.Properties.VariableDescriptions{12}='APASS B-band magnitude ';
self.data.Properties.VariableUnits{13} = 'mag';self.data.Properties.VariableDescriptions{13}='APASS V-band magnitude';
self.data.Properties.VariableUnits{14} = 'mag';self.data.Properties.VariableDescriptions{14}='APASS g-band magnitude';
self.data.Properties.VariableUnits{15} = 'mag';self.data.Properties.VariableDescriptions{15}='APASS r-band magnitude';
self.data.Properties.VariableUnits{16} = 'mag';self.data.Properties.VariableDescriptions{16}='APASS i-band magnitude';
end
function self=get_gaiadr1(self)
% A easist mode query gaia online
% example url is
% http://vizier.u-strasbg.fr/viz-bin/asu-txt?-source=I/337/gaia&-c.ra=10.6847&-c.dec=41.2687&-c.bm=4/2
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_gaiadr1();
% disp(t.fields)
% summary(t.data)
self.source='I/337/gaia';
tmpurl=strcat(self.hostname,'viz-bin/asu-txt?',...
'-source=',self.source,sprintf('&-c.ra=%f&-c.dec=%f',self.center.ra,self.center.dec),...
sprintf('&-c.bm=%f/%f',self.box.x,self.box.y));
self.url=tmpurl;
% disp(self.url);
woption=weboptions('UserAgent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36',...
'Timeout',30,'RequestMethod','get');
src=webread(self.url,woption);
self.originSrc=src;
fieldnames={'RA','e_RA','DE','e_DE',...
'GAIA_ID','parallax','pmRA','pmDE','RADEcor','Dup','GF','e_GF','Gmag','Var'};
pos1=regexp(src,'-------------\n\d','ONCE','end');
pos2=regexp(src,'\n#END#','ONCE','start');
% from uiimport
% read fixed width text
formatSpec = '%14s%7s%15s%8s%20s%7s%10s%10s%7s%2s%12s%12s%7s%[^\n\r]';
try
C= textscan(src(pos1:pos2),formatSpec, 'Delimiter', '', 'WhiteSpace', '', 'ReturnOnError', false);
catch
error('check source file %s\n',src);
end
for k=[1,2,3,4,6,7,8,9,10,11,12,13]
C{k}=cell2mat(cellfun(@str2double,C{k},'UniformOutput', false));
end
self.data=table(C{1:end},'VariableNames',fieldnames);
self.data.Properties.VariableUnits{1} = 'deg';self.data.Properties.VariableDescriptions{1} = 'Right ascension (ICRS) at epoch 2015.0';
self.data.Properties.VariableUnits{2} = 'mas';self.data.Properties.VariableDescriptions{2}='Standard error of right ascension';
self.data.Properties.VariableUnits{3} = 'deg';self.data.Properties.VariableDescriptions{3}='Declination (ICRS) at epoch 2015.0';
self.data.Properties.VariableUnits{4} = 'mas';self.data.Properties.VariableDescriptions{4}='Standard error of declination ';
self.data.Properties.VariableDescriptions{5}='Source ID';
self.data.Properties.VariableUnits{6} = 'mas';self.data.Properties.VariableDescriptions{6}='Absolute barycentric stellar parallax of the source at the reference epoch Epoch';
self.data.Properties.VariableUnits{7} = 'mas/yr';self.data.Properties.VariableDescriptions{7}='Proper motion in right ascension direction';
self.data.Properties.VariableUnits{8} = 'mas/yr';self.data.Properties.VariableDescriptions{8}='Proper motion in declination direction ';
self.data.Properties.VariableDescriptions{9}='Correlation between right ascension and declination';
self.data.Properties.VariableDescriptions{10}='Source with duplicate sources';
self.data.Properties.VariableUnits{11} = 'e-/s';self.data.Properties.VariableDescriptions{11}='G-band mean flux';
self.data.Properties.VariableUnits{12} = 'e-/s';self.data.Properties.VariableDescriptions{12}='Error on G-band mean flux';
self.data.Properties.VariableUnits{13} = 'mag';self.data.Properties.VariableDescriptions{13}='G-band mean magnitude';
self.data.Properties.VariableDescriptions{14}='Photometric variability flag';
end
function self=get_ppmxl(self)
% A easist mode query urat1 online
% example url is
% http://vizier.u-strasbg.fr/viz-bin/asu-txt?-source=I/317/sample&-c.ra=10.6847&-c.dec=41.2687&-c.bm=4/2
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_ppmxl();
% disp(t.fields)
% summary(t.data)
self.source='I/317/sample';
tmpurl=strcat(self.hostname,'viz-bin/asu-txt?',...
'-source=',self.source,sprintf('&-c.ra=%f&-c.dec=%f',self.center.ra,self.center.dec),...
sprintf('&-c.bm=%f/%f',self.box.x,self.box.y));
self.url=tmpurl;
% disp(self.url);
woption=weboptions('UserAgent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36',...
'Timeout',30,'RequestMethod','get');
src=webread(self.url,woption);
self.originSrc=src;
fieldnames={'RA','DE','pmRA','pmDE','Jmag','Kmag','b1mag','b2mag',...
'r1mag','r2mag','imag','No','f1'};
try
pos1=regexp(src,'--\n\d','ONCE','end');
pos2=regexp(src,'\n#END#','ONCE','start');
catch
error('no stars in the box in catalogue,please check source file %s\n',src);
end
% read fixed width text
formatSpec = '%10s%11s%9s%9s%7s%7s%6s%6s%6s%6s%6s%3s%[^\n\r]';
try
C= textscan(src(pos1:pos2),formatSpec, 'Delimiter', '', 'WhiteSpace', '', 'ReturnOnError', false);
catch
error('check source file %s\n',src);
end
for k=1:size(C,2)
C{k}=cell2mat(cellfun(@str2double,C{k},'UniformOutput', false));
end
self.data=table(C{1:end},'VariableNames',fieldnames);
% add unit and comments
self.data.Properties.VariableUnits{1} = 'deg';self.data.Properties.VariableDescriptions{1}='Right Ascension J2000.0, epoch 2000.0';
self.data.Properties.VariableUnits{2} = 'deg';self.data.Properties.VariableDescriptions{2}='Declination J2000.0, epoch 2000.0';
self.data.Properties.VariableUnits{3} = 'mas/yr';self.data.Properties.VariableDescriptions{3}='Proper Motion in RA*cos(DEdeg)';
self.data.Properties.VariableUnits{4} = 'mas/yr';self.data.Properties.VariableDescriptions{4}='Proper Motion in Dec';
self.data.Properties.VariableUnits{5} = 'mag';self.data.Properties.VariableDescriptions{5}='2MASS J-band magnitude';
self.data.Properties.VariableUnits{6} = 'mag';self.data.Properties.VariableDescriptions{6}='2MASS Ks-band magnitude';
self.data.Properties.VariableUnits{7} = 'mag';self.data.Properties.VariableDescriptions{7}='B mag from USNO-B, first epoch';
self.data.Properties.VariableUnits{8} = 'mag';self.data.Properties.VariableDescriptions{8}='B mag from USNO-B, second epoch';
self.data.Properties.VariableUnits{9} = 'mag';self.data.Properties.VariableDescriptions{9}='R mag from USNO-B, first epoch';
self.data.Properties.VariableUnits{10} = 'mag';self.data.Properties.VariableDescriptions{10}='R mag from USNO-B, second epoch ';
self.data.Properties.VariableUnits{11} = 'mag';self.data.Properties.VariableDescriptions{11}='Number of observations used';
self.data.Properties.VariableDescriptions{12}='Flags';
end
function self=get_gaiadr2(self)
% A easist mode query gaia dr2 online
% example url is
% http://vizier.u-strasbg.fr/viz-bin/asu-txt?-source=I/337/gaia&-c.ra=10.6847&-c.dec=41.2687&-c.bm=4/2
% example:
% t=queryVizieR(10.684708,41.232,2,4);
% t=t.get_gaiadr2();
% disp(t.fields)
% summary(t.data)
self.source='I/345/gaia2';
tmpurl=strcat(self.hostname,'viz-bin/asu-txt?',...
'-source=',self.source,sprintf('&-c.ra=%f&-c.dec=%f',self.center.ra,self.center.dec),...
sprintf('&-c.bm=%f/%f',self.box.x,self.box.y));
self.url=tmpurl;
% disp(self.url);
woption=weboptions('UserAgent','Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.62 Safari/537.36',...
'Timeout',30,'RequestMethod','get');
src=webread(self.url,woption);
self.originSrc=src;
fieldnames={'RA','eRA','DE','eDE','Source','Plx','ePlx','pmRA','epmRA','pmDE','epmDE','Gmag','eGmag'};
pos1=regexp(src,'---------\n\d','ONCE','end');
pos2=regexp(src,'\n#END#','ONCE','start');
% from uiimport
% read fixed width text
formatSpec = '%16s%8s%16s%8s%20s%11s%8s%10s%7s%10s%7s%2s%12s%12s%8s%7s%12s%12s%8s%7s%12s%12s%8s%7s%8s%8s%6s%8s%8s%8s%7s%[^\n\r]';
try
C= textscan(src(pos1:pos2),formatSpec, 'Delimiter', '', 'WhiteSpace', '', 'ReturnOnError', false);
catch
error('check source file %s\n',src);
end
for k=[1,2,3,4,5,6,7,8,9,10,11,15,16]
C{k}=cell2mat(cellfun(@str2double,C{k},'UniformOutput', false));
end
self.data=table(C{[1,2,3,4,5,6,7,8,9,10,11,15,16]},'VariableNames',fieldnames);
self.data.Properties.VariableUnits{1} = 'deg';self.data.Properties.VariableDescriptions{1} = 'Right ascension (ICRS) at epoch 2015.0';
self.data.Properties.VariableUnits{2} = 'mas';self.data.Properties.VariableDescriptions{2}='Standard error of right ascension';
self.data.Properties.VariableUnits{3} = 'deg';self.data.Properties.VariableDescriptions{3}='Declination (ICRS) at epoch 2015.0';
self.data.Properties.VariableUnits{4} = 'mas';self.data.Properties.VariableDescriptions{4}='Standard error of declination ';
self.data.Properties.VariableDescriptions{5}=' Unique source identifier';
self.data.Properties.VariableUnits{6} = 'mas';self.data.Properties.VariableDescriptions{6}='Absolute barycentric stellar parallax of the source at the reference epoch Epoch';
self.data.Properties.VariableUnits{7} = 'mas';self.data.Properties.VariableDescriptions{7}='Standard error of parallax';
self.data.Properties.VariableUnits{8} = 'mas/yr';self.data.Properties.VariableDescriptions{8}='Proper motion in right ascension direction';
self.data.Properties.VariableUnits{9} = 'mas/yr';self.data.Properties.VariableDescriptions{9}='Standard error of proper motion in right ascension direction';
self.data.Properties.VariableUnits{10} = 'mas/yr';self.data.Properties.VariableDescriptions{10}='Proper motion in declination direction';
self.data.Properties.VariableUnits{11} = 'mas/yr';self.data.Properties.VariableDescriptions{11}='Standard error of proper motion in declination direction ';
self.data.Properties.VariableUnits{12} = 'mag';self.data.Properties.VariableDescriptions{12}='G-band mean magnitude';
self.data.Properties.VariableUnits{13} = 'mag';self.data.Properties.VariableDescriptions{13}='Standard error of G-band mean magnitude';
end
end
end