def _load_info_lbl(self): """ 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/ """ if self.grid == 'WAC': 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 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('=')] if len(attr) == 2: setattr(self, attr[0], attr[1].split(' ')[0]) self.start_byte = 0 self.bytesize = 2 self.projection = '' self.dtype = np.int16
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
def _load_info_lbl(self): """ 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 WAC, 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/ """ if self.grid == 'WAC': 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('=')] if len(attr) == 2: setattr(self, attr[0], attr[1].split(' ')[0]) self.start_byte = 0 self.bytesize = 2 self.projection = '' self.dtype = np.int16
def _parse_label(self, stream): return load_label(stream)