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

Fix geolocation errors of the FY-4 AGRI reader base #2533

Merged
merged 6 commits into from
Aug 4, 2023

Conversation

yukaribbba
Copy link
Contributor

@yukaribbba yukaribbba commented Jul 19, 2023

Fix the offset calculations in FY-4 reader base according to HSD reader.

1.Area extent of the GEOS projection
This is calculated by column/line offset (COFF/LOFF), CFAC, width/height of the image using get_area_extent under _geos_area. But, this method begins at (0, 0) which is fit for full-disk image. When the scan mode is regional, the initial column/line position is also important. And that is why FY-4 REGC mode got the wrong area.

2.Comparison between Himawari HSD with FY-4
HSD reader, no matter whether the data is fulldisk / regional, also uses get_area_extent . The differences are:

Himawari full-disk COFF/LOFF
[22000.5, 11000.5, 5500.5, 2750.5, 1375.5]
Himawari full-disk width/height
[44000, 22000, 11000, 5500, 2750]

FY-4 full-disk COFF/LOFF
[21983.5, 10991.5, 5495.5, 2747.5, 1373.5]
FY-4 full-disk width/height
[43968, 21984, 10992, 5496, 2748]

Apparently,
Himawari's offset = width(height) / 2 + 0.5
While
FY-4's offset = width(height) / 2 - 0.5
That 1 pixel diff could explain why FY-4's center coord isn't at (0, 0).

And the calculation:
Himawari:

pdict['coff'] = np.float32(self.proj_info['COFF'])
pdict['loff'] = -np.float32(self.proj_info['LOFF']) + 1
pdict['loff'] = pdict['loff'] + (self.segment_number * pdict['nlines'])

pdict['ncols'] = width
pdict['nlines'] = height

When testing on a target-area scanning dataset HS_H09_20230701_0000_B01_R301_R10_S0101.DAT:

pdict['coff'] = 360.5
pdict['loff'] = -2279.5

The COFF/LOFF of HSD is stored inside the dataset, not fixed like FY-4. So it seems that these two numbers come from nowhere. But, if this regional image reprojected to full-disk frame, it is clear that the scanning start at col 5140 / line 2220.
image
This is a 1000x1000 B01 dataset. The fulldisk size of B01 is 11000 and the COFF/LOFF is 5500.5.

Therefore:

pdict['coff'] = fulldisk_COFF - start_column
pdict['loff'] = -fulldisk_LOFF + 1 + start_line + pdict['nlines']

3.Back on FY-4
Because of the 1-pixel difference:

pdict['coff'] = fulldisk_COFF - start_column + 1
pdict['loff'] = -fulldisk_LOFF + 1 + start_line + pdict['nlines'] - 1 = -fulldisk_LOFF + start_line + pdict['nlines']

Further:
end_line + 1 = start_line + pdict['nlines']

pdict['coff'] = fulldisk_COFF - start_column + 1
pdict['loff'] = -fulldisk_LOFF + end_line + 1

Luckily, both start_column and end_line are attributes in the FY-4 HDF files. So it is very easy to get them.

4.Results
The center point back to zero.
image

And the REGC image
image

@codecov
Copy link

codecov bot commented Jul 19, 2023

Codecov Report

Merging #2533 (6c7e5d0) into main (b0473aa) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #2533      +/-   ##
==========================================
- Coverage   94.89%   94.89%   -0.01%     
==========================================
  Files         349      349              
  Lines       50859    50855       -4     
==========================================
- Hits        48263    48259       -4     
  Misses       2596     2596              
Flag Coverage Δ
behaviourtests 4.32% <0.00%> (+<0.01%) ⬆️
unittests 95.50% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
satpy/tests/reader_tests/test_agri_l1.py 100.00% <ø> (ø)
satpy/readers/fy4_base.py 99.30% <100.00%> (-0.02%) ⬇️

@djhoese
Copy link
Member

djhoese commented Jul 19, 2023

Pinging @simonrp84 who I think added this reader or helped me add it.

@simonrp84
Copy link
Member

Yes, this is my reader. Will have a look in next few days.

@yukaribbba
Copy link
Contributor Author

@simonrp84 What can I do with this PR?

@simonrp84
Copy link
Member

Sorry, haven't had time to look at this. Will test this evening if possible.

For reference, the coff and loff numbers used in the reader were provided by the China Meteorological Administration. It wouldn't surprise me if the values are wrong as the CMA has been very inconsistent with their data over the years.

@simonrp84
Copy link
Member

Just tested this and it looks good for all modes of AGRI on FY-4A and -4B. Also works for GHI on FY-4B.

@yukaribbba
Copy link
Contributor Author

Great. @djhoese If you have any suggestions

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5737717677

  • 4 of 4 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 95.45%

Totals Coverage Status
Change from base Build 5727005357: 0.0%
Covered Lines: 48372
Relevant Lines: 50678

💛 - Coveralls

@yukaribbba yukaribbba requested a review from djhoese August 4, 2023 09:57
@djhoese djhoese self-assigned this Aug 4, 2023
@djhoese djhoese merged commit 3a84a3b into pytroll:main Aug 4, 2023
19 checks passed
@djhoese
Copy link
Member

djhoese commented Aug 4, 2023

Thanks!

@yukaribbba yukaribbba deleted the fix_fy4_geolocation_errors branch August 7, 2023 01:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

FY-4 AGRI reader can't get the right geolocations
4 participants