nco常用命令及高级玩法.docx

上传人:b****5 文档编号:4526144 上传时间:2022-12-01 格式:DOCX 页数:11 大小:130.62KB
下载 相关 举报
nco常用命令及高级玩法.docx_第1页
第1页 / 共11页
nco常用命令及高级玩法.docx_第2页
第2页 / 共11页
nco常用命令及高级玩法.docx_第3页
第3页 / 共11页
nco常用命令及高级玩法.docx_第4页
第4页 / 共11页
nco常用命令及高级玩法.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

nco常用命令及高级玩法.docx

《nco常用命令及高级玩法.docx》由会员分享,可在线阅读,更多相关《nco常用命令及高级玩法.docx(11页珍藏版)》请在冰豆网上搜索。

nco常用命令及高级玩法.docx

nco常用命令及高级玩法

NNcocommand:

注意:

nc文件中的文件名最好不要用数字开头,

1. ncdump –hnc文件名 查看nc文件的信息

2. ncrcat2001.nc2002.nc2003.ncout.nc  n个nc文件按时间顺序合并

3.  ncks:

ncks-dtime,624,635nswrs.mon.mean.kang.ncnswrs.month.00.nc 将时次624到635的资料从nswrs.mon.mean.kang.nc中分割出来放在nswrs.month.00.nc中

ncks-A-vuavg,vavgin.ncout.nc 将in.nc中的uavg,vavg变量添加到out.nc中去,同时in.nc和out中的cordinatevariablename重复,in.nc中的cordinatevariable  替换out.nc中的coordinatevariable

ncks-O-x-vUSin.ncout.nc:

RemoveUSvariablefromin.nc,thatis,theout.nccontainsallvariablesofin.ncexceptUS

ncks–O–dlon,12in.ncout.nc:

subsetvariableswithlon(12)

ncks–O–dlon,12.in.ncout.nc:

subsetvariableswithlon=12.

4. ncea–dtime,0,2–dlat,0,3685.nc86.nc87.ncave.nc, 对前面多个文件在规定的维数范围内求平均,放在后面一个文件里面。

5.ncl_convert2nca.grb ,将grb文件转化成为nc文件

6.ncl_filedump–ca.grb

7.

8、ncatted:

   比较简单,但是也比较容易出错,最好参考教材

   ncatted-O-aunits,y_T,o,c,nounitsoda_test_restore.nc 为变量y_T的units属性修改为字符型属性nounits

   ncatted-O-acartesian_axis,grid_y_T,c,c,Yoda_test_restore.nc 为变量grid_y_T 增加属性cartesian_axis=”Y”

ncatted-acase,global,m,c,fwffwf.cpl.r.1941-01-01-00000.nc:

changeglobalattributes.

ncatted-amissing_value,temp,m,f,36oda_sub_kang.nc 将变量的缺省值修改为36.0,注意,修改的不仅是metadata,而且也修改了temp变量里面缺省值的值为36.0,注意,此时最好_Fill_Value最好不要出现

   ncatted-O-afilename,global,m,c,temp_sfc_restore.ncoda_test_restore.nc 修改oda_test_restore.nc中globalattributes 下面filename的值为temp_sfc_restore.nc

ncatted-aTITLE,global,c,c,"OUTPUTFROMWRFV3.3MODEL"wrf.d01.nc

   ncatted-O-acalendar,time,d,,,  u10_07sep1_08mar2.nc 删除time的calendar属性

9、ncrename:

 ncrename –vtemp,temin.nc 给变量改名

   ncrename –dlat1,latin.nc 给坐标改名

10、ncap2(ncap):

必须要两个文件名:

in.ncout.nc

ncapusuallylosestheattributewhilencap2keepsattribute.

ncap2-O-s'anomaly_2hour_outchange=temp-temp_restore'in.ncout.nc 两个变量相减生成第三个变量

ncap2-O-s'temp_oda=float(temp_oda)'in.ncout.nc 将in.nc中的变量temp_oda转变成float类型

ncap2 –O –s ‘lon_lat[lon,lat]=lat+lon’ in.ncout.nc lat和lon分别是一维数组,产生一个二维数组lon_lat(lon,lat)

11、ncpdq:

ncpdq-a-latoda_sub_kang.ncout.nc 改变lat的排列方向

ncpdq-aT,Z,Y,X-vtemptemperature_jccom.ncout.nc 改变变量temp的排放顺序为temp(t,z,y,x)

ncpdq-azt,TIMEregrid_3d.ncout.nc changetherecorddimensionfromTIMEtozt

ncpdqin.ncout.ncallvariabletonc_short

ncpdq–Uin.ncout.ncunpackallvariabletofloat

12、ncra

ncra-dTIME,0,30,1u_10.ncu.nc 对u_10.nc的第一个月求平均值

13、ncwa:

Note:

onlyvalidinonedimensionaverage.

ncwa -O –alonin.ncout.nc storethezonalmeanofin.ncinout.nc

14 ncbo

needonly3files.

ncbo  -O--op_typ=add/sub/mlt/dvdin1.ncin2.ncout.nc “ncboperformsbinaryoperations(additionsubtractionmultiplicationdivision,file1+-*/file2=out.nc)onvariablesinfile1andcorrespondingvariables(thosewiththesamename)infile2andstorestheresultsinfile3

15 ncflint

ncflint-O-C-vprs_sfc-w0.01,0.0in.ncin.ncout.nc  -C, whichcauses NCO to notautomaticallyaddcoordinatestothevariablesappearingintheoutput-file. Rescalethedimensionalunitsofthesurfacepressureprs_sfcfromPascalstohectopascals (millibars)

含nc文件的fortran编译命令

ifort-ofortran.exefortran1.f90-I/usr/local/include-L/usr/local/lib –lnetcdf

17上用32位编译:

xlf90layer.f90-I/gpfs/fs4/kangxb/software/software.32bit/include-L/gpfs/fs4/kangxb/software/software.32bit/lib-lnetcdf

Xlf90 –ca.f90 只编译不链接

Segmentationfault:

堆栈不够的标志,此时尝试用-q64编译,如果还不行,就只好修改程序,减少堆栈

GRADS:

1、grads二进制文件转换成为nc文件:

lats4d-itest.ctl-otest.nc-ftypectl-varsclfmi

2、命令行执行lats4d:

gradsc -lbc "lats4d -v -q -i model -o ex1"

 

CDO

./configureCC=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/

./configureCC=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.5.0/hdf5-pgi/ 

--with-szlib=/usr/common/usg/szip/2.1/pgi/

onevergreen:

./configure--prefix=/homes/xkang/software/cdo--with-netcdf=/cell_root/software/netcdf/4.1.1/intel400CC=icc--with-hdf5=/cell_root/software/hdf/1.8.6/intel/sys/include LIBS='-lcurl'

./configure--prefix=/homes/xkang/software/cdo--with-netcdf=/cell_root/software/netcdf/4.1.1/intel400CC=iccLIBS='-lcurl-lgssapi_krb5-lssl-lcrypto-ldl-lidn-ldes425-lkrb5-lk5crypto-lcom_err-lkrb5support-lresolv'

1. binary->nc   /global/u2/k/kang/software/cdo-1.4.3/bin/cdo-fncimport_binaryin.ctlout.nc

2.nc->grib:

https:

//code.zmaw.de/boards/1/topics/2907

 

operatorstrategies:

1、 specifyinglargenumberfiles:

ncfilename=alphanumeric_prefix+numeric_suffix+’.’+filetype#

ncea/ncecat/ncra/ncrcat –nfile_number,digit_number,numeric_increment #wheredigitnumberisthefixednumberofnumericdigitscomprisingthenumeric_suffix,asthefollowingexample:

digit_numberis2,noalphanumeric_prefix,ifdigit_numberis1,thenthealphanumeric_prefixis8.

ncra –n5,2,185.nc8589.nc #ncra85.nc86.nc87.nc88.nc89.nc8589.nc

specialskills:

 

2、 converttimefromarecorddimensiontoanon-recorddimension

ncecatin.ncout.nc   #Converttimetonon-recorddimension

ncwa-arecordin.ncout.nc   #Removenewdegeneraterecorddimension

 

3、 converttimefromafixeddimensiontoarecorddimension

ncecatin.ncout.nc   #createarecorddimension:

 “record”

ncpdq-aTIME,recordout.ncin.nc#changetherecorddimensionfrom “record” toTIME

ncwa-arecordin.ncout.nc   #Removenewdegeneraterecorddimension

 

4、 howtogluetimedimensionlackingfilestogetherwithtimedimensionadded?

 (ex:

temp_0hour(lat,lon),temp_6hour(lat,lon)totemp(time,lon,lat))

ncecattemp1.nctemp_0hour.nc  result:

temp(record,lat,lon),record=UNLIMITED;//(1currently)

ncecattemp2.nctemp_6hour.nc  result:

temp(record,lat,lon),record=UNLIMITED;//(1currently)

ncrcattemp_0hour.nctemp_6hour.nctemp.nc,result:

temp(record,lat,lon),record=UNLIMITED;//(2currently)

ncrename –drecord,timetemp.nc result:

temp(time,lat,lon)

