Skip to content
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

Feature/fix bm #146

Merged
merged 8 commits into from
Feb 18, 2021
Merged

Feature/fix bm #146

merged 8 commits into from
Feb 18, 2021

Conversation

aleeciu
Copy link
Collaborator

@aleeciu aleeciu commented Feb 15, 2021

A fix to some bugs in black marble:

I also updated the tutorial.

fix test failures, crash with NASA data, wrong path assignment, update tutorial
@chahank chahank requested review from Evelyn-M and removed request for chahank, emanuel-schmid and tovogt February 15, 2021 10:55
Copy link
Collaborator

@tovogt tovogt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at my comments in the code.

climada/entity/exposures/nightlight.py Outdated Show resolved Hide resolved
climada/entity/exposures/nightlight.py Outdated Show resolved Hide resolved
climada/test/test_blackmarble.py Outdated Show resolved Hide resolved
climada/test/test_blackmarble.py Outdated Show resolved Hide resolved
climada/test/test_blackmarble.py Outdated Show resolved Hide resolved
climada/test/test_blackmarble.py Outdated Show resolved Hide resolved
@@ -363,7 +364,7 @@ def load_nightlight_noaa(ref_year=2013, sat_name=None):
for pre_i in np.arange(ini_pre, end_pre, -1):
url = NOAA_SITE + 'F' + str(pre_i) + str(ref_year) + '.v4.tar'
try:
file_down = download_file(url)
file_down = download_file(url, download_dir=SYSTEM_DIR)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm still not fully acquainted with the outcomes of the new config settings, but shouldn't file downloads etc. be configurable by setting the path in the config accordingly, as opposed to hard-coding system_dir as the option of choice here?

Copy link
Collaborator Author

@aleeciu aleeciu Feb 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's what I thought too.. but it was not the case for me when I ran it, it was saving the downloaded files in my working directory

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @emanuel-schmid can comment on this?

I'm not sure what exactly is happening here, but the rest of this PR is fine from my side.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep, same from my side, all good, but would be nice if Emanuel could explain / help out on this one.

Copy link
Collaborator

@emanuel-schmid emanuel-schmid Feb 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter download_dir of the download_file functions was introduced with the changes of the config settings.
(Before the changes, it used to download files into the working directory. Which was sometimes countered by undesired os.chdir() calls.)
The function's default directory is CONFIG.local_data.save_dir. The configuration's default value for this is ./results.

SYSTEM_DIR is a constant, but it's not exactly hard coded. Its value is defined as CONFIG.local_data.system.

I hope these explanations help clarify the behaviour?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SYSTEM_DIR is a constant, but it's not exactly hard coded. Its value is defined as CONFIG.local_data.system.

Thanks! I think that is the answer to @Evelyn-M's original question and solves this confusion.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks Emanuel, yes, it was creating a ./results folder in the working directory and saving files therein. Problem is, the loading function called after was expecting the files to be in SYSTEM_DIR, so that was the problem.

So maybe that also explaines why the same did not crash on Jenkins? (see #143) Can it be that there it is CONFIG.local_data.save_dir == CONFIG.local_data.system ? (my guess)

Copy link
Collaborator

@tovogt tovogt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the changes, this PR is fine from what I can judge.

@@ -363,7 +364,7 @@ def load_nightlight_noaa(ref_year=2013, sat_name=None):
for pre_i in np.arange(ini_pre, end_pre, -1):
url = NOAA_SITE + 'F' + str(pre_i) + str(ref_year) + '.v4.tar'
try:
file_down = download_file(url)
file_down = download_file(url, download_dir=SYSTEM_DIR)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe @emanuel-schmid can comment on this?

I'm not sure what exactly is happening here, but the rest of this PR is fine from my side.

@aleeciu
Copy link
Collaborator Author

aleeciu commented Feb 15, 2021

thanks @tovogt for the feedback

@tovogt tovogt merged commit 41a110a into develop Feb 18, 2021
@tovogt tovogt deleted the feature/fix_bm branch February 18, 2021 13:51
@aleeciu aleeciu mentioned this pull request Feb 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants