How to use the cdflib.cdfwrite.CDF._set_bit function in cdflib

To help you get started, we’ve selected a few cdflib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
if recVary:
            flags = CDF._set_bit(flags, 0)
        flags = CDF._set_bit(flags, 1)
        sRecords = sparse
        rfuB = 0
        rfuC = -1
        rfuF = -1
        if zVar:
            num = len(self.zvars)
        else:
            num = len(self.rvars)

        if compression > 0:
            offsetCPRorSPR = self._write_cpr(f, CDF.GZIP_COMPRESSION,
                                             compression)
            flags = CDF._set_bit(flags, 2)
        else:
            offsetCPRorSPR = -1

        if blockingfactor is None:
            blockingFactor = 1
        else:
            blockingFactor = blockingfactor

        # Increase the block size to account for "zDimSizes" and "DimVarys" fields
        if numDims > 0:
            if zVar:
                block_size = block_size + numDims * 8
            else:
                block_size = block_size + numDims * 4

        # Determine pad value
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
def _write_cdr(self, f, major, encoding, checksum) -> int:
        f.seek(0, 2)
        byte_loc = f.tell()
        block_size = CDF.CDR_BASE_SIZE64 + CDF.CDF_COPYRIGHT_LEN
        section_type = CDF.CDR_
        gdr_loc = block_size + 8
        version = CDF.version
        release = CDF.release
        flag = 0
        if (major == 1):
            flag = CDF._set_bit(flag, 0)
        flag = CDF._set_bit(flag, 1)
        if checksum:
            flag = CDF._set_bit(flag, 2)
            flag = CDF._set_bit(flag, 3)
        rfuA = 0
        rfuB = 0
        increment = CDF.increment
        identifier = 2
        rfuE = -1
        copy_right = '\nCommon Data Format (CDF)\nhttps://cdf.gsfc.nasa.gov\n' + \
                     'Space Physics Data Facility\n' + \
                     'NASA/Goddard Space Flight Center\n' + \
                     'Greenbelt, Maryland 20771 USA\n' + \
                     '(User support: gsfc-cdf-support@lists.nasa.gov)\n'

        cdr = bytearray(block_size)
        cdr[0:8] = struct.pack('>q', block_size)
        cdr[8:12] = struct.pack('>i', section_type)
        cdr[12:20] = struct.pack('>q', gdr_loc)
        cdr[20:24] = struct.pack('>i', version)
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
def _write_cdr(self, f, major, encoding, checksum) -> int:
        f.seek(0, 2)
        byte_loc = f.tell()
        block_size = CDF.CDR_BASE_SIZE64 + CDF.CDF_COPYRIGHT_LEN
        section_type = CDF.CDR_
        gdr_loc = block_size + 8
        version = CDF.version
        release = CDF.release
        flag = 0
        if (major == 1):
            flag = CDF._set_bit(flag, 0)
        flag = CDF._set_bit(flag, 1)
        if checksum:
            flag = CDF._set_bit(flag, 2)
            flag = CDF._set_bit(flag, 3)
        rfuA = 0
        rfuB = 0
        increment = CDF.increment
        identifier = 2
        rfuE = -1
        copy_right = '\nCommon Data Format (CDF)\nhttps://cdf.gsfc.nasa.gov\n' + \
                     'Space Physics Data Facility\n' + \
                     'NASA/Goddard Space Flight Center\n' + \
                     'Greenbelt, Maryland 20771 USA\n' + \
                     '(User support: gsfc-cdf-support@lists.nasa.gov)\n'

        cdr = bytearray(block_size)
        cdr[0:8] = struct.pack('>q', block_size)
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
def _write_cdr(self, f, major, encoding, checksum) -> int:
        f.seek(0, 2)
        byte_loc = f.tell()
        block_size = CDF.CDR_BASE_SIZE64 + CDF.CDF_COPYRIGHT_LEN
        section_type = CDF.CDR_
        gdr_loc = block_size + 8
        version = CDF.version
        release = CDF.release
        flag = 0
        if (major == 1):
            flag = CDF._set_bit(flag, 0)
        flag = CDF._set_bit(flag, 1)
        if checksum:
            flag = CDF._set_bit(flag, 2)
            flag = CDF._set_bit(flag, 3)
        rfuA = 0
        rfuB = 0
        increment = CDF.increment
        identifier = 2
        rfuE = -1
        copy_right = '\nCommon Data Format (CDF)\nhttps://cdf.gsfc.nasa.gov\n' + \
                     'Space Physics Data Facility\n' + \
                     'NASA/Goddard Space Flight Center\n' + \
                     'Greenbelt, Maryland 20771 USA\n' + \
                     '(User support: gsfc-cdf-support@lists.nasa.gov)\n'

        cdr = bytearray(block_size)
        cdr[0:8] = struct.pack('>q', block_size)
        cdr[8:12] = struct.pack('>i', section_type)
        cdr[12:20] = struct.pack('>q', gdr_loc)
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
section_type = CDF.zVDR_
        else:
            block_size = CDF.rVDR_BASE_SIZE64
            section_type = CDF.rVDR_

        nextVDR = 0
        dataType = cdataType
        if dataType == -1:
            raise ValueError('Bad data type.')

        maxRec = -1
        headVXR = 0
        tailVXR = 0
        flags = 0
        if recVary:
            flags = CDF._set_bit(flags, 0)
        flags = CDF._set_bit(flags, 1)
        sRecords = sparse
        rfuB = 0
        rfuC = -1
        rfuF = -1
        if zVar:
            num = len(self.zvars)
        else:
            num = len(self.rvars)

        if compression > 0:
            offsetCPRorSPR = self._write_cpr(f, CDF.GZIP_COMPRESSION,
                                             compression)
            flags = CDF._set_bit(flags, 2)
        else:
            offsetCPRorSPR = -1
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
def _write_cdr(self, f, major, encoding, checksum) -> int:
        f.seek(0, 2)
        byte_loc = f.tell()
        block_size = CDF.CDR_BASE_SIZE64 + CDF.CDF_COPYRIGHT_LEN
        section_type = CDF.CDR_
        gdr_loc = block_size + 8
        version = CDF.version
        release = CDF.release
        flag = 0
        if (major == 1):
            flag = CDF._set_bit(flag, 0)
        flag = CDF._set_bit(flag, 1)
        if checksum:
            flag = CDF._set_bit(flag, 2)
            flag = CDF._set_bit(flag, 3)
        rfuA = 0
        rfuB = 0
        increment = CDF.increment
        identifier = 2
        rfuE = -1
        copy_right = '\nCommon Data Format (CDF)\nhttps://cdf.gsfc.nasa.gov\n' + \
                     'Space Physics Data Facility\n' + \
                     'NASA/Goddard Space Flight Center\n' + \
                     'Greenbelt, Maryland 20771 USA\n' + \
                     '(User support: gsfc-cdf-support@lists.nasa.gov)\n'

        cdr = bytearray(block_size)
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
else:
            block_size = CDF.rVDR_BASE_SIZE64
            section_type = CDF.rVDR_

        nextVDR = 0
        dataType = cdataType
        if dataType == -1:
            raise ValueError('Bad data type.')

        maxRec = -1
        headVXR = 0
        tailVXR = 0
        flags = 0
        if recVary:
            flags = CDF._set_bit(flags, 0)
        flags = CDF._set_bit(flags, 1)
        sRecords = sparse
        rfuB = 0
        rfuC = -1
        rfuF = -1
        if zVar:
            num = len(self.zvars)
        else:
            num = len(self.rvars)

        if compression > 0:
            offsetCPRorSPR = self._write_cpr(f, CDF.GZIP_COMPRESSION,
                                             compression)
            flags = CDF._set_bit(flags, 2)
        else:
            offsetCPRorSPR = -1