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

Nan values when resample with Kompsat #1664

Closed
ptcongbk opened this issue May 9, 2021 · 19 comments
Closed

Nan values when resample with Kompsat #1664

ptcongbk opened this issue May 9, 2021 · 19 comments

Comments

@ptcongbk
Copy link

ptcongbk commented May 9, 2021

Hi everyone,

I am trying to get samples from Kompsat full-disk using ami_l1b. The final results contained a lot of Nan values as the sample images. Do you have any ideas why it happened?

Much appreciated.

koreaIR087_202104050300

@simonrp84
Copy link
Member

Can you please share the code you're using to read and resample the data?

@ptcongbk
Copy link
Author

ptcongbk commented May 9, 2021

Yes, for sure, @simonrp84. Here is my code.

import glob
from satpy import Scene
from pyresample import get_area_def
from pyresample.utils import get_area_def

files =  glob(path + "*.nc")
scn = Scene(files, reader='ami_l1b')
area_id = 'korea'
x_size = 230
y_size = 258
area_extent =  (-230081.30238210218, -255028.30785934266, 230081.30238209982, 260877.24912037785)
projection = '+proj=laea +lat_0=36.48944825845746 +lon_0=127.43408442536264 +ellps=WGS84'
description = "korea"
proj_id = 'laea_127.43408442536264_36.48944825845746'

areadef = get_area_def(area_id, description, proj_id, projection,x_size, y_size, area_extent)
lons, lats = areadef.get_lonlats() 
available_datasets = scn.available_dataset_names()

 for dataset in available_datasets:
    scn.load([dataset])
    local_scene = scn.resample(areadef,resampler='nearest', skipna=True)
    local_scene.save_dataset(dataset, '{channel}_{datetime}.png'.format(channel=dataset, datetime=scn.start_time.strftime('%Y%m%d%H%M')))
    del scn[dataset]

Thanks in advance, @simonrp84

@djhoese
Copy link
Member

djhoese commented May 9, 2021

This isn't the issue, but I don't think skipna is used by the nearest resampler.

Do you get these types of results for all data cases? There are certain patterns that we expect if some resampling parameters are misconfigured/sub-optimal, but not like what you're seeing. These results make me think that something in the reader is wrong...or I'm just wrong about the resampling. What does the image look like if you don't resample and call save_datasets on the original scn? Do you see any missing/bad pixels there?

@ptcongbk
Copy link
Author

ptcongbk commented May 9, 2021

I tried the different resamplers and I forgot to remove the skipna so that is the reason it is there. I tested the resample in many different timeframes but the results were quite the same.

However, if I saved it from the original scn, it works perfectly as the attached image.

image

Do you have any suggestions for me? Thanks @djhoese

@djhoese
Copy link
Member

djhoese commented May 9, 2021

In your resample call with the local scene, try passing radius_of_influence=50000 and see if that changes the results.

@ptcongbk
Copy link
Author

Thank you so much for your helps @djhoese,

It works 👯.

koreaIR087_202104050300

I will play around more with this parameter.

@djhoese
Copy link
Member

djhoese commented May 10, 2021

@simonrp84 you do a lot of AMI stuff, right? Do you do resampling? Have you seen results like this?

@ptcongbk Satpy is supposed to make an educated guess about what this parameter should default to. I'm surprised it is this bad, especially near the middle of the full disk.

Edit: actually Korea is higher up I guess, right (on mobile hard to tell)? Still, not great.

@simonrp84
Copy link
Member

@djhoese I always work in full disk or cropped disk, never resampled. Will have al ook and see what I can find, though.

@simonrp84
Copy link
Member

Hm, running the same code as @ptcongbk (only replacing import glob with from glob import glob I get output that looks OK. There's no NaN areas at all...

@djhoese
Copy link
Member

djhoese commented May 10, 2021

@simonrp84 @ptcongbk What reader(s) are you using? I see somehow that the reader doesn't exist in the code example above.

@simonrp84
Copy link
Member

I'm using ami_l1b.

@ptcongbk
Copy link
Author

ptcongbk commented May 10, 2021

Hi @djhoese and @simonrp84,

I am using ami_l1b too. I got the main branch in your GitHub so can it be the problem?

@djhoese
Copy link
Member

djhoese commented May 11, 2021

@ptcongbk Where are you getting your data from (sorry if you've said this already)? Could you put it somewhere where we could try running it?

Running from the GitHub main branch should still be fine.

@ptcongbk
Copy link
Author

@djhoese I got a copy from my professor for research purposes (I am not sure how he got it).

I uploaded it to google drive here https://drive.google.com/drive/folders/1nGq8w4xCH1ZqW6rkU6AYITtBW-N5CN0G?usp=sharing.

@djhoese
Copy link
Member

djhoese commented May 11, 2021

@ptcongbk Do you normally provide all of these files to a single Scene? The Scene isn't able to handle more than one time step at a time. Try changing your glob pattern so you are only operating on one time step of data and see if that changes the results.

@ptcongbk
Copy link
Author

@djhoese how stupid I am. It works. Sorry I missed it from the beginning. Thank you so much for your help.

@djhoese
Copy link
Member

djhoese commented May 11, 2021

No, this is really our fault. This is probably the most frequent misunderstanding new users have when working with Satpy. We really need to make it more clear.

@djhoese
Copy link
Member

djhoese commented May 11, 2021

@mraspaud maybe we create a separate issue specifically for this task and close this? I think @pnuu or someone had a suggested way of handling this and mentioned it on slack.

@mraspaud
Copy link
Member

Agreed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants