qp
<xarray.Dataset>
Dimensions: (lat: 360, lon: 720)
Coordinates:
pcts int32 90
* lat (lat) float32 89.75 89.25 88.75 88.25 87.75 87.25 86.75 ...
* lon (lon) float32 -179.75 -179.25 -178.75 -178.25 -177.75 ...
Data variables:
EM (lat, lon) float64 nan nan nan nan nan nan nan nan nan nan .
bin_data = qp.groupby_bins('EM',[-100,-50,0,50,100],labels=['vgood','good','bad','vbad'])
bin_data.groupsbin_data.group_indices
>>..
51755, 51757, 51974, 51981, 51982, 51986, ...]}To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/57ed4013-c720-45cc-82ea-f2ed5c34dab1%40googlegroups.com.--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+unsubscribe@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
Thanks Ryani think I am almost there.The 2nd population dataset is gridded population, as integers. The intention being: what is the sum of population experiencing temperature value changes between the bins of [-100,-50,0,50,100]?I realise that in my original question I meant to say that we are summing the values in the population dataset, split by the bins... not summing the values in the bins.So
- Bin the temperature changes in qp.
- Get the indices for each bin, and select the relevant values in the population dataset, and sum.
What i eneded up with now is:#Temp dataset:
bins = [-100,-50,0,50,100]
tempb = temp.groupby_bins('EnsembleMean',bins)
#Population dataset:
pv = pop.p2010.values
pvsum = np.zeros(len(bins)) # Assign an zeros array
# Now loop through the bins in tempb and get the indicesfor binn in range(0,len(bins)-1):tempbi = tempb.group_indices[binn]# Grab the values from pv using indices qbpi and sumpvsum1[binn] = np.nansum(pv.take(qpbi))
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/57ed4013-c720-45cc-82ea-f2ed5c34dab1%40googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "xarray" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xarray+unsubscribe@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/5b2d3b21-64f2-42a0-abcc-862714db3418%40googlegroups.com.
Thanks Ryani think I am pretty much there.The population dataset is gridded population, as integers. The intention being: what is the sum of population experiencing temperature value changes between the bins of [-100,-50,0,50,100]?I realise that in my original question I meant to say that we are summing the values in the population dataset, split by the bins... not summing the values in the bins of the temp datasetSo
- Bin the temperature changes in temp.
- Get the indices for each bin, and select the relevant values in the population dataset (pv), and sum.
What i eneded up with now is:
#Temp dataset:
bins = [-100,-50,0,50,100]
tempb = temp.groupby_bins('EM',bins)
#Population dataset:
pv = pop.p2010.values
# Assign an zeros array
pvsum = np.zeros(len(bins))
# Now loop through the bins in tempb and get the indices
for binn in range(0,len(bins)-1):
tempbi = tempb.group_indices[binn]
# Grab the values from pv using indices qbpi and sum
pvsum[binn] = np.nansum(pv.take(qpbi))

To unsubscribe from this group and stop receiving emails from it, send an email to xarray+unsubscribe@googlegroups.com.
To post to this group, send email to xar...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/xarray/afd698fc-4a06-40da-97cf-de2e3bd2d942%40googlegroups.com.