0

I have a netCDF file output from a particle dispersion model (GNOME). As it is a particle dispersion model, I have every particle identified by a particle id variable:

int id(data) ;

            id:description = "particle ID" ;

            id:units = "1" ;

I need to extract only some specific particle id and their locations. I have tried with cdo and nco operators and I get these errors:

  • ncks -v longitude,latitude -d id,62001. infile.nc outputfile.nc ncks: ERROR dimension id is not in input file
  • cdo -select,name=latitude,longitude,id=62968 infile.nc outputfile.nc cdo select (Abort): Unsupported selection keyword: 'id'!

I hope someone could help me. Thanks

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Cla93
  • 1
  • 1
  • iis "id" a variable as you state in the question, or a dimension? your nco command tries to extract a dimension but the error indicates it is a variable, perhaps it would help to post the entire output from ncdump -h to the question so we can see the whole netcdf file structure – ClimateUnboxed Sep 17 '21 at 12:09

1 Answers1

1

The dimension is actually named "data". I suggest you rename the dimension to "id". Then your command should work:

ncrename -d data,id in.nc
ncks -v longitude,latitude -d id,62001. in.nc out.nc

or you could leave the names alone, and if the id is really the data index, then this should work:

   ncks -v longitude,latitude -d data,62001 in.nc out.nc

NB: no decimal point this time since data is not a coordinate, as explained here.

EDIT: 20210921 in response to comment below, unless I am missing something, the dataset would need to have a variable traj dimensioned traj(time,data) in order for the suggested commands to have the result you desire. The header of your file shows no such variable.

Charlie Zender
  • 5,929
  • 14
  • 19
  • Thank you, both commands work but only for one time-step and not for all the time-steps available in the file. – Cla93 Sep 20 '21 at 15:05