ECV netCDF file format

Home Page Forums C3S_422_Lot1_SMHI forum ECV netCDF file format

This topic contains 3 replies, has 2 voices, and was last updated by  PeterBerg 2 months, 1 week ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #4961


    Dear all,
    I have some issues reading the ECV netCDF files downloaded from the Graphs tab at

    Maybe it is just my knowledge on how to read nc-files in R that is limited.

    If I open a HydrGFD tas-netCDF file in R and check it’s content, it seems to have 3 dimensions in the following order: time, lat, lon

    > nc = nc_open(gfdFile)
    > nc$ndims
    > nc$dim[[1]]$name
    > nc$dim[[2]]$name
    > nc$dim[[3]]$name

    or simply check everything by

    > nc
    File ../HydroGFD/yakutia-test/tas/ (NC_FORMAT_CLASSIC):

    1 variables (excluding dimension variables):
    float tas[lon,lat,time]
    standard_name: air_temperature
    long_name: Near-Surface Air Temperature
    units: K
    code: 167
    table: 128
    cell_methods: time: mean
    title: tas
    _ChunkSizes: 1
    _ChunkSizes: 360
    _ChunkSizes: 720
    coordinates: time lat lon

    3 dimensions:
    time Size:1826 *** is unlimited ***
    standard_name: time
    long_name: time
    bounds: time_bnds
    units: hours since 1949-12-01 00:00:00
    calendar: standard
    _ChunkSizes: 524288
    _CoordinateAxisType: Time
    lat Size:14
    standard_name: latitude
    long_name: latitude
    units: degrees_north
    axis: Y
    _CoordinateAxisType: Lat
    lon Size:24
    standard_name: longitude
    long_name: longitude
    units: degrees_east
    axis: X
    _CoordinateAxisType: Lon

    Then, I would assume that I could read the entire timeseries from the first gridpint with the following command:

    > ncvar_get(nc = nc,varid = nc$var[[“tas”]],start = c(1,1,1), count=c(1826,1,1))

    However, this produces an error. Instead I need to use this command:

    > ncvar_get(nc = nc,varid = nc$var[[“tas”]],start = c(1,1,1), count=c(1,1,1826))

    So it seems that the data is indeed sorted along the time dimension first, but the data is still somehow on the format [lon, lat, time].

    Previously, the global GFD netCDF-files distributed by Peter had the dimensions in the order [lon, lat, time] and I could read them in a more straight forward way.

    I would be thankful for any response and help to improve my reading of these files.



    I still dont know how I should understand this netcdf format.

    The data is defined as a 3-dimensional matrix:

    float tas[lon,lat,time]

    but the dimension order is reversed

    _ChunkSizes: 1
    _ChunkSizes: 360
    _ChunkSizes: 720
    coordinates: time lat lon

    In the meantime however, I wrote some R functions to read the data which can be shared on request.

    By the way, the elevation of the GFD grid is missing. Coudl be useful to some users if it could be distributed along with the data.




    I have not personally seen this issue before, but it must lie in the order they write arrays to netcdfs in the portal. I will forward the issue to the webteam.

    Regarding the elevation data, we will make sure to add this information to the portal as soon as possible.




    Me and David had another look at this, and the error seems to have been in our interpretation of the order of the dimensions as written out when printing information in the file e.g:
    >id <- nc_open(“”)

    1 variables (excluding dimension variables):
    float tas-ymonmean[lon,lat,time]
    standard_name: mean_temperature_index_per_time_period
    long_name: mean air temperature (seasonality)
    units: Degree Celsius
    coordinates: time lat lon
    _FillValue: 1.00000002004088e+20
    missing_value: 1.00000002004088e+20
    original_name: TREFHT
    cell_methods: time:mean
    cell_measures: area:areacella
    history: –
    associated_files: –
    title: temperature (seasonality)
    variable: tas-ymonmean


    The order is however [lon, lat, time] as interpreted by R, i.e. the same as in the earlier distributed files.

    An easier way to read complete dimensions is to read the file like this:
    >tas <- ncvar_get(id,”tas-ymonmean”,start=c(1,1,1),count=c(-1,-1,1))
    which is equivalent to:
    >tas <- ncvar_get(id,”tas-ymonmean”,start=c(1,1,1),count=c(13,52,1))


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.