# Daily precipitation

#### seti

##### Member
Hi all,

How can I calculate daily precipitation from WRF output, please?

This can be tricky @seti depending on which post processing tool you are using.

The general form is you add the output variables like so

Total_Rain_at_given_hour = (rainc + rainnc + rainsh)

Since the rain variables are cumulative over the area of interest you need to calculate the total rain at the ending time step and then subtract the initial time step.

For example here is a 3-hr calculation in python:
Python:
``````    rainc = wrf.getvar(
ncfile, "RAINC"
)  # Cumulative convective (grid-scale) precipitation
rainnc = wrf.getvar(
ncfile, "RAINNC"
)  # Cumulative non-convective (resolved-scale) precipitation
rainsh = wrf.getvar(ncfile, "RAINSH")  # Cumulative shallow precipitation
total_rain = (rainc + rainnc + rainsh) * 0.0393701  # mm to inch

# Add the total rain for the current hour to the recent rains list
recent_rains.append(total_rain)

# If we have more than 3 hours of data, remove the oldest hour's data
if len(recent_rains) > 3:
recent_rains.pop(0)

# Calculate the 3-hour accumulated rain
three_hour_rain = recent_rains[-1] - recent_rains[0] if len(recent_rains) == 3 else np.zeros_like(total_rain)

# Update the previous total rain and datetime for the next iteration
prev_total_rain = total_rain.copy()
prev_datetime = file_datetime``````

Also @Ming Chen has a post here that goes into more detail

Thanks @William.Hatheway. I would like to use "NCL" to plot the daily precipitation. I already visited these links before, and am looking for daily precipitation for a specific date. In those given examples, I could not find "Date" for plotting the data for a specific day.

@seti
You can always derive 'Date' based on your initial time, output intervals, and integration period. For example, suppose you run a 48-hr simulation and wrfout is at 6-hr intervals, you will have 9 times of wrfout files. The last 5 wrfout files correspond to the 2nd day simulation starting from 00UTC, i.e., output at 24hr, 30hr, 36hr, 42hr, 48hr simulation. You can then calculate the 2nd rainfall based on these wrfout files.