一、获取CDF变量信息

pro testfile = 'C:\Users\XCL\Desktop\omni_hro_1min_20080801_v01.cdf';打开cdf文件id = cdf_open(file);获取CDF文件全局变量信息inq = cdf_inquire(id)cdf_control,id,get_numattrs=num_attrsif (inq.nzvars ge 1) then beginfor i=0, inq.nzvars-1 do beginvar_inf=cdf_varinq(id,i,/zvariable)cdf_control,id,var=var_inf.name,get_var_info=info, /zvarif(info.maxrec le 0) then continueprint,'-------------------------------'print,' ',var_inf.nameprint,'-------------------------------'for j=0, num_attrs[1]-1 do begincdf_attinq,id,j+num_attrs[0],name1,scope1,maxentry1,maxzentry1if (cdf_attexists(id,j+num_attrs[0],i,/zvariable)) then begincdf_attget,id,j+num_attrs[0],i,value1,/zvariableprint,name1,value1,format='(2x,A10,":",4x,A)'endifendforendforendifprint, 'Run over!'
end

得到基本参量信息后根据自己所需要的变量编写读取函数。本文需要的是磁场及太阳风相关

二、函数

pro read_cdf_OMNI,file,bx,by,bz,vx,vy,vz,pr,alid = cdf_open(file)a = cdf_inquire(id)cdf_control,id, variable='Epoch', get_var_info=info1cdf_control,id, variable='BY_GSM', get_var_info=info2cdf_control,id, variable='BZ_GSM', get_var_info=info3cdf_control,id, variable='BX_GSE', get_var_info=info4cdf_control,id, variable='Vx', get_var_info=info5cdf_control,id, variable='Vy', get_var_info=info6cdf_control,id, variable='Vz', get_var_info=info7cdf_control,id, variable='Pressure', get_var_info=info8cdf_control,id, variable='AL_INDEX', get_var_info=info9cdf_varget,id, 'Epoch', tt, rec_count=info1.maxrec, /zvariablecdf_varget,id, 'BY_GSM', by2, rec_count=info2.maxrec, /zvariablecdf_varget,id, 'BZ_GSM', bz2, rec_count=info3.maxrec, /zvariablecdf_varget,id, 'BX_GSE', bx2, rec_count=info4.maxrec, /zvariablecdf_varget,id, 'Vx', vx2, rec_count=info5.maxrec, /zvariablecdf_varget,id, 'Vy', vy2, rec_count=info6.maxrec, /zvariablecdf_varget,id, 'Vz', vz2, rec_count=info7.maxrec, /zvariablecdf_varget,id, 'Pressure', p2, rec_count=info8.maxrec, /zvariablecdf_varget,id, 'AL_INDEX', al2, rec_count=info9.maxrec, /zvariablecdf_close,idbx= {x: transpose(tt), y: transpose(bx2)}bad = where(bx.y gt 10,c)if c ne 0 then bx.y[bad] = !values.f_nanby = {x: transpose(tt), y: transpose(by2)}bad = where(by.y gt 10,c)if c ne 0 then by.y[bad] = !values.f_nanbz = {x: transpose(tt), y: transpose(bz2)}bad = where(bz.y gt 10,c)if c ne 0 then bz.y[bad] = !values.f_nanvx = {x: transpose(tt), y: transpose(vx2)}bad = where(vx.y gt 100,c)if c ne 0 then vx.y[bad] = !values.f_nanvy = {x: transpose(tt), y: transpose(vy2)}bad = where(vy.y gt 100,c)if c ne 0 then vy.y[bad] = !values.f_nanvz = {x: transpose(tt), y: transpose(vz2)}bad = where(vz.y gt 100,c)if c ne 0 then vz.y[bad] = !values.f_nanpr = {x: transpose(tt), y: transpose(p2)}bad = where(pr.y gt 2,c)if c ne 0 then pr.y[bad] = !values.f_nanal = {x: transpose(tt), y: transpose(al2)}bad = where(al.y gt 10,c)if c ne 0 then al.y[bad] = !values.f_nanreturn
end

三、绘图

