0

I'm working with a netCDF file with a spatially averaged wind variable, which is a function of time only.

I would like to split the file into years with east wind and years with west wind.

I thought I would do it with cdo but I don't know how to write the condition. Anything with splityear, 'u <0'?

ClimateUnboxed
  • 7,106
  • 3
  • 41
  • 86
Valeria
  • 1
  • 2
  • I agree with @Robert Wilson that this is a strange thing to do,how does having missing data help you eventually with any postprocessing, or you want to calculate the mean east and mean west wind over the years. Also the question needs clarifying as you haven't stated what the time resolution of the data is, are the files annual means? Otherwise the the concept of a year of easterly wind doesn't make sense. – ClimateUnboxed Oct 09 '20 at 06:59

1 Answers1

1

I do not think this is advisable, as you will split the files in to two different NetCDF files with incompatible grids. In my view this would defeat the purpose of storing the data in NetCDF files.

But, if you wish to do it, there is a way within CDO. As you haven't provided files I can outline a strategy.

First create a mask file identifying cells with u<0:

cdo -setrtomiss,-10000,0 -selname,u infile.nc mask.nc

Then apply reducegrid to the infile using this mask:

cdo -reducegrid,mask.nc infile.nc outfile.nc

That should do it for the u condition. Just test that and modify it for the other variables.

Robert Wilson
  • 3,192
  • 11
  • 19
  • good answer. I think the selname can be dropped as the second "variable" in the question is actually the dimension time, and I think probably it is enough to leave the masked years as missing... Then one can anyway perform stats across +ve or -ve years. I think the question requires clarification though as it doesn't make sense if the input in daily! – ClimateUnboxed Oct 09 '20 at 07:05
  • Indeed. On second reading I notice it is spatially averaged data. In which case I wouldn't use cdo to begin with – Robert Wilson Oct 10 '20 at 13:48