[Thread Prev][Thread Next][Index]

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




Hi,

The concatenation and creation of a record dimension can be done concisely with the NCO command "ncecat"

ncecat -u Time data_*.nc concat_data.nc

will create a new file with a record axis named Time. To get the right time axis just create a time axis like Ansley has done and use the @ASN regridding.

e.g.

ncecat -u Time data_198[0-5].nc concat_data.nc

then in ferret

def axis/t="1-jul-1980":"1-jul-1985"/unit=year tannual
use concat_data.nc
let var_with_time = var[t=tannual@asn]
...

This can be saved to a new file to get the time information in the file or the values of time can be easily written to. If you are adding attributes to the Time variable in the file concat_data.nc I recommend using the option --hdr_pad to avoid copy of intermediate files


ncecat -u Time --hdr_pad 1028 data_198[0-5].nc concat_data.nc

Russ

On 29/03/16 04:04, Ansley C. Manke wrote:
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



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

Privacy Policy | Disclaimer | Accessibility Statement