Project

General

Profile

Extracting time series at a large number of grid points from a global grid

Added by David Heineke almost 2 years ago

Good day,

I am trying to extract time series from a global grid (see attached) at a large number of grid points (~10,000, see attached indices).
I am working in Python using CDO version 1.9.9rc1 on a Windows Subsystem for Linux (WSL).

As looping over the grid points takes too much time, I have tried to first select the required grid cells and then to distribute the horizontal grid as follows:

reduced_fields = cdo.selgridcell(*indices, input = ERA5_19800101_19800102.nc)
cdo.distgrid(10543, input = reduced_fields, output = 'test_')

However, the distgrid function seems to return only one time step per grid cell. Can you please advise? Are there any alternative methods to do this?

Thanks in advance.

Kind regards,
David


Replies (3)

RE: Extracting time series at a large number of grid points from a global grid - Added by Karin Meier-Fleischer almost 2 years ago

Hi David,

for me it works and each single file has 16 time steps. Maybe it is a problem caused by the Windows WSL installation?

print(cdo.__version__())
1.5.4
print(cdo.version())
1.9.9

I used the following Python script to do your calculations:

indices_file = 'Coverage_coast_ind2.txt'
infile = 'ERA5_19800101_19800102.nc'

indices = [ e.rstrip('\n') for e in open(indices_file, 'r')]

reduced_fields = cdo.selgridcell(*indices, input=infile)

!mkdir -p tmp_files

cdo.distgrid(10543, input=reduced_fields, output='./tmp_files/test_')

E.g. the first file:

cdo sinfon ./tmp_files/test_00000.nc
   File format : NetCDF2
    -1 : Institut Source   T Steptype Levels Num    Points Num Dtype : Parameter name
     1 : unknown  unknown  v instant       1   1         1   1  I16  : u10           
     2 : unknown  unknown  v instant       1   1         1   1  I16  : v10           
     3 : unknown  unknown  v instant       1   1         1   1  I16  : mdts          
     4 : unknown  unknown  v instant       1   1         1   1  I16  : mdww          
     5 : unknown  unknown  v instant       1   1         1   1  I16  : mpts          
     6 : unknown  unknown  v instant       1   1         1   1  I16  : mpww          
     7 : unknown  unknown  v instant       1   1         1   1  I16  : mwd           
     8 : unknown  unknown  v instant       1   1         1   1  I16  : mwp           
     9 : unknown  unknown  v instant       1   1         1   1  I16  : wmb           
    10 : unknown  unknown  v instant       1   1         1   1  I16  : pp1d          
    11 : unknown  unknown  v instant       1   1         1   1  I16  : swh           
    12 : unknown  unknown  v instant       1   1         1   1  I16  : shts          
    13 : unknown  unknown  v instant       1   1         1   1  I16  : shww          
   Grid coordinates :
     1 : unstructured             : points=1
                              lon : 71 degrees_east
                              lat : 77 degrees_north
   Vertical coordinates :
     1 : surface                  : levels=1
   Time coordinate :  16 steps
     RefTime =  1900-01-01 00:00:00  Units = hours  Calendar = gregorian
  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss  YYYY-MM-DD hh:mm:ss
  1980-01-01 00:00:00  1980-01-01 03:00:00  1980-01-01 06:00:00  1980-01-01 09:00:00
  1980-01-01 12:00:00  1980-01-01 15:00:00  1980-01-01 18:00:00  1980-01-01 21:00:00
  1980-01-02 00:00:00  1980-01-02 03:00:00  1980-01-02 06:00:00  1980-01-02 09:00:00
  1980-01-02 12:00:00  1980-01-02 15:00:00  1980-01-02 18:00:00  1980-01-02 21:00:00

-Karin

RE: Extracting time series at a large number of grid points from a global grid - Added by David Heineke almost 2 years ago

Thank you very much for your quick response Karin.

I do think it a problem caused by the Windows WSL. Is there any way to update to a more recent version, or should I use a different platform?

print(cdo.__version__())
1.5.3rc1
print(cdo.version())
1.9.9rc1

Kind regards,
David

RE: Extracting time series at a large number of grid points from a global grid - Added by Karin Meier-Fleischer almost 2 years ago

Most of our Windows users are using Cygwin to run CDO. Maybe it is worth a try to use conda (from miniconda) to install cdo and python-cdo.

    (1-3/3)