Choose not to generate vis image at night?

29 views
Skip to first unread message

Cris B

unread,
Sep 23, 2024, 4:25:59 PM9/23/24
to pytroll
Hi

I'd like to prevent true colour (and also greyscale vis) images from being generated when it is night time, and also perhaps for instances when there are only a few "lit" pixels. What's the most efficient way of doing this with a satpy.scene.Scene instance? I'm imagining something like this, but it takes quite a while to compute:

array = list(scn_resampled.values())[0]
num_pixels = np.prod(array.shape)
# 5% threshold
thresh = 0.05 * num_pixels
num_lit_pixels = (array.compute() > 0).sum()
if num_lit_pixels > thresh:
    scn_resampled.save_dataset(...)

Cheers
Cris

Panu Lahtinen

unread,
Sep 24, 2024, 1:23:47 AM9/24/24
to pyt...@googlegroups.com
On 23.9.2024 23.25, 'Cris B' via pytroll wrote:
> Hi
>
> I'd like to prevent true colour (and also greyscale vis) images from
> being generated when it is night time, and also perhaps for instances
> when there are only a few "lit" pixels. What's the most efficient way
> of doing this with a satpy.scene.Scene instance? I'm imagining
> something like this, but it takes quite a while to compute:

Hi,

This is what we do in Trollflow2 to check day-light coverage:

https://github.com/pytroll/trollflow2/blob/main/trollflow2/plugins/__init__.py#L767

The relevant parts are

overpass = Pass(platform_name, start_time, end_time, instrument=sensor)

and calling the

_get_sunlight_coverage(area_def, start_time, overpass=None)

function to get the actual percentage where sun is up on the target
area. We then compare to configured values and discard the product if
the day-light covered area is too small or too small (for night-only
products).


P

--
Arctic Space Centre
Finnish Meteorological Institute
Phone: +358 50 380 3261

Cris B

unread,
Sep 24, 2024, 4:51:48 AM9/24/24
to pytroll
Great, thanks very much Panu.

I'm only using geo imagery so I guess all I need is to import  _get_sunlight_coverage and use?

It's not clear to me how to install trollflow2 into my conda environment. conda search can't find trollflow. Please could you suggest how?

Thanks

Cris B

unread,
Sep 24, 2024, 11:40:05 AM9/24/24
to pytroll
No worries, I got it using 'pip install trollflow2'

Gerrit Holl

unread,
Sep 25, 2024, 2:53:08 AM9/25/24
to pyt...@googlegroups.com
Hi,

trollflow2 is not in conda-forge. You need to install it with pip
from pypi or directly from the git repo.

regards,
Gerrit.

On Tue, 24 Sept 2024 at 10:51, 'Cris B' via pytroll
> --
> 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/dfaa4bb0-b217-4327-911f-0a287f2c8511n%40googlegroups.com.

Panu Lahtinen

unread,
Sep 25, 2024, 3:23:33 AM9/25/24
to pyt...@googlegroups.com
On 24.9.2024 11.51, 'Cris B' via pytroll wrote:
> Great, thanks very much Panu.
>
> I'm only using geo imagery so I guess all I need is to import 
> _get_sunlight_coverage and use?

Sorry for being a bit late, got entangled in work.

You shouldn't import and use private functions (their names starting
with "_") from any package, they are an implementation detail that might
change without any notice. I would instead just copy the relevant parts
to your own wrapper script
Reply all
Reply to author
Forward
0 new messages