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

scn.load('C01') gives - TypeError #1344

Closed
raybellwaves opened this issue Sep 5, 2020 · 4 comments
Closed

scn.load('C01') gives - TypeError #1344

raybellwaves opened this issue Sep 5, 2020 · 4 comments

Comments

@raybellwaves
Copy link
Contributor

raybellwaves commented Sep 5, 2020

I know I have to do scn.load(['C01']).

and if do scn.load('C01') I get

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-12-697a49a0eee1> in <module>
----> 1 scn.load('C01')

~/local/bin/anaconda3/envs/dev/lib/python3.8/site-packages/satpy/scene.py in load(self, wishlist, calibration, resolution, polarization, level, generate, unload, **kwargs)
    957         """
    958         if isinstance(wishlist, str):
--> 959             raise TypeError("'load' expects a list of datasets, got a string.")
    960         dataset_keys = set(wishlist)
    961         needed_datasets = (self.wishlist | dataset_keys) - \

TypeError: 'load' expects a list of datasets, got a string.

Could you accept a string if the string is in scn.available_dataset_names(). i.e. under the hood call a list on the string so it's in the format scene likes? 'C01' -> ['C01']. No idea if this will mess things up downstream.

In addition, show accepts a string scn.show('C01')

@raybellwaves
Copy link
Contributor Author

Hmm I guess that wouldn't work for true_color

@djhoese
Copy link
Member

djhoese commented Sep 5, 2020

There is available_composite_names and you can pass scn.available_dataset_names(composites=True).

My argument for not supporting a single string is that I think we should limit how many inputs we accept. My worry is that if someone is passing a string there may be some other misunderstanding or misuse going on. Rather than producing an odd error later on we decided to produce this direct error. Believe it or not we used to not do this check and you would get an error later on about how Satpy couldn't load datasets ['C', '0', '1'].

@raybellwaves
Copy link
Contributor Author

Ah interesting. Welcome to close.

@djhoese
Copy link
Member

djhoese commented Sep 6, 2020

Anyone feel free to disagree and provide your ideas. It doesn't have to be this way, but it seemed "safest" to me.

@djhoese djhoese closed this as completed Sep 6, 2020
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

No branches or pull requests

2 participants