Skip to content

Commit

Permalink
Merge pull request #19 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
fixed precipitation error
  • Loading branch information
santiago123x authored Aug 9, 2024
2 parents f0b5ce9 + 645e09d commit 4889997
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/postprocessing/export_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def export_raster(dataset, file_name, specific_variable, output_path, inputs_pat

xtime = dataset.variables['XTIME'][:]

previous_day = np.zeros(var_data.shape[1:])
# Iterate over each day (8 intervals per day)
for day in range(var_data.shape[0] // 8):
start_index = day * 8
Expand All @@ -82,13 +83,13 @@ def export_raster(dataset, file_name, specific_variable, output_path, inputs_pat
previous_total = np.zeros(daily_data.shape[1:])
result_variable = np.zeros(daily_data.shape[1:])
for i in range(daily_data.shape[0]):
current_total = daily_data[i, :, :]
current_total = daily_data[i, :, :] - previous_day
# Calculate the 3-hourly accumulated precipitation
result_variable += current_total - previous_total
previous_total = current_total
else:
result_variable = np.mean(daily_data, axis=0)

previous_day += result_variable
# Create a unique name for the raster file
raster_filename = os.path.join(var_output, f'{specific_variable}_{date}_raster.tif')

Expand Down

0 comments on commit 4889997

Please sign in to comment.