Sum of subdaily precipitation data with cdo

I have been working with precipitation data from the IMERG satellite which is every 30 minutes.

I have been building the precipitation between 12 UTC one day and 12 UTC the other day.

cdo shifttime,-12hours -daysum -shifttime,12hours in.nc4 out.nc4

But I see that the "daysum" command adds 2 times each value, check this by downloading a daily data and I see that the values ​​are exactly double.

Does anyone know how to fix this since it seems that the daysum command is not working for me.

Thank you very much!

Upvotes: 1

Views: 783

Answers (1)

ClimateUnboxed
ClimateUnboxed

Reputation: 8087

I think the issue is that the units of the 30 minute data are mm/hour and so if you sum the data you will not get mm/day, since the data is every thirty minutes, but 2*mm/day. Instead the file you downloaded to check has units of mm/day (well done, by the way, for independently checking your answer). This is why self-describing files having units is so important ;-)

To get units of mm/day you simply need to divide by 2:

cdo -divc,2 -shifttime,-12hours -daysum -shifttime,12hours in.nc4 out.nc4

Easy error to make by the way, I've done it myself in the past, especially if you are used to dealing with fluxes from weather forecast output which are usually always accumulated over the output step time (i.e. that would be 30 minutes in this case).

This is why it is usually safer and less confusing to use mean instead of sum for two reasons.

  1. if you use mean you have always exactly the same units as the input file correctly, in this case mm/hr. It doesn't matter what the data frequency is, you can't get it wrong. If you prefer something like mm/day then you can convert using cdo mulc and update the metadata but it is easier to do this without making mistakes.
  2. by using mean you can also control in cdo how to handle missing data, i.e. using mean or avg.

Upvotes: 1

Related Questions