Basic IDL knowledge 1 What is IDL IDLInteractive
Basic IDL knowledge )
1. What is IDL? IDL(Interactive Data Language, 交互式数据 语言)是进行交互数据分析和可视化应用 程跨平台开发 http: //www. ittvis. com/Product. Services/IDL. aspx Why using IDL? 1. 矩阵处理 2. 图形显示 3. 非常多的程序包(SSW,CDALIB等)
2. 1 Quick Look of IDL常用命令. complile [filename 1, filename 2, …. ] compile files from 1 to n. run [filename 1, filename 2, …. ] compile and run the compiled program(只运行主程序). rnew [filename 1, filename 2, …. ] the same as. run, but free all the variants before running, except for the common blocks (只运行主程序). go run the compiled program. out continues executing statements in the current program until it returns. reset_session 初始化IDL系统,使其返回到I DL启动后的初始状态
IDL file commad cd [, path] [current=variant] file_mkdir, dirname file_copy, file_delete, file_move spawn [, command]
建立主程序 filename: “main. pro” 内容 command 1 command 2 end
PLOT, [X, ] Y [, /ISOTROPIC] [, MAX_VALUE=value] [, MIN_VALUE=value] [, NSUM=value] [, /POLAR] [, THICK=value] [, /XLOG] [, /YNOZERO]
常用的系统变量 !dpi (3. 1415926) & !pi !dtor: value used to convert degrees to radians(π/180) !d (device, 对设备进行控制) !map: the information needed to effect coordinate conversions between points of latitude and longitude and map coordinates. !p 控制显示 如:!p. font, !p. color !path: 系统路径 !radeg : used to convert radians to degrees (180/π). !version !values
http: //idlastro. gsfc. nasa. gov/idl_html_help/IDL_En vironment_System_Variables. html
数组引用:array[subscript],或(array) [subscript] 下标语法:e、e 0: e 1、e: *、*、array。 array=make_array(10, /integer), sub=indgen(12) 合法的下标表示:array[5, 5]、array[2: 3, 5]、 array[*, 4]、array[*, 5: 8]、array[4, 4: *]、 array[sub]、array[[1, 3, 5], 7: 9]
结构数组 定义:dotarr=replicate({PIXEL} , 10),或 dotarr=replicate(dot , 10) 引用:dotarr[1]. x=10、 dotarr. x=10将所有结构的x赋值 为 10 dotarr. y=indgen(10)
case 2 of 1: print, 'one' 2: print, 'two' 3: print, 'three' 4: print, 'four' endcase switch 2 of 1: print, 'one' 2: print, 'two' 3: print, 'three' 4: print, 'four' endswitch IDL results: two three four
Goto 语句 程序的执行无条件转向标号所指定的语句 Goto语句只能从循环语句的循环体中转到循环语句的外面, 反之则不允许 pro example_goto for i=0, 10 do begin print, i if I eq 8 then begin no=i goto, jump endif endfor Jump: print, 'goto here', no end
Set_Plot, ‘PS’ Device, filename=‘test. eps’, XSize=xs, YSize=ys, XOffset=xoff, YOffset=yoff, /Landscape, /color
二:坐标系统(win,ps,x) 1. 数据坐标系统 499 1 2. 设备坐标系统 3. 归一化坐标系统 Data coordinate Device coordinate Normalized coordinate 0 00 1 499
●例如: DEVICE, DECOMPOSED=0 LOADCT, 25 SURFACE, DIST(80) LOADCT, 26 SURFACE, DIST(80) LOADCT, 30 SURFACE, DIST(80) XLOADCT, /BLOCK SURFACE, DIST(80)
关于颜色的程序库 fsc_color: 获取指定颜色的代码(88种颜色) 使用方法: plot, [1, 2, 3], color=fsc_color(‘red’) 例:fsc_color. pro D Fanning的程序库 http: //www. dfanning. com/ $ssw/packages/nrl/id/nrlgen/dfanning
建立自己的颜色表 pro mycolortable ; ; ; r g b ; ; ; blue = ( 0 0 255) ; ; ; white= ( 255) ; ; ; red = ( 255 0 0) ; ; Thus want a blue-white-red table than needs; ; ; the r from 0 -> 255 ; ; g from 0 -> 255 -> 0 ; ; b from 255 ->0 steps = 128 scale. Factor = FINDGEN(steps) / (steps - 1) ; Do first 128 colors ( blue to white). ; Red vector: 0 -> 255 red. Vector = 0 + (255 - 0) * scale. Factor ; Green vector: 0 -> 255 green. Vector = 0 + (255 - 0) * scale. Factor ; Blue vector: 255 -> 255 blue. Vector = 255 + (0 - 0) * scale. Factor
; Do second 128 colors (white to red). ; Red vector: 255 -> 255 red. Vector = [red. Vector, 255 + (0 - 0) * scale. Factor] ; Green vector: 255 -> 0 green. Vector = [green. Vector, 255 + (0 - 255) * scale. Factor] ; Blue vector: 255 -> 0 blue. Vector = [blue. Vector, 255 + (0 - 255) * scale. Factor] save, red. Vector, green. Vector, blue. Vector, filename='mycolortb. sav', description='blue-white-red table' end
linstyle=[0|1|2|3|4|5] 例:show_linestyle. pro
PSYM Symsize: 符号大小 例:show_psym. pro
Psym=-1
自定义符号(psym=8) Filled Circle phi = Findgen(32) * (!PI * 2 / 32. ) phi = [ phi, phi[0] ] User. Sym, Cos(phi), Sin(phi), /Fill Plot, data, PSym=8, Symsize=1. 25 Filled Triangles User. Sym, [ -1, 1, -1 ], [1, 0, -1, 1 ], /Fill ; Filled right-facing triangle. User. Sym, [ 1, -1, 1, 1 ], [1, 0, -1, 1 ], /Fill ; Filled left-facing triangle. User. Sym, [ -1, 1, -1 ], [1, 0, -1, 1 ] ; Open right-facing triangle.
Psym=10 plot, findgen(10), psym=10
[X|Y]Style 例: example_xysytle. pro (only xstyle) 思考题: Ystyle=5|10分 别代表什么?那 些数字对应的 style是相同的?
XYOUTS示例
●例 在给定图形中,定位系列列一点,并在图上打印该点的 坐标值。 Pro test !p. color=255 !p. background=0 a=findgen(100)/99. *2*!pi Plot, a, sin(a) ; 利用鼠标取点 cursor, x, y, /data WHILE (!MOUSE. button NE 4) DO BEGIN cursor, x, y, /data Xyouts, x, y, strcompress(string(x), /remove_all)+'+'+strc ompress(string(y), /remove_all) ENDWHILE end
例如:分析如下命令的运行结果。 XYOUTS, 0, 0. 2, '!MI!S!A!E!8 x!R!B!Ip!N !7 q!Ii!N!8 U!S!E 2!R!Ii!Ndx', SIZE=3, /NORMAL !MI :Changes to the math set and draws the integral sign, uppercase I. (等效!9 I) !S :Saves the current position on the position stack. !A!E!8 x :Shifts above the division line and to the exponent level, switches to the Complex Italic font (Font 8), and draws the " x. " !R!B!Ip : Restores the position to the position immediately after the integral sign, shifts below the division line to the index level, and draws the " p. " !N !7 q : Returns to the normal level, advances one space, shifts to the Complex Greek font (Font 7), and draws the Greek letter rho, which is designated by "q" in this set. !Ii!N : Shifts to the index level and draws the " i " at the index level. Returns to the normal level. !8 U : Shifts to the Complex Italic font (Font 8) and outputs the upper case " U. " !S!E 2 : Saves the position and draws the exponent " 2. " !R!Ii : Restores the position and draws the index " i. " !N dx : Returns to the normal level and outputs " dx. "
lhs = '!8 f(x!S!Ii!R , x!S!Ij!R ) = !X' XYOUTS, 0. 1, 0. 5, lhs, WIDTH = lhs_width, CHARSIZE = 2. , /NORMAL rhs = '!8!S!Af(x!S!Ii!R ) - f(x!S!Ij!R )!R!B x!S!Ii!R - $ x!S!Ij!R !X' XYOUTS, 0. 1 + lhs_width, 0. 5, rhs, CHARSIZE = 2. , $ WIDTH = rhs_width, /NORMAL PLOTS, [0. 1 + lhs_width, 0. 1 + lhs_width + rhs_width], $ [0. 51, 0. 51], /NORMAL 使用 Textoidl程序包: XYOUTS, 0, 0. 2, textoidl( ‘int_{p}^{x}rho_{i}U_{i}^{2}dx’), SIZE=3, /NORMAL XYOUTS, 0. 5, 0. 7, '!9 I!3'+textoidl('_{p}^{x}rho_{i}U_{i}^{2}dx'), size=5
设备字体 例:example_device_font. pro
Contour Levels:
Contour Labels:
Net. CDF
CDF : Common Data File
For example: IDL> a=read_mycdf(‘’, ’ ac_h 0_mfi_19980924_v 04. cdf’, /all) IDL> help, /stru, a ** Structure <2819 e 10>, 17 tags, length=381576, data length=381564, refs=1: EPOCH STRUCT -> <Anonymous> Array[1] TIME_PB 5 STRUCT -> <Anonymous> Array[1] MAGNITUDE STRUCT -> <Anonymous> Array[1] BGSEC STRUCT -> <Anonymous> Array[1] LABEL_BGSE STRUCT -> <Anonymous> Array[1] BGSM STRUCT -> <Anonymous> Array[1] LABEL_BGSM STRUCT -> <Anonymous> Array[1] DBRMS STRUCT -> <Anonymous> Array[1] Q_FLAG STRUCT -> <Anonymous> Array[1] SC_POS_GSE STRUCT -> <Anonymous> Array[1] LABEL_POS_GSE STRUCT -> <Anonymous> Array[1] SC_POS_GSM STRUCT -> <Anonymous> Array[1] LABEL_POS_GSM STRUCT -> <Anonymous> Array[1] UNIT_TIME STRUCT -> <Anonymous> Array[1] LABEL_TIME STRUCT -> <Anonymous> Array[1] FORMAT_TIME STRUCT -> <Anonymous> Array[1] CARTESIAN STRUCT -> <Anonymous> Array[1]
For example: IDL> help, /stru, a. magnitude ** Structure <28994 d 8>, 54 tags, length=22388, data length=22388, refs=2: VARNAME STRING 'Magnitude' TITLE STRING 'ACE> Magnetometer Parameters' PROJECT STRING Array[2] DISCIPLINE STRING 'Space Physics>Interplanetary Studies' SOURCE_NAME STRING 'AC>Advanced Composition Explorer' DATA_TYPE STRING 'H 0>16 -Sec Level 2 Data' DESCRIPTOR STRING 'MAG>ACE Magnetic Field Instrument' DATA_VERSION STRING '4' GENERATED_BY STRING 'ACE Science Center' GENERATION_DATE STRING '20030112' LINK_TEXT STRING 'Release notes and other info available at' LINK_TITLE STRING 'the ACE Science Center Level 2 Data website' HTTP_LINK STRING 'http: //www. srl. caltech. edu/ACE/ASC/level 2/index. html' TEXT STRING Array[11] MODS STRING Array[2] ADID_REF STRING 'NSSD 0327' LOGICAL_FILE_ID STRING 'AC_H 0_MAG_19980924_V 04' LOGICAL_SOURCE STRING 'AC_H 0_MFI' LOGICAL_SOURCE_DESCRIPTION STRING 'H 0 - ACE Magnetic Field 16 -Second Level 2 Data' PI_NAME STRING 'N. Ness'
PI_AFFILIATION STRING 'Bartol Research Institute' MISSION_GROUP STRING 'ACE' INSTRUMENT_TYPE STRING 'Magnetic Fields (space)' TIME_RESOLUTION STRING '16 second' WEB_SITE STRING 'http: //www. srl. caltech. edu/ACE/' ACKNOWLEDGEMENT STRING Array[3] RULES_OF_USE STRING Array[3] FIELDNAM STRING 'B-field magnitude' VALIDMIN FLOAT 0. 000000 VALIDMAX FLOAT 500. 000 SCALEMIN FLOAT 0. 000000 SCALEMAX FLOAT 10. 0000 UNITS STRING 'n. T' FORMAT STRING 'F 8. 3' MONOTON STRING '' VAR_TYPE STRING 'data' DICT_KEY STRING 'magnetic_field>magnitude' FILLVAL FLOAT -1. 00000 e+031 LABL_PTR_1 STRING '' LABL_PTR_2 STRING '' UNIT_PTR STRING '' FORM_PTR STRING '' DEPEND_0 STRING 'Epoch' DEPEND_1 STRING '' CATDESC STRING 'B-field magnitude' LABLAXIS STRING '<|B|>' AVG_TYPE STRING '' DISPLAY_TYPE STRING 'time_series' VAR_NOTES STRING '' SCALETYP STRING '' SCAL_PTR STRING '' CDFTYPE STRING 'CDF_REAL 4' CDFRECVARY STRING 'VARY' DAT FLOAT Array[5400]
To draw the magnitude v. s. time you can using: IDL-> plot, a. epoch. dat, a. magnitude. dat To avoid the bad data points, refer to ‘Validmin’ and ‘Validmax’ block! IDL-> plot, a. epoch. dat, a. magnitude. dat, yrange=[a. magnitude. validmin, a. magnitude. validmax] For your beautiful plot, you decide the choice! IDL-> plot, a. epoch. dat *10. ^(-13), a. magnitude. dat, yrange=[0, 60]
例:solar Soft. Ware(SSW): 太阳数据处理软件 作环境: IDL 包含软件:几乎所有的太阳观测数据的处 理软件,如SOHO, STEREO, HINODE等 http: //www. lmsal. com/solarsoft/index_old. html
n SSW组织结构 SITE branch for local configuration files GEN branch which contains the SSW general purpose library Mission branches include single instrument observatories Software packages by other individuals or groups which provide useful extensions are integrated and distributed with SSW
(2)从网络安装SSW http: //www. lmsal. com/solarsoft/ssw_install. html
- Slides: 122