 Welcome to the second section of tutorial 8. So we have been trying to understand more about Doppler weather radar data, how to visualize the same using open source packages like WCT and where to access, where to download the DWR data. So we have seen two options that is next RAD and the MOSDAC site. And we slowly moved on to Python wherein we were trying to install the libraries that are relevant for opening the next CDF files from Doppler weather radar data. So let us try to move further. So in the last section we stopped at installing PyArt and its dependencies that is NumPy, Matplotlib, SciPy and NetCDF4. And then we created a blank Jupyter notebook and then we named it as tutorial 8 followed by name of the course. Let us try to visualize the data now in Python. So as you see I have named the notebook as tutorial 8 followed by name of the course. And I have imported PyArt and from Matplotlib I have imported Pyplot as PLT and I have imported NumPy as NP. Now since we are handling NetCDF files we have imported the module from NetCDF4 library. Now let us try to read the data for which I am going to use PyArt.io.read and the path where the NetCDF file is being saved. So I want to learn more about what the radar contains because I have read the NetCDF file to radar. Now this radar.info gives me information about the opened file. The array size and the fields that is the variables you can see reflectivity and velocity, the coordinates, the spectrum width, the angles. So all these information are present inside the file which has been read into the variable and named it as radar. So from the radar.info output we can observe that there are 20 elevation angles. So we can extract the reflectivity and radial velocity from one particular elevation angle because you know every time the way the radar collects information is it is going to scan 360 degree at one elevation. So likely increase the elevation scan again, increase the elevation scan again and so on. So for this particular data there are 20 elevation angles and to visualize the data we can pick any one sample elevation and try to see how the reflectivity image is going to look like or the radial velocity image is going to look like. So let us try to extract the required variables from the file. For this also I am going to introduce you to some functions which are useful to extract the variables at a particular elevation angle. So I am going to use radar.get underscore slice. This function takes input as elevation number. So I have given the 3 as the number. It takes input as elevation number and it provides output coordinate information about that specified elevation angle. And then I am going to use radar.fields that is for extracting the reflectivity and radial velocity information. I am going to use radar.fields function which takes variable name and slice underscore indices that is coordinate information as input. So now I am typing radar.fields using it to extract the reflectivity values from the data into REF. And then I am going to use radar.fields to extract the velocity information and then assign it to velocity VEL. And also I need radar.azimuth. You know that that particular function is used to extract azimuth information that is the number of azimuth angles. And finally radar.range function we are using to extract the range information that is the number of observations in the range direction. Now remember to visualize the extracted reflectivity data and radial velocity data we have to convert the data to Cartesian coordinate system which is what we are trying to accomplish by this line. So the following lines whatever you see on the screen it converts the data in range and azimuth direction to Cartesian coordinate system X and Y that is why I am using the formula sin theta and cos theta conversion. So now let us try to visualize the single elevation angle reflectivity and radial velocity. Why single angle? Because I mentioned that there are 20 elevation angles at which DWR gives you the information in this case and out of that you are picking the third elevation angle 3. So how to plot a figure and the functions to create subplots these were discussed as part of previous tutorials. So let me just type the commands without going into much details because by now I am assuming that you are familiar with how to plot a diagram plot a raster in Python. So you are specifying the limit of X and the limit of Y and contour F is used to plot contours. Let me add or set the title. My aim is the downloaded net CDF file I have read it into Python and I want to visualize. In WCT what happens is at the click of a button you are able to visualize but you may not know the data structure and what is contained in the .nc net CDF file. So here what you are doing is you are reading the file analyzing the variables. So looking at the structure of the data contained in the net CDF file and by now you know the variable names that is reflectivity and radial velocity and you are using specific functions available in PyArt to extract these variables one by one reflectivity and radial velocity and then you are converting to Cartesian coordinate system and finally you are using the plt.figure function to visualize the figure. So let me finish adding everything. So I am trying to plot the reflectivity wherein I have X labeled as east-west direction from radar and Y labeled as north-south distance from radar. Similarly I am going to add the limits and try to visualize the radial velocity and add the labels X label and Y label. So I am adding the X label as before east-west distance from radar and the Y label as before that is the north-south distance from radar. And then let me use the color bar plt.colorbar and finally plt.show to display the plots. So let us wait for the reflectivity plot to come. You see the colors, stronger the reflectivity, lighter the color and then you see the radial velocity plots as well. So these plots you see are for Hurricane Katrina, the file that you downloaded from the next rad site. So that is why you can see that near the eye the reflectivity and radial velocity are high. So visually you get an idea that higher the reflectivity, higher the severity of precipitation that is going to occur. Now you may have noticed the warning messages that were appearing every time I run the commands you know. They are nothing but deprecation warnings. So I can use these two lines to ignore the warnings or suppress the warnings. So you know deprecation warnings are nothing but it tells me to stop using some existing feature either because it is going to be removed or because it has been superseded by a better alternative. So the compiler and even the IDE wants me repeatedly whenever I am trying to use a feature that has been marked as deprecated. But then you know if you know that your code is correct and you wish to suppress the recurring warning messages, you can use the two lines that I have written to suppress it. So I am suppressing all the warnings and of course this is not recommended always, but I am just showing for representation purpose. Let us try to understand more about the Doppler weather radars in India. So towards your left side you can see the location where radars are available in India and the details are from India Meteorological Department that is the IMD website. So shown here is sample of the plots that are being made available. This plot is by the radar at Delhi. So the IMD that is the India Meteorological Department it provides products like these which are updated at every 10 minute interval and we have Doppler S-band radars, C-band, X-band radars along with non-Doppler S-band radars in India. So typically I know you will notice that along the coastline there are numerous locations where radars are available. So S-band radars are typically preferred in the coastal stations owing to less attenuation because you know the coastlines, coastal regions are battered by cyclones that tend to produce heavy rainfall and therefore if radars of higher operating frequencies are installed in coastal regions, those radar rays are going to be obscured by heavy precipitation and hence effective coverage range of radar will be reduced. That is why we tend to have specific frequencies of radars at the coastal regions. So here what you see is the level 3 Doppler weather radar data. You know it gives information like reflectivity, radial velocity, precipitation, intensities and so on and they are for a particular altitude. As before the Doppler weather radar data from India is also going to be captured in different altitudes and shown here is the data corresponding to one particular altitude. So now that we have completed how to visualize the NEXRAD data, let us try to handle the data from Indian Doppler weather radar. So for this if you remember in earlier part of the section I mentioned about going to MOSDAC website, creating a user ID password, downloading a sample data. So for representation we have used the Trivandrum radar data from Kerala and one file is being used to complete this exercise. So as before I am going to import a dataset from NETCDF because you know these data come with .NC extension that is they are NETCDF files. And this dataset module is used for opening and extracting the variables from NETCDF files. We already know that numpy is imported for handling arrays and we are also familiar with matplotlib and cartopy modules which are used for plotting the figures. So what I am doing is I am trying to import all the necessary libraries that are required for me to visualize the reflectivity and radial velocity information from Indian DWR data. Import matplotlib and again from matplotlib I need null for matter. We will see what they are used for. First let me import everything. As before I need null for matter, func for matter. It is already written. So let me not repeat it. So now we have imported all the necessary libraries required for us to visualize the data. Let us first see how to open the NETCDF file because we have the NETCDF4 library installed for helping us with this. So I am going to use the dataset function and as before I need to specify the path where the file has been located. The path is same. So in the interest of saving time I am going to copy paste the path and just change the name of the file because the nomenclature for next rat data is different. The nomenclature for Indian Doppler weather radar data is different. I do not want to make any syntax errors. So what I will do is I will try to minimize the windows so that I can see the name of file and then type it dprf underscore corrected dot nc. So now we have opened the NETCDF file. Next we need to extract the relevant information from the file. By relevant information I mean the reflectivity and the radial velocity variable. So this tutorial is going to focus on these two variables. So let us try to first see what the data contains. You can see the variables that the data contains that is the time information, latitude, longitude, information, heights, the dimension or the size of the data is also given and the data type is given whether it is float 64 or float 32 and so on. So what we will do is we will see how to visualize reflectivity using the max z plot. First let me read everything. So I have read the data into fn and now I want to extract the reflectivity, velocity, latitude, longitude and height information from fn. Because we have seen before that there are numerous variables that are present in fn. fn is nothing but the name I have given to the file that contains information about the NETCDF file. So as I mentioned earlier to visualize the reflectivity information I need to use a specific function known as max z. So max z plot is like the most commonly used figure by meteorologist for understanding the nature and intensity of precipitation occurring over a Doppler weather radar covering region. So first let me try to use np.squeeze and np.nanmax. Now visualizing the max z plot gives wide information about how the reflectivity echoes are spread in all directions. So shown here are the steps to plot the max z plot. Now initially what we try to do is we use the nanmax function. The maximum reflectivity values along height, latitude and longitude are computed using the nan np.nanmax function. And the rest of the lines are used for calculating maximum reflectivity values along the heights, latitude and longitude direction respectively. So some attribute error which means spelling mistake let me correct that. So what we have done is we have tried to create the max z plots to begin with we have used the np.nanmax function. Now the plotting max z plot has four sections. We will try how to write lines of code to address each of these four sections. Now the first section is how you define the axis for the three figures and how you define the color bars. So let me try to define the axis left bottom width height. So here the variables a x underscore x y and a x underscore x and a x underscore y they contain axis information for plotting the maximum reflectivity along the height along the latitude and along the longitude. So this is the first section wherein I am defining the axis. PLT dot axis is used to define a x underscore x y underscore x and underscore y. So what are we trying to do? We are trying to plot the max z plot. Why is it important? Because it is most commonly used by meteorologists for understanding the intensity of precipitation occurring over a region from Doppler weather radar data and it also helps us to understand the nature of precipitation. Now this particular plot has four parts. We are trying to address these four parts or four sections. Small spelling mistakes which we need to correct. So every time you make a mistake in typing by your oversight what happens is the lines are going to prompt you to correct the same. So now I have defined the axis. They are empty because I have just defined the axis and now let us go to the second part that is I want to plot the maximum reflectivity along the height using PLT dot contour F function. So what does it do? It plots the contours. So let us see the commands to implement the same. So we are setting the axis label for matters to make the plot look more legible. And then we need to plot the maximum reflectivity along the height using PLT dot contour F function. So now you can see I have defined the axis. I have set the label for matters moving on. I want to plot color map is kept as jet. So once I use PLT dot contour F I can plot the grid. I can you know make the color bar be visible. All these options are made available in Python. So because you know once you know how to create plots and how to plot them side by side using subplots you can use it in a variety of ways. So now you see the plot being displayed. What is this? This is maximum reflectivity values which are plotted along the height. Now let us move on to the third section wherein the maximum reflectivity along the latitude needs to be plotted. So what are we trying to do? We are trying to plot the maximum reflectivity along the height, along the latitude and along the longitude. Again I am going to use the contour F function. So by looking at the color bar you can get an idea that higher the reflectivity darker will be the color according to the color bar. So wherever you see dark red lines or orange lines that denotes high reflectivity z and what am I doing here? I am trying to plot the maximum reflectivity along the height, along the latitude and along the longitude and each time I am using the contour F function which is used to give you contours. So once when we have completed the plotting to make the figure look more legible we can label the axis. Let us try to set the x label and the y label. Every time I am using dot set underscore x label and dot set underscore y label. Elevation and kilometers. Now I see the final plot which has been labeled elevation latitude longitude and which has a color bar that helps us identify the maximum reflectivity values. So let me zoom out so that you get the full picture of the plot in one go. So this is the maximum reflectivity plot of the downloaded data. Now one can observe that the max z plot contains three figures, one at the center, one at the top and one at the right. So the center figure provides information about the maximum reflectivity along all the elevation and by looking at the center plot you can observe that a wide spread 2025 DBZ echo is observed towards the north of the radar location. And there are also of course scattered small clusters of 30-35 DBZ echoes observed throughout the plot. So the center plot does not give much information about the depth of these echoes. The top and right plots gives us information about the maximum reflectivity along the longitude and latitude respectively. So if you look at the plot at the right side you can see there are echoes between 30-35 DBZ. Now typically when we have strong echoes which are tower shaped structures they represent the presence of convective type rainfall. Convective type is the type of rainfall which is accompanied by heavy precipitation which has a high intensity rainfall in short interval of time. So what we have done now is we have tried to visualize reflectivity. Similarly we can add a few lines of code to visualize radial velocity. So in this particular section we will be trying to visualize radial velocity using the average velocity plot, average velocity plot. So a few lines of code are already written because they are similar to what we have seen just now. So I am using np.squeeze and np.nanmin. It performs the same function as we discussed earlier and as before we get to define the axis. Now when you ask me the difference between max z plot and average velocity plot, the answer is both of them are similar but then there is one major difference that is instead of calculating the maximum values here we will be calculating the average values along elevation along latitude and along longitude. So max z plot we are trying to calculate the maximum value along latitude longitude and height and in this case that is in the average velocity plot the only difference is that instead of maximum value you are trying to calculate the average value along latitude longitude and height. So this is the complete set of codes that are used for calculating the velocity average along the elevation latitude and longitude and for displaying the mean velocity plots because the functions used here are very similar to the max z code I am not repeating it but then feel free to pause your screen and then have a look at how each line of code is written. So what I have done is I have used similar lines of code only differences instead of maximum I am trying to calculate mean average and then I am trying to label the axis as before so that I can see the final plot that is final result. So as before for the max z plot as similar to that the average velocity plot will also contain three figures one at the center one at the top and one towards your right side. The center figure gives us information about the average radial velocity along the elevations and we try to look at positive values of rain band if it is present from the center plot. So let us try to plot it and then we will discuss how to interpret the plot. So now I have the plot which has been labeled and as mentioned I have a plot at the center I have a plot at the top and I have a plot towards the right side. This is average velocity plot and typically we try to look at the center plot and infer whether or not we have positive values of rain band say located to the north of radar and it that helps us understand whether the band rain band is moving away from the radar or not. You try to get an idea of the movement of rain band and sometimes we can also get to notice high velocity rain cells say that are moving at the rate of 10 to 15 meter per second that are embedded in this low moving rain band that is also possible. So what we have seen is we have tried to read the net CDF files first of Nexrad then from MOSDAC site and we have tried to visualize the same using WCT package as well as we have tried to import the net CDF files into Python and use the existing functions in PyArt to open the file to extract variables of reflectivity and radial velocity and finally to create plots like the max z plots and the average plots wherein you have three figures one at the center one at the right and one at the top that helps you to get information about the rain bands and the reflectivity values. Now rainfall estimation using reflectivity data this is just one section that I wanted to discuss as part of this tutorial because you know mostly rainfall is measured using in situ rain gauges that are instruments which are placed in situ. So one of the major disadvantage of rain gauge is that it provides you with point measurement of rainfall. Wherever you have the instrument it captures the rainfall and then it gives you point information. It does not stay true to the spatial variability of rainfall across a region and this gap gets filled by Doppler weather radar data because you know variables like reflectivity that is z has a direct relationship with the rainfall rate. So we have an empirical relation in front of you that is between z and r where z is the reflectivity, r is the rainfall and a and b are nothing but the constants. So for each radar site the values of constants are predetermined and then used to estimate rainfall from reflectivity. For example for the Trivandrum radar data that we have used already the constants of a and b will have it will be known beforehand and then we can directly use those values to estimate the value of corresponding rainfall. So with this let me try to summarize what we were learning as part of tutorial 8. So we learned how to access the Doppler weather radar data from Nexrad and Mostach and we learned how to handle the files of Doppler weather radars using Python and very briefly we touched upon rainfall estimation from BWR data. So let me hope that you found this section useful and I shall meet you in the next class. Have a good day.