[gradsusr] Multiple netcdf files in one control file

mehwish ramzan mehwish.ramzan at gmail.com
Tue May 13 04:38:35 EDT 2014


 Dear Jim and Charles,

Thank you for your kind help again.
I figure out an easy way to combine multiple netcdf files by following
links ( http://www.iges.org/grads/gadoc/gradcomdsdfwrite.html) and
(http://nco.sourceforge.net/nco.html#Concatenation<http://nco.sourceforge.net/nco.html#Concatenation>).
So I can simply convert the multiple files using below command;

ncrcat <http://nco.sourceforge.net/nco.html#ncrcat> -O –h
cru_ts3.21.1971.1980.tmp.dat.nc cru_ts3.21.1981.1990.tmp.dat.nc
cru_ts3.21.1991.2000.tmp.dat.nc tmp.nc

Thank you so much .

With Best Regards,

Mehwish


On Tue, May 13, 2014 at 2:28 PM, mehwish ramzan <mehwish.ramzan at gmail.com>wrote:

> Dear Jim and Charles,
>
> Thank you so much for your kind reply and help.
> Based upon Jim's suggestions, I prepared the following control file by
> using %ch template to use multiple files like below;
>
> dset ^cru_ts3.21.%ch.tmp.dat.nc
> chsub   1  120 1971.1980
> chsub 121  240 1981.1990
> chsub 241  360 1991.2000
> options template
> title cru_ts3.21 near-surface temperature
> undef -9.99+08
> xdef  720 linear 0.0     0.5
> ydef  360 linear -89.75  0.5
> zdef    1 levels 0  0
> tdef  480 linear jan1971 1mo
> vars    1
>  tmp 0 -999  near-surface temperature
> endvars
>
>
> Also based upon Charles kind suggestion I checked for dtype netcdf but
> as I just followed the this link *http://www.iges.org/grads/gadoc/templates.html
> <http://www.iges.org/grads/gadoc/templates.html> *when first prepared the
> control file so I am not sure whether dtype option is needed or not? (sorry
> for my poor understanding)
>
> But when I exclude the dtype option from control file, it opened in GrADS
> but the output image was incorrect.
>
> The correct output from original netcdf file as well as the one prepared
> using above ch. ctl  is attached.
> Kindly guide me further in this regards or suggest me an alternate method
> (such as using fwrite script etc.)
>
> I will be grateful
>
> Thank you
>
> With Best Regards,
>
> Mehwish
>
>
>
>
>
> On Tue, May 13, 2014 at 7:22 AM, Charles Seman - NOAA Federal <
> charles.seman at noaa.gov> wrote:
>
>> Mehwish,
>>
>> from http://grads.iges.org/grads/gadoc/descriptorfile.html#VARS
>> ---
>> units
>> (DTYPE netcdf,
>> hdfsds, or hdf5_grid)
>>
>> (GrADS version 1.9) For DTYPE netcdf or hdfsds or hdf5_grid (GrADS
>> version 2.0.a7+) , the units field is a comma-delimited list of the
>> varying dimensions of the variable. Dimensions expressed as x, y, z, or
>> t correspond to the four axes defined by XDEF, YDEF, ZDEF and TDEF. For
>> example, a surface variable such as sea level pressure might look like
>> this:
>>
>>      presSFC=>psfc   0   y,x   Surface Pressure
>> ---
>>
>> would the above apply since you are using "dtype netcdf"?
>>
>> Hope this helps,
>> Chuck
>>
>> On 05/12/2014 03:11 PM, James T. Potemra wrote:
>> > Mehwish,
>> >
>> > I think the problem is your file names contain different decades, so in
>> > your .ctl file where you have:
>> >
>> > DSET  cru_ts3.21.%x31.%x30.tmp.dat.nc
>> >
>> > the %x3 will be the same.  For example, the first time through the
>> > substitution will be 197, or
>> >
>> > DSET cru_ts3.21.1971.1970.tmp.dat.nc
>> >
>> > One way around this would be to instead use chsub:
>> >
>> > DSET ^cru_ts3.21.%ch.tmp.dat.nc
>> > CHSUB     1 120 1971.1980
>> > CHSUB 121  240 1981.1990
>> > CHSUB 241  360 1991.2000
>> > OPTIONS template
>> > DTYPE netcdf
>> >
>> > More details at http://www.iges.org/grads/gadoc/templates.html
>> >
>> > Jim
>> >
>> > On 5/11/14 9:02 PM, Malleswararao Maguluri wrote:
>> >> Hi,
>> >>
>> >>    Better to use cdo for calculating climatology. otherwise you can
>> >> combine your decadal files as a single file using cat command in cdo
>> >> and use it as input to grads.
>> >>
>> >> Thanks & regards,
>> >>
>> >>
>> >> On Mon, May 12, 2014 at 12:18 PM, mehwish ramzan
>> >> <mehwish.ramzan at gmail.com <mailto:mehwish.ramzan at gmail.com>> wrote:
>> >>
>> >>     Dear GrADS community,
>> >>
>> >>     I am trying to merge multiple netcdf files into one control file
>> >>     so that i can calculate the climatology of 25 years. The data is
>> >>     available in decadal format like this;
>> >>
>> >>     cru_ts3.21.1971.1980.tmp.dat.nc
>> >>     <http://cru_ts3.21.1971.1980.tmp.dat.nc>
>> >>     cru_ts3.21.1981.1990.tmp.dat.nc
>> >>     <http://cru_ts3.21.1981.1990.tmp.dat.nc>
>> >>     cru_ts3.21.1991.2000.tmp.dat.nc
>> >>     <http://cru_ts3.21.1991.2000.tmp.dat.nc>
>> >>     cru_ts3.21.1991.2000.tmp.dat.nc
>> >>     <http://cru_ts3.21.1991.2000.tmp.dat.nc>
>> >>
>> >>     while the information of one .nc file is as;
>> >>
>> >>     File 1 : CRU TS3.21 Mean Temperature
>> >>
>> >>     Descriptor: cru_ts3.21.1971.1980.tmp.dat.nc
>> >>     <http://cru_ts3.21.1971.1980.tmp.dat.nc>
>> >>
>> >>     Binary: cru_ts3.21.1971.1980.tmp.dat.nc
>> >>     <http://cru_ts3.21.1971.1980.tmp.dat.nc>
>> >>
>> >>     Type = Gridded
>> >>
>> >>     Xsize = 720Ysize = 360Zsize = 1Tsize = 120
>> >>
>> >>     Number of Variables = 1
>> >>
>> >>     tmp 0 -999 near-surface temperature
>> >>
>> >>     By following some previous posts regarding same issue, according
>> >>     to my understanding i prepared one ctl file which can be used as a
>> >>     combination of above four separate files. The .ctl file is as
>> follows;
>> >>
>> >>     DSETcru_ts3.21.%x31.%x30.tmp.dat.nc <http://x30.tmp.dat.nc>
>> >>
>> >>     OPTIONS template
>> >>
>> >>     DTYPE netcdf
>> >>
>> >>     XDEF 720 linear -89.75 89.75
>> >>
>> >>     YDEF 360 linear 0 360
>> >>
>> >>     ZDEF1 linear 1000
>> >>
>> >>     TDEF 480 linear jan1971 1mo
>> >>
>> >>     vars 1
>> >>
>> >>     tmp 099 near-surface temperature
>> >>
>> >>     endvars
>> >>
>> >>
>> >>     But when i tried to open this control file. It give error message;
>> >>
>> >>     Invalid variable record
>> >>
>> >>     --> The invalid description file record is:
>> >>
>> >>     --> tmp 0 -999 near-surface temperature
>> >>
>> >>     The data file was not opened.
>> >>
>> >>     I know i am making mistake in preparing ctl file but i don't know
>> >>     how to put right information ?
>> >>
>> >>     Please help me in solving this issue.
>> >>
>> >>
>> >>     Thank You
>> >>
>> >>
>> >>     With Best Regards,
>> >>
>> >>
>> >>     Mehwish
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>
>> >>     _______________________________________________
>> >>     gradsusr mailing list
>> >>     gradsusr at gradsusr.org <mailto:gradsusr at gradsusr.org>
>> >>     http://gradsusr.org/mailman/listinfo/gradsusr
>> >>
>> >>
>> >>
>> >>
>> >> --
>> >> M. MALLESWARA RAO
>> >> M.Tech (Atmospheric Science) & M.Sc (Physics)
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> 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
>> >
>>
>> --
>>
>> Please note that Charles.Seman at noaa.gov should be considered my NOAA
>> email address, not cjs at gfdl.noaa.gov.
>>
>> ********************************************************************
>>   Charles Seman                                Charles.Seman at noaa.gov
>>   U.S. Department of Commerce / NOAA / OAR
>>   Geophysical Fluid Dynamics Laboratory         voice: (609) 452-6547
>>   201 Forrestal Road                              fax: (609) 987-5063
>>   Princeton, NJ  08540-6649            http://www.gfdl.noaa.gov/~cjs/
>> ********************************************************************
>>
>> "The contents of this message are mine personally and do not reflect any
>> official or unofficial position of the United States Federal Government,
>> the United States Department of Commerce, or NOAA."
>> _______________________________________________
>> 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/20140513/14e8a513/attachment-0001.html 


More information about the gradsusr mailing list