pro last_hwread_cdf_OMNI,'C:\Users\XCL\Desktop\omni_hro_1min_20080801_v01.cdf',bx,by,bz,vx,vy,vz,pr,alt_om=CDF_EPOCH_TOJULDAYS(bx.x)trag=julday(8,25,2008,[6,10],0,0);设置图片尺寸相关参数x0=0.2;画图区域的左下角X坐标(归一化坐标系)xs=0.7;每一栏的长度y0=0.95;画图区域最大y坐标值ys=0.12;每一栏的高度yg=0.003;相邻两栏的间隔pngon,xsize=1800,ysize=2100loadct, 39plots, [0.491, 0.491], [0.34, 0.95], /normal, linestyle = 5, thick = 3,color=200plots, [0.551, 0.551], [0.34, 0.95], /normal, linestyle = 5, thick = 3,color=100plots, [0.2, 0.9], [0.89, 0.89], /normal, linestyle = 5, thick = 3plot,t_om,bx.y,/noerase,charsize=4,thick=4, $position=[x0,y0-1*ys-0*yg,x0+ xs,y0-0*ys-0*yg], $xthick=2,xticklen=0.1,xstyle=1,xminor=6,xtitle=' ',xtickinterval=3600/(24*60.0*60D),xtickname=replicate(' ',10), $ythick=2,yticklen=0.015,ystyle=1,xrange=trag,yrange=[-4,4],ytickinterval=2,yminor=4,ytitle=''oplot,t_om,by.y,thick=4,color=250;red oplot,t_om,bz.y,thick=4,color=50axis,x0-0.04, y0 - 1*ys - 0*yg, yaxis=0, yticklayout=1, /normal, ytickname =replicate(' ',10), charsize=5,ytitle = 'B!dIMF!n!c[nT]'plot,t_om,vx.y,/noerase,charsize=4,thick=4, $position=[x0,y0-2*ys-1*yg,x0+ xs,y0-1*ys-1*yg], $xthick=2,xticklen=0.1,xstyle=1,xminor=6,xtitle=' ',xtickinterval=3600/(24*60.0*60D),xtickname=replicate(' ',10), $ythick=2,yticklen=0.015,ystyle=1,xrange=trag,yrange=[-304,-280],ytickinterval=10,yminor=5,ytitle=''axis,x0-0.04, y0 - 2*ys - 1*yg, yaxis=0, yticklayout=1, /normal, ytickname =replicate(' ',10),charsize=5, ytitle = 'V!dX,SW!n!c[km/s]'plot,t_om,vy.y,/noerase,charsize=4,thick=4, $position=[x0,y0-3*ys-2*yg,x0+ xs,y0-2*ys-2*yg], $xthick=2,xticklen=0.1,xstyle=1,xminor=6,xtitle=' ',xtickinterval=3600/(24*60.0*60D),xtickname=replicate(' ',10), $ythick=2,yticklen=0.015,ystyle=1,xrange=trag,yrange=[-20,4],ytickinterval=10,yminor=5,ytitle=''oplot,t_om,vz.y,thick=4,color=250axis,x0-0.04, y0 - 3*ys - 2*yg, yaxis=0, yticklayout=1, /normal, ytickname =replicate(' ',10),charsize=5, ytitle = 'V!dYZ,SW!n!c[km/s]'plot,t_om,pr.y,/noerase,charsize=4,thick=4, $position=[x0,y0-4*ys-3*yg,x0+ xs,y0-3*ys-3*yg], $xthick=2,xticklen=0.1,xstyle=1,xminor=6,xtitle=' ',xtickinterval=3600/(24*60.0*60D),xtickname=replicate(' ',10), $ythick=2,yticklen=0.015,ystyle=1,xrange=trag,yrange=[0.7,1.2],ytickinterval=0.2,yminor=2,ytitle=''axis,x0-0.04, y0 - 4*ys - 3*yg, yaxis=0, yticklayout=1, /normal, ytickname =replicate(' ',10), charsize=5,ytitle = 'P!dSW!n!c[nPa]'plot,t_om,al.y,/noerase,charsize=4,thick=4, $position=[x0,y0-5*ys-4*yg,x0+ xs,y0-4*ys-4*yg], $xthick=2,xticklen=0.1,xstyle=1,xminor=6,xtitle=' ',xtickinterval=3600/(24*60.0*60D),xtickname=replicate(' ',10), $ythick=2,yticklen=0.015,ystyle=1,xrange=trag,yrange=[-150,0],ytickinterval=50,yminor=5,ytitle=''axis,x0-0.04, y0 - 5*ys - 4*yg, yaxis=0, yticklayout=1, /normal, ytickname =replicate(' ',10), charsize=5,ytitle = 'AL!n!c[nT]' xyouts,0.74,0.96,'2008-08-25',charsize = 6,CHARTHICK = 1,/normalxyouts,0.2,0.96,'OMNI',charsize = 6,CHARTHICK = 1,/normalxyouts, 0.91, 0.93, 'B!dx', charsize = 5, /normal, color = 0xyouts, 0.91, 0.905, 'B!dy', charsize = 5, /normal, color = 250xyouts, 0.91, 0.88, 'B!dz', charsize = 5, /normal, color = 50  xyouts,0.1,0.31,'UT',charsize = 5,charthick =5,/normalxyouts,0.17,0.31,'0600',charsize = 5,/normalxyouts,0.35,0.31,'0700',charsize = 5,/normalxyouts,0.53,0.31,'0800',charsize = 5,/normalxyouts,0.71,0.31,'0900',charsize = 5,/normalxyouts,0.88,0.31,'1000',charsize = 5,/normalxyouts, 0.91, 0.68,'V!dy',charsize = 5, /normal, color = 0xyouts, 0.91, 0.655,'V!dz',charsize = 5, /normal, color = 250pngoff,'E:\Plot3.png'end

