insarlab / MintPy

Miami InSAR time-series software in Python
https://mintpy.readthedocs.io
Other
555 stars 244 forks source link

Request for Large Image Size #1196

Open hariiirs opened 1 month ago

hariiirs commented 1 month ago

I am trying to plot the displacement time-series like this

opt = ' timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3824818 --sub-lon 477810 694969 --ref-lalo 3755123 555512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections'
cmd_list = [
    f'view.py ./output/timeseries.h5 {opt} --lalo-loc 1 0 1 0',
    f'view.py ./output/timeseries_SET.h5 {opt} --lalo-loc 0 1 1 0',
    f'view.py ./output/timeseries_SET_tropHgt.h5 {opt} --lalo-loc 1 0 0 0', 
    f'view.py ./output/timeseries_SET_tropHgt_ramp.h5 {opt} --lalo-loc 0 1 0 0',
    f'view.py ./output/timeseries_SET_tropHgt_ramp_demErr.h5 {opt} --lalo-loc 1 0 0 1', 
    f'view.py ./output/timeseriesResidual_ramp.h5 {opt} --lalo-loc 0 1 0 1'
]

# plot using matplotlib & mintpy.view
fig, axs = plt.subplots(nrows=3, ncols=2, figsize=[25, 25], subplot_kw=dict(projection=ccrs.PlateCarree()))
for ax, cmd in zip(axs.flatten(), cmd_list):
    data, atr, inps = prep_slice(cmd)
    plot_slice(ax, data, atr, inps)

fig.tight_layout() 
plt.show()

Many times, I did this and earlier used to get proper plots, but now it is showing the following error message-

view.py ./output/timeseries.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 1 0 1 0
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
view.py ./output/timeseries_SET.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 0 1 1 0
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
view.py ./output/timeseries_SET_tropHgt.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 1 0 0 0
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
view.py ./output/timeseries_SET_tropHgt_ramp.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 0 1 0 0
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
view.py ./output/timeseries_SET_tropHgt_ramp_demErr.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 1 0 0 1
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
view.py ./output/timeseriesResidual_ramp.h5 timeseries*20240429 --scalebar 0.2 0.15 0.04 -d ./output/inputs/geometryGeo.h5 -m ./output/maskTempCoh.h5 --notitle --ref-date 20180119 --sub-lat 3755123 3760818 --sub-lon 477810 479869 --ref-lalo 3758123 478512 --ref-marker k+ --ref-size 18 --pts-marker kd --pts-ms 10 --fignum 6 --nrows 3 --wspace 5 --ncols 2 --fontsize 24 --cbar-nbins 7 --lalo-fs 20 --figsize 25 25 --ylabel-rot 90 -c jet_r --noverbose --dpi 400 -o ./Maps/Disp_Corrections --lalo-loc 0 1 0 1
WARNING: elevation range (1577.6-1696.3 m) < 2 contour levels (400.0 m) --> skip plotting DEM contour and continue
/tmp/ipykernel_303729/2288354908.py:21: UserWarning: Tight layout not applied. The left and right margins cannot be made large enough to accommodate all axes decorations.
  fig.tight_layout()
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/IPython/core/formatters.py:340, in BaseFormatter.__call__(self, obj)
    338     pass
    339 else:
--> 340     return printer(obj)
    341 # Finally look for special method names
    342 method = get_real_method(obj, self.print_method)

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/IPython/core/pylabtools.py:152, in print_figure(fig, fmt, bbox_inches, base64, **kwargs)
    149     from matplotlib.backend_bases import FigureCanvasBase
    150     FigureCanvasBase(fig)
--> 152 fig.canvas.print_figure(bytes_io, **kw)
    153 data = bytes_io.getvalue()
    154 if fmt == 'svg':

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backend_bases.py:2193, in FigureCanvasBase.print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, bbox_inches, pad_inches, bbox_extra_artists, backend, **kwargs)
   2189 try:
   2190     # _get_renderer may change the figure dpi (as vector formats
   2191     # force the figure dpi to 72), so we need to set it again here.
   2192     with cbook._setattr_cm(self.figure, dpi=dpi):
-> 2193         result = print_method(
   2194             filename,
   2195             facecolor=facecolor,
   2196             edgecolor=edgecolor,
   2197             orientation=orientation,
   2198             bbox_inches_restore=_bbox_inches_restore,
   2199             **kwargs)
   2200 finally:
   2201     if bbox_inches and restore_bbox:

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backend_bases.py:2043, in FigureCanvasBase._switch_canvas_and_return_print_method.<locals>.<lambda>(*args, **kwargs)
   2039     optional_kws = {  # Passed by print_figure for other renderers.
   2040         "dpi", "facecolor", "edgecolor", "orientation",
   2041         "bbox_inches_restore"}
   2042     skip = optional_kws - {*inspect.signature(meth).parameters}
-> 2043     print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
   2044         *args, **{k: v for k, v in kwargs.items() if k not in skip}))
   2045 else:  # Let third-parties do as they see fit.
   2046     print_method = meth

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:497, in FigureCanvasAgg.print_png(self, filename_or_obj, metadata, pil_kwargs)
    450 def print_png(self, filename_or_obj, *, metadata=None, pil_kwargs=None):
    451     """
    452     Write the figure to a PNG file.
    453 
   (...)
    495         *metadata*, including the default 'Software' key.
    496     """
--> 497     self._print_pil(filename_or_obj, "png", pil_kwargs, metadata)

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:445, in FigureCanvasAgg._print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata)
    440 def _print_pil(self, filename_or_obj, fmt, pil_kwargs, metadata=None):
    441     """
    442     Draw the canvas, then save it using `.image.imsave` (to which
    443     *pil_kwargs* and *metadata* are forwarded).
    444     """
--> 445     FigureCanvasAgg.draw(self)
    446     mpl.image.imsave(
    447         filename_or_obj, self.buffer_rgba(), format=fmt, origin="upper",
    448         dpi=self.figure.dpi, metadata=metadata, pil_kwargs=pil_kwargs)

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:383, in FigureCanvasAgg.draw(self)
    381 def draw(self):
    382     # docstring inherited
--> 383     self.renderer = self.get_renderer()
    384     self.renderer.clear()
    385     # Acquire a lock on the shared font cache.

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:398, in FigureCanvasAgg.get_renderer(self)
    396 reuse_renderer = (self._lastKey == key)
    397 if not reuse_renderer:
--> 398     self.renderer = RendererAgg(w, h, self.figure.dpi)
    399     self._lastKey = key
    400 return self.renderer

File ~/miniconda3/envs/mintpy/lib/python3.11/site-packages/matplotlib/backends/backend_agg.py:70, in RendererAgg.__init__(self, width, height, dpi)
     68 self.width = width
     69 self.height = height
---> 70 self._renderer = _RendererAgg(int(width), int(height), dpi)
     71 self._filter_renderers = []
     73 self._update_methods()

ValueError: Image size of 1126239x8835838 pixels is too large. It must be less than 2^16 in each direction.

<Figure size 2500x2500 with 12 Axes>

I have given the extent of image as [W S E N]: [477810, 3755123, 694969, 3824818]