How to use pvl - 10 common examples

To help you get started, we’ve selected a few pvl 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 Arcanewinds / FDL-LunarResources / testNAC.py View on Github external
def _load_info_lbl(image):
        """ Load info on the image
        Note:
            If the image is from LOLA, the .LBL is parsed and the
            information is returned.
            If the image is from NAC, the .IMG file is parsed using
            the library `pvl`_ which provide nice method to extract
            the information in the header of the image.
        .. _pvl: http://pvl.readthedocs.org/en/latest/
        """
        label = load_label(image.img)
        for key, val in label.iteritems():
            if type(val) == pvl._collections.PVLObject:
                for key, value in val.iteritems():
                    try:
                        setattr(image, key, value.value)
                    except:
                        setattr(image, key, value)
            else:
                setattr(image, key, val)
        image.start_byte = image.RECORD_BYTES
        image.bytesize = 4
        image.projection = str(label['IMAGE_MAP_PROJECTION'][
                                  'MAP_PROJECTION_TYPE'])
        image.dtype = np.float32
github Arcanewinds / FDL-LunarResources / testNAC.py View on Github external
def _load_info_lbl(image):
        """ Load info on the image
        Note:
            If the image is from LOLA, the .LBL is parsed and the
            information is returned.
            If the image is from NAC, the .IMG file is parsed using
            the library `pvl`_ which provide nice method to extract
            the information in the header of the image.
        .. _pvl: http://pvl.readthedocs.org/en/latest/
        """
        label = load_label(image.img)
        for key, val in label.iteritems():
            if type(val) == pvl._collections.PVLObject:
                for key, value in val.iteritems():
                    try:
                        setattr(image, key, value.value)
                    except:
                        setattr(image, key, value)
            else:
                setattr(image, key, val)
        image.start_byte = image.RECORD_BYTES
        image.bytesize = 4
        image.projection = str(label['IMAGE_MAP_PROJECTION'][
                                  'MAP_PROJECTION_TYPE'])
        image.dtype = np.float32
github planetarypy / planetaryimage / tests / test_pds3file.py View on Github external
# ^PTR = nnn <BYTES>
    assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)

    # ^PTR = "filename"
    assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename")
    assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename", nnn)
    # Example tests/mission_data/W1782844276_1.LBL
    assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)

    # ^PTR = ("filename", nnn <BYTES>)
    assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)

    # Test bad type
    with pytest.raises(ValueError):
        Pointer.parse(None, 64)

    # Test wrong sized arrays
    with pytest.raises(ValueError):
        Pointer.parse([], 64)

    with pytest.raises(ValueError):
        Pointer.parse(['W1782844276_1.IMG', 5, 6], 64)
