Skip to content

Commit

Permalink
Fix syntax problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
ctslater committed May 5, 2021
1 parent 84e14c7 commit 37f04a3
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions axs/axsframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,23 +303,23 @@ def histogram2d(self, cond1, cond2, numbins1, numbins2, min1=None, max1=None, mi
step1 = rng1 / numbins1
step2 = rng2 / numbins2

hist2d = res.withColumn("bin1", ((res[colname1]-min1)/step1).cast("int")) \
.withColumn("bin2", ((res[colname2]-min2)/step2).cast("int")) \
.groupBy("bin1", "bin2").count()
hist2data = hist2d.orderBy(hist2d.bin1, hist2d.bin2).collect()
bin1 = np.array(list(map(lambda row: row.bin1, hist2data)))
bin2 = np.array(list(map(lambda row: row.bin2, hist2data)))
vals = np.array(list(map(lambda row: row["count"], hist2data)))

x, y = np.mgrid[slice(min1, max1 + step1, step1),
slice(min2, max2 + step2, step2)]

z = np.zeros(numbins1*numbins2)
ok_bins = np.where((bin1 >= 0) & (bin1 < numbins1) & (bin2 >= 0) & (bin2 < numbins2))
bin_onedim_index = bin2 + bin1*numbins2
z[bin_onedim_index[ok_bins]] = vals[ok_bins]

return x, y, z.reshape((numbins1, numbins2))
hist2d = res.withColumn("bin1", ((res[colname1]-min1)/step1).cast("int")) \
.withColumn("bin2", ((res[colname2]-min2)/step2).cast("int")) \
.groupBy("bin1", "bin2").count()
hist2data = hist2d.orderBy(hist2d.bin1, hist2d.bin2).collect()
bin1 = np.array(list(map(lambda row: row.bin1, hist2data)))
bin2 = np.array(list(map(lambda row: row.bin2, hist2data)))
vals = np.array(list(map(lambda row: row["count"], hist2data)))

x, y = np.mgrid[slice(min1, max1 + step1, step1),
slice(min2, max2 + step2, step2)]

z = np.zeros(numbins1*numbins2)
ok_bins = np.where((bin1 >= 0) & (bin1 < numbins1) & (bin2 >= 0) & (bin2 < numbins2))
bin_onedim_index = bin2 + bin1*numbins2
z[bin_onedim_index[ok_bins]] = vals[ok_bins]

return x, y, z.reshape((numbins1, numbins2))

def healpix_hist(NSIDE=64, groupby=[], agg={"*": "count"}, healpix_column="hpix12",
return_df=False):
Expand Down

0 comments on commit 37f04a3

Please sign in to comment.