milankl / BitInformation.jl

Information between bits and bytes.
MIT License
30 stars 3 forks source link

Bitinformation of masked arrays #30

Closed milankl closed 2 years ago

aaronspring commented 2 years ago

Great. I can test this PR next week.

milankl commented 2 years ago

The last commit 5a7b6fb adds a simple test that for a given array and a mask that has all entries unmasked with bitwise real information is identical. Before I merge this, @aaronspring could you install this branch via ] add https://github.com/milankl/BitInformation.jl#mk/masked and report back in #29 how your results change with and without mask provided?

aaronspring commented 2 years ago

@milankl I find differences whether using mask or not, specially the first bits and within 99-100% information:

dim: 4 time image from https://gist.github.com/aaronspring/5de0bc6be5a8d547f3503ff8b1aef8c6

dim: 1 x image from https://gist.github.com/aaronspring/7b0675e36467e5c647f2fe3f546d4bf5

dim analysis: image from https://gist.github.com/aaronspring/52662dd885eebfd6ce4b88939be016c6

milankl commented 2 years ago

Thanks Aaron, that looks awesome. Good to see that all these information patches in the exponent bits disappear! For dissicos could you convert your arrays to signed exponent bits? It looks like there's a bunch of exponent bits that simultaneously flips over (which happens when your data covers a range across floating-point 2)

julia> A = rand(Float32,3,3)
3×3 Matrix{Float32}:
 0.408687   0.922863  0.0622634
 0.838222   0.947521  0.141393
 0.0944574  0.991588  0.576514

julia> signed_exponent(A)
3×3 Matrix{Float32}:
 13.078    7.3829   127.515
  6.70577  7.58017   18.0983
 48.3622   7.93271    4.61211

It looks wrong, because Julia will interpret the exponent bits still as being biased (the information that the exponent bits are now to be interpreted differently is not stored), but you can always check that nothing went wrong by applying the inverse biased_exponent. If you use signed_exponent as a preprocessing step, note that also your mask will change

julia> signed_exponent([-9e-33])
1-element Vector{Float64}:
 -4.739053125085073e32
aaronspring commented 2 years ago

signed_exponent added makes the black bar in dissicos disappear

image
milankl commented 2 years ago

Can we move this discussion to #29 ?