《最新nco常用命令及高级玩法.doc》由会员分享,可在线阅读,更多相关《最新nco常用命令及高级玩法.doc(11页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、精品资料nco常用命令及高级玩法.NNco command:注意:nc文件中的文件名最好不要用数字开头,1.ncdumph nc文件名查看nc文件的信息2.ncrcat 2001.nc 2002.nc 2003.nc out.ncn个nc文件按时间顺序合并3.ncks:ncks -d time,624,635 nswrs.mon.mean.kang.nc nswrs.month.00.nc将时次624到635的资料从nswrs.mon.mean.kang.nc中分割出来放在nswrs.month.00.nc中ncks -A -v uavg,vavg in.nc out.nc将in.nc中的ua
2、vg,vavg变量添加到out.nc中去,同时in.nc和out中的cordinate variable name重复,in.nc中的cordinate variable替换out.nc 中的coordinate variablencks -O -x -v US in.nc out.nc : Remove US variable from in.nc, that is, the out.nc contains all variables of in.nc except USncks O d lon,12 in.nc out.nc: subset variables with lon(12)nc
3、ks O d lon,12. in.nc out.nc: subset variables with lon=12.4.ncea d time,0,2 d lat,0,36 85.nc 86.nc 87.nc ave.nc,对前面多个文件在规定的维数范围内求平均,放在后面一个文件里面。5.ncl_convert2nc a.grb,将grb文件转化成为nc文件6. ncl_filedump c a.grb7.8、ncatted:比较简单,但是也比较容易出错,最好参考教材ncatted -O -a units,y_T,o,c,nounits oda_test_restore.nc为变量y_T的un
4、its属性修改为字符型属性nounitsncatted -O -a cartesian_axis,grid_y_T,c,c,Y oda_test_restore.nc为变量grid_y_T增加属性cartesian_axis”Y” ncatted -a case,global,m,c,fwf fwf.cpl.r.1941-01-01-00000.nc : change global attributes.ncatted -a missing_value,temp,m,f,36 oda_sub_kang.nc将变量的缺省值修改为36.0,注意,修改的不仅是metadata,而且也修改了temp变
5、量里面缺省值的值为36.0,注意,此时最好_Fill_Value最好不要出现ncatted -O -a filename,global,m,c,temp_sfc_restore.nc oda_test_restore.nc修改oda_test_restore.nc中global attributes下面filename的值为temp_sfc_restore.ncncatted -a TITLE,global,c,c,OUTPUT FROM WRF V3.3 MODEL wrf.d01.nc ncatted -O -a calendar,time,d,u10_07sep1_08mar2.nc删除
6、time的calendar属性9、ncrename:ncrenamev temp,tem in.nc给变量改名ncrenamed lat1,lat in.nc给坐标改名10、ncap2(ncap):必须要两个文件名:in.nc out.ncncap usually loses the attribute while ncap2 keeps attribute.ncap2 -O -s anomaly_2hour_outchange=temp-temp_restore in.nc out.nc两个变量相减生成第三个变量ncap2 -O -s temp_oda=float(temp_oda) in.
7、nc out.nc将in.nc中的变量temp_oda转变成float类型ncap2Oslon_latlon,lat=lat+lonin.nc out.nclat和lon分别是一维数组,产生一个二维数组lon_lat(lon,lat)11、ncpdq:ncpdq -a -lat oda_sub_kang.nc out.nc改变lat的排列方向ncpdq -a T,Z,Y,X -v temp temperature_jccom.nc out.nc改变变量temp的排放顺序为temp(t,z,y,x)ncpdq -a zt,TIME regrid_3d.nc out.ncchange the re
8、cord dimension from TIME to ztncpdq in.nc out.nc all variable to nc_shortncpdq U in.nc out.nc unpack all variable to float12、ncrancra -d TIME,0,30,1 u_10.nc u.nc对u_10.nc的第一个月求平均值13、ncwa: Note: only valid in one dimension average.ncwaOa lon in.nc out.ncstore the zonal mean of in.nc in out.nc14ncbonee
9、d only 3 files.ncbo-O -op_typ=add/sub/mlt/dvd in1.nc in2.nc out.nc“ncbo performs binary operations(addition subtraction multiplication division, file1+-*/file2=out.nc) on variables in file1 and corresponding variables(those with the same name) in file2 and stores the results in file315ncflintncflint
10、 -O -C -v prs_sfc -w 0.01,0.0 in.nc in.nc out.nc -C,which causesNCOtonot automatically add coordinates to the variables appearing in the output-file.Rescale the dimensional units of the surface pressure prs_sfc from Pascals to hectopascals(millibars)含nc文件的fortran编译命令ifort -o fortran.exe fortran1.f90
11、 -I/usr/local/include -L/usr/local/liblnetcdf17上用32位编译:xlf90 layer.f90 -I/gpfs/fs4/kangxb/software/software.32bit/include -L /gpfs/fs4/kangxb/software/software.32bit/lib -lnetcdfXlf90c a.f90只编译不链接Segmentation fault:堆栈不够的标志,此时尝试用-q64编译,如果还不行,就只好修改程序,减少堆栈GRADS: 1、grads二进制文件转换成为nc文件: lats4d -i test.ctl
12、 -o test.nc -ftype ctl -vars clfmi2、命令行执行lats4d: gradsc-lbclats4d-v-q-imodel-oex1CDO./configure CC=pgcc -prefix=/global/u2/k/kang/software/cdo-1.4.3 -with-netcdf=/opt/cray/netcdf/4.0.1.0/netcdf-pgi/ -with-hdf5=/opt/cray/hdf5/1.8.3.0/hdf5-pgi/ -with-szlib=/usr/common/usg/szip/2.1/pgi/./configure CC=p
13、gcc -prefix=/global/u2/k/kang/software/cdo-1.4.3 -with-netcdf=/opt/cray/netcdf/4.0.1.0/netcdf-pgi-with-hdf5=/opt/cray/hdf5/1.8.5.0/hdf5-pgi/-with-szlib=/usr/common/usg/szip/2.1/pgi/on evergreen:./configure -prefix=/homes/xkang/software/cdo -with-netcdf=/cell_root/software/netcdf/4.1.1/intel400 CC=ic
14、c -with-hdf5=/cell_root/software/hdf/1.8.6/intel/sys/includeLIBS=-lcurl./configure -prefix=/homes/xkang/software/cdo -with-netcdf=/cell_root/software/netcdf/4.1.1/intel400 CC=icc LIBS=-lcurl -lgssapi_krb5 -lssl -lcrypto -ldl -lidn -ldes425 -lkrb5 -lk5crypto -lcom_err -lkrb5support -lresolv1. binary
15、- nc /global/u2/k/kang/software/cdo-1.4.3/bin/cdo -f nc import_binary in.ctl out.nc2. nc - grib : https:/code.zmaw.de/boards/1/topics/2907operator strategies:1、specifying large number files :nc file name = alphanumeric_prefix+numeric_suffix+.+filetype #ncea/ncecat/ncra/ncrcatn file_number,digit_numb
16、er,numeric_increment#where digit number is the fixed number of numeric digits comprising the numeric_suffix, as the following example:digit_number is 2, no alphanumeric_prefix, if digit_number is 1, then the alphanumeric_prefix is 8.ncran 5,2,1 85.nc 8589.nc# ncra 85.nc 86.nc 87.nc 88.nc 89.nc 8589.
17、ncspecial skills:2、convert time from a record dimension to a non-record dimensionncecat in.nc out.nc# Convert time to non-record dimensionncwa -a record in.nc out.nc# Remove new degenerate record dimension3、convert time from a fixed dimension to a record dimensionncecat in.nc out.nc# create a record
18、 dimension:“record”ncpdq -a TIME,record out.nc in.nc #change the record dimension from“record”to TIMEncwa -a record in.nc out.nc# Remove new degenerate record dimension4、how to glue time dimension lacking files together with time dimension added?(ex: temp_0hour(lat,lon), temp_6hour(lat,lon) to temp(
19、time,lon,lat) )ncecat temp1.nc temp_0hour.ncresult: temp(record,lat,lon), record = UNLIMITED ; / (1 currently)ncecat temp2.nc temp_6hour.ncresult: temp(record,lat,lon), record = UNLIMITED ; / (1 currently)ncrcat temp_0hour.nc temp_6hour.nc temp.nc,result: temp(record,lat,lon), record = UNLIMITED ; /
20、 (2 currently)ncrenamed record,time temp.ncresult:temp(time,lat,lon)create time.nc file (like : time = UNLIMITED ; / (2 currently) , double time(time) ) with nclncksA time.nc temp.ncresult: temp(time,lat,lon)5、How to use .ps file in the word ?Open the *.ps file with gsv software - select the“PS to E
21、PS”button in“file”menu - save as *.eps (the word supported format) Open .ps with gsview - convert -jpeg6、Ncl multiple input files skills:Ex:#define variable #name = new(/2/),string)in = new(/2/),file)temp=new(/2,50,200,360/),double)#give the variable the value#name(0) = (/temp.2005_1.nc/)name(1) = (
22、/temp.2005_2.nc/)do i = 0,1in(i) = addfile(name(i),r)in2 = in(i)temp(i,:,:,:)=in2-tempend do7、add time record#!/bin/cshset echo# attribute time dimension as record dimensionforeach label ( soda_u_1981.nc soda_v_1981.nc )ncecat -O $label out.ncncpdq -O -a time,record out.nc out1.ncncwa -O -a record o
23、ut1.nc $labelrm out*end8. daily mean to monthly mean including leap year.#!/bin/tcshset echorm *.tmp yr = 1951while ( $yr a.gifconvert a.gif a.pngconvert salt.pdf salt.gif将pdf文档转化成了gif文件格式(如果pdf中有多张图片,则gif文件是动画)convert salt.pdf salt.png将pdf文档转化成了png格式(如果pdf中有多张图片,则转化成多张png图片)convert -crop 360x320+12
24、0+260 salt1.png/salt.pdf salt.png/salt1.png/salt.gif切割图片,(120260)指切割后图形的左下角在原图的坐标,360指切割后图形的宽,320指切割后图形的高convertdelay 80.0 temp.*.png temp.gif将图片连接成动画,图形间间隔0.2秒packing data:unix系统下grads的运行命令运行ps:gradsnclbc/pbc temp.gs看图xv *.png/tif/gif/jpg/ncl skill:1、在linux下,可以用idt查看ncgm文件2、两种运行ncl的方式:一种是直接键入ncl,然后
25、依次输入命令行,另外一种是编辑脚本文件*.ncl,然后用命令ncl *.ncl执行该脚本文件*.ncl3、Ncl中的变量由三部分组成:variable name, metadata(attribute, and dimension)和variable value三部分4、变量的metadata有两种获取渠道:一种直接来源于其它nc文件,例如lat1=input-lat,另外一种是用户自己定义variableattribute=attribute_value5、system(rm oda.nc);check to make sure netcdf file doesnt exist; if it does, remove it每次运行ncl之前,清除以前生成的nc文件6、ncl_convert2nc data.grb将grib文件转换成nc文件data.nc7、ncl script must add frame(wks), then it is much easier from ps to jpeg with gsview.