Project

General

Profile

Converting text to netCDF

Added by Guilherme Martins almost 8 years ago

Hi users,

I have a vertical profile (temperature) in a txt file and I'd like to convert to netCDF. I used the command:

cdo -f nc input,r1x1 temp_z.nc < temp_z.txt

But the CDO understand the z level like time dimension. That is my problem. How to do the CDO understand that my file is vertical level and not time? I want to create a vertical level of temperature.

I'm sending a piece of my file (temp_z.txt).

Thanks in advance!


Replies (7)

RE: Converting text to netCDF - Added by Guilherme Martins almost 8 years ago

I forgot to attach the vertical level file.

Thank you!

RE: Converting text to netCDF - Added by Uwe Schulzweida almost 8 years ago

Hi Guilherme,

The CDO operator input can only read 2D variables. I have added support for 3D variable to the next CDO release. A prerelease for testing will be available next Friday. To use this new feature you have to add the new optional parameter zaxis. zaxis is an ASCII file with the description of the Z-axis:

cdo -f nc input,r1x1,zaxis temp_z.nc < temp_z.txt
Please find attached an example zaxis file.

Cheers,
Uwe

zaxis (3.22 KB) zaxis

RE: Converting text to netCDF - Added by Guilherme Martins almost 8 years ago

Dear Uwe,

Thanks a lot! Good hear it! Perfect.

Guilherme.

RE: Converting text to netCDF - Added by ibrahim erkol about 3 years ago

Dear all,
I have a similar problem with this one.
I have a precipitation dataset from a single observation point in txt format. And, I need to convert it into nc file format so that I can use it in RCMES for bias correction operations.
However, as I tried this "cdo -f nc input,r1x1 temp_z.nc < temp_z.txt" code and I create my nc file, I run into this problem that I shared with you in the screenshot that I put here. The error is " Time unit has too small an increment (min. 1 minute).". I'm guessing that CDO does not read time dimension of the text file.

What I need to do is to create an nc file for a single point (that is the same coordinates and elevation for all) with only changing variable "time" which extends from 1980 to 2018 on a monthly basis.

Aydin_cnrm_Prec_rcp45.txt (10.2 KB) Aydin_cnrm_Prec_rcp45.txt My txt file
Ekran Görüntüsü (1061).png (202 KB) Ekran Görüntüsü (1061).png The "too small time increment" error/warning
Ekran Görüntüsü (1062).png (166 KB) Ekran Görüntüsü (1062).png The "too small time increment" error/warning

RE: Converting text to netCDF - Added by Guilherme Martins about 3 years ago

Try this:

cdo -f nc input,r1x1 tmp.nc < Aydin_cnrm_Prec_rcp45.txt

cdo -r -chname,var1,prec -settaxis,1980-01-01,00:00:00,1mon tmp.nc prec.nc

See your new Aydin_cnrm_Prec_rcp45.txt file.

RE: Converting text to netCDF - Added by ibrahim erkol about 3 years ago

Thank you sooooooooooo much Guilherme, you saved me from a lot of trouble
You're simply the best :))

    (1-7/7)