ecmwf / magics-python

Python interface to Magics meteorological plotting package
Apache License 2.0
49 stars 12 forks source link

How to put wind field into minput? #18

Open NMC-DAVE opened 5 years ago

NMC-DAVE commented 5 years ago

Hi, I want to plot wind flags with data fields. But I can not find the examples which show how to put data filed into minput, just like:

  data =  magics.minput(
        input_type = "geographical",
        input_x_component_field = uwind_field,    # 2D array, [nlat, nlon]
        input_y_component_field = vwind_field,    # 2D array, [nlat, nlon]
        input_latitude_list = lat,         # 1D vector
        input_longitude_list = lon,     # 1D vector
        input_metadata = metadata)

but this is not working. Very thanks!

Dave

sylvielamythepaut commented 5 years ago

To plot wind with minput, Magics needs 4 1D vectors. (x, y, lat, lon)

input_x_component_field and input_y_component_field are 1D vectors with the u and v components of the winds. I hope this helps Sylvie

NMC-DAVE commented 5 years ago

Sylvie, Thanks for your help. Now I can put vector data in to minput:

  return magics.minput(
        input_type = "geographical",
        input_x_component_values = uwind_field,    # 1D nlon x nlat vector
        input_y_component_values = vwind_field,    # 1D nlon x nlat vector
        input_latitude_values = lat,    # 1D nlon x nlat vector
        input_longitude_values = lon,    # 1D nlon x nlat vector
        input_metadata = metadata)

But when i plot the wind field, the "wind_thinning_factor" is not working.

# Defining Wind plotting
wind_flags = magics.mwind(
    legend                  = 'off',
    wind_field_type         = 'flags',
    wind_flag_length        = 1.0,
    wind_thinning_factor    = 5.,
    wind_flag_calm_below    = 0.5,
    wind_flag_calm_indicator = 'off',
    wind_flag_thickness = 1,
    wind_flag_origin_marker = "circle",
    wind_flag_colour        = 'chestnut')

Thanks very much!

sylvielamythepaut commented 5 years ago

Yes, you are right, the wind thinning factor is only working when using GRIB or NetCDF data. We could implement it , in the meantime you can subsample your vectors .. I think lat[start:end:step] should work.

Sylvie