IDL 程序設(shè)計筆記_第1頁
IDL 程序設(shè)計筆記_第2頁
IDL 程序設(shè)計筆記_第3頁
IDL 程序設(shè)計筆記_第4頁
IDL 程序設(shè)計筆記_第5頁
已閱讀5頁,還剩8頁未讀 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

2 35、科學(xué)數(shù)據(jù)格式讀寫*** 4 6 7 7 9 格式代碼d輸出效果字符或者字符串按照N個字符寬度輸出浮點型數(shù)組按照N個字符寬度輸出,小數(shù)點保留M位double型數(shù)組按照N個字符寬度輸出,小數(shù)點保留M位按照N個字符寬度的科學(xué)計數(shù)法輸出,小數(shù)點后精確到M位N*輸出N個空格字符串/H直接引用字符串輸出或者用H直接輸出字符串c()用于輸出日期數(shù)據(jù)fn=dialog_pickfile(title='選擇ASCII文件:',get_path=work_dir)cd,work_dir;用于跳轉(zhuǎn)到當(dāng)前工作路徑*如何獲取某個文件你的列數(shù):;讀取cha06下的風(fēng)云02衛(wèi)星數(shù)據(jù)proread_AW*file='E:\zengsk\IDL\Cha06\data\FY2C_TBB_IR1_OTG_20061130_AOAD.AW*'openr,lun,file,/get_lun;跳過前20個字節(jié)point_lun,lun,20Headline=indgen(3);定義三個整型數(shù)據(jù),分別讀取記錄長度、頭文件記錄數(shù)、數(shù)據(jù)記錄數(shù)readu,lun,Headlineprint,headline[0],headline[1],headline[2];定位到第58個字節(jié),讀取數(shù)據(jù)日期point_lun,lun,58Begindate=indgen(5);記錄開始日期readu,lun,BegindateEnddate=indgen(5);記錄結(jié)束日期readu,lun,Enddatelat_long=indgen(4);記錄網(wǎng)格左上和右上角的經(jīng)緯度readu,lun,lat_longprint,Begindateprint,Enddateprint,lat_long;基于Headline信息數(shù)組,定義字節(jié)數(shù)組,其行列數(shù)分別為記錄長度和數(shù)據(jù)記錄數(shù)data=bytarr(Headline[2],Headline[0]);定位到數(shù)據(jù)部分,其頭文件結(jié)束的字節(jié)位置為“頭文件記錄數(shù)*記錄長度”point_lun,lun,Headline[0]*Headline[1]print,Headline[0]*Headline[1];讀取數(shù)據(jù)部分readu,lun,datahelp,datawindow,0,*size=500,ysize=500endIV、對遙感圖像而言,其數(shù)據(jù)存放方式有BSQ\BIP\接用.tiff存儲的。;;;讀取E:\ENVI\IDL下的MODIS數(shù)據(jù)的經(jīng)緯度以及其1KM的反射率數(shù)據(jù)集protest_hdfcd,cur_dirhdf_id=hdf_sd_start(fname);打開hdf文件,返回一個文件idhdf_sd_fileinfo,hdf_id,sd_nums,attribute;用于獲取HDF文件的數(shù)據(jù)集數(shù)目和屬性數(shù)目print,sd_nums,attributelat_inde*=hdf_sd_nametoinde*(hdf_id,'Latitude');根據(jù)數(shù)據(jù)集名稱來獲取數(shù)據(jù)集的索引號lat_id=hdf_sd_select(hdf_id,lat_inde*);利用索引號選擇數(shù)據(jù)集,返回一個數(shù)據(jù)集的idhdf_sd_getinfo,lat_id,name=name,unit=unit;查詢已打開的數(shù)據(jù)集的基本信息print,name,"",unithdf_sd_getdata,lat_id,lat;讀取數(shù)據(jù),參數(shù)lat用于返回讀取的數(shù)據(jù)hdf_sd_endaccess,lat_id;關(guān)閉已經(jīng)打開的數(shù)據(jù)集help,latlon_inde*=hdf_sd_nametoinde*(hdf_id,'Longitude')lon_id=hdf_sd_select(hdf_id,lon_inde*)hdf_sd_getinfo,lon_id,name=name,unit=unitprint,name,"",unithdf_sd_getdata,lon_id,lonhdf_sd_endaccess,lon_idhelp,lon;讀取1KM反射率數(shù)據(jù)ref_inde*=hdf_sd_nametoinde*(hdf_id,'EV_1KM_RefSB')ref_id=hdf_sd_select(hdf_id,ref_inde*)hdf_sd_getinfo,ref_id,name=name,unit=unitprint,name,"",unithdf_sd_getdata,ref_id,ref_valuehdf_sd_endaccess,ref_idhelp,ref_valuehdf_sd_end,hdf_id;關(guān)閉打開的文件end運行效果;;下面介紹一個讀取環(huán)境衛(wèi)星*.h5數(shù)據(jù)格式的例子proread_hdf5cd,cur_dir;打開一個圖形用戶界面查看h5文件;h5_message=h5_parse(fname);查詢文件的基本信息,返回一個結(jié)構(gòu)體變量;print,h5_messageh5_id=h5f_open(fname);打開一個h5文件,返回一個文件的idsd_id=h5d_open(h5_id,'ImageData/BandData');打開相應(yīng)的數(shù)據(jù)集,數(shù)據(jù)集名稱可帶路徑Bandata=h5d_read(sd_id);讀取數(shù)據(jù)h5d_close,sd_idh5f_close,h5_idhelp,Bandata;將Bandata轉(zhuǎn)成BIP格式存儲Bandata_BIP=transpose(Bandathelp,Bandata_BIPwrite_tiff,'E:\ENVI\IDL\HJ-1.tif',Bandata_BIPend;下面介紹一個讀取ECMWF數(shù)據(jù)的例子,ECMWF為*.nc格式數(shù)據(jù);protest_nccd,cur_dirnc_id=ncdf_open(fname);打開netCDF文件nc_message=ncdf_inquire(nc_id);對打開的文件進(jìn)行查詢,返回文件基本信息help,nc_message;后一個參數(shù)為變量索引號或者名稱;這里我讀取的是它的第四個變量'V10'var_message=ncdf_varinq(nc_id,4)help,var_messagevar_id=ncdf_varid(nc_id,'v10');根據(jù)變量名稱獲取對應(yīng)變量的索引號print,var_id;ncdf_varget獲取數(shù)據(jù)ncdf_varget,nc_id,var_id,valuencdf_close,nc_idhelp,valueend;利用過程plot繪制散點圖proplot_scatter;********讀取數(shù)據(jù)**************cd,work_dirprint,nlopenr,lun,fname,/get_lunhelp,resultreadf,lun,temp_varreadf,lun,datafree_lun,lunprint,temp_varprint,data;************繪制散點圖*****************;*=data[0,*];觀測數(shù)據(jù)y=data[1,*];估算數(shù)據(jù)plot,*,y,psym=2,*range=[5,15],yrange=[5,15],$*title='Observedvalue',ytitle='Estimatedvalue',$background='FFFFFF'*l,color='oooooo'*l,$charsize=,/nodataoplot,*,y,psym=5,color='000000'*l;繪制基準(zhǔn)線oplot,*2,y2,color='FF0000'*l;***********計算MAE與RMSE并在散點圖中添加標(biāo)注********;MAE_label='MAE='+string(MAE,format='(f5.2)')RMSE_label='RMSE='+string(RMSE,format='(f5.2)')*youts,6,,MAE_label,color='000000'*l,charsize=,/data*youts,6,,RMSE_label,color='000000'*l,charsize=,/data;保存散點圖為圖像文件,格式為.pngimg=tvrd(true=1)write_png,o_fn,img;write_png,'E:\ENVI\scatter.png',imgend;plot函數(shù)繪制散點圖proplot_scatter02cd,work_diropenr,lun,file,/get_lunreadf,lun,varreadf,lun,datafree_lun,lunprint,datagraphic01=plot(ob,Es,*rang=[7,15],yrang=[7,15],*minor=5,yminor=5,$;先數(shù)據(jù)title='scatter',*title='ObservedValue',ytitle='Estima$;再坐標(biāo)軸symbol='*',sym_size=,linestyle='nomargin=)graphic02=plot(*2,y2,linestyle=1,/overplot);計算平均絕對誤差和均方根誤差并添加標(biāo)注MAE_label='MAE='+string(MAE,format='(f5.2)')RMSE_label='RMSE='+string(RMSE,format='(f5.2)')t01=te*t(,,MAE_label,target=graphic01,font_size=12);fonts_size用于設(shè)置標(biāo)注的字體大小t01=te*t(,,RMSE_label,target=graphic01,font_size=12)graphic01.save,o_fngraphic02.save,o_fnend;barplot功能函數(shù)繪制柱狀圖protest_histogram02;*******讀取文本文件數(shù)據(jù)************************cd,work_diropenr,lun,file,/get_lunreadf,lun,varfree_lun,lunprint,varfori=0,nl-1dobeginendforhelp,areaprint,areahelp,numberprint,number[3];******************畫柱狀圖****************baselines=replicatebottom_values=baselines,*ticklen=0,*range=[-,],*tickname=area,$yrange=[65,100],title='Histogram',ytitle='ImpactFacter',$width=,dimensions=[900,500],$bottom_color='EEEEEE'*l,fill_color='AOAOFF'*l,$margin=);**************繪制誤差線**********************error_lines=errorplot(number,error,linestyle=6,errorbar_capsize=,$errorbar_color='blue',/overplot);************文件保存為jpg*********************o_fn=dialog_pickfile(title='圖片保存為:')+'.jp串更加方便error_lines.save,o_fnend;;bar_plot函數(shù)繪制條形圖chart;protest_chart;*******讀取文本文件數(shù)據(jù)************************cd,work_diropenr,lun,file,/get_lunreadf,lun,varfree_lun,lunprint,varfori=0,nl-1dobeginendforhelp,areaprint,areahelp,numberprint,number[3];******************畫柱狀圖****************baselines=replicateHis=barplot(number,bottom_values=baselines,$yticklen=0,yrange=[-,],ytickname=area,$*range=[65,100],title='Histogram',*title='ImpactFacwidth=,dimensions=[700,500],$bottom_color='EEEEEE'*l,fill_color='AOAOFF'*l,$margin=,/horizontal);************文件保存為jpg*********************o_fn=dialog_pickfile(title='圖片保存為:')+'.jp串更加方便EndIDL>w=window(dimensions=[600,400])2);創(chuàng)建一個Colorbar,有自定義顏色表,不設(shè)置標(biāo)注位置。IDL>cb=colorbar(POSITION=[,,,],R3);創(chuàng)建一個Colorbar具有自定義顏色表,設(shè)置標(biāo)標(biāo)注在頂部——te*pos=1。IDL>cb=colorbar(POSITION=[,,,],RGB_TABLE=72,TE*TPOS=1)4);創(chuàng)建Colorbar具有自定義顏色表,設(shè)置自定義范圍自定義范圍——range=[*,*]。5);Colorbar具有自定義范圍和自定義標(biāo)簽——tickname=Aarray。IDL>cb=COLORBAR(POSITION=[,,,],RGB_TABLE=72,RANGE=[500,1000],TICKVALUES=[550,650,750,850,950],6);創(chuàng)建一個colorbar,設(shè)置垂直色條——orientation=1,范圍0-100——range,錐形端——tapar=1(左圖)。IDL>cb=COLORBAR(POSITION=[,,,],TAPER=1,RGB_TABLE=72,RANGE=[0,100],ORIENTATION=1)IDL>cb=COLORBAR(POSITION=[,,,],RGB_TABLE=rgb,IDL>TICKNAME=tickname,BORDER=1,TAPER=1,$>ORIENTATION=1,TE*TPOS=1)7);加載顏色表的一個子集,注意:這不是一個“離散”的色條因為每個顏色沒有刻度標(biāo)簽。IDL>LOADCT,72,RGB_TABLE=rgbIDL>cb=COLORBAR(POSITION=[,,,],RGB_TABLE=rgb)8);創(chuàng)建一個離散顏色條,顏色條的顏色數(shù)量與標(biāo)注的數(shù)量匹配,標(biāo)注集中在顏色之下。并且添加輪廓線——BORDER=1。IDL>tickname=STRING(10*INDGEN(10),FORMAT='(I0)')IDL>cb=COLORBAR(POSITION=[,,,],RGB_TABLE=rgb,$>TICKNAME=tickname,BORDER=1)9);離散色條與一個額外的標(biāo)簽相比;顏色數(shù)量與這些標(biāo)簽在線下方。;與填充輪廓圖中使用的類似IDL>tickname=STRING(10*INDGEN(11),FORMAT='(I0)')IDL>cb=

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

最新文檔

評論

0/150

提交評論