Home > Mobile >  Calculate difference in variable within same day in two nc file
Calculate difference in variable within same day in two nc file

Time:02-12

I have two NC files with ERA5land precipitation data from the months AMJJASO of 2001-2020. One NC file of precipitation data from UTC 00.00 and one NC file with precipitation data from UTC 12.00. I would like to subtract the precipitation from UTC 00.00 from the precipitation at timeslot 12.00, hence;

UTC12.00 - UTC00.00 = UTCprecip

I have previously used cdo as

cdo sub UTC12.nc UTC00.nc UTCprecip.nc

but was looking for something like daysub, not ydaysub though(!).

But does this simple subtraction using cdo sub occur within each day only?

Or do I have to use a different call?

CodePudding user response:

Based on what you have said the sub method will correctly handle your problem.

The sub method in CDO will do the subtraction for matching time steps. It only matches time steps, not dates etc. So time step 1 in UTC00.nc is subtracted step 1 from UTC12.nc and so on until the last remaining time step that is in both files.

CodePudding user response:

Rob's answer is correct, I was just wondering though what you want to get from this? The ERA5 land description of precip is that

This variable is accumulated from the beginning of the forecast time to the end of the forecast step.

I'm trying to understand what you are trying to achieve, if the files are accumulated and you subtract one from the other, are you not getting the 12 hour accumulated precip?

Anyway

cdo sub in1.nc in2.nc out.nc 

would do this, but then you would also need a

cdo sub in2.nc in1.nc out.nc

to get the 12-24 hour precip. I'm waiting for my download to finish and will update this as necessary.

By the way, if you want more details on how sub, broadcasting and the time stamp locking with daysub, monsub and yearsub works, you can check out this video I recently posted on this topic.

  • Related