Trying to get the weighted mean using dsim.weighted(generate_weights(dsim_array,weights)).mean() currently results in NaN values, since the coordinate for weights does not correspond to the realization coordinate for dsim.
Generating weights currently gives me a dataset with the coordinate "realization" = [0,1,2,3,4,5,6], for example. In my case, it should give the coordinates "realization"=['ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp245', 'ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp370', 'ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp585', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp245', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp370', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp585']
What I Did
Generate a dictionary of datasets indexed by {realization: dataset}, with each dataset having the appropriate "cat:" attributes. (see #301)
Generate the weights with xs.ensemble.generate_weights
Be sad that you can't do ds.weighted(weights).mean()
Generic Issue
Description
As an example:
Trying to get the weighted mean using
dsim.weighted(generate_weights(dsim_array,weights)).mean()
currently results in NaN values, since the coordinate for weights does not correspond to the realization coordinate for dsim.Generating weights currently gives me a dataset with the coordinate
"realization" = [0,1,2,3,4,5,6]
, for example. In my case, it should give the coordinates "realization"=['ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp245', 'ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp370', 'ScenarioMIP_BCC_BCC-CSM2-MR_r1i1p1f1_ssp585', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp245', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp370', 'ScenarioMIP_CAS_FGOALS-g3_r1i1p1f1_ssp585']
What I Did
Solution
weights = weights.assign_coords(realization=dsim.realization)