-
Notifications
You must be signed in to change notification settings - Fork 54
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
Download size with MB #85
Comments
Hey Alexis, that output is enough, we just need to make it a bit more flexible, so it would replace anything at the end. I'd be happy to help you do a pull request, or to work on it myself in the coming weeks. Happy to point you in the right direction if y ou're feeling brave :) Quick fix would be to add another Cheers, |
Hello dear KBodolai, Thanks a lot for the advice and for the good disposition to work into it in the future, I’ll give it a shot and try to make something with the sort of “if else” to round the images with Mb suffix to 1, so that the final sum be the closest as possible; I’ll also check out RegEx and try to apply it if it’s not too time consuming. It will be very important for me because I’ll star to download soon a hole year of Sentinel-1 images for a national project and the space is a big deal. Saludos. Alexis A. |
Dear Alexis, I am implementing the fix suggested by KBodolai, so it won't throw an error. |
Dear @BuddyVolly, As always, I’m really thankful in all the work and effort everyone invests in this code, it really helps me a lot.
Thanks both of you for your kind help. Saludos cordiales. |
Hi Alexis, no need for a PR. I think it can be simplified, but that piece of code already helps me |
can you check if this works for you?I only have GBs in my inventory def download_size(self, inventory_df=None):
"""Function to get the total size of all products when extracted in GB and MB
:param inventory_df:
:return:
"""
if inventory_df is None:
size = self.inventory["size"]
else:
size = inventory_df["size"]
size = size.apply(
lambda x: re.sub(' GB', '' , (x)) if re.search(' GB', str(x)) else re.sub(' MB', '' , (x))/1024
).astype('float32')
print(f"There are about {round(size.sum(), 3)} GB need to be downloaded.") |
I'm sorry, I already made a PL, should I close it?. When I tried to compile my working script it showed me the next error:
|
that's normal you're trying to divide a "str" by 1024. The result of the size = size.apply(
lambda x: x.replace("GB", "") if "GB" in x else int(x.replace("MB", ""))/1024
).astype('float32') |
yes, my idea for regex was avoiding the if / else statement by just pattern matching to the string bit, but hadn't thought about the scale factor, so it ends up not providing that much of an advantage, in which case just the string method is probably best, sorry for the confusion! |
Hello everyone,
Thanks a lot for all your hard work developing this tool, it has been very helpful to me in my work.
I’ll like to report a problem with the method “download_size” in the Class “Proyect.py” of “ost” directory, in my query I have a series of Sentinel-1 images that have less than 1 Gb of information, and the method cannot transform the str to a flout because mb is not deleted from the str, so it shot an error (or that's what I understand) and I’m not able to know the complete download size of my search.
Terminal error:
Script of "download_size":
I’m not a programmer so I’m not able to give more information about the issue.
Thanks a lot.
Alexis A.
The text was updated successfully, but these errors were encountered: