CNES / MAJA

Level-2A processor used for atmospheric correction and cloud-detection. The active repository is the one below, this one is kept to leave access to the older issues.
https://gitlab.orfeo-toolbox.org/maja/maja
Apache License 2.0
137 stars 25 forks source link

Error in DTMCreation.py (cause : underscore in TILE_ID) #26

Open EkicierNico opened 4 years ago

EkicierNico commented 4 years ago

Hi, I have a new error with this script, it seems to be the TILE_ID in MTD_TL.xml file. Here are two examples of TILE_ID from different xml files :

S2A_OPER_MSI_L1C_TL_SGS__20180228T014607_A014027_T54HYF_N02.06 S2A_OPER_MSI_L1C_TL_EPAE_20190424T015912_A020033_T54HYF_N02.07

The archiving centre is not the same (SGS and EPA), and when you split this string, the lenght of the list is different because of underscore number (11 & 10).

Here is the error : python DTMCreation.py -i /media/tmp/S2A_MSIL1C_20190424T002711_N0207_R016_T54HYF_20190424T015912.SAFE/ -s /media/raster/monde/SRTM/ -w /media/raster/monde/SWBD/ -o /media/raster/MAJA/DTM/S2/54HYF/

Found SRTM zip-archives... Found Water zip-archives... Traceback (most recent call last): File "DTMCreation.py", line 326, in creator.run(args.out, args.tempout) File "DTMCreation.py", line 274, in run self.site = self.getSiteInfo(self.mtd, self.dtype) File "DTMCreation.py", line 210, in getSiteInfo assert len(tileFilenameItems) == 11 AssertionError

jerome-colin commented 4 years ago

Hi, Thank you for reporting the issue. I have fixed it on the following fork: https://github.com/jerome-colin/Start-MAJA

I'd be curious to get your feedback before merging it with the main project since I can't reproduce the issue on my computer. Thanks, Jerome

olivierhagolle commented 4 years ago

Salut Jérôme, je t'ai invité au projet starts_maja. J'espère que ça marchera https://github.com/CNES/Start-MAJA/invitations Olivier


De : jerome-colin [notifications@github.com] Envoyé : mercredi 17 juillet 2019 15:14 À : CNES/Start-MAJA Cc : Subscribed Objet : Re: [CNES/Start-MAJA] Error in DTMCreation.py (cause : underscore in TILE_ID) (#26)

Hi, Thank you for reporting the issue. I have fixed it on the following fork: https://github.com/jerome-colin/Start-MAJA

I'd be curious to get your feedback before merging it with the main project since I can't reproduce the issue on my computer. Thanks, Jerome

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/CNES/Start-MAJA/issues/26?email_source=notifications&email_token=ABFNSJ4M22GJ7W6RVBRZ5ADP74LLZA5CNFSM4IDUZDB2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD2EEXOA#issuecomment-512248760, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABFNSJ3IM3N3LAKGQU5UQCTP74LLZANCNFSM4IDUZDBQ.

EkicierNico commented 4 years ago

Hi Jerome, Olivier, Thanks for the fix, I'm going to test it as soon as possible, but it seems to be good according to the code.

Nicolas

EkicierNico commented 4 years ago

Hello, You can merge with the main project, it works fine on my side.

Thanks

EkicierNico commented 4 years ago

Hi Olivier and Jerome, Given that I needed this fix in my work, I added this one in my fork, so my pull request includes the code from Jerome.

https://github.com/CNES/Start-MAJA/pull/19/commits/eef20f6efdc1997fc3359c9436fa2b9ddf031f46

Thanks again. Nicolas

jerome-colin commented 4 years ago

Great, thanks ! It may be wise to have both python 2 and 3 versions living alongside for a while, I'll check with Olivier and come back to you later. Jerome

EkicierNico commented 4 years ago

Yes I understand about Python version... I made a little fix in your code, actually I fully tested the function and it was necessary to add an increment at row 216 :

https://github.com/CNES/Start-MAJA/pull/19/commits/52e571a8c19f802d39470fdba0fb4839763c44fa

Sorry about that, it works fine now. Nicolas

jerome-colin commented 4 years ago

Hi Nicolas, I'm a bit doubtful about this indent. As far as I see it, if you move the assert in the if clause, you're sure the assertion is True since it's the if condition too. Whenever you have time, I'd be curious to see what error you get before indenting this line (or even remove the try... except statement for testing). Besides, I must admit that I'm not a big fan of assertion (I just kept it since this code is using aplenty). I would preferably catch and manage any other (more explicit) exceptions. Anyway thanks for your help ! Jerome

EkicierNico commented 4 years ago

Hi Jerome, I understand your point of view, I'm not used to employing assert function.

Actually, here the aim is to get the Tile ID, that means the if condition has to be True too. If you don't put the indent, the assert function is always interpreted, that returns a False because the first for loop iteration (tileFilenameItems[s] with s = 0) is not the Tile ID.

That provokes the except statement at the first loop and finally the "sys.exit(1)".

I hope I was clear... Thanks again.

Nicolas

jerome-colin commented 4 years ago

Ok, I see : this assertion should be out of the for loop, my mistake. It should act as a final check on the tile name pattern once each element of the list passed through the loop. Unindent the assert statement twice will do the job. Thanks !

olivierhagolle commented 4 years ago

I agree with you, Jérome and Nicolas, it is way time to switch to python 3. Olivier