Re: Re : concatenate pairs of files

From: Jiaxin Zhang <jiaxinzhang3_at_nyahnyahspammersnyahnyah>
Date: Sun Apr 13 2014 - 19:33:06 MDT

Dear NCL users,

I am trying to concatenate pairs of netcdf files with NCL.

When I use the attached code "test_concatenate_files.ncl" works for 2
specific files. But, I need to modify that script to use a loop for pairs
of files (2 consecutive months). I have tried the attached script
"test_concatenate_files_loop.ncl", but it does not work (it seems that the
file extension "*.nc" should appear before using "addfiles", and I am also
not sure on how to name and write the new netcdf files created in the
loop).

What I would need to do is to concatenate pairs of files (the file of one
month, with the file of the following month). For instance concatenate file
site1_tair_2009_01.nc (year 2009 month January) with file
site1_tair_2009_02.nc (year 2009 month February) and create a new netcdf
including information of both files; also concatenate file
site1_tair_2009_02.nc with site1_tair_2009_03.nc and create a new
netcdf;... and so on. Also at the end of the year concatenate the December
netcdf with the January netcdf of the following year (concatenate
site1_tair_2009_12.nc with site1_tair_2010_01.nc).

I am attaching netcdf files for 24 consecutive months and the script
"test_concatenate_files_loop.ncl". Could anyone please let me know what has
to be modified in the attached ncl script to work with the attached netcdf
files?

Thank you in advance.

Jiaxin

2014-04-01 8:17 GMT-07:00 Jiaxin Zhang <jiaxinzhang3@gmail.com>:

> Thank you Louis, but if it is possible I prefer to use NCL for this part.
>
> I guess it is possible to solve this problem with NCL, right? Could anyone
> please let me know how to do this in NCL? What has to be modified in the
> NCL script that I sent to concatenate pairs of netcdf files?
>
> Thank you.
>
> Jiaxin
>
> 2014-03-31 22:23 GMT-07:00 louis Vonder <appopson@yahoo.fr>:
>
> Dear Jiaxin,
>>
>> What about using nco or cdo
>>
>> with nco you can do: ncrcat site1_tair_*.nc output_files
>> with cdo you can do: cdo mergetime site1_tair_*.nc output_file
>>
>> Regards
>>
>> --------------------------------------------
>> En date de : Mar 1.4.14, Jiaxin Zhang <jiaxinzhang3@gmail.com> a écrit :
>>
>> Objet: [ncl-talk] concatenate pairs of files
>> À: "ncl-talk@ucar.edu maillist" <ncl-talk@ucar.edu>
>> Date: Mardi 1 avril 2014, 4h13
>>
>> Dear NCL
>> users,
>>
>> I have one question
>> about concatenate pairs of netcdf
>> files.
>>
>> I need to concatenate
>> two netcdf files and create a new netcdf file including
>> information of both netcdf files. Attached is a code
>> that works for the two attached netcdf
>> files. The problem is that the code
>> has to be modified to work for all the netcdf files.
>>
>>
>>
>> I have the following
>> netcdf files (the file name means site1_tair_year1980_month01.nc):
>>
>>
>> site1_tair_1980_01.nc,
>> site1_tair_1980_02.nc,
>> site1_tair_1980_03.nc,
>> site1_tair_1980_04.nc,
>> ..., site1_tair_1980_10.nc,
>> site1_tair_1980_11.nc,
>> site1_tair_1980_12.nc,
>> site1_tair_1981_01.nc,
>> site1_tair_1981_02.nc,
>> ..., site1_tair_1981_12.nc,
>> site1_tair_1982_01.nc,
>> ..., and so on until site1_tair_2012_12.nc.
>>
>>
>> What I would need to
>> do is to concatenate pairs of files (the file of one month,
>> with the file of the following month). For instance
>> concatenate file site1_tair_1980_01.nc
>> with file site1_tair_1980_02.nc
>> and create a new netcdf including information of both files;
>> also concatenate file site1_tair_1980_02.nc
>> with site1_tair_1980_03.nc
>> and create a new netcdf;... and so on. Also at the end of
>> the year concatenate the December netcdf with the January
>> netcdf of the following year (for instance concatenate
>> site1_tair_1980_12.nc
>> with site1_tair_1981_01.nc).
>> The last netcdf file that I have is December 2012 (no netcdf
>> file for January 2013 to concatenate with December
>> 2012).
>>
>>
>> Could someone please
>> let me know what has to be modified in the attached NCL code
>> to concatenate pairs of files (consecutive months) for all
>> the netcdf files (starting in January 1980 until
>> December 2012)?
>>
>>
>> Thank you in
>> advance.
>>
>> Jiaxin
>> -----La pièce jointe associée suit-----
>>
>> _______________________________________________
>> ncl-talk mailing list
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>

_______________________________________________
ncl-talk mailing list
List instructions, subscriber options, unsubscribe:
http://mailman.ucar.edu/mailman/listinfo/ncl-talk

Received on Sun Apr 13 19:33:22 2014

This archive was generated by hypermail 2.1.8 : Fri Apr 18 2014 - 17:37:58 MDT