Sorry you are not able to rename dimensions in an HDF5 file.
That's because HDF5 does not have the concept of shared dimensions. When
you open a pure HDF5 file with netCDF, it creates and names some dimensions
dynamically. The dimension information is not saved to the file.
You can use nccopy to convert the file to a netCDF/HDF5 file, and then you
could rename the dimensions.
Ed
On Thu, Jul 9, 2020 at 1:54 PM Lucas Sterzinger via netcdfgroup <
netcdfgroup@xxxxxxxxxxxxxxxx> wrote:
> Hello,
>
> I have a set of HDF5 files that have the following header:
>
> netcdf control-A-2017-05-12-090000-g1 {
> dimensions:
> phony_dim_0 = 16 ;
> phony_dim_1 = 16 ;
> phony_dim_2 = 200 ;
> phony_dim_3 = 2 ;
> phony_dim_4 = 1 ;
> phony_dim_5 = 4 ;
> variables:
> ...
>
> Since it's HDF5, the dimensions are created as phony_dim_x. In this case,
> phony_dim_0 and phony_dim_1 are the y and x coordinates, respectively. I
> would like to rename the dimensions appropriately. Since renaming
> dimensions in HDF5 is not possible (since they don't technically exist), I
> need to convert to netcdf first. to do so I use ncks in.h5 out.nc.
>
> However, the header info of the converted file is:
>
> netcdf control-A-2017-05-12-090500-g1 {
> dimensions:
> phony_dim_0 = 16 ;
> phony_dim_1 = 200 ;
> phony_dim_2 = 2 ;
> phony_dim_3 = 1 ;
> phony_dim_4 = 4 ;
> variables:
> ...
>
> Here's the part that's giving me issue: the two phony_dim_[0,1]
> dimensions have been combined to a single dimension, phony_dim_0. I
> assume this is because they have the same value, and so the netcdf
> conversion assumes they're the same.
>
> A variable that was listed in the hdf5 file as ACCPA(phony_dim_0,
> phony_dim_1) ; is now ACCPA(phony_dim_0, phony_dim_0) ;, with two
> identical dimensions.
>
> Thus, I am not able to rename the dimensions individually. If I do ncrename
> -d phony_dim_0,y out.nc, I get ACCPA(y, y) ;
>
> Is there a way to get around this?
>
> Thanks!
>
> Lucas
>
> --
> Lucas Sterzinger
> PhD Student
> UC Davis Cloud Physics Research Group
> Hoagland Hall 230
> lsterzinger@xxxxxxxxxxx
> https://lucassterzinger.com
> _______________________________________________
> NOTE: All exchanges posted to Unidata maintained email lists are
> recorded in the Unidata inquiry tracking system and made publicly
> available through the web. Users who post to any of the lists we
> maintain are reminded to remove any personal information that they
> do not want to be made public.
>
>
> netcdfgroup mailing list
> netcdfgroup@xxxxxxxxxxxxxxxx
> For list information or to unsubscribe, visit:
> https://www.unidata.ucar.edu/mailing_lists/
>