do not create .tif file when running save_dataset()

14 views
Skip to first unread message

Rey Koki

unread,
Jul 25, 2024, 5:35:28 PM (2 days ago) Jul 25
to pytroll
Hi there!

I am using Scene objects in order to apply corrections/projections to GOES imagery and get out RGB numpy arrays of the data. The input is GOES ABI L1b C01, C02, C03 the output I'd like is the True Color RGB values. I'm able to obtain the R, "G", B values using the code below.

def get_RGB_save_dataset(scn, composite):
    data = scn.save_dataset(composite, compute=False)
    R = normalize(data[0][0])
    G = normalize(data[0][1])
    B = normalize(data[0][2])
    RGB = np.dstack([R, G, B])
    RGB = RGB.compute()
    return RGB
RGB_save_ds = get_RGB_save_dataset(scn, 'true_color')

this gives me expected results shown here:

save_dataset.jpg


But I only want the RGB arrays and don't want to save a GeoTiff so I tried obtaining the data through scn.compute() using the same exact Scene object but get weird results

def get_RGB_compute(scn, composite):
    computed_scn = scn.compute()
    R = normalize(computed_scn[composite].data[0])
    G = normalize(computed_scn[composite].data[1])
    B = normalize(computed_scn[composite].data[2])
    RGB = np.dstack([R, G, B])
    return RGB
RGB_compute = get_RGB_compute(scn, 'true_color')

compute.jpg

I thought that using the scn.compute() function would allow me to get the projected/corrected values without creating the geotiff but the output is not right for the corrections (projection looks fine). How do I get the true color RGB values without having to create the geotiff file?

Thank you!
Rey

David Hoese

unread,
Jul 25, 2024, 9:49:27 PM (2 days ago) Jul 25
to pyt...@googlegroups.com
Hi Rey,

I really thought we had this better documented, but I'm having trouble finding it at the moment. The step you're looking for that is part of "save_datasets" is enhancing (applying an enhancement). When you want to do it manually you should be able to do:

from satpy.writers import get_enhanced_image

enh_data_arr = get_enhanced_image(scn["true_color"]).data

This uses a class from the trollimage package called XRImage and that's what is being returned by "get_enhanced_image". We use the ".data" at the end to access the xarray DataArray underneath the XRImage. If you want to get the computed xarray DataArray you could call ".compute()" on this enhanced data array. Let me know if you have any additional questions.

Dave

--
You received this message because you are subscribed to the Google Groups "pytroll" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pytroll/d6e60f9a-642f-444c-8ccb-403b64df98ean%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages