Skip to content

Obtaining wind with fastmeteo: Unable to plot #25

Description

@marklit

I'm using fastmeteo==1.2.0 and opentop==2.5.0.

I've pasted the code from the tutorial into iPython. After the following I get the error: ValueError: cannot convert float NaN to integer

import matplotlib.pyplot as plt

optimizer = top.CompleteFlight(actype, origin, destination, m0)
optimizer.enable_wind(wind)
flight = optimizer.trajectory(objective="fuel")

top.vis.trajectory(flight, windfield=wind, barb_steps=15)
plt.show()
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/lib/python3.12/tkinter/__init__.py", line 1967, in __call__
    return self.func(*args)
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/tkinter/__init__.py", line 861, in callit
    func(*args)
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/backends/_backend_tk.py", line 312, in idle_draw
    self.draw()
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/backends/backend_tkagg.py", line 10, in draw
    super().draw()
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/backends/backend_agg.py", line 438, in draw
    self.figure.draw(self.renderer)
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/artist.py", line 94, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/artist.py", line 71, in draw_wrapper
    return draw(artist, renderer)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/figure.py", line 3282, in draw
    mimage._draw_list_compositing_images(
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/image.py", line 133, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/artist.py", line 71, in draw_wrapper
    return draw(artist, renderer)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/axes/_base.py", line 3367, in draw
    mimage._draw_list_compositing_images(
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/image.py", line 133, in _draw_list_compositing_images
    a.draw(renderer)
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/artist.py", line 71, in draw_wrapper
    return draw(artist, renderer)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/axis.py", line 1477, in draw
    ticks_to_draw = self._update_ticks()
                    ^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/axis.py", line 1344, in _update_ticks
    major_locs = self.get_majorticklocs()
                 ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/axis.py", line 1673, in get_majorticklocs
    return self.major.locator()
           ^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/ticker.py", line 2299, in __call__
    return self.tick_values(vmin, vmax)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/ticker.py", line 2307, in tick_values
    locs = self._raw_ticks(vmin, vmax)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/ticker.py", line 2237, in _raw_ticks
    nbins = np.clip(self.axis.get_tick_space(),
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/mark/.opentop/lib/python3.12/site-packages/matplotlib/axis.py", line 2755, in get_tick_space
    return int(np.floor(length / size))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: cannot convert float NaN to integer

The ZARR data looks to load without issue into QGIS:

Image

The solver looks to have run without issue:

In [59]: optimizer.objective_value
Out[59]: 7093.827417810349

In [60]: optimizer.solver
Out[60]:
OptiSol(Opti {
  instance #10
  #variables: 217 (nx = 995)
  #parameters: 0 (np = 0)
  #constraints: 753 (ng = 2219)
  CasADi solver allocated.
  CasADi solver was called: Solve_Succeeded
})

This is the flight data frame:

In [61]: flight
Out[61]:
            mass         ts              x              y             h   latitude  longitude  altitude      mach       tas  vertical_rate   heading   fuel_cost  grid_cost  fuelflow         wu         wv
0   66299.999901    -0.0000 -652421.018894  840655.020494     30.480000  52.316620   4.746300     100.0  0.300000  198.3755         2417.0  129.5056  428.386028        NaN  1.872044 -13.050335 -11.020740
1   65871.613873   226.4148 -636521.693374  825144.035092   2810.527189  52.195872   5.006230    9221.0  0.500000  320.0837         1980.0  140.6801  331.499844        NaN  1.487898  -0.721328   0.433960
2   65540.114028   452.8297 -612406.154190  797775.150880   5088.222169  51.977402   5.404483   16694.0  0.614641  382.5282         1474.0  140.6791  285.432587        NaN  1.294515   8.089537   8.274947
3   65254.681441   679.2445 -581981.696884  766155.113347   6783.389158  51.725856   5.896691   22255.0  0.686016  417.6258         1197.0  140.7262  260.585410        NaN  1.182341  14.017031  13.167891
4   64994.096031   905.6594 -547796.398235  732228.891975   8159.833978  51.455136   6.440842   26771.0  0.756097  451.7736          936.0  140.8129  240.688316        NaN  1.090877  18.471008  16.446361
5   64753.407715  1132.0742 -510230.354572  695728.886376   9235.891129  51.161801   7.030350   30301.0  0.792025  466.1482          996.0  140.9336  237.796158        NaN  1.071500  21.857801  18.548892
6   64515.611558  1358.4891 -470982.592956  658320.246540  10381.339277  50.858752   7.637404   34060.0  0.790991  457.8796          150.0  141.0849  181.791629        NaN  0.799735  25.048297  20.139812
7   64333.819929  1584.9039 -431703.515000  621475.768080  10554.287480  50.557720   8.236446   34627.0  0.781170  451.0416           16.0  141.2499  170.423139        NaN  0.749652  26.353316  20.472000
8   64163.396789  1811.3188 -392744.498615  585159.777151  10572.463717  50.258243   8.822892   34687.0  0.783149  452.0623           26.0  141.4220  170.948721        NaN  0.751600  27.342788  20.598518
9   63992.448068  2037.7336 -353615.754512  548677.830014  10602.224046  49.954511   9.404555   34784.0  0.782918  451.7299           24.0  141.6010  170.287982        NaN  0.748593  28.311220  20.666266
10  63822.160086  2264.1484 -314425.322283  512130.787846  10630.107731  49.647405   9.979866   34876.0  0.783012  451.5973           24.0  141.7870  169.806132        NaN  0.746383  29.233126  20.664756
11  63652.353954  2490.5633 -275174.585197  475482.055937  10658.113676  49.336650  10.548897   34968.0  0.783053  451.4333           24.0  141.9800  169.300744        NaN  0.744149  30.111875  20.595295
12  63483.053210  2716.9781 -235880.963116  438715.548814  10685.960655  49.022145  11.111479   35059.0  0.783096  451.2710           24.0  142.1801  168.800447        NaN  0.741933  30.946571  20.457736
13  63314.252763  2943.3930 -196559.783884  401812.228132  10713.687772  48.703771  11.667472   35150.0  0.783132  451.1061           24.0  142.3875  168.301329        NaN  0.739722  31.736904  20.252155
14  63145.951434  3169.8078 -157226.881652  364753.486863  10741.290693  48.381412  12.216730   35240.0  0.783164  450.9390           24.0  142.6022  167.803928        NaN  0.737524  32.482475  19.978658
15  62978.147506  3396.2227 -117898.244805  327520.692813  10768.771159  48.054956  12.759106   35331.0  0.783190  450.7698           24.0  142.8244  167.308203        NaN  0.735324  33.182886  19.637402
16  62810.839303  3622.6375  -78590.070802  290095.265260  10796.130655  47.724295  13.294451   35420.0  0.783212  450.5985           24.0  143.0542  166.814200        NaN  0.733145  33.837731  19.228596
17  62644.025103  3849.0524  -39318.766665  252458.680597  10823.371585  47.389324  13.822615   35510.0  0.783229  450.4251           24.0  143.2916  166.321986        NaN  0.730963  34.446597  18.752500
18  62477.703117  4075.4672    -100.956659  214592.488166  10850.497813  47.049942  14.343448   35599.0  0.783241  450.2496           23.0  143.5369  165.831731        NaN  0.728524  35.009065  18.209428
19  62311.871386  4301.8821   39046.511240  176478.325532  10877.516818  46.706051  14.856797   35687.0  0.783247  450.0717           23.0  143.7901  165.343533        NaN  0.726369  35.524716  17.599747
20  62146.527853  4528.2969   78106.553561  138097.941657  10904.439036  46.357557  15.362512   35776.0  0.783250  449.8918           23.0  144.0514  164.860679        NaN  0.724211  35.993131  16.923876
21  61981.667174  4754.7117  117061.884145   99433.171805  10931.337904  46.004371  15.860441   35864.0  0.783237  449.7034           23.0  144.3209  164.364443        NaN  0.722061  36.413995  16.182259
22  61817.302732  4981.1266  155894.613679   60466.440516  10957.950886  45.646410  16.350431   35951.0  0.783300  449.5603           27.0  144.5988  164.103810        NaN  0.721040  36.786395  15.375586
23  61653.198921  5207.5414  194590.303819   21175.944535  10988.632338  45.283556  16.832373   36052.0  0.782505  448.8976           24.0  144.8852  163.335429        NaN  0.717580  37.117640  14.501336
24  61489.863492  5433.9563  233100.950927  -18413.326569  11016.700685  44.916124  17.305757   36144.0  0.781891  448.4691           23.0  145.1803  162.653118        NaN  0.714851  37.395267  13.565128
25  61327.210374  5660.3711  271422.029004  -58338.710268  11043.088696  44.543861  17.770614   36231.0  0.781542  448.2688           22.0  145.4841  162.079252        NaN  0.712314  37.620616  12.567345
26  61165.131122  5886.7860  309546.868420  -98634.758861  11068.661871  44.166537  18.226945   36315.0  0.781554  448.2755           22.0  145.7969  161.621032        NaN  0.710258  37.794841  11.508106
27  61003.510090  6113.2008  347470.486268 -139338.940735  11094.304724  43.783900  18.674766   36399.0  0.781555  448.2764           22.0  146.1188  161.156412        NaN  0.708205  37.919075  10.387113
28  60842.353678  6339.6157  385173.424646 -180468.004583  11119.888167  43.395886  19.113925   36483.0  0.781560  448.2789           22.0  146.4499  160.693989        NaN  0.706160  37.992575   9.205354
29  60681.659690  6566.0305  422636.317947 -222039.084001  11145.402903  43.002433  19.544277   36566.0  0.781561  448.2798           22.0  146.7905  160.232399        NaN  0.704130  38.014813   7.963775
30  60521.427290  6792.4453  459839.261580 -264068.727925  11170.832054  42.603484  19.965676   36650.0  0.781562  448.2801           22.0  147.1406  159.778420        NaN  0.702097  37.985251   6.663419
31  60361.648870  7018.8602  496762.108446 -306573.307540  11196.289817  42.198987  20.377982   36733.0  0.781522  448.2576           21.0  147.5006  159.237663        NaN  0.699797  37.903594   5.305226
32  60202.411207  7245.2750  533382.662446 -349566.411223  11220.108597  41.788918  20.781038   36811.0  0.781997  448.5297           40.0  147.8705  159.969290        NaN  0.703052  37.766329   3.892936
33  60042.441917  7471.6899  569702.637805 -393096.643021  11266.389109  41.372922  21.174946   36963.0  0.773811  443.8344           -0.0  148.2510  155.863596        NaN  0.686225  37.616595   2.388787
34  59886.578321  7698.1047  605391.352919 -436682.344205  11266.389107  40.955648  21.556396   36963.0  0.783282  449.2669           -0.0  148.6412  157.073003        NaN  0.689287  37.332364   0.917533
35  59729.505318  7924.5196  641038.435462 -481332.803121  11266.389104  40.527695  21.931539   36963.0  0.784479  449.9535          -50.0  149.0410  154.240866        NaN  0.675575  36.990346  -0.616095
36  59575.264452  8150.9344  676318.501383 -526581.886715  11209.208873  40.093562  22.297079   36776.0  0.725684  416.2306        -1182.0  149.4441   80.326081        NaN  0.339103  36.487097  -2.093957
37  59494.938371  8377.3493  709042.084923 -568997.470506   9849.930630  39.685943  22.631582   32316.0  0.647310  377.6284        -1449.0  149.8227   59.472662        NaN  0.247165  33.259403  -1.329046
38  59435.465709  8603.7641  738425.678537 -607645.163332   8183.587212  39.314147  22.928033   26849.0  0.580017  346.4507        -1486.0  150.1640   52.581668        NaN  0.218394  28.637841  -0.498174
39  59382.884041  8830.1790  764588.923175 -643093.070617   6474.505360  38.973261  23.188208   21242.0  0.525472  321.2045        -1499.0  150.4650   48.334637        NaN  0.200920  23.051992  -0.175735
40  59334.549405  9056.5938  787721.310185 -676036.634038   4749.832105  38.657121  23.414319   15583.0  0.481041  300.6689        -1513.0  150.7238   45.414438        NaN  0.188844  16.548345  -0.457632
41  59289.134966  9283.0086  807935.562248 -707076.817108   3009.691358  38.360443  23.607615    9874.0  0.444592  283.9298        -1537.0  150.9392   43.275913        NaN  0.180091   9.112399  -1.397596
42  59245.859054  9509.4235  825272.589954 -736740.652964   1241.765531  38.078640  23.768489    4074.0  0.300000  195.6447        -1053.0  129.5056   39.686571        NaN  0.176111   0.670667  -3.058525
43  59206.172483  9735.8383  842394.396984 -752197.235943     30.480000  37.923510  23.943260     100.0  0.300000  198.3755        -1053.0  129.5056         NaN        NaN  0.174972  -5.683527  -4.759087

Any idea what could be wrong?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions