joe smith
joe smith

Reputation: 29

How to input both wind speed and direction data and pcolormesh plot it in python, with both on the same plot?

I have some wind speed and direction data that I need to plot into python. I got the data from a data file and did some calculations to get the wind speed and data, and here is what I got:

wind_speed = np.sqrt(u**2+ v**2)
wind_speed
wind_dir_trig_to = (np.arctan2((u/wind_speed), (v/wind_speed)))
wind_dir_trig_to_degrees = (wind_dir_trig_to * (180/np.pi))
wind_dir_trig_from_degrees = wind_dir_trig_to_degrees + 180 

wind_dir_trig_from_degrees
wind_dir_cardinal = 90 - wind_dir_trig_from_degrees
wind_dir_cardinal

This is the output of the code shown above:

array([[ 25.05589294,  26.44908142,  25.87358856, ...,  26.09784698,
     24.73834229,  23.79068756],
   [ 25.00778198,  26.04024506,  25.52288055, ...,  24.56259918,
     22.53238678,  21.8249054 ],
   [ 23.54372406,  23.90814972,  24.1379776 , ...,  24.2286377 ,
     22.26264191,  21.62586975],
   ..., 
   [ 26.37328339,  27.58541107,  27.02276611, ...,  22.10659027,
     22.27283478,  23.06639862],
   [ 26.5234375 ,  26.64894867,  25.70041656, ...,  24.78749084,
     24.94545746,  25.05831909],
   [ 25.57256317,  24.58295441,  23.94006348, ...,  27.29759979,
     27.22042084,  26.55405426]], dtype=float32)

How do I use this data to plot both wind speed and direction into the same pcolormesh graph in python?

Upvotes: 1

Views: 2006

Answers (1)

Chiel
Chiel

Reputation: 6194

How about:

import matplotlib.pyplot as pl
pl.pcolormesh(wind_dir_cardinal)

Upvotes: 2

Related Questions