nco常用命令及高级玩法_第1页
nco常用命令及高级玩法_第2页
nco常用命令及高级玩法_第3页
nco常用命令及高级玩法_第4页
nco常用命令及高级玩法_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

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中的coordinatevariablencks-O-x-vUSin.ncout.nc:RemoveUSvariablefromin.nc,thatis,theout.nccontainsallvariablesofin.ncexceptUSncks–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.grb7.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.ncncatted-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.ncncapusuallylosestheattributewhilencap2keepsattribute.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

changetherecorddimensionfromTIMEtoztncpdqin.ncout.ncallvariabletonc_shortncpdq–Uin.ncout.ncunpackallvariabletofloat12、ncrancra-dTIME,0,30,1u_10.ncu.nc

对u_10.nc的第一个月求平均值13、ncwa:Note:onlyvalidinonedimensionaverage.ncwa

-O

–alonin.ncout.nc

storethezonalmeanofin.ncinout.nc14

ncboneedonly3files.ncbo

-O--op_typ=add/sub/mlt/dvdin1.ncin2.ncout.nc

“ncboperformsbinaryoperations(additionsubtractionmultiplicationdivision,file1+-*/file2=out.nc)onvariablesinfile1andcorrespondingvariables(thosewiththesamename)infile2andstorestheresultsinfile315

ncflintncflint-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

–lnetcdf17上用32位编译:xlf90layer.f90-I/gpfs/fs4/kangxb/software/software.32bit/include-L/gpfs/fs4/kangxb/software/software.32bit/lib-lnetcdfXlf90

–ca.f90

只编译不链接Segmentationfault:堆栈不够的标志,此时尝试用-q64编译,如果还不行,就只好修改程序,减少堆栈GRADS:1、grads二进制文件转换成为nc文件:lats4d-itest.ctl-otest.nc-ftypectl-varsclfmi2、命令行执行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//netcdf-pgi/--with-hdf5=/opt/cray/hdf5//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//netcdf-pgi--with-hdf5=/opt/cray/hdf5//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.nc2.nc->grib:https://code.zmaw.de/boards/1/topics/2907operatorstrategies: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.ncspecialskills:

2、

converttimefromarecorddimensiontoanon-recorddimensionncecatin.ncout.nc

#Converttimetonon-recorddimensionncwa-arecordin.ncout.nc

#Removenewdegeneraterecorddimension

3、

converttimefromafixeddimensiontoarecorddimensionncecatin.ncout.nc

#createarecorddimension:

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

“record”

toTIMEncwa-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->jpeg6、

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

enddo7、

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*

