[Thread Prev][Thread Next][Index]

RE: [ferret_users] how to cancatenate nc files that have no time dimension ?



Hey Kishore,

 

Another way to do this would be to use NCO (NetCDF Operators).

ncecat is the command you want, and you can do what you need in one line.

 

Eg.

ncecat –n 100,5,10 file_00001.nc allfiles.nc

 

In the above command:

·         -n means loop

·         100,5,10 are the arguments that go to the loop option, where you want to concatenate 100 files, using 5 digits (numbers in: file_00001.nc), and make jumps by 10 (i.e. file_00001.nc + file_00011.nc + file_00021.nc, etc.)

·         File_00001.nc is the first file in the long list of 100 files you want to concatenate together

·         allfiles.nc is the name of your new concatenated file.

 

Cheers from Tasmania!

Pearse

 

 

 

From: owner-ferret_users@xxxxxxxx [mailto:owner-ferret_users@xxxxxxxx] On Behalf Of Ansley C. Manke
Sent: Tuesday, 29 March 2016 4:04 AM
To: ferret_users@xxxxxxxx
Subject: Re: [ferret_users] how to cancatenate nc files that have no time dimension ?

 

Hi,
You can define a time axis with the correct times, and add a variable which is 0*time on that axis to your input data. This has the effect of putting your data onto a time axis, then you can write out the appropriate timestep to an output file.  The ideas are shown under "Timestamp", a few paragraphs down in this section:

http://ferret.pmel.noaa.gov/Ferret/documentation/users-guide/commands-reference/SAVE

yes? DEFINE AXIS/T="1-JUL-1980":"1-JUL-1985":1/UNIT=year tannual
yes? LET timestamp = T[Gt=tannual] * 0 !always 0

yes? use data_1980.nc
yes? let var_with_time = var + timestamp
yes? set attributes/like=var var_with_time
yes? save/t=1-JUL-1980/file=timedata.nc var_with_time
yes? cancel data 1980

yes? use data_1981
... same definitions, save the data in 1981.

The variable 'var_with_time' is defined at all timesteps, but you write out only the one at the desired time, so that the data for 1980 is associated with the timestep in 1980, and so forth.

You can even preserve the original variable names, by renaming the incoming variable to another name, then using the original variable in the modified version of it.

yes? use data_1980.nc
yes? set var/name=var_in var
yes? let var = var_in + timestamp
...

 

On 3/27/2016 6:27 AM, Kishore Ragi wrote:

Hi ferret users,

I have multiple files with time specified in the file name, but there is no time dimension. I would like to add time dimension and merge all the files into one.

Could anybody tell me how to combine all the files with time dimension?

I appreciate your help.

Thank you in advance.

Regards,

Kishore

PhD student in climate science,

National Institute of Technology, Rourkela,

India- 769008

 



University of Tasmania Electronic Communications Policy (December, 2014).
This email is confidential, and is for the intended recipient only. Access, disclosure, copying, distribution, or reliance on any of it by anyone outside the intended recipient organisation is prohibited and may be a criminal offence. Please delete if obtained in error and email confirmation to the sender. The views expressed in this email are not necessarily the views of the University of Tasmania, unless clearly intended otherwise.


[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement