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

ImportError for the command "from climate_learn.data import DataModule" #117

Open
jdberman opened this issue Nov 14, 2023 · 3 comments
Open
Labels
bug Something isn't working

Comments

@jdberman
Copy link

Describe the bug

I am following the code on page 25 in the ClimateLearn paper (https://arxiv.org/pdf/2307.01909.pdf) and when I try to do the import for DataModule I get the following error:

In [1]: from climate_learn.data import DataModule

ImportError Traceback (most recent call last)
Cell In[1], line 1
----> 1 from climate_learn.data import DataModule

ImportError: cannot import name 'DataModule' from 'climate_learn.data' (/home/user/miniconda3/envs/precip/lib/python3.11/site-packages/climate_learn/data/init.py)

Could someone explain why this import is not working? Perhaps it is related to missing information in the file climate_learn/data/init.py.

As a side question, are there any examples of downscaling with a CNN that could be included in another QuickStart notebook example? For example, similar to the one used in the paper. If so, that would be incredibly helpful.

Thank you for your help!
Jeremy

Environment

  • OS: linux
  • Python version: 3.11
  • Environment: conda, used pip install for climate-learn
@jdberman jdberman added the bug Something isn't working label Nov 14, 2023
@blue-ocean-climate
Copy link

Change the current directory where climate_learn is installed on your system
For instance,

cd /home/user/miniconda3/envs/precip/lib/python3.11/site-packages/

then check in which file does the module exist, now run the import

from climate_learn.data import DataModule

@jdberman
Copy link
Author

Thanks @blue-ocean-climate!

It worked with the command climate_learn.data.module import DataModule

I saw in previous versions of this repo that the init.py file had the line from .module import * which I believe would've made the paper's command ( climate_learn.data import DataModule ) work.

@blue-ocean-climate - on a side note, I am trying to run downscaling and I keep getting errors when using the DataModule like below:

data_module= DataModule(task= "downscaling", dataset= "ERA5", root_dir= f"{data_dir_storage}/data/weatherbench/era5/5.625", root_highres_dir= f"{data_dir_storage}/data/weatherbench/era5/2.8125", in_vars= ["2m_temperature"], out_vars= ["2m_temperature"], train_start_year= Year(2014), val_start_year= Year(2015), test_start_year= Year(2016), end_year= Year(2018), subsample= Hours(6), batch_size= 128, num_workers= 1)

but it keeps giving the error: TypeError: DataModule.init() got an unexpected keyword argument 'task'

Do you know how to use this Module? And also how to set what resolution increase for the downscaling?

@blue-ocean-climate
Copy link

This how you can use the data module,
dm = cl.data.IterDataModule(
task,
inp_root_dir,
out_root_dir,
in_vars,
out_vars,
src="era5",
history=3,
window=6,
pred_range=args.pred_range,
subsample=6,
batch_size=128,
num_workers=8,
)
as mentioned in the "data loading section" of documentation.
I am not very sure about changing the resolution for down-scaling, I will have to dig deeper into that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants