How to use the cdflib.epochs.CDFepoch.parse 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
dataType == CDF.CDF_UCHAR):
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        warnings.warn('Invalid global attribute value')
                                        return
                                    numElems = len(data)
                                elif (dataType == CDF.CDF_EPOCH or
                                      dataType == CDF.CDF_EPOCH16
                                      or dataType == CDF.CDF_TIME_TT2000):
                                    cvalue = []
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        numElems = len(data)
                                        for x in range(0, numElems):
                                            if (isinstance(data[x], str)):
                                                cvalue.append(cdfepoch.CDFepoch.parse(data[x]))
                                            else:
                                                cvalue.append(data[x])
                                        data = cvalue
                                    else:
                                        if (isinstance(data, str)):
                                            data = cdfepoch.CDFepoch.parse(data)
                                        numElems = 1
                                else:
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        numElems = len(data)
                                    else:
                                        numElems = 1
                            else:
                                # Data type not found, both values are data.
                                data = value
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
elif (dataType == CDF.CDF_EPOCH or
                                      dataType == CDF.CDF_EPOCH16
                                      or dataType == CDF.CDF_TIME_TT2000):
                                    cvalue = []
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        numElems = len(data)
                                        for x in range(0, numElems):
                                            if (isinstance(data[x], str)):
                                                cvalue.append(cdfepoch.CDFepoch.parse(data[x]))
                                            else:
                                                cvalue.append(data[x])
                                        data = cvalue
                                    else:
                                        if (isinstance(data, str)):
                                            data = cdfepoch.CDFepoch.parse(data)
                                        numElems = 1
                                else:
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        numElems = len(data)
                                    else:
                                        numElems = 1
                            else:
                                # Data type not found, both values are data.
                                data = value
                                numElems, dataType = CDF._datatype_define(value[0])
                                numElems = len(value)
                        else:
                            # Length greater than 2, so it is all data.
                            data = value
                            numElems, dataType = CDF._datatype_define(value[0])
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
if (x > 0):
                                    data += str('\\N ')
                                    data += odata[x]
                                else:
                                    data = odata[x]
                        numElems = len(data)
                    elif (dataType == CDF.CDF_EPOCH or dataType == CDF.CDF_EPOCH16
                          or dataType == CDF.CDF_TIME_TT2000):
                        cvalue = []
                        if isinstance(data, (list, tuple)):
                            numElems = len(data)
                            for x in range(0, numElems):
                                cvalue.append(cdfepoch.CDFepoch.parse(data[x]))
                            data = cvalue
                        else:
                            data = cdfepoch.CDFepoch.parse(data)
                            numElems = 1
            else:
                # No data type defined...
                data = entry
                if isinstance(entry, (list, tuple)):
                    numElems, dataType = CDF._datatype_define(entry[0])
                    if (dataType == CDF.CDF_CHAR or dataType == CDF.CDF_UCHAR):
                        data = str('')
                        for x in range(0, len(entry)):
                            if (x > 0):
                                data += str('\\N ')
                                data += entry[x]
                            else:
                                data = entry[x]
                    numElems = len(data)
                else:
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
odata = data
                            data = str('')
                            for x in range(0, items):
                                if (x > 0):
                                    data += str('\\N ')
                                    data += odata[x]
                                else:
                                    data = odata[x]
                        numElems = len(data)
                    elif (dataType == CDF.CDF_EPOCH or dataType == CDF.CDF_EPOCH16
                          or dataType == CDF.CDF_TIME_TT2000):
                        cvalue = []
                        if isinstance(data, (list, tuple)):
                            numElems = len(data)
                            for x in range(0, numElems):
                                cvalue.append(cdfepoch.CDFepoch.parse(data[x]))
                            data = cvalue
                        else:
                            data = cdfepoch.CDFepoch.parse(data)
                            numElems = 1
            else:
                # No data type defined...
                data = entry
                if isinstance(entry, (list, tuple)):
                    numElems, dataType = CDF._datatype_define(entry[0])
                    if (dataType == CDF.CDF_CHAR or dataType == CDF.CDF_UCHAR):
                        data = str('')
                        for x in range(0, len(entry)):
                            if (x > 0):
                                data += str('\\N ')
                                data += entry[x]
                            else:
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
if (dataType == CDF.CDF_CHAR or
                                        dataType == CDF.CDF_UCHAR):
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        raise ValueError('Invalid variable attribute value')
                                    numElems = len(data)
                                elif (dataType == CDF.CDF_EPOCH or
                                      dataType == CDF.CDF_EPOCH16
                                      or dataType == CDF.CDF_TIME_TT2000):
                                    cvalue = []
                                    if (isinstance(data, list) or
                                            isinstance(data, tuple)):
                                        numElems = len(data)
                                        for x in range(0, numElems):
                                            if (isinstance(data[x], str)):
                                                avalue = cdfepoch.CDFepoch.parse(data[x])
                                            else:
                                                avalue = data[x]
                                            if (dataType == CDF.CDF_EPOCH16):
                                                cvalue.append(avalue.real)
                                                cvalue.append(avalue.imag)
                                            else:
                                                cvalue.append(avalue)
                                                data = cvalue
                                    else:
                                        if (isinstance(data, str)):
                                            data = cdfepoch.CDFepoch.parse(data)
                                        numElems = 1
                                else:
                                    if (isinstance(data, list) or isinstance(data, tuple)):
                                        numElems = len(data)
                                    else:
github MAVENSDC / cdflib / cdflib / cdfwrite.py View on Github external
isinstance(data, tuple)):
                                        numElems = len(data)
                                        for x in range(0, numElems):
                                            if (isinstance(data[x], str)):
                                                avalue = cdfepoch.CDFepoch.parse(data[x])
                                            else:
                                                avalue = data[x]
                                            if (dataType == CDF.CDF_EPOCH16):
                                                cvalue.append(avalue.real)
                                                cvalue.append(avalue.imag)
                                            else:
                                                cvalue.append(avalue)
                                                data = cvalue
                                    else:
                                        if (isinstance(data, str)):
                                            data = cdfepoch.CDFepoch.parse(data)
                                        numElems = 1
                                else:
                                    if (isinstance(data, list) or isinstance(data, tuple)):
                                        numElems = len(data)
                                    else:
                                        numElems = 1
                            else:
                                data = value
                                numElems, dataType = CDF._datatype_define(value[0])
                                numElems = len(value)
                        else:
                            data = value
                            numElems, dataType = CDF._datatype_define(value[0])
                            numElems = len(value)
                    else:
                        data = value