github planetarypy / planetaryimage / tests / test_pds3file.py View on Github external
def test_parse_pointer():
    # ^PTR = nnn
    # Example tests/mission_data/1p432690858esfc847p2111l2m1.img
    assert Pointer.parse(56, 640) == Pointer(None, 35200)

    # ^PTR = nnn <BYTES>
    assert Pointer.parse(Units(101337, 'BYTES'), 0) == Pointer(None, 101337)

    # ^PTR = "filename"
    assert Pointer.parse('W1782844276_1.IMG', 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename")
    assert Pointer.parse(['W1782844276_1.IMG'], 1024) == Pointer('W1782844276_1.IMG', 0)

    # ^PTR = ("filename", nnn)
    # Example tests/mission_data/W1782844276_1.LBL
    assert Pointer.parse(['W1782844276_1.IMG', 5], 1024) == Pointer('W1782844276_1.IMG', 4096)

    # ^PTR = ("filename", nnn <BYTES>)
    assert Pointer.parse(['W1782844276_1.IMG', Units(101337, 'BYTES')], 1024) == Pointer('W1782844276_1.IMG', 101337)

    # Test bad type
    with pytest.raises(ValueError):
github planetarypy / planetaryimage / tests / test_mission_data.py View on Github external
def test_mission_data():
    data_products = PlanetaryTestDataProducts()

    for file_name in data_products.products:
        image_path = os.path.join(data_products.directory, file_name)
        try:
            image = PDS3Image.open(image_path)
            assert data_products.mission_data[file_name]['opens'] == "True"
            assert data_products.mission_data[file_name]['label'] \
                == image.label.items()[0][1]
        except (pvl.decoder.ParseError, KeyError, UnicodeDecodeError,
                ValueError):
            try:
                assert data_products.mission_data[file_name]['opens'] \
                    == "False"
            except:
                print (file_name, "is marked as True and should be false")
        except AssertionError:
            print (file_name, "is marked as False and should be True")
github Arcanewinds / FDL-LunarResources / DataPreparation / AlternativeUnused / coordinateTransform.py View on Github external
for key, value in val.iteritems():
                        try:
                            setattr(self, key, value.value)
                        except:
                            setattr(self, key, value)
                else:
                    setattr(self, key, val)
            self.start_byte = self.RECORD_BYTES
            self.bytesize = 4
            self.projection = str(label['IMAGE_MAP_PROJECTION'][
                                      'MAP_PROJECTION_TYPE'])
            self.dtype = np.float32
        elif self.grid == 'NAC':
            label = load_label(self.img)
            for key, val in label.iteritems():
                if type(val) == pvl._collections.PVLObject:
                    for key, value in val.iteritems():
                        try:
                            setattr(self, key, value.value)
                        except:
                            setattr(self, key, value)
                else:
                    setattr(self, key, val)
            self.start_byte = self.RECORD_BYTES
            self.bytesize = 4
            self.projection = str(label['IMAGE_MAP_PROJECTION'][
                                      'MAP_PROJECTION_TYPE'])
            self.dtype = np.float32
        else:
            with open(self.lbl, 'r') as f:
                for line in f:
                    attr = [f.strip() for f in line.split('=')]
github wtolson / pysis / pysis / cubefile.py View on Github external
def _parse_label(self, stream):
        return pvl.load(stream)
github planetarypy / planetaryimage / planetaryimage / image.py View on Github external
def _load_label(self, stream):
        return pvl.load(stream)
github Arcanewinds / FDL-LunarResources / DataPreparation / AlternativeUnused / coordinateTransform.py View on Github external
for key, val in label.iteritems():
                if type(val) == pvl._collections.PVLObject:
                    for key, value in val.iteritems():
                        try:
                            setattr(self, key, value.value)
                        except:
                            setattr(self, key, value)
                else:
                    setattr(self, key, val)
            self.start_byte = self.RECORD_BYTES
            self.bytesize = 4
            self.projection = str(label['IMAGE_MAP_PROJECTION'][
                                      'MAP_PROJECTION_TYPE'])
            self.dtype = np.float32
        elif self.grid == 'NAC':
            label = load_label(self.img)
            for key, val in label.iteritems():
                if type(val) == pvl._collections.PVLObject:
                    for key, value in val.iteritems():
                        try:
                            setattr(self, key, value.value)
                        except:
                            setattr(self, key, value)
                else:
                    setattr(self, key, val)
            self.start_byte = self.RECORD_BYTES
            self.bytesize = 4
            self.projection = str(label['IMAGE_MAP_PROJECTION'][
                                      'MAP_PROJECTION_TYPE'])
            self.dtype = np.float32
        else:
            with open(self.lbl, 'r') as f:
github Arcanewinds / FDL-LunarResources / DataPreparation / AlternativeUnused / lat_lon_coordinate_calculator.py View on Github external
def _load_info_lbl(image):
        """ Load info on the image
        Note:
            If the image is from LOLA, the .LBL is parsed and the
            information is returned.
            If the image is from NAC, the .IMG file is parsed using
            the library `pvl`_ which provide nice method to extract
            the information in the header of the image.
        .. _pvl: http://pvl.readthedocs.org/en/latest/
        """
        label = load_label(image.img)
        for key, val in label.iteritems():
            if type(val) == pvl._collections.PVLObject:
                for key, value in val.iteritems():
                    try:
                        setattr(image, key, value.value)
                    except:
                        setattr(image, key, value)
            else:
                setattr(image, key, val)
        image.start_byte = image.RECORD_BYTES
        image.bytesize = 4
        image.projection = str(label['IMAGE_MAP_PROJECTION'][
                                  'MAP_PROJECTION_TYPE'])
        image.dtype = np.float32

pvl

Python implementation for PVL (Parameter Value Language) parsing and encoding.

BSD-3-Clause
Latest version published 4 months ago

Package Health Score

64 / 100
Full package analysis

Similar packages