Suppress Warning from logger Module using Pyresample create_area_def()

26 views
Skip to first unread message

Amy Huff - NOAA Affiliate

unread,
May 20, 2025, 11:12:39 AMMay 20
to pytroll
Hi everyone,

I'm a scientist at the NOAA/NESDIS Center for Satellite Applications and Research (STAR). I'm working on Python code to generate RGB composites from VIIRS SDR swath granules. I am using Pyresample's create_area_def() to create the AreaDefinition to resample my VIIRS swaths, as shown below.  

    # Create AreaDefinition (resolution ~750m)
    viirs_area = create_area_def('viirs_area', {'proj': proj,
                                                'lon_0': central_longitude},
                                 area_extent=[west_lon, south_lat,
                                              east_lon, north_lat],
                                 units='degrees', resolution=(6.8E-3, 6.8E-3))

I'm setting the resolution of the AreaDefinition grid to be ~750 m, to match the spatial resolution of the VIIRS M-band SDRs at nadir.  This is working correctly, and I can successfully generate the VIIRS RGBs.  However, I'm getting a WARNING message from the Python logger module about needing to round the shape and resolution of the AreaDefinition grid to integer values, for example:

WARNING:root:shape found from radius and resolution does not contain only integers: (2647.0588235281784, 2426.470588240133) Rounding shape to (2648, 2427) and resolution from (756.9725373927504, 756.972537394613) meters to (756.8074157762725, 756.7034872654548) meters

I would like to silence this WARNING message, since I don't need to see it.  Could you please advise on which module (bolded below) is prompting the message?  I tried the following options, but they didn't work. 

logging.getLogger('pyresample').setLevel(logging.ERROR)
logging.getLogger('pyresample.create_area_def').setLevel(logging.ERROR)

Thanks for your help!
Amy

David Hoese

unread,
May 20, 2025, 11:16:55 AMMay 20
to pytroll
Hi Amy,

That warning is coming from `pyresample/area_config.py` so the logger should be `pyresample.area_config`. However, skimming the code now, I see that the original author of this code used the `logging` module directly (ex. `logging.warning`) so it might be using the root logger: `getLogger('')`. This is going to cause issues. I can submit a bug fix for it, but if it isn't easy for you to update pyresample then it may not matter. With this fix in using the "pyresample.area_config" or "pyresample" logger and setting the level should work.

Dave

David Hoese

unread,
May 20, 2025, 11:21:46 AMMay 20
to pytroll

Amy Huff - NOAA Affiliate

unread,
May 20, 2025, 1:00:49 PMMay 20
to pytroll
Thank you Dave!  I appreciate your help.  I have a conda environment set up for my code, so it will be straightforward to update pyresample after the fix.  

Thanks,
Amy

David Hoese

unread,
May 21, 2025, 6:48:04 PMMay 21
to pytroll
Sorry for the late update on this. The new version was released and made available on conda-forge late yesterday. Let me know if you still have issues.

Dave
Reply all
Reply to author
Forward
0 new messages