createtime.ncfile(like:

time=UNLIMITED;//(2currently),doubletime(time))withncl

 ncks –Atime.nctemp.nc   result:

temp(time,lat,lon)

5、 Howtouse.psfileintheword?

   Openthe*.psfilewithgsvsoftware->selectthe “PStoEPS” buttonin “file” menu->saveas*.eps(thewordsupportedformat)

Open.pswithgsview->convert->jpeg

6、 Nclmultipleinputfilesskills:

Ex:

######definevariable#################

name=new((/2/),string)

in=new((/2/),file)

temp=new((/2,50,200,360/),double)

######givethevariablethevalue#######

   name(0)=(/"temp.2005_1.nc"/)

   name

(1)=(/"temp.2005_2.nc"/)

   doi=0,1

      in(i)=addfile(name(i),"r")

      in2=in(i)

  temp(i,:

:

:

)=in2->temp

   enddo

7、  addtimerecord

 #!

/bin/csh

setecho

#attributetimedimensionasrecorddimension

foreachlabel(soda_u_1981.ncsoda_v_1981.nc )

ncecat-O$labelout.nc

ncpdq-O-atime,recordout.ncout1.nc

ncwa-O-arecordout1.nc$label

rmout*

end

8.dailymeantomonthlymeanincludingleapyear.

#!

/bin/tcsh

setecho

rm*.tmp

@yr=1951

while($yr<=2007)

setisleap=0

foreachyr1(1952195619601964196819721976198019841988199219962000200420082012)

if($yr==$yr1)then

setisleap=1

endif

end

if($isleap==0)then

ncra-O-dtime,0,30download/APHRO_MA_025deg_V1003R1.$yr.ncout.10.nc

ncra-O-dtime,31,58download/APHRO_MA_025deg_V1003R1.$yr.ncout.11.nc

ncra-O-dtime,59,89download/APHRO_MA_025deg_V1003R1.$yr.ncout.12.nc

ncra-O-dtime,90,119download/APHRO_MA_025deg_V1003R1.$yr.ncout.13.nc

ncra-O-dtime,120,150download/APHRO_MA_025deg_V1003R1.$yr.ncout.14.nc

ncra-O-dtime,151,180download/APHRO_MA_025deg_V1003R1.$yr.ncout.15.nc

ncra-O-dtime,181,211download/APHRO_MA_025deg_V1003R1.$yr.ncout.16.nc

ncra-O-dtime,212,242download/APHRO_MA_025deg_V1003R1.$yr.ncout.17.nc

ncra-O-dtime,243,272download/APHRO_MA_025deg_V1003R1.$yr.ncout.18.nc

ncra-O-dtime,273,303download/APHRO_MA_025deg_V1003R1.$yr.ncout.19.nc

ncra-O-dtime,304,333download/APHRO_MA_025deg_V1003R1.$yr.ncout.20.nc

ncra-O-dtime,334,364download/APHRO_MA_025deg_V1003R1.$yr.ncout.21.nc

else

ncra-O-dtime,0,30download/APHRO_MA_025deg_V1003R1.$yr.ncout.10.nc

ncra-O-dtime,31,59download/APHRO_MA_025deg_V1003R1.$yr.ncout.11.nc

ncra-O-dtime,60,90download/APHRO_MA_025deg_V1003R1.$yr.ncout.12.nc

ncra-O-dtime,91,120download/APHRO_MA_025deg_V1003R1.$yr.ncout.13.nc

ncra-O-dtime,121,151download/APHRO_MA_025deg_V1003R1.$yr.ncout.14.nc

ncra-O-dtime,152,181download/APHRO_MA_025deg_V1003R1.$yr.ncout.15.nc

ncra-O-dtime,182,212download/APHRO_MA_025deg_V1003R1.$yr.ncout.16.nc

ncra-O-dtime,213,243download/APHRO_MA_025deg_V1003R1.$yr.ncout.17.nc

ncra-O-dtime,244,273download/APHRO_MA_025deg_V1003R1.$yr.ncout.18.nc

ncra-O-dtime,274,304download/APHRO_MA_025deg_V1003R1.$yr.ncout.19.nc

ncra-O-dtime,305,334download/APHRO_MA_025deg_V1003R1.$yr.ncout.20.nc

ncra-O-dtime,335,365download/APHRO_MA_025deg_V1003R1.$yr.ncout.21.nc

endif

ncrcat-O-n12,2,1out.10.ncmonth/APHRO_MA_025deg_V1003R1.$yr.nc

rmout*

@yr+=1

End

9.Fourtimesperdailymeantomonthlymean

forvarinslp_t_10_modq_10_modu_10_modv_10_mod

do

filein=$var.clim.nc

fileout=$var.clim.monthly.nc

ncra-O-dtime,0,123$fileinout.10.nc

ncra-O-dtime,124,235$fileinout.11.nc

ncra-O-dtime,236,359$fileinout.12.nc

ncra-O-dtime,360,479$fileinout.13.nc

ncra-O-dtime,480,603$fileinout.14.nc

ncra-O-dtime,604,723$fileinout.15.nc

ncra-O-dtime,724,847$fileinout.16.nc

ncra-O-dtime,848,971$fileinout.17.nc

ncra-O-dtime,972,1091$fileinout.18.nc

ncra-O-dtime,1092,1215$fileinout.19.nc

ncra-O-dtime,1216,1335$fi

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 高中教育 > 高中教育

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1