Git Product home page Git Product logo

elepyant's People

Contributors

fraserwg avatar milankl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

zmoon

elepyant's Issues

Command line interface

A command line interface allowing operations on NetCDF files (but not xarray objects) could be useful. I'm thinking something that would work along the lines of

ncround -i /path/to/in/file.nc -o /path/to/out/file.nc --UVEL 2 --VVEL 2 --WVEL 6

Zstandard as default?

AFAIK netCDFs default compression algorithm is zlib. Zlib is not bad, but I highly recommend to use Zstandard as I achieve much better compression factors with it. In general benchmarks, Zstd is better than Zlib in every aspect. Could you check whether there is a way that the netCDF python implementation supports it?

Round in binary not in decimal representation

Be aware that rounding in decimal representation does is general not round in binary representation too, as the former is not an integer power of the latter. Currently, you seem to use np.around(x,decimals=d), but this does not yield zeroed trailing bits.

import struct 
def binary(num): 
    return ''.join('{:0>8b}'.format(c) for c in struct.pack('!f', num))

In [12]: binary(np.around(np.pi,decimals=2))                                    
Out[12]: '01000000010010001111010111000011'

In [13]: binary(np.around(np.pi,decimals=3))                                    
Out[13]: '01000000010010010001011010000111'

In [14]: binary(np.around(np.pi,decimals=4))                                    
Out[14]: '01000000010010010000111111111001'

Note that you can convert significant digits (i.e. decimal) to significant bits via

"""Number of significant bits `nsb` given the number of significant digits `nsd`."""
nsb(nsd::Integer) = Integer(ceil(log(10)/log(2)*nsd))

which is 7 significant bits to guarantee 2 significant (decimal) digits, 10 for 3, 14 for 3, etc. So what you want is a rounding function that does this:

julia> bitstring(round(Float32(π),sigdigits=7,base=2))
"01000000010010100000000000000000"

julia> bitstring(round(Float32(π),sigdigits=10,base=2))
"01000000010010010000000000000000"

julia> bitstring(round(Float32(π),sigdigits=14,base=2))
"01000000010010010001000000000000"

Question is obviously why the compression still works well? I assume this is because if you round two numbers x,y that are fairly close to each other, to the same decimal places, you get the same bitpatterns in the significant:

In [15]: binary(np.around(np.pi,decimals=2))                                    
Out[15]: '01000000010010001111010111000011'

In [16]: binary(np.around(np.pi*1.001,decimals=2))                              
Out[16]: '01000000010010001111010111000011'

Which is presumably also somewhat compressable. But I guess 0's everywhere are more compressible than these seemingly random, but repeating bitpatterns.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.