Project

General

Profile

how to subtract running means to a daily data while retaining the same number of time steps

Added by Lyndon Mark Olaguera almost 4 years ago

Dear CDO-experts,

I have a daily netcdf file of zonal winds. From this, I want to:

[1] Apply a 25-day running mean.
[2] Subtract the 25-day running mean to the original daily data.

Questions:

How do I do this in CDO in such a way that the first and last 25 days after applying the 25-day running mean will be set to missing values?
The original daily should also have the same number of time steps after subtracting the 25-day running mean.

I'll appreciate any help on this.

--Lyndz


Replies (6)

RE: how to subtract running means to a daily data while retaining the same number of time steps - Added by Ralf Mueller almost 4 years ago

hi Lyndon!

For playing around the input file would be very helpful. Can you upload it?

RE: how to subtract running means to a daily data while retaining the same number of time steps - Added by Ralf Mueller almost 4 years ago

hi!

CDO_TIMESTAT_DATE=last cdo -L  -sub -seltimestep,25/4000 uwnd_850hPa_1979.nc -runmean,25 uwnd_850hPa_1979.nc rmSub.nc

Creates output without the first 24 timesteps.

cdo -L -setrtomiss,-999999,9999999 -select,timestep=1/24 uwnd_850hPa_1979.nc start.nc
creates 24 timesteps with missing values

All-in-one:

cdo -L cat [ -setrtomiss,-999999,9999999 -select,timestep=1/24 uwnd_850hPa_1979.nc ] [ -sub -seltimestep,25/4000 uwnd_850hPa_1979.nc -runmean,25 uwnd_850hPa_1979.nc ] rmSubAll.nc

All done with the current release 1.9.9

hth
ralf

RE: how to subtract running means to a daily data while retaining the same number of time steps - Added by Lyndon Mark Olaguera almost 4 years ago

Hi Ralf,

Thank you for this.

Just a follow question, the last 25 steps should be missing too right because there are not enough points.

From the one you posted, there are still values at the last 25 steps.

I'll appreciate your suggestions for this.

RE: how to subtract running means to a daily data while retaining the same number of time steps - Added by Ralf Mueller almost 4 years ago

Lyndon Mark Olaguera wrote:

Hi Ralf,

Thank you for this.

Just a follow question, the last 25 steps should be missing too right because there are not enough points.

From the one you posted, there are still values at the last 25 steps.

Let's look at the running mean field first. You can label the running mean fields in different ways: with the first or the last timestep or the middle

  • CDO_TIMESTAT_DATE=last cdo -L -sinfov -runmean,25 uwnd_850hPa_1979.nc
  • CDO_TIMESTAT_DATE=first cdo -L -sinfov -runmean,25 uwnd_850hPa_1979.nc
  • CDO_TIMESTAT_DATE=middle cdo -L -sinfov -runmean,25 uwnd_850hPa_1979.nc

In any case you get 24 timesteps less because every 25 timesteps are computed into a single one. How you apply it to your input data is up to you.

if you want to ignore the first 24 and last 25 steps, you can delete/deselect them

cdo -seltimestep,1/$(($(cdo -s ntime rmSubAll.nc) - 25)) rmSubAll.nc rmSubAll_rest.nc

taking into account the result file of my former post

hth
ralf

    (1-6/6)