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

scene.save_datasets() outputs different values for AHI_HSD reader with calibration="brightness_temperature" #2710

Closed
jayepraveen999 opened this issue Jan 3, 2024 · 5 comments

Comments

@jayepraveen999
Copy link

Describe the bug

I want to save the raw infrared bands from AHI sensor to .tif files with brightness_temperature as calibration.
However, scene.load(filenames, reader="ahi_hsd", calibration="brightness_temperature") works as expected but when I try to save it using scene.save_datasets(), the values are within the range of [0-1] which doesn't make any sense for brightnesss_temperature product.
To Reproduce

# Your code here
scene = satpy.Scene(reader='ahi_hsd', filenames=filenames)

scene.load(['B07', 'B11', 'B12', 'B13', 'B14', 'B15'],calibration='brightness_temperature')
print(np.unique(scene["B07"].values)) # to check if the calibration is applied and how the values look like

# save datasets as geotiffs   
scene.save_datasets(writer='geotiff', dtype= np.float32, enchance= False, base_dir="reprocess_data/input_data/himawari8")

Expected behavior
When I read any of the saved .tif files from above, I expect they would have values of brightness_temperature which I printed after loading.

output of the print statement in the above code:
array([176.01837, 176.40892, 176.7933 , ..., 330.69333, 330.8056 ,
             nan], dtype=float32)

Actual results

import rasterio

data = rasterio.open("../reprocess_data/input_data/himawari8/B07_20200108_042000.tif")
np.unique(data.read(1))

output:
array([-0.34350264, -0.27109495, -0.22607319, ...,  1.6576164 ,
        1.6579522 ,         nan], dtype=float32)

Environment Info:

  • OS: [Linux]
  • Satpy Version: [0.44.0]
  • PyResample Version: [1.27.1]
@djhoese
Copy link
Member

djhoese commented Jan 3, 2024

You have a typo:

enchance= False

should be:

enhance=False

@djhoese
Copy link
Member

djhoese commented Jan 3, 2024

Also note that the brightness temperature calibration is the default in Satpy for those types of bands so no need to specify it in the .load call.

@jayepraveen999
Copy link
Author

jayepraveen999 commented Jan 3, 2024

oops. Thank you!!

I am thinking if I should submit PR to raise Value Error if valid arguments are not passed for save_datasets() method. Your thoughts @djhoese ?

@djhoese
Copy link
Member

djhoese commented Jan 3, 2024

That is not actually possible due to the way many of Satpy's Scene's methods use **kwargs. For writers it is even more difficult as a single set of kwargs is passed, split by a special classmethod on the Writer object, then some kwargs are sent to Writer.__init__ and the rest to Writer.save_datasets.

It is one of those: if we did it over again we'd probably be smarter about it, but it is the way it is. If you'd like to still look at it and see if it can be done then be my guest it would be great to do those types of checks. I'm just not very optimistic about how cleanly it can be implemented.

@jayepraveen999
Copy link
Author

Agreed. Then I will push this further in my list :)
Closing the issue for now.

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