Project

General

Profile

maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1

Added by Antonius Heger 18 days ago

The error in the title appears when I try to mask a region in CARRA West temperature Data. The mask file is attached. I have transformed the coordinates to the cdo conform format, but it is still not working.

catch1.nc (44.9 KB) catch1.nc

Replies (5)

RE: maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1 - Added by Estanislao Gavilan 18 days ago

Hi Antonious,

You need to more specific. What command do you use? Here I can only see a nc file. I think the maskregion command needs a csv or text file. Take a look to this post

https://code.mpimet.mpg.de/boards/2/topics/11284?r=14764#message-14764

Best regards,

Estanislao

RE: maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1 - Added by Antonius Heger 18 days ago

Hi Estanislao,

I used

cdo maskregion,outline.csv data.nc dataout.nc

The problem may be in the format of the input file, that's why I tried to convert it to .nc. It has columns headed with lat and lon and then coordinates that outline my catchment. I attached the .csv file with the coordinates. My data.nc is 6GB, I can't attach that here. But when using ncdump it showed coordinates in lon lat format, that also intersect with the coordinates in my .csv

Thanks and best,
Antonius

RE: maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1 - Added by Estanislao Gavilan 18 days ago

Hi Antonius,

does your data use an unstructured grid? In theory, maskregion should support unstructured and curvilinear grids. It seems it is a problem of the input file format. If you type.

cdo -sinfo catch1.nc

it shows
$ cdo sinfo catch1.nc
File format : NetCDF4
-1 : Institut Source Steptype Levels Num Points Num Dtype : Parameter ID
1 : unknown unknown constant 1 1 4979 1 F32 : -1
2 : unknown unknown constant 1 1 4979 1 F32 : -2
Grid coordinates :
1 : generic : points=4979
Vertical coordinates :
1 : surface : levels=1
cdo sinfo: Processed 2 variables ( 0.00s )

I think generic grid are not supported. The grid coordinates should be unstructured. Maybe it is because the dimension is called points instead of ncells. Try to rename your dimensions.

Best regards,

Estanislao

RE: maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1 - Added by Karin Meier-Fleischer 17 days ago

The csv file has the wrong format. See https://code.mpimet.mpg.de/projects/cdo/embedded/cdo.pdf#subsection.2.6.11

1. the columns are ordered lat/lon but they have to be lon/lat --> swap the columns
2. first line is a header line --> delete the header line

RE: maskregion error: cdo maskregion (Abort): Wrong value format in file catch1.nc at segment 0 line 1 - Added by Karin Meier-Fleischer 17 days ago

Here a short Python example script using CDO's topography as input data.

#!/usr/bin/env python

from cdo import *
cdo = Cdo()

cdo.topo('global_0.05', options='-f nc', output='topo_1x1.nc')

fin  = open('outline.csv', 'r')
fout = open('outline2.csv','w')

for line in fin.readlines():
    y, x = [float(x.strip()) for x in line.split()]
    fout.write(f'{x} {y}\n')

cdo.maskregion('outline2.csv', input='topo_1x1.nc', output='outfile.nc')

    (1-5/5)