cwebster2 / pyMeteo

Meteorological routines
BSD 3-Clause "New" or "Revised" License
75 stars 19 forks source link

Error producing pdf skewt plot from WRF output #8

Closed cwebster2 closed 8 years ago

cwebster2 commented 8 years ago

As reported by wxguy in #6 the following error was produced while trying to produce a PDF skewt plot:

$ skewt-wrf -d ../old_wrf_plotting_scripts-master/wrfout_.nc --lat 9.6 --lon 76 -t 1 -o test.pdf
2015-10-13_01:00:00
('lats/lons dims: ', (60, 102))
('LAT ', 9.6, ': ', 28, ': ', 9.6010742)
('LON ', 76.0, ': ', 33, ': ', 75.992729)
(0, 0, 0.0, 1, 301.15186, 0.27468511, -1.4772046, 101136.3, 0.018818898)
[ 101136.3046875   100797.53125      99971.3984375    98852.7265625
   97445.40625      95696.921875     93512.765625     90892.9765625
   87042.9609375    82160.171875     77285.2421875    72418.78125
   65817.609375     57898.98046875   50776.41796875   44379.95703125
   38650.20703125   33528.41015625   28959.16796875   24892.08789062
   21281.29101562   18085.21289062   15265.07910156   12785.54492188
   10613.87304688    8720.015625      7076.27685547    5656.82861328]
[     0.             30.11538696    103.48806763    203.42379761
    330.5630188     490.24029541    693.01287842    941.31762695
   1318.57165527   1814.96191406   2335.54150391   2883.32788086
   3686.47680664   4731.38720703   5778.36328125   6828.95898438
   7882.62792969   8936.20800781   9988.45214844  11039.34277344
  12088.88476562  13136.5234375   14182.37109375  15231.70117188
  16300.1171875   17422.47265625  18644.11523438  19990.46679688]
[ 301.15185547  301.07305908  301.06292725  301.06689453  301.07958984
  301.44128418  302.18136597  303.00375366  304.48361206  306.68695068
  309.28460693  311.88391113  315.49234009  320.8661499   325.97399902
  331.90634155  336.73202515  340.33770752  343.7522583   346.53143311
  349.15374756  350.74981689  352.4848938   356.46813965  367.31921387
  392.98141479  431.60040283  469.5869751 ]
[ 0.27468511  0.2141853   0.22274287  0.23309466  0.23982641 -0.01485114
 -0.97769964 -2.35944128 -4.14654589 -5.00909996 -4.40022182 -2.62400174
 -0.22619     0.33385721 -1.4100827  -2.03568912 -2.70660758 -5.46401072
 -9.2687645  -8.66651917 -7.31954575 -6.34951162 -6.35857153 -8.59183216
 -8.30127144 -2.01154876  6.34280682  8.49809265]
[-1.47720456 -1.48186922 -1.46820331 -1.43099642 -1.36923695 -1.0809679
 -0.28034401  0.72824627  1.52775264  1.48237514  1.11611152  0.87334806
 -0.24181348 -1.43732142 -1.36976671 -1.13704371 -1.53739798 -1.06609881
 -0.69038689 -3.56384349 -3.63325047 -1.63354123  0.41438103 -0.34079829
 -1.45487368 -0.09732136  2.0640626   0.21578003]
[ 101136.3046875   100797.53125      99971.3984375    98852.7265625
   97445.40625      95696.921875     93512.765625     90892.9765625
   87042.9609375    82160.171875     77285.2421875    72418.78125
   65817.609375     57898.98046875   50776.41796875   44379.95703125
   38650.20703125   33528.41015625   28959.16796875   24892.08789062
   21281.29101562   18085.21289062   15265.07910156   12785.54492188
   10613.87304688    8720.015625      7076.27685547    5656.82861328]
[  1.88188981e-02   1.77619401e-02   1.75294727e-02   1.73988324e-02
   1.72312222e-02   1.64061189e-02   1.58520155e-02   1.56307649e-02
   1.46574536e-02   1.29882134e-02   1.11317541e-02   9.67478659e-03
   8.42783041e-03   6.21006219e-03   5.10617020e-03   3.67291085e-03
   2.33886018e-03   1.26966520e-03   6.03648543e-04   3.04679823e-04
   1.29808279e-04   4.62024655e-05   1.36182225e-05   4.43334011e-06
   2.71074146e-06   3.43757733e-06   1.51017355e-06   9.97768666e-07]
Traceback (most recent call last):
  File "/usr/bin/skewt-wrf", line 27, in <module>
    skewt.plot_wrf(base,lat,lon,time,out)
  File "/usr/lib/python2.7/site-packages/pymeteo/skewt.py", line 327, in plot_wrf
    plot(0. ,0. ,z, t, th, p, qv, u, v, filename, output)
  File "/usr/lib/python2.7/site-packages/pymeteo/skewt.py", line 580, in plot
    plt.savefig(output, dpi=300,bbox_inches=0)
  File "/usr/lib/python2.7/site-packages/matplotlib/pyplot.py", line 688, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/figure.py", line 1539, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_qt5agg.py", line 196, in print_figure
    FigureCanvasAgg.print_figure(self, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/backend_bases.py", line 2230, in print_figure
    **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2536, in print_pdf
    self.figure.draw(renderer)
  File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/figure.py", line 1133, in draw
    func(*args)
  File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 2304, in draw
    a.draw(renderer)
  File "/usr/lib/python2.7/site-packages/matplotlib/artist.py", line 61, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/lib/python2.7/site-packages/matplotlib/text.py", line 796, in draw
    ismath=ismath, mtext=mtext)
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2077, in draw_text
    return draw_text_simple()
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 2006, in draw_text_simple
    self._setup_textpos(x, y, angle)
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 1770, in _setup_textpos
    self.file.output(x - oldx, y - oldy, Op.textpos)
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 589, in output
    self.write(fill([pdfRepr(x) for x in data]))
  File "/usr/lib/python2.7/site-packages/matplotlib/backends/backend_pdf.py", line 149, in pdfRepr
    raise ValueError("Can only output finite numbers in PDF")
ValueError: Can only output finite numbers in PDF
cwebster2 commented 8 years ago

The specific issue here is that TOPS could not be calculated because it would be outside the top of the domain, and the 'default' error value returns a negative height, which for a logarithmic axis becomes -infinity and the PDF backend doesn't handle such a value well.