四、运行效果

补充: 此代码需要安装spedas库。pngon、pngoff两个函数上篇文章已记录

IDL读取卫星数据可视化(作业记录:行星际磁场及太阳风绘图)相关推荐

  1. python气象数据可视化学习记录1——基于ERA5数据画风场和海平面气压填色叠加图

    python气象数据可视化学习记录1--基于ERA5数据画风场和海平面气压填色叠加图 1. 写在前面 2. 图片效果 3. 逐步代码解析 3.1导入库 3.2 读取NC格式数据 3.3 对数据进行加工 ...

  2. PCA降维+SVR+数据可视化 实战记录

    基于SVR算法对四姑娘山景区2019年下半年客流量进行预测 文章目录 基于SVR算法对四姑娘山景区2019年下半年客流量进行预测 1.整理用机器学习进行回归分析的过程和原理(入门)10 回归分析过程 ...

  3. Python金融大数据分析——第五章数据可视化(1)二维绘图

    目录 第五章 数据可视化 5.1 二维绘图 5.1.1 一维数据集 5.1.2 二维数据集 5.1.3绘制其他图表 5.1.3.1绘制散点图 5.1.3.2 直方图 5.1.3.3 箱型图 第五章 数 ...

  4. Python-gdal读取卫星数据,并提取三个波段写入新的tif

    #导入gdal包 from osgeo import gdal #读取遥感影像数据 path=r'E:\oil.tif' ds=gdal.Open(path) num=ds.RasterCount # ...

  5. 数据可视化作业(pivot_wider)(pivot_longer)

    --- title: "Task 5" author: "11.11不买" date: "`11.4`" output:   html_do ...

  6. 【数据分析师---数据可视化】第二章:plotly绘图基础篇

    plotly绘图基础篇 1 Plotly简介与安装 2 Plotly简单绘图入门 3 Plotly绘制散点图和饼图 4 Plotly绘图流程详细梳理 5 Plotly绘制密度图和三维散点图 5.1 绘 ...

  7. Python数据可视化第 3 讲:matplotlib绘图之函数plot()

    1. plot 函数介绍 plot() 函数是 matplotlib 的 pyplot 模块中最常用的绘图函数.其调用格式如下: plot([x], y, [fmt], *, data=None, * ...

  8. Python数据可视化第 2 讲:matplotlib 绘图中文字体设置

    1. 常见报错 Font family ['sans-serif'] not found 1.1 报错现象 在使用 matplotlib 绘图时,中文设置(如 titile.x label.y lab ...

  9. IDL和MATLAB读取grib数据

    IDL读取grib数据 (1)      需要IDL8.1以上版本 (2)      代码如下:        (3)      读取的数据结果在ENVI中查看如下: 可以看到在山东半岛的角上的值为0 ...

最新文章

  1. 获取线程结束代码(Exit Code)
  2. cad方格网高程lisp编程_分享:方格网法土方工程量计算实例例题(疏浚清淤工程)...
  3. 洛谷P2534 [AHOI2012]铁盘整理
  4. sublime 常用快捷键
  5. 小米8吃鸡战斗服务器响应超时,小米8使用1天真实体验,看完再决定买不买?
  6. [转]如何撰写学术论文
  7. rsync aws ec2 pem
  8. [入门] Delphi XE2 的控件安装方法。
  9. Lost Cows POJ 2182 思维+巧法
  10. C#-SpecialFolder-特殊路径获取
  11. 反射的学习(参考尚硅谷视频)
  12. 文件共享锁溢出 请增加MaxLocksperFile注册表项值
  13. VSIX 安装失败解决方案
  14. 马化腾:这个市场不是拼钱、拼流量,而是拼团队、拼使命感和危机感
  15. Java歌手评分系统
  16. 中国建成世界海中最高5G基站 采用微波传输方案
  17. NOI / 1.5编程基础之循环控制——02:财务管理
  18. security基于数据库的认证(二)
  19. 【webpack】输入npm run dev报错: This is probably not a problem with npm. There is likely additional loggin
  20. Kettle邮件发送

热门文章

  1. micropython仿真器_MicroPython 介绍
  2. css 实现蒙版效果
  3. 博客写作小技巧【2】:段落首行缩进、添加分割线……
  4. 用Python实现全国二手房数据抓取+地图展示
  5. win10可以联网,但显示无法连接到Internet
  6. Ubuntu下tomcat安装
  7. 有哪些好的科研习惯?
  8. 中国人非常喜欢6这个数字,因为大家总爱说66大顺啊。数学狂人李某人喜欢把什么都数字化,于是她把顺利这个词也定义了数量级,6代表1级顺利,66代表2级顺利,666代表3级顺利,以此类推。你看,数学狂人的
  9. 技术总监“阿朱”是何许人也
  10. Db2连接的详细信息