Exporting geoTIFF as float32

35 views
Skip to first unread message

nevermind

unread,
Jun 18, 2022, 8:48:50 AM6/18/22
to pytroll
Hi everybody,

I am working with some MODIS level-2 data (MOD06_L2.A2021272.1640.061.2021274182421.hdf) and I am trying to export some of the datasets as geoTIFFs using the following code:

============================
# package import:
from satpy import Scene
import numpy as np

# load MODIS level 2 data:
file = ["E:/Jasper/Studium/BA_Thesis/MODIS_data/MOD06_L2.A2021299.1620.061.2021300211624.hdf"]
data = {"modis_l2": file}
modis = Scene(filenames=data)

modis.load(["cloud_effective_radius", "cloud_optical_thickness"])

modis.save_datasets(writer="geotiff",
dtype=np.float32,
datasets=["cloud_effective_radius", "cloud_optical_thickness"],
filename="{name}_georef_test.tif",
base_dir="E:/Jasper/Studium/BA_Thesis/MODIS_data/output")
============================

I am exporting them in float32 format, since the modis_l2 reader imports them this way. Plotting the data with matplotlib.pyplot shows me that the pixels values range from 0-60 for the effective radius and 0-150 for the optical thickness. This is also the valid range for those datasets according to the MODIS user guide.

After exporting the TIFFs, however, I am getting pixel values between -0.00758981 and 2.51779 for the optical thickness and similar values for the effective radius. How do I tell satpy to export the TIFFs in a way that does not change the pixel values?

Thanks in advance for any help!
  Jasper

Panu Lahtinen

unread,
Jun 20, 2022, 1:35:00 AM6/20/22
to pyt...@googlegroups.com
On 18.6.2022 15.48, nevermind wrote:
> Hi everybody,
>
> I am working with some MODIS level-2 data
> (MOD06_L2.A2021272.1640.061.2021274182421.hdf) and I am trying to export
> some of the datasets as geoTIFFs using the following code:

<snip>

> modis.save_datasets(writer="geotiff",
> dtype=np.float32,
> datasets=["cloud_effective_radius", "cloud_optical_thickness"],
> filename="{name}_georef_test.tif",
> base_dir="E:/Jasper/Studium/BA_Thesis/MODIS_data/output")

Adding the keyword argument `enhance=False` here should give you the
full 32 bit floating point resolution.


P

--
Finnish Meteorological Institute
Erik Palménin aukio 1, P.O.Box 503, FIN-00101 Helsinki, Finland
Room: 4B15a, Phone: +358 50 380 3261

nevermind

unread,
Jun 29, 2022, 12:14:10 PM6/29/22
to pytroll
Hi Panu,

This worked, thanks a lot!
 
- Jasper
Reply all
Reply to author
Forward
0 new messages