satpy reprojection full disk cropped?

348 views
Skip to first unread message

Christian Peters

unread,
Nov 11, 2017, 6:56:50 AM11/11/17
to pytroll
Hi,

I tried to dive into satpy and did first steps.

My code:

from satpy.scene import Scene
from datetime import datetime
from satpy.resample import get_area_def
scn = Scene(platform_name="Meteosat-10", sensor="seviri",
            start_time=datetime(2016, 19, 17, 12, 00),
            end_time=datetime(2016, 9, 1, 17, 15),
            base_dir="/root/decomp2",
            reader='hrit_msg',
            )


composite = 'natural'
scn.load([composite])
local_scn = scn.resample("met09globeFull")
local_scn.save_dataset('natural', 'my_nice_overview1.png')

All well. I want a full globe image so did
local_scn = scn.resample("met09globeFull")

But the resulting image is cropped-see picture attatched!?

Did I something wrong??


Regards,

Christian

Btw: I tried to save as a .jpg with

local_scn.save_dataset('natural', 'my_nice_overview1.jpg')

but this doesn't work?
my_nice_overview.jpg

David Hoese

unread,
Nov 14, 2017, 2:15:20 PM11/14/17
to pytroll
Hi Christian,

Some other developers and I are still discussing why the image looks clipped. It's been a while since we've analyzed the builtin areas.

Regardless, I thought you should know that the data you are loading is already gridded so you shouldn't need to resample it, just load and save. Let us know how it goes.

Dave

Christian Peters

unread,
Nov 14, 2017, 5:45:57 PM11/14/17
to pytroll
Hi Dave,

thanks for your response.
Yes...I already tried to save the data without resampling. No cropping.

But as mentioned in the new tutorial the fulldisk images are upside down.
Is there a way to flip while saving or how can I do this (reloading and doing some image processing afterwards necessary?).

Next problem is how to get a black background?

Computing MSG data with mpop results in a black background. Now the background is white.
Any chance to set the background color?

FYI: Saving as jpeg stalls with:

File "/usr/local/lib/python2.7/dist-packages/PIL/JpegImagePlugin.py", line 607, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
IOError: cannot write mode RGBA as JPEG

Seems to work on my mpop installation from last year...now on a fresh satpy/Debian installation.


Regards,

Christian

Christian Peters

unread,
Nov 14, 2017, 7:25:32 PM11/14/17
to pytroll
Dave,

I did some tests, this is my workaround for the moment:

from satpy.utils import debug_on
debug_on()

from PIL import Image

from satpy.scene import Scene
from datetime import datetime
from satpy.resample import get_area_def
scn = Scene(platform_name="Meteosat-10", sensor="seviri",
            start_time=datetime(2017, 9, 3, 12, 00),

            base_dir="/root/decomp2",
            reader='hrit_msg',
            )

composite = 'natural'
scn.load([composite])
scn.save_dataset('natural', 'my_nice_overview2.png')
png = Image.open('my_nice_overview2.png')
png2 = png.rotate(180)
jpg = Image.new("RGB", png2.size, (0, 0, 0))
jpg.paste(png2, mask=png2.split()[3]) # 3 is the alpha channel
jpg.save('rotate.jpg', 'JPEG', quality=80)

Is this the way to go or is there a simpler build in solution in Pytroll/satpy...?

Regards,

Christian

David Hoese

unread,
Nov 15, 2017, 11:15:38 AM11/15/17
to pyt...@googlegroups.com
Christian,

It is possible you've found a bug in satpy. Could you try resampling but
also pass the keyword "reduce_data=False" to the resample call?

local_scn = scn.resample("met09globeFull", reduce_data=False)

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
> <mailto:pytroll+u...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Martin Raspaud

unread,
Nov 15, 2017, 2:48:18 PM11/15/17
to pyt...@googlegroups.com
Christian,

As Dave said, there might be a problem here. I will be looking into it later this week.

In the meanwhile, a dirty hack to flip the image is to do something like:

scn.load(['overview'])
mda = scn['overview'].info
scn['overview'] = scn['overview'][:, ::-1, ::-1]
scn['overview'].info = mda
scn.show('overview')

Regarding the background, satpy uses a transparent background by default, which apparently gets translated to white when saving to jpeg (which doesn't support transparency). If you want the background to be black, I think you could fill the composite array with 0 instead of masked values.

Best regards,
Martin


To unsubscribe from this group and stop receiving emails from it, send an email to pytroll+u...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
--
Martin Raspaud, PhD
Software engineer
SMHI, SE-60176

Christian Peters

unread,
Nov 15, 2017, 5:19:13 PM11/15/17
to pytroll
Dave,

I tried (adding "reduce_data=False") but it didn't change anything.

Regards,

Christian



my_nice_overview2_reduced_false Kopie.jpg

Christian Peters

unread,
Nov 15, 2017, 8:07:35 PM11/15/17
to pytroll
Martin,

thanks for this hack, it works well.

If you will find some time to review the raised problem it would be nice.

Regards,

Christian
Reply all
Reply to author
Forward
0 new messages