CODING Snippet 003: Spatial Analysis using Python Xarray & Cartopy| METEOROLOGY-RELATED Pep Talk

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 พ.ย. 2024

ความคิดเห็น • 60

  • @poumba0
    @poumba0 6 หลายเดือนก่อน

    I enjoy watching your tutorials, very clear and very informative. You are very generous for sharing your coding skills. Thanks!!

  • @swagatapaul5351
    @swagatapaul5351 3 ปีที่แล้ว

    Thank you so much for this tutorial

  • @LilianeUWAJENEZA
    @LilianeUWAJENEZA 2 ปีที่แล้ว +1

    Thank you. I already watched this video, it's about temperature. We have one variable but in wind, we have to compute the wind vector. The problem I faced is to add wind direction on a seasonal.

    • @meteodata
      @meteodata  2 ปีที่แล้ว +2

      Which variable do you have?

    • @LilianeUWAJENEZA
      @LilianeUWAJENEZA 2 ปีที่แล้ว +1

      @@meteodata I calculate wind speed from (u,v)component.

    • @meteodata
      @meteodata  2 ปีที่แล้ว +2

      The wind direction formula is indicated in the final paragraphs of this page: confluence.ecmwf.int/pages/viewpage.action?pageId=133262398
      1. Build a function for it and apply to the (U, V) data
      2. Alternatively, you can use MetPy for such conversions. They're pre-built in MetPy.

  • @Dabblez
    @Dabblez 2 ปีที่แล้ว +1

    Hi, Great video and helps a ton. My question is: How would you pull out specific years within the 1901-2021 dataset. For instance lets say I want to pull ou 1979-2021. How could I implement that into the code. Thanks

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      you can simply slice it from your Data, as shown below.
      Data.sel(time=slice(1979, 2021))

  • @jacobagyekum3915
    @jacobagyekum3915 4 ปีที่แล้ว +2

    Finally!!!

  • @milkessagebeyehuhoma5653
    @milkessagebeyehuhoma5653 2 ปีที่แล้ว +1

    thank you for your nice presentation. Is it possible to define our season with four months?

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Yes, absolutely. You can build a function and apply on the data or resample the data over your proposed seasons.

  • @akindefisayo3267
    @akindefisayo3267 ปีที่แล้ว +1

    You are great Sir. Really helpful. Thank you. But, the gridlines doesn't work with my plot. Whenever I initiate the gridlines code you provided, it doesn't display any plot

    • @meteodata
      @meteodata  ปีที่แล้ว +1

      Confirm that you issued gridliner not gridlines.

    • @akindefisayo3267
      @akindefisayo3267 ปีที่แล้ว

      Ok Sir

    • @akindefisayo3267
      @akindefisayo3267 ปีที่แล้ว

      @@meteodata Thank you Sir. I replicate what you did here with my data. I finally got the gridlines. However, I wanted to do a time range for my CRU data, example I want to do 1970-2019. And, since I used this code ds_use.sel(lon=np.arange(-20,15,0.5), lat=np.arange(0,20,0.5),time=slice('1970','2019). I got the error which says, KeyError: "not all value found in index 'lon'". Please, how do I select a range of time in my dataset. Cos, when I tried using slice for the long and lat I did not get the gridlines, now I finally got that the gridlines works with using np.arange, how do I select a range of time??? Thank you Sir

  • @codenust2753
    @codenust2753 2 ปีที่แล้ว +1

    Thank you for nice explanation. I have a question: Can we do an average over a specific time span. For example with a daily or hourly data of any month can we just do an average for that one month. Thank you!

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Yes, absolutely. You can simply select that time period and find the mean over the extracted/sliced period.

  • @Rainstorm121
    @Rainstorm121 3 ปีที่แล้ว +1

    Thank you very much Sir. Very useful content. Can you please make a video on how to draw hurricane tracks?

    • @meteodata
      @meteodata  3 ปีที่แล้ว +2

      We gladly will do so.
      Just a quick one. Do you have sample data to help or a link to such datasets?
      Glad you found the content useful. Share within your network and subscribe for more of such tutorial.

    • @Rainstorm121
      @Rainstorm121 3 ปีที่แล้ว +1

      @@meteodata thanks much for the positive response. Really looking forward for that. Definitely I will pass on this to my other colleagues.
      A sample of hurricane dataset (csv) known as SPEArTC can be accessed from here.
      apdrc.soest.hawaii.edu/projects/speartc/

    • @debashispaul197
      @debashispaul197 3 ปีที่แล้ว +1

      Yes i agree with torrential rain.. Make a video of plotting hurricane or tropical cyclone tracks.. It will be much helpful

  • @Simplecly
    @Simplecly 3 ปีที่แล้ว +1

    Hii, I'm watching it from France and this video is really interesting and helpful.
    It would be useful if you could also give tutorials to handle netcdf4 and HDF files.
    Have a nice day!! Merci:)

    • @meteodata
      @meteodata  3 ปีที่แล้ว +2

      Duly noted with thanks.

  • @akindefisayo3267
    @akindefisayo3267 ปีที่แล้ว +1

    Gridlines doesn't work for me Sir. I wanted to do a plot for the West Africa Region. And the plot doesn't look good without the country line demacation( gridlines). It brings out a blank plot each time I initiated the code you privided

    • @meteodata
      @meteodata  ปีที่แล้ว +1

      For the country lines (BORDERS),
      1. from cartopy import feature as cf
      then add the BORDERS to your axes (ax)
      2. ax.add_feature(cf.BORDERS)
      If the issue is with the longitudinal and latitudinal gridlines, then be sure you used gridliner not gridlines.

  • @maatouknadia4824
    @maatouknadia4824 2 ปีที่แล้ว +1

    Thank you à lot for this intersting vidéo. I have a question. How can I merge contries in map with Cartopy? Is it obligatory to une geopandas ?

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      geopandas is the recommended option for now. But you could read the shapefiles separately via cartopy.

  • @olorunfemiomonigbehin389
    @olorunfemiomonigbehin389 3 ปีที่แล้ว +1

    Thank you again for this video. I have been trying to incorporate contour labels into the code provided in this video (matplotlib)to no avail. Could you guide me on how to do that?

    • @meteodata
      @meteodata  3 ปีที่แล้ว +1

      Femi, you can assign your plot line to a variable (eg. h), and then add the clabel line
      plt.clabel( h, inline=1 )
      Hope this helps.

  • @phyllisowusu-afriyie8579
    @phyllisowusu-afriyie8579 2 ปีที่แล้ว +1

    Can you do subplot on different netcd4 files.Diff data files without looping

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Sure, you can, Phyllis.
      Find a sample with explanations here: th-cam.com/video/BKHcq1l332w/w-d-xo.html

  • @codenust2753
    @codenust2753 2 ปีที่แล้ว +1

    If I slice a time span from the xarray dataset and then do a mean by simply doing ds.mean() and plot it, it gives a histogram and not a spatial plot. How can we do a spatial plot of averaged temperature data over a certain time span? Thank you!

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Xarray always produces a histogram when your data is more than a 2-dimensional data. Check the data dimensions first.

  • @popuriann8983
    @popuriann8983 2 ปีที่แล้ว +1

    Hi! I've tried this code in spyder, then install the cartopy package in miniconda. But then I got this error ModuleNotFoundError: No module named 'cartopy._crs'. I've changed the spyder environment, but didn't solve this issue. Could you help me fix it ?

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Apologies for the late response.
      There's no need for the underscore in 'cartopy.crs'. Kindly check and fix.

  • @LilianeUWAJENEZA
    @LilianeUWAJENEZA 2 ปีที่แล้ว +1

    Hi, Thank for this video its very helpful. I did it on the wind data and I can see the map but i need to add the wind direction what can i do on the season of wind data

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      I believe this is what you're asking of: th-cam.com/video/1Nr9KW89lCc/w-d-xo.html

  • @funnyhow6249
    @funnyhow6249 4 ปีที่แล้ว +2

    Please any recommended site , I can get accurate meteorological data

    • @meteodata
      @meteodata  4 ปีที่แล้ว

      Hello Felix, I have included a link for sample meteorological datasets in the description box (eg. CRU Dataset - data.ceda.ac.uk/badc/cru/data/...)
      Under BADC, there are various datasets available (reanalysis, campaign-based, aircraft, etc.). Kindly find for your perusal.

    • @funnyhow6249
      @funnyhow6249 4 ปีที่แล้ว

      @@meteodata thank you very much

  • @zalexdavis3938
    @zalexdavis3938 3 ปีที่แล้ว +1

    how do I do this for the Caribbean?

    • @meteodata
      @meteodata  3 ปีที่แล้ว +1

      Get the coordinates of the Caribbean and substitute for the ones in the code.

  • @ejeefe4816
    @ejeefe4816 2 ปีที่แล้ว +1

    what is xarray used for?I installed it on conda..................but I have no clue what it really does to data

    • @meteodata
      @meteodata  2 ปีที่แล้ว +1

      Xarray is used for analysing multidimensional data, which can be in the form of netcdf, hdf, etc. It has powerful functionalities to make such analysis seamless. If you've ever used CDO (Climate Data Operators) before, then think of Xarray as a powerful Python variant.
      Good you have it installed. You can follow the other videos on this channel. Most of our tutorial videos are centered around "using Xarray".

    • @ejeefe4816
      @ejeefe4816 2 ปีที่แล้ว

      @@meteodata OK. I sent you some emails.... Seems to be bouncing back.

    • @ejeefe4816
      @ejeefe4816 2 ปีที่แล้ว

      So with the xarrary, one can visualize/analyze climate data from three locations in one script?

  • @thasweerah
    @thasweerah 4 ปีที่แล้ว +1

    how to convert time in xarray dataframe and how to convert xarray to pdarray

    • @meteodata
      @meteodata  3 ปีที่แล้ว +1

      Your question isn't too clear. Could you clarify, please?

  • @nembilwiwamashudu7692
    @nembilwiwamashudu7692 3 ปีที่แล้ว +1

    Hi, HOW DO I WRITE TITLE IN ALL IMAGES AT ONCE?
    Thanks for the video!!!

    • @meteodata
      @meteodata  3 ปีที่แล้ว +1

      At the last line within the loop, you can pass the title as a string in the following:
      ax.set_title(' title ')

    • @nembilwiwamashudu7692
      @nembilwiwamashudu7692 3 ปีที่แล้ว +1

      @@meteodata Thanks so much
      But when i pass that it writes the same tittle in all images...

    • @meteodata
      @meteodata  3 ปีที่แล้ว +2

      An easy approach is to create a list of titles you want outside the loop and call them in your loop by index.
      Eg.
      Titles = ['DJF', 'MAM', 'JJA', 'SON']
      Now, within the loop, pass
      ax.set_title( titles[count-1] )

    • @nembilwiwamashudu7692
      @nembilwiwamashudu7692 3 ปีที่แล้ว +2

      Man🙏 You are a Blessing Thank you so Much