(data,least_significant_digit)
quantize data to improve compression. data is quantized using
around(scale*data)/scale, where scale is 2**bits, and bits is determined
from the least_significant_digit. For example, if
least_significant_digit=1, bits will be 4.
quantize data to improve compression. data is quantized using
around(scale*data)/scale, where scale is 2**bits, and bits is determined
from the least_significant_digit. For example, if
least_significant_digit=1, bits will be 4.
quantize data to improve compression . data is quantized using around ( scale * data ) / scale where scale is 2 ** bits and bits is determined from the least_significant_digit . For example if least_significant_digit = 1 bits will be 4 .
def _quantize(data,least_significant_digit):
    """
quantize data to improve compression. data is quantized using
around(scale*data)/scale, where scale is 2**bits, and bits is determined
from the least_significant_digit. For example, if
least_significant_digit=1, bits will be 4.
    """
    precision = pow(10.,-least_significant_digit)
    exp = np.log10(precision)
    if exp < 0:
        exp = int(np.floor(exp))
    else:
        exp = int(np.ceil(exp))
    bits = np.ceil(np.log2(pow(10.,-exp)))
    scale = pow(2.,bits)
    datout = np.around(scale*data)/scale
    if ma.isMA(datout):
        datout.set_fill_value(data.fill_value)
        return datout
    else:
        return datout
def _quantize ( data , least_significant_digit ) : precision = pow ( 10. , - least_significant_digit ) exp = np . log10 ( precision ) if exp < 0 : exp = int ( np . floor ( exp ) ) else : exp = int ( np . ceil ( exp ) ) bits = np . ceil ( np . log2 ( pow ( 10. , - exp ) ) ) scale = pow ( 2. , bits ) datout = np . around ( scale * data ) / scale if ma . isMA ( datout ) : datout . set_fill_value ( data . fill_value ) return datout else : return datout