[gradsusr] How to combine the different nc files to calculate the mean and SD? Thanks.

Muhammad Yunus Ahmad Mazuki ukm.yunus at gmail.com
Mon Jan 7 10:04:19 EST 2013


Hi

I believe your hgt.'yr' is not correct in GrADS. GrADS will open the file
hgt.1981.nc as file 1, and hgt.2010.nc as file as file 30. So you should
just use xxx=1 and while(xxx<=30), since you also you also use yr to set
the times. Instead of hgt.1981, it will be registered as hgt.1, which is
how GrADS use it. you will also need to add xxx=xxx+1 at the end of the
loop. Using cdo will make your life easier.

You can also use template option in GrADS. You can also go to a long length
using GrADS to read the files and write it to a single file.

Yunus


On Mon, Jan 7, 2013 at 9:54 PM, Kishore Babu <kishoreragi at gmail.com> wrote:

> Hi,
>
> you can play very easily with nc file with simple handling cdo commands..
>
> As per your question, you want to add many files into a single file
> containing same variable for a longer time.
>
> I hope that you have installed cdo. If yes, just invoke the following
> command ...
>
> cdo mergetime input1.nc input2.nc input3.nc ........... output.nc
>
> That's it! you are done !!!  your output file contains all the time you
> need..
>
> Cheers,
>
> Kishore
>
>
> On Mon, Jan 7, 2013 at 5:49 PM, 2008 duan <duan.scut.cn at gmail.com> wrote:
>
>> Dear Everyone,
>>
>>         Happy New Year!
>>
>>         Now I have a question to ask you. Thank you very much!
>>
>>  'reinit'
>>
>> 'sdfopen D:\TDDOWNLOAD\hgt.1981.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1982.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1983.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1984.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1985.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1986.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1987.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1988.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1989.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1990.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1991.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1992.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1993.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1994.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1995.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1996.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1997.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1998.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.1999.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2000.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2001.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2002.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2003.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2004.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2005.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2006.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2007.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2008.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2009.nc'
>> 'sdfopen D:\TDDOWNLOAD\hgt.2010.nc'
>> 'set mpdset hires'
>> yr=1981
>> while(yr<=2010)
>>
>> *******************************************************
>> *Standard deviation will be caculated
>> 'set lat 0 50.5'
>> 'set lon 119.5 179.5'
>>
>>
>> 'define mean=ave(hgt.'yr',time=01JAN'yr',time=31DEC'yr')'
>> 'define sd=sqrt(ave(pow(hgt.'yr'-mean,2),time=01JAN'yr',time=31DEC'yr'))'
>>
>> *********************************************************
>> *This is a skill to plot a shaded map with contour on it
>> 'set grads off'
>> 'set gxout shaded'
>> 'd sd'
>> 'cbarn'
>> 'set gxout contour'
>> 'set cthick 5'
>> 'd sd'
>> 'draw title Standard Deviation of 'yr' '
>> 'printim D:\TDDOWNLOAD\'yr'.png x1000 y800 white'
>> 'c'
>> yr=yr+1
>> endwhile
>> ;
>>
>> I donot know where are the wrongs.  I want to figure out the mean and SD between 1981 to 2010.
>>
>> I want to ask how to combine the files containing hgt.1981.nc to hgt.2010.nc. If it is a single file, I think it is easy to figure out the mean and SD.
>>
>> Thank you everyone!
>>
>>
>> --
>> Weili Duan
>> Disaster Prevention Research Institute (DPRI), Kyoto University, Uji,
>> Kyoto 611-0011, Japan
>> TEL: +81-774-38-4131 FAX: +81-774-38-4130
>> E-mail: duan.scut.cn at gmail.com
>>            duanwl1986 at flood.dpri.kyoto-u.ac.jp<dyuan.weiri.88r at st.kyoto-u.ac.jp><dyuan.weiri.88r at st.kyoto-u.ac.jp>
>>
>> _______________________________________________
>> gradsusr mailing list
>> gradsusr at gradsusr.org
>> http://gradsusr.org/mailman/listinfo/gradsusr
>>
>>
>
> _______________________________________________
> gradsusr mailing list
> gradsusr at gradsusr.org
> http://gradsusr.org/mailman/listinfo/gradsusr
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://gradsusr.org/pipermail/gradsusr/attachments/20130107/5764367c/attachment-0003.html 


More information about the gradsusr mailing list