function sounding
%设置爬取时间 49行可以选取早八晚八,默认是都下载
start_year =2019 ;
start_month =06 ;
start_day =04 ;
end_year =2019 ;
end_month =07 ;
end_day =24 ;
%读取爬取站点编号
stan=xlsread(''); %%%站号信息在后面保存excel
%设置保存文件夹
total_folder = '';
%设置重新载入时间(s)
timeout = 30 ;
for i_stan=1:1:size(stan,1) %多站点循环,如果只下载单一站点,修改下一行
%station_nu =stan(i_stan,1);
station_nu =59280; %清远站
%station_nu =54511 %读取单一站点,北京站
for year=start_year:1:end_year
start_month1=start_month;
end_month1 = end_month;
if year > start_year %判断一年中的起止月份
start_month1 = 1;
end
if year < end_year
end_month1 = 12;
end
if ISLEAPYRAR(year) %判断是否为闰年
months_day=[31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
else
months_day=[31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
end
for month=start_month1:1:end_month1
start_day1=start_day;
end_day1=end_day ;
if month > start_month1 %判断一月中的起止日期
start_day1 = 1;
end
if month < end_month1
end_day1 = months_day(month);
end
for day=start_day1:1:end_day1
for time=[0,12] %探空时间
tic;
[sourcefile, status] =urlread(sprintf('http://weather.uwyo.edu/cgi-bin/sounding?region=seasia&TYPE=TEXT%%3ALIST&YEAR=%04d&MONTH=%02d&FROM=%02d%02d&TO=%02d%02d&STNM=%05d&ICE=1',year,month,day,time,day,time,station_nu),'Timeout',timeout);
if ~status
itime=1;
while (~status)&&(itime<=3)
disp(['!!!! 载入失败 stn=',num2str(station_nu,'%05d'),' ,Data ',num2str(year,'%04d'),num2str(month,'%02d'),num2str(day,'%02d'),' ,Time ',num2str(time,'%02d'),'尝试重新载入 ',num2str(itime,'%1d次'),' !!']);
[sourcefile, status] =urlread(sprintf('http://weather.uwyo.edu/cgi-bin/sounding?region=seasia&TYPE=TEXT%%3ALIST&YEAR=%04d&MONTH=%02d&FROM=%02d%02d&TO=%02d%02d&STNM=%05d&ICE=1',year,month,day,time,day,time,station_nu),'Timeout',timeout);
itime=itime+1;
end
if itime>3
disp(['!!!! 载入失败 stn=',num2str(station_nu,'%05d'),' ,Data ',num2str(year,'%04d'),num2str(month,'%02d'),num2str(day,'%02d'),' ,Time ',num2str(time,'%02d'),' !!'])
end
end
%去除sourcefile不相关字符,这个地方可根据自己需要调整。如果只需要探空数据截止 则不需要更改
sourcefile = sourcefile(strfind(sourcefile,' PRES HGHT'):strfind(sourcefile,'Station information')-11);
t=toc;
if (strfind(sourcefile,' PRES HGHT')>0) %判断是否有缺测
%保存文件到对应文件夹
folder=[total_folder, station_nu,'00-12Time','\'];
if exist(folder,'dir')==0 %判断站点文件是否已经存在
mkdir(folder);
end
filename=[folder,num2str(year,'%04d'),num2str(month,'%02d'),num2str(day,'%02d'),num2str(time,'%02d'),'.txt'];
fid=fopen(filename,'w');
fprintf(fid,'%s',sourcefile);
fclose(fid);
disp(['** Finish stn=',num2str(station_nu,'%05d'),' ,Data ',num2str(year,'%04d'),num2str(month,'%02d'),num2str(day,'%02d'),' ,Time ',num2str(time,'%02d'),' ,t= ',num2str(t,' %03f'),' **',])
else
disp(['** cannot get stn_',num2str(station_nu,'%05d'),' ,Data ',num2str(year,'%04d'),num2str(month,'%02d'),num2str(day,'%02d'),' ,Time ',num2str(time,'%02d'),' ,t= ',num2str(t,' %03f'),' **',])
end
clear sourcefile
end
end
end
end
endfunction [result]=ISLEAPYRAR(year)
%判断是否为闰年
if((rem(year,100)~=0)&&(rem(year,4)==0))
result=0;
elseif(rem(year,4)==0)
result=0;
else result=1;
end
end
end
用MATLAB在俄怀明大学上爬取探空资料,设置爬取时间区间,以及站号进行下载。如果只需要Station上面的数据,则不需要进行修改。
需要下面的数据,对sourcefile进行修改。
站号信息
29862 | Hakasskaja, NO | 53.76 | 91.31 |
30635 | Ust-Barguzin, IR | 53.41 | 109.01 |
30758 | Chita, IR (UIAA) | 52.08 | 113.48 |
30935 | Krasnyj Chikoj, IR | 50.36 | 108.75 |
30965 | Borzja, IR | 50.4 | 116.51 |
31510 | Blagovescensk, HA | 50.53 | 127.5 |
31538 | Sutur | 50.07 | 132.13 |
31736 | Habarovsk, HA | 48.53 | 135.23 |
31873 | Dalnerechensk, HA | 45.86 | 133.73 |
31977 | Vladivostok (Sad Gorod), HA | 43.26 | 132.05 |
32150 | Juzhno-Sahalinsk, HA (UHSS) | 46.95 | 142.71 |
35394 | Karaganda, AL | 49.8 | 73.15 |
35671 | Zhezkazgan, AL | 47.8 | 67.71 |
36003 | Pavlodar, AL | 52.3 | 76.93 |
36096 | Kyzyl, NO | 51.71 | 94.5 |
36872 | Almaty, AL | 43.36 | 77 |
38064 | Kyzylorda | 44.77 | 65.52 |
38341 | Zhambyl, AL | 42.85 | 71.38 |
40745 | Mashhad (OIMM) | 36.26 | 59.63 |
40856 | Zahedan (OIZH) | 29.46 | 60.88 |
40948 | Kabul Airport (OAKB) | 34.55 | 69.21 |
41859 | Rangpur | ||
41891 | Sylhet (VGSY) | 24.9 | 91.88 |
41907 | Ishurdi (VGIS) | ||
41923 | Dhaka (VGTJ) | 23.76 | 90.38 |
41936 | Jessore (VGJR) | ||
41977 | Chittagong (Ambagan) | 22.35 | 91.81 |
42027 | Srinagar | 34.08 | 74.83 |
42101 | Patiala | 30.33 | 76.46 |
42182 | New Delhi/Safdarjung (VIDD) | 28.58 | 77.2 |
42299 | Gangtok | 27.33 | 88.61 |
42314 | Dibrugarh/Mohanbari (VEMN) | 27.48 | 95.01 |
42339 | Jodhpur (VIJO) | 26.3 | 73.01 |
42361 | Gwalior (VIGR) | 26.23 | 78.25 |
42369 | Lucknow/Amausi (VILK) | 26.75 | 80.88 |
42379 | Gorakhpur (VEGK) | 26.75 | 83.36 |
42410 | Gauhati (VEGT) | 26.1 | 91.58 |
42492 | Patna (VEPT) | 25.6 | 85.1 |
42647 | Ahmadabad (VAAH) | 23.06 | 72.63 |
42667 | Bhopal/Bairagarh (VABP) | 23.28 | 77.35 |
42701 | M.O. Ranchi (VERC) | 23.31 | 85.31 |
42724 | Agartala (VEAT) | 23.88 | 91.25 |
42809 | Calcutta/Dum Dum (VECC) | 22.65 | 88.45 |
42867 | Nagpur Sonegaon (VANP) | 21.1 | 79.05 |
42874 | Pbo Raipur | 21.23 | 81.65 |
42971 | Bhubaneswar (VEBS) | 20.25 | 85.83 |
43003 | Bombay/Santacruz (VABB) | 19.11 | 72.85 |
43041 | Jagdalpur | 19.08 | 82.03 |
43063 | Poona | 18.53 | 73.85 |
43128 | Hyderabad Airport (VOHY) | 17.45 | 78.46 |
43150 | Vishakhapatnam/Waltair | 17.7 | 83.3 |
43185 | Mapatnam | 16.2 | 81.15 |
43192 | Goa/Panjim | 15.48 | 73.81 |
43279 | Madras/Minambakkam (VOMM) | 13 | 80.18 |
43285 | Mangalore/Panambur | 12.95 | 74.83 |
43295 | Bangalore | 12.96 | 77.58 |
43333 | Port Blair (VEPB) | 11.66 | 92.71 |
43369 | Minicoy | 8.3 | 73.15 |
43371 | Thiruvananthapuram | 8.48 | 76.95 |
43418 | Trincomalee (VCCT) | ||
43466 | Colombo | ||
43497 | Hambantota | ||
44231 | Muren | 49.56 | 100.16 |
44292 | Ulaan-Baator | 47.55 | 106.52 |
44373 | Dalanzadgad | 43.35 | 104.25 |
45004 | Kings Park | 22.31 | 114.17 |
47102 | Baengnyeongdo | 37.97 | 124.63 |
47104 | Bukgangneung | 37.81 | 128.85 |
47122 | Osan Ab (RKSO) | 37.1 | 127.03 |
47138 | Pohang | 36.03 | 129.38 |
47158 | Kwangju Ab (RKJJ) | 35.11 | 126.81 |
47169 | Heuksando | 34.68 | 125.45 |
47186 | National Typhoon Centre | 33.33 | 126.68 |
47401 | Wakkanai | 45.41 | 141.68 |
47412 | Sapporo | 43.05 | 141.33 |
47418 | Kushiro | 42.98 | 144.4 |
47580 | Misawa Ab (RJSM) | 40.7 | 141.38 |
47582 | Akita | 39.71 | 140.1 |
47600 | Wajima | 37.38 | 136.9 |
47646 | Tateno | 36.05 | 140.13 |
47678 | Hachijyojima/Omure | 33.11 | 139.78 |
47741 | Matsue | 35.45 | 133.07 |
47778 | Shionomisaki | 33.45 | 135.76 |
47807 | Fukuoka | 33.58 | 130.38 |
47827 | Kagoshima | 31.55 | 130.55 |
47909 | Naze/Funchatoge | 28.38 | 129.55 |
47918 | Ishigakijima (ROIG) | 24.33 | 124.16 |
47945 | Minamidaitojima (ROMD) | 25.83 | 131.23 |
48327 | Chiang Mai (VTCC) | 18.78 | 98.98 |
48378 | Phitsanulok (VTPS) | ||
48407 | Ubon Ratchathani (VTUU) | 15.25 | 104.86 |
48431 | Nakhon Ratchasima (VTUN) | ||
48453 | Bangna | 13.67 | 100.6 |
48477 | Sattahip | ||
48500 | Prachuap Khirikhan (VTBP) | ||
48551 | Surat Thani (VTSB) | ||
48565 | Phuket Airport (VTSP) | 8.11 | 98.31 |
48568 | Songkhla (VTSH) | 7.2 | 100.6 |
48601 | Penang/Bayan Lepas (WMKP) | 5.3 | 100.26 |
48615 | Kota Bharu (WMKC) | 6.16 | 102.28 |
48650 | Sepang | 2.71 | 101.7 |
48657 | Kuantan (WMKD) | 3.78 | 103.21 |
48698 | Singapore/Changi Arpt (WSSS) | 1.36 | 103.98 |
48811 | Dien Bien Phu | 21.4 | 103.02 |
48820 | Ha Noi (VVNB) | 21.01 | 105.8 |
48839 | Bach Longvi | 20.13 | 107.72 |
48845 | Vinh (VVVH) | 18.68 | 105.67 |
48870 | Qui Nhon | ||
48877 | Nha Trang | ||
48887 | Phan Thiet | ||
48900 | Ho Chi Minh (VVTS) | 10.81 | 106.66 |
48914 | Ca Mau | ||
50527 | Hailar, SY | 49.21 | 119.75 |
50557 | Nenjiang, SY | 49.16 | 125.23 |
50774 | Yichun, SY | 47.71 | 128.9 |
50953 | Harbin, SY | 45.75 | 126.76 |
51076 | Altay, UQ | 47.73 | 88.08 |
51431 | Yining, UQ (ZWYN) | 43.95 | 81.33 |
51463 | Urumqi, UQ | 43.78 | 87.62 |
51644 | Kuqa, UQ | 41.71 | 82.95 |
51709 | Kashi, UQ (ZWSH) | 39.46 | 75.98 |
51777 | Ruoqiang, UQ | 39.03 | 88.16 |
51828 | Hotan, UQ (ZWTN) | 37.13 | 79.93 |
51839 | Minfeng, UQ | 37.06 | 82.71 |
52203 | Hami, UQ (ZWHM) | 42.81 | 93.51 |
52267 | Ejin Qi, LZ | 41.95 | 101.06 |
52323 | Mazong Shan, LZ | 41.8 | 97.03 |
52418 | Dunhuang, LZ | 40.15 | 94.68 |
52533 | Jiuquan, LZ (ZLJQ) | 39.76 | 98.48 |
52681 | Minqin, LZ | 38.63 | 103.08 |
52818 | Golmud, LZ | 36.41 | 94.9 |
52836 | Dulan, LZ | 36.3 | 98.1 |
52866 | Xining, LZ (ZLXN) | 36.71 | 101.75 |
52983 | Yu Zhong, LZ | 35.87 | 104.15 |
53068 | Erenhot, BJ | 43.65 | 112 |
53463 | Hohhot, BJ (ZBHH) | 40.81 | 111.68 |
53513 | Linhe, BJ | 40.76 | 107.4 |
53614 | Yinchuan, LZ (ZLIC) | 38.48 | 106.21 |
53772 | Taiyuan, BJ (ZBYN) | 37.78 | 112.55 |
53845 | Yan An, LZ (ZLYA) | 36.6 | 109.5 |
53915 | Pingliang, LZ | 35.55 | 106.66 |
54102 | Xilin Hot, BJ | 43.95 | 116.06 |
54135 | Tongliao, SY | 43.6 | 122.26 |
54161 | Changchun, SY (ZYCC) | 43.9 | 125.21 |
54218 | Chifeng, SY | 42.26 | 118.96 |
54292 | Yanji, SY | 42.88 | 129.46 |
54374 | Linjiang, SY | 41.71 | 126.91 |
54511 | Beijing, BJ (ZBAA) | 39.93 | 116.28 |
54662 | Dalian, BJ (ZYTL) | 38.9 | 121.63 |
54727 | Zhangqiu | 36.7 | 117.55 |
54857 | Qingdao, BJ (ZSQD) | 36.06 | 120.33 |
55299 | Nagqu, CD | 31.48 | 92.06 |
55591 | Lhasa, CD (ZULS) | 29.66 | 91.13 |
56029 | Yushu, LZ | 33.01 | 97.01 |
56080 | Hezuo, LZ | 35 | 102.9 |
56137 | Qamdo, CD | 31.15 | 97.16 |
56146 | Garze, CD | 31.61 | 100 |
56187 | Wenjiang | 30.7 | 103.83 |
56571 | Xichang, CD | 27.9 | 102.26 |
56691 | Weining, CD | 26.86 | 104.28 |
56739 | Tengchong, CD | 25.11 | 98.48 |
56778 | Kunming, CD (ZPPP) | 25.01 | 102.68 |
56964 | Simao, CD | 22.76 | 100.98 |
56985 | Mengzi, CD | 23.38 | 103.38 |
57083 | Zhengzhou, BJ (ZHCC) | 34.71 | 113.65 |
57127 | Hanzhong, LZ | 33.06 | 107.03 |
57131 | Jinghe | 34.43 | 108.97 |
57178 | Nanyang, BJ | 33.03 | 112.58 |
57447 | Enshi, HK | 30.28 | 109.46 |
57461 | Yichang, HK | 30.7 | 111.3 |
57494 | Wuhan, HK (ZHHH) | 30.61 | 114.13 |
57516 | Chongqing, CD (ZUCK) | 29.51 | 106.48 |
57749 | Huaihua, HK | 27.56 | 110 |
57816 | Guiyang, CD (ZUGY) | 26.48 | 106.65 |
57957 | Guilin, GZ (ZGKL) | 25.33 | 110.3 |
57972 | Chenzhou, HK | 25.8 | 113.03 |
57993 | Ganzhou, HK (ZSGZ) | 25.85 | 114.95 |
58027 | Xuzhou, SH | 34.28 | 117.15 |
58150 | Sheyang, SH | 33.76 | 120.25 |
58203 | Fuyang, HK | 32.86 | 115.73 |
58238 | Nanjing, SH (ZSNJ) | 32 | 118.8 |
58362 | Shanghai, SH | 31.4 | 121.46 |
58424 | Anqing, HK | 30.53 | 117.05 |
58457 | Hangzhou, SH (ZSHC) | 30.23 | 120.16 |
58606 | Nanchang, HK (ZSCN) | 28.6 | 115.91 |
58633 | Qu Xian, SH | 28.96 | 118.86 |
58665 | Hongjia, SH | 28.61 | 121.41 |
58725 | Shaowu, SH | 27.33 | 117.46 |
58847 | Fuzhou, SH (ZSFZ) | 26.08 | 119.28 |
58968 | Taibei, SH | 25.03 | 121.51 |
59134 | Xiamen, SH (ZSAM) | 24.48 | 118.08 |
59211 | Baise, GZ | 23.9 | 106.6 |
59265 | Wuzhou, GZ | 23.48 | 111.3 |
59280 | Qing Yuan, GZ | 23.66 | 113.05 |
59316 | Shantou, GZ (ZGOW) | 23.35 | 116.66 |
59431 | Nanning, GZ (ZGNN) | 22.63 | 108.21 |
59758 | Haikou, GZ (ZGHK) | 20.03 | 110.35 |
59981 | Xisha Dao, GZ | 16.83 | 112.33 |
96009 | Lhokseumawe/Malikussaleh (WITM) | ||
96011 | Banda Aceh/Blang Bintang (WITT) | 5.51 | 95.41 |
96035 | Medan/Polonia (WIMM) | 3.56 | 98.68 |
96073 | Sibolga/Pinangsori (WIMS) | ||
96091 | Tanjung Pinang/Kijang (WIKN) | ||
96109 | Pekan Baru/Simpangtiga (WIBB) | ||
96145 | Tarempa | ||
96147 | Ranai (WION) | 3.95 | 108.38 |
96163 | Padang/Tabing (WIMG) | -0.88 | 100.35 |
96171 | Rengat/Japura (WIPR) | ||
96179 | Singkep/Dabo (WIKS) | ||
96195 | Jambi/Sultan Taha (WIPA) | ||
96221 | Palembang/St. Badarudin (WIPP) | ||
96237 | Pangkal Pinang (WIKK) | -2.16 | 106.13 |
96249 | Tanjung Pandan/Buluh (WIKD) | ||
96253 | Bengkulu/Padang Kemiling (WIPL) | -3.88 | 102.33 |
96295 | Tanjung Karang/Radin (WIIT) | ||
96315 | Brunei Airport (WBSB) | 4.93 | 114.93 |
96413 | Kuching (WBGG) | 1.48 | 110.33 |
96441 | Bintulu (WBGB) | 3.2 | 113.03 |
96471 | Kota Kinabalu (WBKK) | 5.93 | 116.05 |
96481 | Tawau (WBKW) | 4.26 | 117.88 |
96509 | Tarakan/Juwata (WRLR) | 3.33 | 117.56 |
96535 | Paloh | ||
96581 | Pontianak/Supadio (WIOO) | -0.15 | 109.4 |
96607 | Samarinda/Temindung (WRLS) | ||
96633 | Balikpapan/Sepinggan (WRLL) | -1.26 | 116.9 |
96645 | Pangkalan Bun/Iskandar (WRBI) | -2.7 | 112.7 |
96655 | Palangka Raya/Tjilik (WRBP) | ||
96685 | Banjarmasin/Syamsudin (WRBB) | -3.43 | 114.75 |
96749 | Jakarta/Soekarno-Hatta (WIII) | -6.11 | 106.65 |
96791 | Cirebon/Jatiwangi | ||
96797 | Tegal | ||
96805 | Cilacap (WIIL) | -7.73 | 109.01 |
96839 | Semarang/Ahmad Yani (WIIS) | ||
96925 | Sangkapura (Bawean Is.) | ||
96935 | Surabaya/Juanda (WRSJ) | -7.36 | 112.76 |
96973 | Kalianget (Madura Is) | ||
96987 | Banyuwangi | ||
97014 | Menado/ Sam Ratulangi (WAMM) | 1.53 | 124.91 |
97048 | Gorontalo/Jalaluddin (WAMG) | ||
97072 | Palu/Mutiara (WAML) | -0.68 | 119.73 |
97096 | Poso/Kasiguncu (WAMP) | ||
97180 | Ujung Pandang/Hasanuddin (WAAA) | -5.06 | 119.55 |
97192 | Bau-Bau/Beto Ambari (WAAB) | ||
97230 | Denpasar/Ngurah Rai (WRRR) | ||
97240 | Mataram/Selaparang (WRRA) | ||
97260 | Sumbawa Besar/Brangbiji (WRRS) | ||
97270 | Bima/M.Salahuddin (WRRB) | ||
97300 | Maumere/Wai Oti (WRKC) | ||
97340 | Waingapu/Mau Hau (WRRW) | ||
97372 | Kupang/Eltari (WRKK) | -10.16 | 123.66 |
97430 | Ternate/Babullah (WAMT) | 0.76 | 127.36 |
98223 | Laoag (RPLI) | 18.18 | 120.53 |
98328 | Baguio (RPUB) | 16.41 | 120.6 |
98433 | Tanay | 14.56 | 121.36 |
98444 | Legaspi (RPMP) | 13.13 | 123.73 |
98618 | Puerto Princesa (RPVP) | 9.75 | 118.73 |
98646 | Mactan (RPMT) | 10.3 | 123.96 |
98747 | Cagayan De Oro | 8.41 | 124.61 |
98753 | Davao Airport (RPMD) | 7.11 | 125.65 |