end8.dailymeantomonthlymeanincludingleapyear.#!/bin/tcshsetechorm*.tmp@yr=1951while($yr<=2007)setisleap=0foreachyr1(1952195619601964196819721976198019841988199219962000200420082012)if($yr==$yr1)thensetisleap=1endifendif($isleap==0)thenncra-O-dtime,0,30download/APHRO_MA_025deg_V1003R1.$yr.ncout.10.ncncra-O-dtime,31,58download/APHRO_MA_025deg_V1003R1.$yr.ncout.11.ncncra-O-dtime,59,89download/APHRO_MA_025deg_V1003R1.$yr.ncout.12.ncncra-O-dtime,90,119download/APHRO_MA_025deg_V1003R1.$yr.ncout.13.ncncra-O-dtime,120,150download/APHRO_MA_025deg_V1003R1.$yr.ncout.14.ncncra-O-dtime,151,180download/APHRO_MA_025deg_V1003R1.$yr.ncout.15.ncncra-O-dtime,181,211download/APHRO_MA_025deg_V1003R1.$yr.ncout.16.ncncra-O-dtime,212,242download/APHRO_MA_025deg_V1003R1.$yr.ncout.17.ncncra-O-dtime,243,272download/APHRO_MA_025deg_V1003R1.$yr.ncout.18.ncncra-O-dtime,273,303download/APHRO_MA_025deg_V1003R1.$yr.ncout.19.ncncra-O-dtime,304,333download/APHRO_MA_025deg_V1003R1.$yr.ncout.20.ncncra-O-dtime,334,364download/APHRO_MA_025deg_V1003R1.$yr.ncout.21.ncelsencra-O-dtime,0,30download/APHRO_MA_025deg_V1003R1.$yr.ncout.10.ncncra-O-dtime,31,59download/APHRO_MA_025deg_V1003R1.$yr.ncout.11.ncncra-O-dtime,60,90download/APHRO_MA_025deg_V1003R1.$yr.ncout.12.ncncra-O-dtime,91,120download/APHRO_MA_025deg_V1003R1.$yr.ncout.13.ncncra-O-dtime,121,151download/APHRO_MA_025deg_V1003R1.$yr.ncout.14.ncncra-O-dtime,152,181download/APHRO_MA_025deg_V1003R1.$yr.ncout.15.ncncra-O-dtime,182,212download/APHRO_MA_025deg_V1003R1.$yr.ncout.16.ncncra-O-dtime,213,243download/APHRO_MA_025deg_V1003R1.$yr.ncout.17.ncncra-O-dtime,244,273download/APHRO_MA_025deg_V1003R1.$yr.ncout.18.ncncra-O-dtime,274,304download/APHRO_MA_025deg_V1003R1.$yr.ncout.19.ncncra-O-dtime,305,334download/APHRO_MA_025deg_V1003R1.$yr.ncout.20.ncncra-O-dtime,335,365download/APHRO_MA_025deg_V1003R1.$yr.ncout.21.ncendifncrcat-O-n12,2,1out.10.ncmonth/APHRO_MA_025deg_V1003R1.$yr.ncrmout*@yr+=1End9.Fourtimesperdailymeantomonthlymeanforvarinslp_t_10_modq_10_modu_10_modv_10_moddofilein=$var.clim.ncfileout=$var.clim.monthly.ncncra-O-dtime,0,123$fileinout.10.ncncra-O-dtime,124,235$fileinout.11.ncncra-O-dtime,236,359$fileinout.12.ncncra-O-dtime,360,479$fileinout.13.ncncra-O-dtime,480,603$fileinout.14.ncncra-O-dtime,604,723$fileinout.15.ncncra-O-dtime,724,847$fileinout.16.ncncra-O-dtime,848,971$fileinout.17.ncncra-O-dtime,972,1091$fileinout.18.ncncra-O-dtime,1092,1215$fileinout.19.ncncra-O-dtime,1216,1335$fileinout.20.ncncra-O-dtime,1336,1459$fileinout.21.ncncrcat-O-n12,2,1out.10.nc$fileoutrmout*done

10.#rearrangelon(lon:-180:180to0:360)ncpdq-O-alon,timein.ncout.ncncks-O-dlon,0,179out.ncout1.ncncap2-O-s'lon=lon+360'out1.ncout3.ncncks-O-dlon,180,359out.ncout2.ncncatted-along_name,lon,d,,out3.ncncatted-aaxis,lon,d,,out3.ncncatted-aunits,lon,d,,out3.ncncatted-astandard_name,lon,d,,out3.ncncatted-along_name,lon,d,,out2.ncncatted-aaxis,lon,d,,out2.ncncatted-aunits,lon,d,,out2.ncncatted-astandard_name,lon,d,,out2.ncncrcat-Oout2.ncout3.ncout.ncncatted-along_name,lon,c,c,"longitude"out.ncncatted-aaxis,lon,c,c,"X"out.ncncatted-aunits,lon,c,c,"degrees_east"out.ncncatted-astandard_name,lon,c,c,"longitude"out.ncncpdq-O-atime,lonout.ncin.nc11.climatology,anomaly,standarddeviation#!/bin/bashset-xbe=0#recordofdatabegined=215#recordofdataendfilein=chla.9801-1512.nc#forclimatologymon0=$belet"mon11=$mon0+11"num=100while[$mon0-le$mon11]doncra-O-dtime,$mon0,$ed,12$fileinout.$num.nclet"mon0=$mon0+1"let"num=$num+1"donelet"num=$num-100"ncrcat-O-n$num,2,1out.100.ncltm.nc#foranomalymon0=$belet"mon11=$mon0+11"num=100while[$mon11-le$ed]doncks-O-dtime,$mon0,$mon11$fileinout.ncncbo-O--op_typ=subout.ncltm.ncout.$num.nclet"mon0=$mon0+12"let"mon11=$mon11+12"let"num=$num+1"donelet"num=$num-

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论