-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve Error when opening Detached Label #75
Comments
I'm not sure I understand since you should never need to guess an extension. The full filename should be listed. Here are some valid ^Image uses.
you can see how GDAL attempts to handle this but below it gets more complicated; Another label complication, which I really didn't like see incorporated, was the allowed additions for COMPRESSED_FILE and UNCOMPRESSED_FILE in the same label. The problem being now the code has to make a choice. Do I open the compressed file or uncompressed file? They should be the same but... Some label examples for this.
And ^IMAGE can also exist in the UNCOMPRESSED_FILE section too. |
Sorry, I meant to include an example. >>> from planetaryimage import PDS3Image
>>> image = PDS3Image('tests/mission_data/0047MH0000110010100214C00_DRCL.IMG')
...
121 if isinstance(key, INDEX_TYPES):
122 return self.__items[key]
--> 123 return dict_getitem(self, key)[0]
124
125 def __delitem__(self, key):
KeyError: '^IMAGE'
>>> image = PDS3Image('tests/mission_data/0047MH0000110010100214C00_DRCL.LBL')
>>> image.bands
3 What I don't like is the error is not explicit that the >>> from planetaryimage import PDS3Image
>>> image = PDS3Image('tests/mission_data/0047MH0000110010100214C00_DRCL.IMG')
...
121 if isinstance(key, INDEX_TYPES):
122 return self.__items[key]
--> 123 return dict_getitem(self, key)[0]
124
125 def __delitem__(self, key):
As for the uncompressed/compressed sections, that does present a complication, especially with detached labels... would being explicit in the function call be better? This is my initial thought: >>> from planetaryimage import PDS3Image
>>> # Opening compressed image:
>>> compressed_image = PDS3Image('filename.jp2', lbl_path='filename.lbl')
>>> # opening uncompressed image:
>>> uncompressed_image = PDS3Image('filename.img', lbl_path='filename.lbl') So we strip as much decision making from the code and put that responsibility on the user. By default the code can use the first instance of |
That error looks fine to me. You could try to find the *.lbl or *.LBL if the *.IMG is simply a raw binary stream, but users generally figure they need to point to a label when available. It is handled now, but GDAL is pretty strict with the PDS hierarchical structure of the PVL label. The original implementation only looked for "^IMAGE" at the root level. When "^IMAGE" started showing up inside the "OBJECT = UNCOMPRESSED_FILE" the group, it would fail to load the image. Nothing to worry about here - just something we had to fix as the standard changed. |
I thought about looking for .lbl/.LBL but there are other extensions like .haf that would not work. I'm very tempted to still look for the .lbl/.LBL and other extensions have to be explicitly passed in, but on the fence. |
What the heck is a "haf" file - never seen that... For an initial push I would just send the error. If you get a lot of feedback to auto-search for other files, then it can be added. The GDAL driver, since it supports so many image formats, can't really be expected to look around for detached labels. But since you are mostly supporting PDS3, perhaps looking for labels could be added. I think PDS4 files will more likely have detached labels (if not mandatory), so users will be force to get use to detached labels. BTW, here is the fairly cryptic GDAL error. But really, what else can it report? At least you can warn for a detached label.
|
There should be a better error when attempting to open a detached label image with the image file rather than the label file. This is the most common error I come across:
Which doesn't really explain to me that there is a detached label I should open. I don't have any immediate ideas on how to make this more explicit. In a perfect world, we would search for the label file ourselves but since there is a lack of consistency in the extensions, I don't see how my perfect world can exist.
The text was updated successfully, but these errors were encountered: