Skip to content

Commit

Permalink
Merge pull request #20 from CIAT-DAPA/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
santiago123x authored Aug 22, 2024
2 parents 4889997 + 923d5db commit 174468b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/postprocessing/export_average.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ def export_raster(dataset, file_name, specific_variable, output_path, inputs_pat
# Calculate the 3-hourly accumulated precipitation
result_variable += current_total - previous_total
previous_total = current_total
if day == 0 or day == 1:
result_variable = result_variable * 0.6
else:
result_variable = np.mean(daily_data, axis=0)
previous_day += result_variable
Expand Down
8 changes: 4 additions & 4 deletions src/postprocessing/generate_images.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def generate_image(raster_path, csv_path, data_path, shapefile_path=None):
cmap = LinearSegmentedColormap.from_list('custom_cmap', cmap_colors)
norm = BoundaryNorm(boundaries, cmap.N)

title = f"CENAOS/WRF {csv_title} desde {date} hasta {new_date_str}"
title = f"CENAOS/WRF {csv_title}\ndesde {date} hasta {new_date_str}"

# Configurar la figura de Matplotlib con tamaño personalizado
fig, ax = plt.subplots(figsize=(14, 10))
Expand Down Expand Up @@ -75,10 +75,10 @@ def generate_image(raster_path, csv_path, data_path, shapefile_path=None):
ax.add_artist(ab)

# Añadir barra de colores (colorbar) abajo a la izquierda
cbar = fig.colorbar(im, ticks=boundaries, orientation='horizontal', boundaries=boundaries, pad=0.1, aspect=30, fraction=0.02)
cbar = fig.colorbar(im, ticks=boundaries, orientation='horizontal', boundaries=boundaries, pad=0.1, aspect=25, shrink=0.75, fraction=0.05)
cbar.set_label(csv_title, fontsize=12)
cbar.ax.tick_params(labelsize=10)
cbar.ax.set_xticklabels([str(int(b)) for b in boundaries])
cbar.ax.tick_params(labelsize=10, length=5) # Ajusta el tamaño de las etiquetas y los ticks
cbar.ax.set_xticklabels([str(int(b)) for b in boundaries], rotation=45, ha='right') # Rota las etiquetas si es necesario

# Guardar la visualización como un archivo PNG
plt.savefig(png_file, bbox_inches='tight', dpi=300)
Expand Down

0 comments on commit 174468b

Please sign in to comment.