Project

General

Profile

Turn variables into dimensions

Added by Kaleigh Ross about 3 years ago

Hello!

I've merged and thus created a single, 4-dimensional netcdf file by concatenating 3d files along the z-axis.

My problem now is, I've created the following variables: lat, lon, alt (altitude) and time. However, they are read as variables and not dimensions, and thus I can't load them well in Panoply.

I'm fairly new to this so I hope anyone here could help me georeference these variables using CDO. Thank you!

!cdo sinfo C1_u_4D.nc

Warning (find_time_vars): Time variable >time< not found!
File format : NetCDF4 classic
-1 : Institut Source T Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown v instant 7 1 9801 1 F64 : -1
2 : unknown unknown c instant 1 2 216 2 F64 : -2
3 : unknown unknown c instant 1 2 7 3 F64 : -3
Grid coordinates :
1 : generic : points=9801 (121x81)
lon : 110 to 140 by 0.25
lat : 24 to 4 by -0.25
2 : generic : points=216
3 : generic : points=7
Vertical coordinates :
1 : generic : levels=7
2 : surface : levels=1
Time coordinate : 216 steps


Replies (11)

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

hi Kaleigh!

Could you upload the file? or at least a single timestep?

cheers
ralf

RE: Turn variables into dimensions - Added by Kaleigh Ross about 3 years ago

Hello Ralf!

Please see attached file.
Thanks!

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

netcdf C1_u_4D {
dimensions:
        lon = 121 ;
        lat = 81 ;
        alt = 7 ;
        time = 216 ;
        t = 216 ;
        z = 7 ;
variables:
        double uwind(time, alt, lat, lon) ;
        double lon(lon) ;
        double lat(lat) ;
        double time(t) ;
        double alt(z) ;

your data variables have no attributes, that's why CDO cannot identify 'alt' as a vertical coordinate. This violates the CF-convention.

you can repair it a bit with

ncatted -a axis,time,c,c,'T' -a axis,alt,c,c,'Z' -a units,lon,c,c,'degrees_east' -a units,lat,c,c,'degrees_north' -a axis,lat,c,c,'Y' -a axis,lon,c,c,'X' C1_u_4D.nc

hth
ralf

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

ncatted is from the NCO package

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

and please check if the coordinates are ok that way

RE: Turn variables into dimensions - Added by Kaleigh Ross about 3 years ago

Hello, Ralf.

It worked perfectly. Thank you so much for the help! :) :) :)

RE: Turn variables into dimensions - Added by Kaleigh Ross about 3 years ago

Hello again Ralf,

Do you happen to know how to add attributes to time? Mine is supposed to be "seconds since 1970-1-1" but Panoply is just reading them as integers. Thanks again!

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

hi!

you can use "seconds since 1970-01-01" instead. Leaving out the leading zeros in the units attribute is ok with the CF-convention, but some applications might need them. It's worth a try

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

You could also try to convert it to another unit with cdo -settunits,days`

RE: Turn variables into dimensions - Added by Kaleigh Ross about 3 years ago

Hi, Ralf.

I was able to make it work with cdo -settunits,days.
Thank you so much again! :)

RE: Turn variables into dimensions - Added by Ralf Mueller about 3 years ago

my pleasure , Kaleigh

have a good day
-ralf

    (1-11/11)