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

FY4A REGC data resampling return all nan #2593

Closed
LiangHongli1 opened this issue Oct 9, 2023 · 12 comments
Closed

FY4A REGC data resampling return all nan #2593

LiangHongli1 opened this issue Oct 9, 2023 · 12 comments
Labels

Comments

@LiangHongli1
Copy link

LiangHongli1 commented Oct 9, 2023

Describe the bug
When scn.resample FY4A REGC file, it returns all nan with version 3.8.0 and above. It works fine with version lower than 3.7.0. It might have something to do with FY4B compatibility. While version 3.7.0 supports FY4B and the reader name is still agri_l1, it doesn't work with FY4B.
------------ Here is the code. Files can be downloaded from the NSMC web. ----------

from satpy import Scene
from pyresample import load_area
from pyresample.geometry import GridDefinition
from satpy.resample import get_area_def
import numpy as np
f = "FY4A-_AGRI--_N_REGC_1047E_L1-_FDI-_MULT_NOM_20231002233836_20231002234253_4000M_V0001.HDF"
scn = Scene(filenames=[f], reader="agri_fy4a_l1"). # agri_fy4a_l1
scn.load(["C11"])
scn.save_dataset("C11", "fy4b_c11_2023100812.png")
area_projection = load_area("areas.yaml", "china_4000M_webmerc"
                            )
tmp_scn = scn.resample(area_projection, cache_dir="cache")
newdata = tmp_scn["C11"].values
data = scn["C11"].values
print(np.isnan(newdata).all(), np.isnan(data).all())
tmp_scn.save_dataset("C11", "fy4b_c11_china_2023100812_4km.png")

Expected behavior
After resampling, np.isnan(newdata).all() shoud be "False", yet it is "True", with REGC file, satpy version 3.8.0 and above. np.isnan(newdata).all() is False with DISK file.

@mraspaud
Copy link
Member

mraspaud commented Oct 9, 2023

@LiangHongli1 thanks a lot for bringing this issue to our attention! I don't have a REGC file myself, I will ask around, but if you can share the file, that would be great!

@mraspaud
Copy link
Member

mraspaud commented Oct 9, 2023

Also could you share the definition of the area you are resampling to?

@zxdawn
Copy link
Member

zxdawn commented Oct 9, 2023

I have tested with Python 3.9 and it works well with native resampler. Could you (@LiangHongli1 ) share your area definition? That would make it easier to reproduce your problem.

@LiangHongli1
Copy link
Author

Thanks for reply! But sorry, I'm unable to upload the files due to its large size, for now.
Here is the area definition:
china_4000M_webmerc:
description: china_4000M_webmerc
projection:
proj: webmerc
ellps: WGS84
lat_0: 30.0
lon_0: 101.0
shape:
height: 1625
width: 1948
area_extent:
lower_left_xy: [-3896182.177765, 669141.057044]
upper_right_xy: [3896182.177765, 7170156.294000]

@zxdawn
Copy link
Member

zxdawn commented Oct 9, 2023

Thanks, I have tested using your area and it works well:

from pyresample.geometry import AreaDefinition

area_id = 'china_4000M_webmerc'
proj_string = '+proj=webmerc +lat_0=30 +lon_0=101 +a=6371228.0 +units=m'
area_extent = (-3896182.177765, 669141.057044, 3896182.177765, 7170156.294000)
shape = (1948, 1625)
area_def = AreaDefinition.from_extent(area_id, proj_string, shape, area_extent)

new_scn = scn.resample(area_def, cache_dir="cache")
new_scn['C11'].plot()

print(new_scn['C11'].isnull().all().values)
# False

image

@LiangHongli1
Copy link
Author

@zxdawn what's the satpy version you are using?

@LiangHongli1
Copy link
Author

Well, I've tested the way you load the area, it doesn't work for me either. I'm using python 3.9.6, satpy 0.41.0 on macos apple m2. And the figure doesn't look right. It shoud look like this.
fy4a_c11_china_2023100812_native

@zxdawn
Copy link
Member

zxdawn commented Oct 9, 2023

Ha, I can reproduce your NaN problem if I use 0.43.0.post0. I tested the newest branch: pip install git+https://github.com/pytroll/satpy.git and it works well.

@LiangHongli1
Copy link
Author

Wow, it works for me too. Looks like the newest branch solved this.
Thanks a lot!

@zxdawn
Copy link
Member

zxdawn commented Oct 9, 2023

You're welcome ;) Actually, I don't know which commit fixes this problem ... Maybe @mraspaud knows.

@LiangHongli1
Copy link
Author

Probably someone fixes it without knowing it? Still, thanks and I'd be happy to know what causes this problem.

@mraspaud mraspaud added the bug label Oct 9, 2023
@mraspaud
Copy link
Member

mraspaud commented Oct 9, 2023

Ok, good that it's fixed. Maybe it's time for a new release then. Closing this now as it seems to be solved.

@mraspaud mraspaud closed this as completed Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants