Skip to content

Conversation

@chpolste
Copy link
Contributor

@chpolste chpolste commented Nov 25, 2025

Following up on point 4 raised in #22, a proposed fix for writing the yield_loss_perc values.

  • Verify that csv and netcdf outputs are identical.

@chpolste chpolste marked this pull request as draft November 25, 2025 16:33
@chpolste
Copy link
Contributor Author

chpolste commented Dec 5, 2025

Output consistency tested by running

import numpy as np
import pandas as pd
import xarray as xr

yield_loss_npy = np.load('agriculture_workflow/results/Cataluña_yield_loss_NUMPY.npy')
yield_loss_csv = pd.read_csv('agriculture_workflow/results/Cataluña_yield_loss_SPREADSHEET.csv')
yield_loss_nc = xr.open_dataset('agriculture_workflow/results/agridrought_hazard_ES51_mpi_m_mpi_esm_lr-smhi_rca4_rcp26_2046-2050.nc')

np.testing.assert_allclose(
    yield_loss_npy,
    yield_loss_csv[["maize", "wheat"]].values.reshape(yield_loss_npy.shape)
)

np.testing.assert_allclose(
    yield_loss_npy,
    yield_loss_nc["yield_loss"].transpose("y", "x", "crop").values
)

with the default configuration of the workflow.

@chpolste chpolste marked this pull request as ready for review December 5, 2025 09:19
@chpolste chpolste merged commit 537eade into main Dec 5, 2025
1 of 2 checks passed
@chpolste chpolste deleted the fix-yield-loss-io branch December 5, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants