pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.06k stars 294 forks source link

changes of 'grid' arguments in pycoast 1.4.0. has no effect on the images, bug #1417

Open arturimgw opened 3 years ago

arturimgw commented 3 years ago

Describe the bug The usage of pycoast 1.4.0 to change frequency and width of the graticules has no effect on the image. When save_datasets are used regadles kwargs major_latlon are always in 10 deg cadence, and minor_latlon are always in 2 deg cadence. change arguments (major_latlon and minor_latlon) to (lon_major, lat_major, lon_minor, lat_minor) allows to change the cadence. However 'width' cannot be change.

To Reproduce

composite = 'hrv_clouds'
scn.load([composite])
newscn = scn.resample('imgw_central_lcc', radius_of_influence=20000)   

# Font color can either be specified 'white' or (R, G, B) = (255, 255, 255)
font = aggdraw.Font('blue','/home/troll/Downloads/fonts/Roboto-Regular.ttf', size = 15) # Font takes only 4 arguments

grid  = {#'major_lonlat': (5,5), 'minor_lonlat': (5, 5), #NOT WORKING
         'lat_major': 5,'lon_major': 5, 'lat_minor': 5, 'lon_minor': 5,
        'outline': (235, 235, 235) , 'outline_opacity': 100,
        'major_width': 0.1, 'minor_width': 0.1, 'minor_is_tick': 0,
        'write_text': True, 'lat_placement': 'lr', 'lon_placement': 'b',
        'font': font}

deco = [{'logo': {'logo_path': '/home/troll/scripts_pytroll/IMGW_cmyk_k_d.eps',
         'height': 78, 'bg': 'white', 'bg_opacity': 127}},
         {'text': {'txt': 'MSG4' + ' ' + newscn.attrs['start_time'].strftime('%d-%m-%Y %H:%M') + "\nComposite:  " + composite + ", Area: imgw_central_lcc \n(C) by EUMETSAT",
         'font': '/home/troll/Downloads/fonts/Roboto-Regular.ttf',
         'font_size': 20, 'height': 10, 'bg': 'white', 'bg_opacity': 127, 'line': 'black'}}]

coast     = {'outline': (235, 235, 235), 'width': 0.5, 'level': 1, 'resolution': 'i'}
borders   = {'outline': (235, 235, 235), 'width': 0.25, 'level': 3, 'resolution': 'i'}
rivers    = {'outline': (0,   0, 255), 'width': 1.0, 'level': 2, 'resolution': 'i'}

newscn.save_dataset(composite, filename=nazwa+composite+".png",
         overlay = {'coast_dir': '/home/troll/config/gshhs',
#      'overlays': {'grid': grid, 'coasts': coast, 'borders': borders, 'rivers': rivers, 'points': points}}, decorate = {'decorate': deco}, fill_value=0)   
'overlays': {'grid': grid, 'coasts': coast, 'borders': borders, 'rivers': rivers}}, decorate = {'decorate': deco}, fill_value=0) 

Expected behavior Should change graticules appearances (width and frequency).

Actual results (pytroll-stacja) [troll@Gaja 15min]$ python img/msg_hrv_test.py /home/troll/msg/5min/H-000-MSG3-MSG3_RSS_-____-EPI__-202010291025-__ /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/satpy/resample.py:150: UserWarning: Gradient search resampler not available, upgrade Pyresample. warnings.warn('Gradient search resampler not available, upgrade Pyresample.') /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyresample/geometry.py:1113: RuntimeWarning: invalid value encountered in double_scalars self.pixel_size_y = (area_extent[3] - area_extent[1]) / float(height) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() The following datasets were not created and may require resampling to be generated: DataID(name='hrv_clouds') /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/pyproj/crs/crs.py:543: UserWarning: You will likely lose important projection information when converting to a PROJ string from another format. See: https://proj.org/faq.html#what-is-the-best-format-for-describing-coordinate-reference-systems proj_string = self.to_proj4() /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/satpy/node.py:105: UserWarning: Attribute access to DataIDs is deprecated, use key access instead. return self.name == other.name /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in cos return func((_execute_task(a, cache) for a in args)) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in sin return func((_execute_task(a, cache) for a in args)) /home/troll/anaconda3/envs/pytroll-stacja/lib/python3.6/site-packages/dask/core.py:121: RuntimeWarning: invalid value encountered in log return func(*(_execute_task(a, cache) for a in args))

Screenshots 202010291055hrv_clouds-old 202010291055hrv_clouds

Environment Info:

Writers

cf: ok geotiff: ok mitiff: ok ninjotiff: cannot find module 'satpy.writers.ninjotiff' (No module named 'pyninjotiff') scmi: ok simple_image: ok Additional context Add any other context about the problem here.

djhoese commented 3 years ago

Copying my findings from slack:

  1. It seems the width argument is not considered in pycoast's add_overlay_from_dict:

    https://github.com/pytroll/pycoast/blob/master/pycoast/cw_base.py#L885-L891

  2. There seem to be three different sets of keyword arguments now that either currently work everywhere, used to work, or work for some interfaces, but none of them are properly documented:

    a. lon_major/lat_major/lon_minor/lat_minor: only seem to be a thing in the add_overlay_from_dict method in pycoast: https://github.com/pytroll/pycoast/blob/master/pycoast/cw_base.py#L859-L862 b. dlonlat and Dlonlat: These are used in the actual add_grid method: https://pycoast.readthedocs.io/en/latest/api/pycoast.html#pycoast.cw_agg.ContourWriterAGG.add_grid c. major_lonlat, minor_lonlat: Seem to only be in the old satpy add_overlay function but are mapped to dlonlat/Dlonlat now: https://satpy.readthedocs.io/en/latest/_modules/satpy/writers.html#add_overlay