Python Data Analysis and Visualization Course – Astronomical Data

Astronomical Image Processing with Python: A Comprehensive Approach

The world of astronomical research data analysis is vast and complex, requiring specialized tools and techniques to extract valuable information from images of celestial objects. One such tool is Python, which has become an essential language for astronomers and researchers alike. In this article, we will explore the various aspects of Python used in astronomical image processing, including feature extraction techniques, visualization, and more.

Using Feature Extraction Techniques with SK Image

One of the most exciting applications of Python in astronomical image processing is the use of feature extraction techniques. These techniques allow us to extract valuable information from images, such as identifying stars, galaxies, and other celestial objects. One popular library for this purpose is SK Image, which provides a range of features for image processing and analysis. We can visualize different aspects of an image using SK Image's built-in tools, including color maps, gray scales, and more.

For example, let's consider a color map called "prism." This tool allows us to visualize the image in a unique way, highlighting different features and patterns that may not be immediately apparent. We can also use DP SP (Dense Pixel Spectral) and other tools to extract information from images, such as identifying stars or galaxies. The output of these techniques can provide valuable insights into the nature of celestial objects.

Visualization with Python

Python is an excellent language for visualization, allowing us to create a wide range of visualizations to represent our data. From simple plots like bar charts and line graphs to more complex visualizations like 3D representations and interactive dashboards, Python has the tools we need to communicate our findings effectively.

In Module One of our program, we explored the basics of Python, including syntax, data types, and control structures. We also learned about various visualization libraries, such as Matplotlib and Seaborn, which provide a range of tools for creating high-quality visualizations. By the end of Module Four, we were able to create complex visualizations that effectively represented our data.

Working with Tabular Data

In Module Two, we worked with tabular data, specifically astronomical surveys like SDSS (Sloan Digital Sky Survey) and DSS (Digital Sky Survey). We learned how to convert this data into a format suitable for analysis using Python. This involved loading the data into a Pandas DataFrame or NumPy array, which provided us with a convenient way to manipulate and analyze the data.

We created various visualizations on top of this data, including bar plots, line charts, and even HR diagrams (Hertzsprung-Russell diagrams). These visualizations helped us understand the distribution of stars in our galaxy and other celestial objects. By working with tabular data, we gained valuable insights into the nature of astronomical objects.

Pixel Scaling and Image Enhancement

In Module Three, we took the data from previous modules and applied pixel scaling to images using Python. This involved loading the image into a library like PIL (Python Imaging Library) or OpenCV, which provided us with tools for manipulating and enhancing the image.

We used various techniques to enhance the features that were present in the image but not visible until Module Three. These included applying filters to remove noise and other artifacts, as well as using feature extraction techniques to identify specific patterns or structures within the image.

By the end of Module Four, we had refined our skills in pixel scaling and image enhancement, allowing us to extract even more valuable information from images. We used feature extraction techniques like SK Image to enhance features that were not visible before.

Conclusion

In conclusion, Python has become an essential tool for astronomers and researchers working with astronomical data analysis. From feature extraction techniques to visualization and image processing, Python provides a wide range of tools and libraries for extracting valuable insights from images of celestial objects. By mastering these skills, we can unlock the secrets of the universe and make new discoveries that benefit humanity.

Our program has provided an in-depth look at the various aspects of Python used in astronomical image processing. We have explored feature extraction techniques using SK Image, visualization with Matplotlib and Seaborn, working with tabular data, and pixel scaling and image enhancement. By following this comprehensive approach, you can become proficient in Python for astronomical research data analysis and unlock new opportunities in your field.

Looking Ahead

For those interested in continuing their journey in astronomical image processing or exploring other areas of research, we have prepared a final video that will conclude our program and provide further guidance on how to proceed. In this video, we will discuss some additional tools and techniques for visualizing data, as well as more advanced methods for feature extraction and analysis.

We hope you found this article informative and helpful in your journey with Python for astronomical image processing. Remember to stay tuned for our final video, where we will provide further insights and guidance on how to take your skills to the next level.

"WEBVTTKind: captionsLanguage: enlearn how to use Python to analyze astronomical data this is a great real world use case to help you improve your data analysis skills the course offers a practical Hands-On approach to simplifying complex Concepts in data analysis making it great for beginners you'll journey through modules covering python Basics tabular and image data visualization and advanced image processing techniques all focused on real world astronomical applications yeah ash from spart official Innovations developed this course hi everyone I first of all like to welcome each and every one of you to this program on astronomy research data analysis where you are going to learn to create some amazing beautiful looking visualizations that you can create from a boring looking CSV data or a tabular data and even from the raw data from the astronomical surveys how you can take that images and extract some amazing features fees present in those images so all of this kind of work you are going to do in this particular program and then whatever kind of visualizations that you will be generating you can extract from python into your particular system and then later on use it for your research work thesis work or internship report right so that's the kind of thing that we are going to deal with in this program so this whole program is divided into four different modules to make these things very easier for you guys okay but before I go ahead explain any of this let me quickly introduce to you all myself so I am Rohan and I'm currently working at SP artificial as a machine learning engineer and I'll be the one who's going to guide you throughout this whole program and I'll promise you guys that you are just going to simply enjoy this program and you just need to code along with me that's one thing that is really important if you don't code along with me it's just going to be boring for you okay especially if you are new to python you need to code along with me because each and every code that I'll be writing in the uh upcoming uh modules I'll be writing from scratch so I'm 100% willing that you all are going to code along with me okay so now let's talk about each and every module that we are having over here so the first module we are going to start from extreme scratch even if you are very new to python it's completely fine in the first module I have covered each and every basics of python that you will require to create some amazing uh visualizations with the help of python okay so module one is compulsory for you guys just in case if you are new to python if you're already aware about the python then you are good to go ahead and move to module two in module two you are going to deal with a CSV tabular data that data will be based on some kind of real stars out there in Universe now from that tabular data you are going to create some beautiful visualizations including an HR diagram if you're not sure about what is HR diagram it's completely fine okay we are going to learn about that in module two then in module three we are going to go to the astronomical surveys where we are having this raw images taken from multiple different telescopes and from that surve we are just going to fetch an image of Andromeda galaxy and then do some of the uh pixel scaling and all this kind of basic visualizations with respect to an image data and finally in the fourth module the last Model you are going to take that Andromeda galaxy and do a bit advanced level of image processing and I going to teach you that if you want to implement any kind of filter if you want to extract any kind of features that how you can do it with the help of python so that's exactly what we are going to cover in all of this upcoming four modules for this particular program and I hope that you are just going to enjoy this okay so let's get started with the first particular module that is basics of python from the next video hey guys welcome to the second video of module one and here I'm going to introduce you to Google collaboratory notebooks or in short you can also call them as Google collab notebooks okay so for those who are not aware about it already we use them in order to code in Python without actually installing anything in our system isn't it just great so that's exactly what we'll be doing throughout this whole particular program so what exactly are this Google collab notebooks how it works all of this kind of information you'll be getting in this particular video so let's get into it right away so let's understand that how we can use this kind of python notebooks that are available online in order to code in Python the one that we are going to use is specifically called as Google collab notebooks okay so you go to Google and search for Google collab and now if you come on to the second link you just click on that it will redirect you to this page where you are getting this option of creating a new notebook so let's go ahead and click on that new notebook and now I don't need that first TP so I'll just close that up now the whole idea about this kind of notebooks which we also call as interactive python notebooks in short ipynb as you can see over here also right these files are basically used in order to have the mixtures of Tex cells along with the code cells so what you are seeing right now on my screen this particular cell which is getting blinked like that this is called the code cell I can create multiple code cells by clicking over here right and I can do my specific task I want to do over here here here and get my outputs done you will be using this a lot as we go ahead in this program but yeah this is a very very basic introduction with respect to this code let's say you writing some kind of a code in Python over here if you want to run it you simply come over here and click on this or else you can also see there is a shortcut that is control enter you click on control enter and this code is going to run okay and let's if you want to go to the next cell by running this cell you click on shift enter it automatically shifts your cursor to the next code cell or any kind of cell let's if I want to create a text Cell between both of this code cell i h my mouse in between two cells and over here I'm getting the option of text I click on that and I get this option of this Tex cell now the purpose of the Tex cell over here in this kind of ipy andb notebooks uh is to give you some kind of description of what will be done in this following code C that we are writing so in this kind of interactive python notebooks you are getting this kind of facilities to decorate your notebook the way you want so that if anyone who is going to look into this notebook or for that matter let's say even yourself who are going to look into this notebook after let's say some months you need to know that if your documentation is good and Visually appealing then it's very easy to find out a lot of stuff and it's going to be interesting to like you know scroll through this whole notebook and get to the exit point where you want want to find out some kind of information so it all depends on to like you know how much decorative notebooks you want to create how much kind of information in text you want to add and then how much kind of code things you want to code over here and get your job done now here that was a very quick introduction about the Google collab notebook and pretty much uh things that you need to know about Google collab is I guess enough over here some of the things that we can do to start over here before moving on to the second video would be let's say by naming this notebook I'll change this notebook name to Let's the basics of python okay any kind of name that is going to describe what kind of content is present within this notebook and then I can also create a text cell and give a heading with the help of this hash and let's say because this kind of uh whole program is dedicated for astronomy visualizations and Analysis from that visualizations what we can do is we can give a good name like python basics for astronomy something like this whatever you you the best right and then after this we can start coding ourself for the first thing in Python let's say just like everyone does in Python like or any kind of programming language here let's say we are going to print hello world right so if I'm writing hello world like this and then I'm just going to pass this kind of hello world within print this is going to be our first code that we have written in Python print hello world and that's exactly being printed over here so now in this video I've have shown you how you can create this kind of text cells give headings or not just headings you can give images over here you can add links to a specific word you want to add like you know you want your people to redirect to some stuff you can have bold ital like and all this kind of stuff after that I've also shown you how you can start using this kind of code cells in Python and obviously if you did not understand what have I written over here why did I specifically have this kind of uh quotation mark everything will be covered in the upcoming videos so stay tuned hello everyone welcome to the third video of module one and here we are going to talk about python commands so what exactly are these python commands why do we need them and what are some kind of different ways to actually create them all of these kind of things we are going to discuss in this video so let's get into it all right so now that we have written a specific code in Python now let's say I want some kind of a way through which I can describe what I have written over here or what is the purpose of writing this kind of code I can do this with the help of python comments okay for that again I'll have to use this kind of hashtag and then I just give any kind of description that describes what is the purpose of writing this code what does it explain so now because this was the my first code that I have shown you in python I can give this kind of a comment like my first code in Python you can also write this thing for yourself right so what is the main purpose of writing this kind of commments so whenever you are writing some kind of a logic of your code if you're are having this kind of comments that you are writing to describe your logic that how did you come up to this particular logic to solve a particular problem then what happens that even after let's say one year two years if you're coming onto this notebook and now because you having this kind of descriptions in Python that is describing what you have done it's giving you a hint a some kind of this kind of a click to your brain that okay now I remember why I had coded this specific thing in this way maybe because after two years of time if you're coming onto this concept which you haven't touched in a while let's say you're trying to apply for an interview you want to take a project that you have created over here and explain it to them so if you are trying to revise something which you haven't used in quite a while now so if you will be having this kind of comments in Python that will help you to revise this kind of things very quickly because this kind of comments is going to click your brain that okay now I remember what was the reason that I had done this kind of code in this specific way right so that's the whole idea with respect to python commands but now that's not the only one way through which you can have the comments in Python okay because over here we are having only one line of comment what if I want multiple lines of comment right for that what I'm going to do is I'm going to create one more text cell over here first of all and just introduce to that my the first thing that I'm teaching you guys is about comments okay and I can also give this into this way of heading okay three hashes and now you can clearly see that this kind of text is much more smaller in size as compared to this so this looks good right but yeah now what I'm going to do is I already explained the first thing about the comments over here now let's if you want want to have multiple line comments okay so what I can do is I can use three quotation marks I either I can use three single quotation marks or three double quotation marks both of them is going to work just the same okay so I am having my first three uh double quotations like this and three double quotations at the bottom now anything that I'm going to write within this quotation marks is going to be like a comment your python is not going to execute as in the format of you know some kind of a code it's going to do something it's just some kind of a description that you are going to mention over here let's say some kind of huge description you want to write have okay as compared to just a single line then obviously you can go ahead and use this kind of things let's say this is my first line of comment this is my second line of comment I'll be showing you this that I'll be using this when I'm going to teach you the concepts of functions at that times I'll be using this kind of multi-line comments now again let's say that you you are having bunch of lines that you you want to write let's again this is my first comment this is my second comment now let's if you want to comment all of this thing with the help of this hashtag only you don't want to use this kind of uh quotation marks then what you can do is let's say how many lines how however how many lines I am having it doesn't matter the important thing is that I'm going to select the whole text and then press control+ forward slash and automatically it's going to give me this kind of hashes by itself I didn't do anything I just press control and the forward slash what did I do I selected the text below and pressed what control plus this by doing this together you can either comment all of this kind of code or maybe DEC comment it by again pressing the same thing that's simple that it gets for the comments so for a quick revision what we have done over here is now you know how to create print statements in Python obviously not like you are not aware about this that what why did we use this kind of quotation marks what happens if we don't use it I'll be explaining all of that thing in the following videos but yeah for now you know how this kind of print statement Works in order to print something and then what are the kind of need of writing com for your code now in the next video I'm going to talk about what are variables and constants that we need in Python hey guys welcome to the fourth video of module one and here we are going to understand the concept of variables and constants in Python what is the difference between them and when and how should we use them all of these things you'll be getting in this particular video now one thing that I really want to make sure over here is that I hope that you all are coding along with me that's the whole fun about this particular program that you are going to code along with me and it's going to give you live experience instead of just watching the video all right so if you haven't begun it till now this is the right time to get started with it okay so let's get into the video so now what I'll be doing is I'll be just uh commenting this whole thing because like you know it's looking very ugly what is the reason behind that you will be understanding right now in this video so what you are studying right now is called as variables and constants okay so before I write any kind of code I'll be giving a text that describes that I'm going to explain about variables and constants okay now what I'm doing over here is just remember your classes of mathematics you know that we give this kind of things like X is equal to 3 Y is equal to 5 or any kind of number six whatever it is right you know that you do these kind of things so so what we are doing over here is essentially we are saying that X is a variable that is going to take the value of three it's just like that Y is a variable that is going to take the value of six now what is the whole purpose of having these kind of variables in your code for example let's say that I'm writing a lot of huge code and somewhere I want to use the idea of that data that I assigned to that letter x I want to use that again and again for example I'm giving you a very short example let's say I'm having uh value of three that I want to add to a value of three itself let's say 3 + 3 now if I want to write let's say 4 + 4 what I'll have to do is I'll have to change this to 4 + 4 manually now like this let's say I'm having a huge chain four five then again four then again five like this okay and now I saying that I want to change this values of all fours to threes I'll have to change this manually and fives to twos I'm doing all of this change manually and let's say that this kind of code is pretty much long and you are having multiple times you have to change these things so it does not make sense to write these things again and again in every kind of lines so what we do is we try to store this kind of data in a variable for example x equal 3 Y is equal 2 and now I just need to type x + x + y + x + y That's it now if I want to see so you can see that this is 3 + 3 why because X is having the value of three now in place of two we know we are giving y because we know that Y is equal to 2 and similarly again x + y now let's if I again want to change this to 4 4 545 I just need to change x value to four y value to five as simple as that so that's the power of having variables in Python now just like that there's also a concept of constants okay what I'm going to do is I'm going to Simply go ahead and first of all print this to show you the outputs how it looks like so you are having this kind of 22 over here directly it's the summation of this 4 + 4 + 5 + 4 + 5 so that's how this kind of thing is working now one difference between this variables and constants in Python is what you are having if you're trying to Define a variable you're always going to Define it with the help of lowercase letter you are always going to Define it in the lowercase letter and the moment if you want to convert this into a constant you define it into an uppercase letter now this uppercase letter is going to indicate anyone who is reading your code in Python that okay yeah now I know that this X is never going to change throughout your code whereas your variables can go ahead and change any kind of data that you want to store in the variable because the name variable itself means that it is varying right it's not constant right so that's the idea what I'm trying to say is that in my next code over here I can change the value of y to some other value for example one but because I have mentioned X in the upper case we are simply saying that okay yeah this x will always be four it will never be changed no matter how deep codes I'm writing X will always be four so that's a very common difference between variables and constants in variables you try to assign any kind of data in form of uh small or lowercase letters and if you want to store the value of constance what you do is you assign any kind of value and uh give a uppercase letter to that so now both of them are now stored in in the format of what constants all right as you can see there are this kind of lines that are appearing that are giving you this kind of yellow yellow lines what it indicates it's simply indicating that X is not defined Y is not defined why it's not defined because I have removed that part of code I have removed that part of code but at the same time it's also stored in the memory of this notebook it is also stored in the memory of this notebook what I'm trying to say is if I comment out this code and now I run this even though I haven't defined XX YX y anymore it's still giving me the output why because initially while explaining you the code over here I had started with small X and small y so now that small X and small Y is by default stored into the memory of this notebook so make sure these kind of things are not uh repeated in your notebook or else you're going to run into some kind of Errors okay but here was a very quick description with respect to what are variables and what are constants and when you should use what variables can change its data that it's trying to store and constant will try to have a very constant value it will never change throughout the whole code that's the whole idea now I'll see you next with respect to what is strings in Python hey guys so welcome to the fifth video of module 1 and here you are going to understand what are some basic data types available in Python we are not going to talk about all of the data types just some of them including string integer and Float okay and also when I'm going to start the video I'm also going to talk about the concept of runtime in Google collab it's really important guys that you understand this particular concept so I'm just going to start with this concept in this video so let's get into it so now now let's look into the strings so what I'm going to do is I'm going to create one text cell give a heading as strings okay and now if I press shift enter it automatically creates a code cell for me now one thing okay before I'm starting the explanation of the concepts of strings I really want to show you what really happens if you try to click on this runtime and let's say for example you want to restart your notebook okay so what you do is you click on restart runtime it saying that whatever kind of memory that was stored in this notebook everything will be reset and if I let's say click on yes and now if I try to run this code see what's going to happen it's going to throw an error this time because XX YX y this small X and small y variables are gone because I deleted all the memory by restarting my run time so that's one thing that you need to keep in mind okay if you want to uh Define this X and Y and if then removing it and changing it to some other thing then you should be cautious about that thing so now moving on to the strings and uh the concepts with respect to that so what is the whole idea behind the strings right so let's if you're having some kind of a numeric data you know how you can assign it to some kind of variable or constants that's fine but now what you if you're having some kind of a text data that you want to assign to a variable for example let's say I'm trying to create some sort of variables create variables to store the information about a planet in our solar system let's say the first thing that I'm trying to store is the name of the planet so I need to assign some kind of variable to that particular name of the planet that I'm going to use so for that again I'll have to create a variable right so let's say I'm going to call it as a planet name something like this you can also call it as a name underscore Planet anything that you like now over here if I want to give a name as Venus like this it's not going to work why because there is nothing like Venus that we have defined anywhere just like for this X and Y that we had seen in our previous video and even for that matter in the starting of this video we if we did not defend this small X small y it's going to give you this kind of uh yellow kind of of line below that thing that hey you haven't given me any kind of value that we need to give to Venus so it's going to run into an error that Venus is not defined if I go ahead and run this it's going to say that name Venus is not defined because we haven't given any value to this so if you want to assign a text data to some kind of a variable you always do it with the help of this kind of quotation marks now this quotation marks is going to ensure that okay now this is a string this is called as a string in Python and now if you run this it is storing this kind of Text data in the variable called planet name now if I want to go ahead and print this thing let's say I'm trying to print the name of this planet by calling the variable in which I have stored it and now you will be seeing that it's printing the Venus value what happens if I'm going to print like Venus without uh even defining what is Venus right like this it's again going to throw an error that Venus is not defined because in itself you have not defined Venus as a variable over here planet name was a variable which we have defined earlier before printing it and that's why this is running without any kind of Errors unlike this thing that you are seeing over here and the same kind of concept has been used over here in order to print hello world I need to pass it in the format of this kind of quotation marks so that it is converting this kind of data into string and now python understands automatically that go ahead and print this string data it's not a variable anymore if you don't give this kind of quotation marks it expects this hello to be a uh some kind of a variable you can again see there is some kind of automatic yellow line appearing right because we haven't defined this hello if I run this it's going to run into an error right so that was the reason why I was having even the quotation mark in in the first code that I had shown you guys to print hello world so that's how you can define a string uh in Python with the help of this quotation marks now it's not that you always use this kind of double quotation marks you can use single quotation mark I can do the same thing by giving this kind of single quotation mark this is also a string I can go ahead and print the same thing it's going to be Venus this time right I'm going to Del this code and now I can also use let's say three quotation marks either of single type or double type even that is fine again this is pretty much useful when you want to create a string which is of multiple lines so let's say I want to give a description line by line let's say this is Venus right and now I want to give this information that planet name is Venus okay now I want to give this kind of information this is the second planet in our solar system first is mercury second is Venus right so this kind of information if I'm giving over here if I want to store it in multiple lines for that I'll required to have this kind of three quotation marks either of single type or double type okay I can change this to double also three double quotations even that will be fine okay but before I run this code cell before I go ahead and run this code cell I'm going to print it see this is how you getting multiple lines of text right now if I run this code and again I run this you will see there is no change because essentially it's happening the same thing but now what happens if you trying to have this kind of multiple lines of code with either single uh quotation or double quotation like this it's not going to work it's only capable of taking this kind of multiple text by using using three quotation marks of either single or double type so yeah that's the idea with respect to Strings now you can store as many kind of information with respect to this kind of planet for example name of the planet is Venus I want to give Venus to it then let's say uh like you know if I want to store the age of the planet approximately Venus is about 4.6 billion years old so Planet age is um 4.6 B million years right I can write this kind of information over here can also write uh let's say what is the index of this planet planet index what do you mean by this planet index that on the first index we are having Mercury on the second index we are having Venus on the third index we are having earth right so Venus comes on the second index so you can store this value is equal to two right now let's say uh in Python if I talk about indexes if I be very specific with respect to indexes in Python we start from index zero we don't start with index one that's one thing you need to keep in mind I'll also give a comment over here indicating that in Python index starts from zero hence Venus is on index one after Mercury on index zero if I wanted to store the information with respect to Mercury I would have written the planet index equal to zero because it's the first planet we are having in our solar system right so that's the reason why uh we'll be indexing that as zero now Venus because it's the second planet we'll be calling it as an index one now one more interesting thing that you can do over here is for if if I'm just going to run this code and now if I print this information that is uh name of the planet and uh Planet age and also the planet index okay now if I going going ahead and running this code it's printing me all of this respective information now if I want to check the type of the data if it's a string type if it's a integer type or if it's a float type now what is the meaning of float if you're having a number in decimals okay if you're having any kind of numbers in either fractions or decimals then you simply call call it as a float number so if I'm trying to check the type in Python what I need to do is along with printing them variable I also want to check the type of the variable so what I do is along with printing this variable name I'm giving one more command in Python called type and now what is this type going to do it's simply going to reveal what is the data type that has been stored in the respective variables that's the thing that I'm trying to look after and now if I simply run this code you can see that the first two things are of class string it means that this planet age and the planet uh name both of them are storing a data that is in the format of strings when I talk about planet index now that is not a string that that is an integer okay now just because I also discussed about the float let's say I'm creating one more variable let's say any random variable for that matter Z and I'm giving some number to it 3.2 now I explained that any kind of decimal number or a number that you are able to express in fraction you can call them as a float type so if I go ahead and print the type of variable Zed see what happens you'll be seeing that it's coming out as a float so yeah this was a very quick introduction with respect to what are strings and not only strings we have also discussed about integers and floats so these are some basic data types that you must know in order to go ahead in this particular program now in the next particular video I'll be explaining you with respect to what are some kind of ways through which you can play around with this string strings and do some more beautiful stuff when it comes to Strings hey guys welcome to the sixth video of module one and here I'm going to discuss about one of my personal favorite Concept in Python known as F string so we're going to talk about what are these F strings how to use them and when should we use them and by the end of this video I'll also be talking about what is the concept of string concatenation and how you can achieve it with the help of F string as well so let's get into it let's try to do something really unique with the strings okay it's going to be some kind of a magic let's try to go ahead and explore what I'm uh talking about but before that I can also call this as like you know basic data types this is looking a very big I'll just change this to basic data types okay I'm going to change this to basic data types okay and this data types are what strings uh float and integers these are the data types that we have discussed about now uh I'm going to talk about F strings okay I'm going to talk about F strings okay now what does this mean for example let's say I want to print some kind of a statement uh which is saying that how many moons does a Jupiter have Okay so let's say I'm trying to print a statement now because I want to print a statement I'm going to give it within a quotation that planet Jupiter has or not Jupiter I should say Saturn because I'm looking forward for Saturn not Jupiter so planet Saturn has um 146 moons the reason I have choosen Saturn is because I just looked onto Google that yeah currently as of June 2023 there are 146 moons that have been confirmed for our planet Saturn right so I'm writing this detail as of now now as you might be knowing that as the astronomers are having much and much more information about this kind of gaseous Giants that we are having in our solar system they are keeping on updating the values of the moons once they are discovering new moons right so now what happens in future if uh we want to update this kind of values let's say we found out that Saturn is now not having 146 moons instead it's having 150 moons right so I'll have to manually change this value to 150 to print this kind of thing right so now what I'm going to do is I'm going to create a variable called as Saturn moons okay and I'm also going to change the name of the planet I'm also going to store that what if I want to print the information for a different planet right so I'm also going to store this thing as a name of planet and I'll change this not certain and moons let's say moons of Planet something like this whatever makes sense to you give a very good name so that if anyone is reading it uh everyone is able to make a sense of what's going on so name planet Moon's Planet so I can give the name of this planet as Saturn as of now and I can give that currently it's having 146 moons now what I want to do is I want to print the variable as it is if I'm changing this variable the print statement should Auto automatically change okay for example if I want to replace this set with this variable what I need to write is I need to write name planet similarly over here I will change this thing to Moon's Planet but now if you notice if I run this it's going to print the same thing as it is it's going to print the same thing as it is right it's going to print the name underscore planet and moons underscore Planet instead of the Saturn 146 what is the reason behind that it is because we are not giving any sort of an information to the string that hey you need to take the information from this uh variable and not print literally the string that we are giving over here so that's the purpose of f strings you are giving F over here and then writing this thing within this kind of curly braces okay I'm giving all the variables that might change into this curly braces and now if I run this you can see that planet Saturn has 146 moons now let's say in future if this changes to 150 you can see that planet Saturn has 150 moons you don't have to go to let's say I'm having multiple print statements with this planets uh Saturn with uh moons of planet Saturn basically when multiple print statements I don't need to manually go ahead and change this 150 150 150 okay I just need to make a change to this variable and everywhere else in the code it will automatically be updated to 150 because we are having the change in the variable that's something you need to keep in mind that's the power of f strings that's completely a magic okay it is also used like you know if you want to let's say uh concatenate two strings if you want to join two different strings even then you can use this kind of f strings there are multiple methods but let's stick to a very specific method because this is a universal method that always works so let's stick to this particular method I can also give a name over here uh describing the code I should say comment not name and I should describe it like uh understanding the power of f strings right over here also I could have given this kind of commment checking the type of variables obviously for me I already know what kind of this kind of things is but for someone who is a beginner who is going to look into this kind of notebooks for them to understand what are the things that we are doing over here right anytime let's say in future they're going to get referring to this particular notebook they want to know what they have done over here so for that we are giving comments that this is uh displaying the data values for H variables so this kind of comments are always recommended you can go ahead and give this kind of variables uh some of commments okay all right so now let's talk about string concatenation what is the spelling of concatination let me check it's um string concatination right I am very bad with spellings but yeah coming back to this thing now let's see if I'm having two strings okay that Earth is the only planet with life let's I'm going to store it in a string one variable and I'm going to have this kind of either double quotation or a single quotation and I'm going to store Earth is the only planet with live okay and after this I'm giving another statement string two or maybe not maybe not right something like this so if I want to print and attach the strings together I want to create a statement out this now there are again multiple ways that you can do a very straightforward way would be to join them with the help of plus operator I can have print of my string one plus string two and now if I run this it's going to create a error because if you can see I have written string to without the underscore now if I give underscore and run this now it's saying that Earth is the only planet with life with full stop but now there is no space in between so so for that you can create one more string in between string one and string two that is the space string this was a string this is also a string and this is also a string right and now you can see that thanks to that space we are having the space between this first sentence and the second sentence you could have also achieved this by having a manual space over here and then write string one plus string two even that is fine but now let's say if I want to do it with the help of f strings how can I do it very simple I'm calling my string one variable and then string two variable with a space in between again it's going to run into an error because of the underscore so yes see that's how it's going to work how we can do it with the help of F string right you will look into its power as we advance our program uh in order to go ahead and do astronomical visualization and Analysis but for now this is how you can play around with the F strings and now in the next uh particular video we'll be discussing about A New Concept Al together that is how you can get an input from the user in Python hey everyone welcome to the sth video of module one here you are going to understand this concept of how you can take user inputs in your code so let's you are writing a code and there is some kind of a problem where you need to take some kind of inputs from anyone who is running your code and save that data in some kind of variable so for that what is the command in Python through which you can achieve these kind of things and by default what is the data type of the output by using this kind of input command we are going to learn about these things in this video so let's get started now I'll just create one more code cell I mean sorry teex cell give a heading as uh user inputs okay so what we are trying to do over here we are going to run a command in Python that is going to allow users to give some kind of input okay so what's going to happen I'm going to use a command called input and now that input if I'm going to run see it's creating this kind of a text box where you can give any kind of input that you want and store it in a particular variable if you want okay okay for now I'm not storing it anywhere I just trying to get an input it's not going to do anything so I'm going to stop this run okay I just clicked on this it's saying keyboard interrupt because I manually stopped it by myself okay now what I'm going to do is I'm going to store it uh with some kind of a variable over here okay for example let's say I'm trying to ask name of the user so I can give a this kind of a variable name username okay now if I'm going to write this kind of input it's going to give an empty text box now if I want to give some kind of description so that users are able to understand what kind of data to give then you can have this kind of a string information that enter your name like this and now if I go ahead and run this code see how beautiful it's asking for the name now user can simply go ahead and give for example my name is ran I'm going to give R and press enter and now if I look into I'll just give a comment over here use input to take user inputs and just like this I could have also come over here and check the type of variables by using type Command right this kind of descriptive uh comments are always like you know recommended now user uh name has been given as Rohan if I want to check how it looks like if I'm trying to print this it's simply going to take this username equal to Rohan that's what we have done that's all about it right and now what if I check about the data type can you go ahead and guess what kind of type is this kind of username going to have because it's a text data we expect this to be a string it's as expected that we got a string now what happens if I'm going to code and ask user to input their favorite number okay I'm again going to give a comment to this code first of all that is displaying the variable and its type given by the user now asking user to input their favorite number so again let's say I'm creating some kind of a variable to store this information User fave number something like this and ask asking as an input I am asking let uh give or enter your favorite number okay I run this so again it's asking user to give their favorite number let's say they are giving seven because my favorite number is seven and I assume most of your lucky number might be seven as well right I don't know why seven is very lucky I'll just hit enter and now again go ahead and display the variable and its type given by the user and now if I'm printing first of all my user Fame number it should display seven and after this uh if I'm going to print the type of this user fave number look into uh the output it's still a string so what is happening over here the way that we are calling this input command that is inbuilt in Python it automatically converts any kind of data that is given by the user into a string format it automatically converts any kind of input given by the user in that text box into the string format even if it's a number we just looked into that so let's say if you want this number to be converted into some kind of a numeric format either let's say integer or a float what you do is you try to convert this kind of data type into integer format or a float format how we can do this I'll explain that in the next video hey guys welcome to the eth video of module one and here we are going to talk about that how you can take a particular data type and convert it to some other data type for example if I'm having a float how can can I convert that into string so all these kind of data type conversions you are going to understand in this particular video so let's get into it so now let's go ahead and understand that how we can take this particular data type that is in the format of string the seven how you can convert that into a numeric data type that is either integer or float or maybe let's say both of them so for that what I'm going to do is I'm going to create a heading which says that data type conversion you're going to learn about how you can convert any data type into some other data type if it's possible to convert or else you'll be getting an error so the commands that you need to know commands to convert if you want to convert any kind of thing into a string any kind of data it could be a integer it could be a float it could be any kind of data type okay we have cover only three of them but let's say it could be any kind of data type if you want to convert that into a string the command in Python is is the string any kind of input that you give to the string that input if it's possible to convert that into a string it's going to convert it into the string just like that in order to convert any kind of input into integers you are having this command of in integers so any kind of input that you pass to this int within this kind of parenthesis it's going to convert that input in the format of integers if it's possible to convert that input in that integer for example let's say if I'm having 3.5 if I try to convert that into an integer it's not going to it's not going to convert that 3.5 into an integer because 3.5 is the format of float however there is some interesting thing that's going to happen if I'm going to run this kind of code you will be understanding it in a while now just like that if you want to convert any kind of input into the float format you call the float that is available in Python itself and then you give some kind of input that's how it works okay and now I'm going to give one more comment after giving one empty line that convert a string data into integer and Float so uh we know that this seven is currently existing in the type of string I can again cross check it by simply typing this uh type and user fave number and this time I'm not writing any kind of print in top of that because in Google column what happens is if I'm going to run this the last line doesn't require print statement to print the output okay but if I giving let's say I'm just copying this thing and printing it again over here it should have been printing twice for me right if I run this code but it's going to print only once why because it's going to give me the print of the last statement automatically I don't need to give print command if I want to print both of them I need to give print print for both this lines okay that's something thing that we need to know okay but anyways coming back to our discussion that is we already know that now this user F number is in the format of string right so now I'm doing is converting a string to integer how I'm passing this int and then passing in this user fave number and uh simply running this code by pressing control enter and I'm also trying to print the type of this string to int and see if that thing has converted and at the same time I'm also going to print the string to int variable that we have created as you can see now the output is again seven see how the seven are looking just the same it's the change in this data type now from the string we have converted it officially into an integer now this string to integer variable is having the value of integer 7 right we how did we do it by just using this kind of inbuilt command in Python of integer I gave an input to it because we know that the seven can be written in the format of integers we are having this kind of an data now what if I let's say for example give a string like this string like this and ask to convert this string into an it's not a number how will this be converted into an integer it's not possible you're are getting this kind of a value error that hey I'm not able to convert this string into an integer invalid literal for this integer it's not possible to convert this into an integer so make sure that you are giving these inputs that are able to be converted into an integer now at the same time now what happens if I'm giving 3.5 now this time you might expect that it can give you an error because now it's in the format of decimals and even 3.5 in itself is not an integer right so what's going to happen over here it's not going to give you an error instead it's going to round it down to the nearest integer so if I'm having 3.5 it's converting to three if I'm having 3.9 it's still going to convert it to three so yeah that's how this kind of integer works so make sure if you want to have 3.9 let's say if this was in the format of string and now if I run this this time it's giving me an error because string cannot directly be converted into an integer that is having a float data with within itself so I need to convert that 3.9 first of all into float so so that this 3.9 that is existing in a string is first of all converted into a float and now that float will be converted into an integer and now it should work perfectly see how that 3.9 string got converted into a float that is 3.9 and now that 3.9 if I'm giving as an integer of this 3.9 it's converting into three right so that's how it's basically uh working the in 3.9 the integer part is that's what essentially we are getting right so yeah coming back to like you know going uh breaking this whole thing into a stepbystep format uh this was user fa number okay and let's say I'm also having the string to integer or let's say yeah string to integer now in is already done right we about to change it to float so now we are having float of user fave number remember this user fave number is already defined over here we haven't done any kind of changes to it so it's still in the format of and string okay it's just that this variable is now given this value that is integer of that string data okay so again if I'm uh first of all printing what is the type of user fave number it won't change it will just be the same because I haven't done any kind of changes to that variable right that variable is still the same okay it's giving me some kind of an error it's giving me a name error that S type is not defined oh yeah because I done a type over here see now it's still you can see it's uh the last this is the last print statement it's saying that it's still a string right now let's say I'm trying to convert that string into a float how we can do it right I'm going to print this thing string to float and also print the type of it see that's how it's working it's converting that 7 into 7.0 and now that decimal indication is saying that it's uh basically float type again I've done some kind of a type over here I should have not written float I should have written string to float right string to float like this because float is a function right it's not some kind of a variable so yeah as you can see now it's giving you the output of float the type of the string to float variable that we have created is is a flute now let's say if I want to get user input of two different integers and add them together how can I do it so what I'll do is I'll take number one as an input I'll ask them to input their number give any integer number okay and then after that I'm going to give another variable that is input give one more integer all right and then if I'm going to add these numbers together and print it N1 plus N2 or else let's say we are having a very feny way to give this kind of a statement by using FST string I'm going to say that uh the sum of N1 variable and N2 variable is the summation of them that is N1 + N2 now remember I am not converting this into integers right because we know that by default this input is going to expect the numbers in the format of what strings so let's if I'm running this as of now and giving let's say seven and another integer is let's say my another favorite number is nine so so 7 + 9 should be what 13 9 10 11 12 13 14 15 16 okay my bad again my very basic mathematics is also very wrong but anyway 9 + 7 whatever is the value okay 9 plus 7 you can do it in KY it it won't be 79 right so now what's going to happen the reason we are getting this 79 is because that this N1 and N2 is a string and we are concatenating them this kind of string with the help of this plus variable I mean plus operator and that's the reason why the seven and N are getting concatenated we are joining the strings together with the help of that plus like how we did over here while uh before this F statement I F string I had given you a way through which you can do it by simply converting this into this plus and there is also no uh quotation marks and if I print this it was giving this right how they were joined this two kind of strings and then we had given this kind of space and everything so yeah that's exactly the same thing that I'm showing you over here okay this is string to just converting it back to what it was and yeah that's uh typically uh what we are going to do over here that because it's in the format of string it's concatenating them now if I want to convert this into an integer I need to pass this int on top of this why because I'm converting the string into an integer and I know user is going to give me an input of an integer it's going to convert it automatically into the format of integers and let's say my mathematics is really very big I'm giving the value of seven and 9 and this value of 16 is now accurate right so yeah that's how it's going to work how you can take inputs from the user if it's a numeric data and if you are sure it's going to be an integer no other data you directly give this input of int on top of this input that you're getting from the user it will automatically convert it into the integers and then you can do any kind of sorts of things you want so yeah that was about how you can uh do the data type conversions convert one kind of data into some different type hey guys welcome back once again to the first module and here is the ninth video of it where I'm going to teach you the concept of control flow in Python now this is the heart of programming if you don't know this concept you are not a good programmer at all not that other concepts are not important they are equally important but as I mentioned this is the heart of this programming language so we're going to start with the looping part specifically we're going to look into the for Loop and while loop once you understand what are this kind of looping why do we use them how to use them we are going to move on towards the condition statements where we're going to understand about if statements if else statements and also if L if L statements and again there are a lot more things that we need to cover in this video so let's get started now let's go ahead and talk about what is control flow in Python okay let me Define this as control flow and the whole idea that you're going to learn over here is I'm just going to cross check if that's the seven yeah that's the seven okay the whole idea we going to learn over here is with respect to for Loop and while and then you're going to learn about some condition statement okay and the main idea over here is that if you are having some kind of a code which is repeating okay and you don't want to manually type all these kind of things for example if I'm writing print zero and then after that print Z I'm also writing print one and then print two then print three right I'm knowing that this kind of integers are giving like being printed starting from zero then 1 2 3 like this let's if I want to do this for 100 times for some reason okay this is just for an example as we'll be going in the upcoming modules in this program you will see the power of all of these things okay right now I'm just trying to teach you that these kind of things exist okay so if I want to do this kind of things if I want to automate this kind of things how can I do it because I know that there is some kind of certain kind of things which are keep on repeating itself in a specific way I can transform this whole idea into for loops or maybe while Loops I'll be first talking about for Loop okay so what happens is if I'm trying to initiate my for loop I need to give the keyword called for then for what so for some kind of index that is present in some Itor now what is the meaning of it rator Itor is nothing but some kind of a storage where you are having multiple values that one can take okay that index can take okay so let's say if I'm having list of numbers so in Python you can create a list with the help of the square brackets okay again this is not important thing to discuss as of now but let's say that you know about this kind of list and I'm storing let's say 0 1 2 3 4 this kind of values in the list now what's going to happen automatically this index is going to be like acting like a temporary variable you can call that as a temporary variable that's going to take one by one values that is present inside this iterator list is an iterator where you are storing multiple different values and uh this index is going to take this values one by one starting from zero in the first loop after the first Loop is over it's starting the second loop it's going to take the value of one this index will keep on changing its value starting from zero then the next value that is one then next two 3 four like that until this kind of last value is been uh taken by this Index this kind of for Loop will keep on running okay so what I'm going to do is I'm simply going to print index as you can see the first time this code ran the index was taking the value of zero that's why it print the value of zero similarly now the first Loop is over it's entering the second Loop it took the value of index uh as one that's why is printing me the output of one so that's how you can uh it rate through this kind of it readers and list is just one of the example let's if you want to create a list of 100 numbers and then you want want to iterate you cannot manually go ahead and create this kind of a list of 0 to 100 or 0 to 99 for that matter right so the way through which you can do this is something by using range okay now what is range the way it works is it takes the start value it takes the ending value and then it takes the skip value if I show you let's if I'm giving first of all range of just any number 10 so it's going to give me integers that are present in between 0 to 10 that's the purpose of range in order to prove you that what I'm going to do is I'm going to convert this into range of 10 and then run this so it's going to give me the values 10 values in between 0 to 10 so starting from zero it goes all the way up to 9 as you can see after 9 there is no output because this are first 10 numbers starting from zero and yeah we are ending at nine one value that is less than this okay now let's if I don't want to start from the index zero I want my first integer that is present in the range to be let's say minus5 so I can start with minus5 because I know that I can give that kind of a syntax start and then end if I'm just giving one number it's just taking the value of end at where you want to end a value before that actually and now if I run this you can see that now it's starting from minus 5 not zero it's going till 10 by default the value is set to zero for the start if you not giving any specific input to it now it's going to take the value of minus5 okay so if I change this 10 to minus5 and then if I run this okay I did a mistake I should have written - 5 comma 10 and now if I run this say starting from - 5 -4 -3 it's going to go all the way up to nine until that 10 until that 10 is achieved you keep on going to it rate okay so it's not like you are going to get only 10 values no anything in between minus 5 to 10 you're going to get that as an output minus 5 is inclusive 10 is exclusive okay just keep that in mind but typically let's say uh we want some kind of numbers to start with one and then go all the way up to 10 in that case I need to go from 1 to 11 so I hope this kind of things are making now a good sense of how to play around with this range to get your things done right it's now going to start from 1 to 10 now 11 is exclusive remember that that's why it's getting printed to 10 right that's the whole idea one more thing that I can write over here is start is ex inclusive and end is exclusive it simply means that the value of end is the actual value one before that end that we are defining that's what range is going to take all right and now what is the meaning of the skip let's if I want to skip right now it's currently by default skipping one one numbers right after one it skipped one value it went to two 1+ 1 is two right then 2 + 1 is 3 if I want to have this plus two instead of plus one I can let's say have this comma two so now after printing one it's going to add two numbers to it it's going to go to three directly without getting this two as an output so it will be like 1 3 5 7 and N okay why stopped at 9 because 9 + 2 is 11 the moment I reach 11 it's not going to give that as an output right that's not not how it works so yeah that's how it's going to be after 9 because the next index value is 11 it's not going to run for that index so yeah that's about how you can uh use for Loop to do some kind of specific thing right now I given a very simple logic that if you want to print some numbers between let's say 1 to 10 and if you want to skip uh two two values starting from one then skip two values you get to three skip two values from three you get to five that's how you do it so that's the concept of for Loop now if I want to do the same thing with the help of while loop how can I do it I can do this by giving while keyword and then a condition I need to provide some kind of a condition and this kind of column is again very important I did not explain you over here but this column is very important this column is going to indicate that whatever you're going to write within this kind of space okay this space is also important which we call as an indentation so if I'm going to delete that space and run this it's going to give me this indentation error why it's giving me this indentation error because the space is missing the for Loop expect this kind of space so that any kind of code that is written within that space that's going to be the part of the loop if I'm going to print some value over here let's say five and run this see it's at the end also printing the value of five but now that Pi is not printed for this many times if I have this kind of space in between so after every number five will be printed after every number five will be printed see after one five is printed after three five is printed so that's the power of this kind of indentation if you're going to give this indentation over here it's going to assume that print five is to be supposed to be there within the for Loop if you don't want to have that indentation then now it's fine it's not going to give an error because it's having at least one line to run within the for Loop and if I skip that thing now it's going to give an error because it needs at least something to run right but now let's if you don't want to get an error like that you can simply use pass keyword okay now this pass keyword what it does you can try to think and uh like you know you can think about the whole logic of the loop uh for that time you can use this pass keyword and if you try to run this if you're thinking about some kind of logic this pass keyword is a very good way to like you know just don't write anything with the for Loop right now just write initiate the for Loop go and do the second part of the code and then come back later on over here so for that you can use pass okay but anyways coming back to where we were okay I'm going to remove this thing and also remove the whole line and come onto the while loop okay so in while loop it expects some kind of a condition that you need to run this Loop until this happens until this condition occurs okay and then over here also automatically if I keep enter if I press enter after the column it gives me this kind of indentation automatically and now over here I can give any kind of way through which I can Loop into this Loop any kind of thing I want to do until a certain kind of condition is met it's simply going to run okay for example let's say I am asking a user I want to create this kind of loop where it's asking user to enter their favorite celestial object okay and every time they are giving the inputs I'm going to also keep a track of an like you know this index I I'll also be updating the index after every iteration so that I'm having like you know favorite celestial object one is this then favorite celestial object two is that so that's kind of stuff that I want to create and uh after that the condition to break this for Loop is again something that I'll be giving and that's how this while loop will be over for the for Loop what's happening in the for Loop we are automatically ending it once the iterators are over like once you're not having anything to itate for it will be over right so once you are hitting that value of 11 you are not going to have anything else to itate so that's about the for Loop but in the while loop it's going to run forever if the condition is not made so it's compulsory for us to write a condition in a way if you want to stop your Loop that condition should be satisfying a certain kind of thing through which you can stop the loop you can break the loop okay so what I can do is I can come up with this kind of a logic that always run this thing okay I'm not giving any kind of specific logic over here I'm just saying that go ahead run this Loop Forever at the same time I'm also having some kind of counter okay I'm having some kind of index that I'm going to track that how many times this kind of iterations are happening and now I'm also asking user to give some kind of input okay let's say enter their favorite Celestial body so let's say I'm going to store this in the variable called object that is obj asking for the input enter your favorite celestial object and then I want to ask them that this is the first thing that they are inputting right CT + 1 because CT by default is zero so I'm just going to write ct+ one over here and then have this F string and this is also typo so I'll convert that into input and now what's going to happen in the for Loop okay if I run this as of now see what's happening it's asking that enter your favorite celestial object one I'm going to say earth now again it's saying enter your favorite celestial object one why because we are not updating the value of the CT and it will keep on asking me because I'm not giving any kind of condition to stop this while loop right so for now I'm manually stopping this over here so let's talk about how we can update this counters I can once I'm done asking this kind of input from the user I'm going to update the value of CT and say that CT is equal to the previous value + one you could have also written this uh as like you know City Plus equal to 1 it's essentially doing the same thing it's taking the previous value of city and adding one to that okay so 0 + 1 is 1 okay and now uh 1 + 1 will be 2 right so that's how this is going to become 1 + 1 2 right so it will ask enter your favorite celestial object when the CT value will be one this 1 + one will be two or by default you could have started this with one and like you know you could have remove this one over here because it will start with one and then automatically it will be two in the next iteration whatever it's up to you right how you code your specific logic so yeah that's what I have done and I'm also going to give the condition that if if user is going to input something that is asking to stop that yeah that's it I don't have any kind of favorite celestial bodies apart from what I have given as an input so if the object input that has been given by the user is equal to let's say something called quit okay then what I'm going to do is I'm going to break the for Lo there are multiple new things that you learning over here that is this if statement along with the break statement so what's happening so until the user is going to write quit it's going to run this F Loop and the moment they are going to type quit it's going to break the for Loop so this is called as condition statement that is if condition if this condition happens then you're going to terminate the for Loop by using this kind of break keyword and then let's say if this is not the quit you can continue the code so you don't need to do anything if this is the condition that is met then break the loop okay and I can also give this kind of a print statement over here that type uh quit type quit to exit right this kind of uh hint is something that I'm trying to write over here so that user knows how you can escape this kind of loop when to St okay right so now let's see what kind of things uh happen if I'm running this code so see how it's coming type quit to exit so now let's say that favorite Celestial body is for example Earth then let's say black hole this kind of inputs now I'm tired I want to give quit but now I give it like this it's not quitting why because I give this Q as capital right I give this Q as capital I need to write small q ID the lowercase Q it only then it will stop so now to tackle this kind of conditions what you can do is you can take the user input and convert it into this kind of lower case the way you can do it by passing this lower function that exist in Python for string so if I want to demonstrate that I'm going to write a commment convert any string into lower case how you can do it let's say I'm having a string demo is equal to uppercase or any kind of combination of letters is upper case just like this okay now if I print this string demo it's going to be as it is upper case now if I want to convert that into a lower case what I'm going to do is my string demo. lower is what I'm going to print now this lower is converting this any kind of upper cases anything to a smaller case if it's existing it will convert into a lower case if it's already a lower case it's not going to do any kind of changes to that so now by applying this even if it's writing capital Q UI even still that is fine okay so if I run this and uh now if I am writing Earth black hole right and then UI let's say capital T also for that matter see it's still quitting why because the power of this lower functionality that is implemented to the string there are again bunch of different methods that you can apply to a string but because we don't have to learn everything in Python only some specific things that you will require in order to do some kind of astronomical visualizations and Analysis then this much amount of information is quite okay for now okay as we'll be going ahead you will be learning a lot of different stuff in Python over here I'm just giving you a warmup so that you are understanding a lot of things in Python and you're not just getting confused of some basic stuffs right so yeah that's about like you know we have talked about how you can have this kind of for Loop you can have while loop then also talk about some kind of conditions like this let's say if uh if this is the condition then do this else if object lower equal to some different thing let's say um Capital quit then do what then let's say print type smaller quit smaller or lower C quit or else it's not going to make any sense as of now so what I'm going to do is I'm simply going to delete this okay I'm just going to keep it as of now over here I'm not going to complicate the things if there will be something where you will be requiring to understand the elsf condition also over that specific time I'll be understanding you like I'll be explaining you okay for now all of these things are again quite a lot of thing to understand in just video so yeah I'm going to end this video over here and in the next video what we are going to learn about is functions and I'll try to incorporate this kind of f else block over there uh with lsf condition also right so stay tuned for that hey guys welcome to the final video of module one and here I'm going to teach you the concept of function in programming so to start with we'll be talking about what is the need of the functions in programming and I'm sure by the end of this program you will be appreciating that you have learned this particular concept so we'll also learn about how you can create your own function in Python then in order to use it how you can call these functions and then at the end of this video you will also be creating a function that's going to work like a very simple basic calculated to perform some kind of addition multiplication subtraction and all that kind of stuff so let's get started with this video now let's understand the concept of function in Python I'm going to create a Texel give heading now the whole concept of the functions in Python is very similar to again what we do in mathematics if you are giving some sort of inputs to a function now that function can take any kind of formula right now if you're giving some kind of inputs to that formula let's say you're having f ofx is equal to 3xΒ² + 2x + two something plus three something like this so now if you're going to give the value of x as two or automatically this x will be taking the value of two and whatever is the output of 3 into 2 s + 2 into 2 + 3 that will be the output of this function now the very similar idea is what we are following in Python also we create this kind of functions to repeat some kind of block in Python okay just like what we did for the for Loop or Y Loop but over there you are continuously iterating one by one but now what if you want to use same block of code in this code cell but then after let's say two three Cod cell again you want to use that again after one two code cells you want to use that so for that you create functions right now how do we create this functions in Python you use this kind of keyword called def for defining the function then you give name to the function now let's say that I'm trying to create a function to GRE everyone of you over here who are watching this video So Def greet I'm giving this random name that came to my mind and then you need to give some kind of input arguments to this function right now I'm not giving any kind of arguments and now again this kind of column is given so that python understands that yeah now anything that is given below this kind of colum with this indentation it's all going to be the part of the function let's say that I'm trying to print the value or not the value but the string called he estro files I'm assuming most of you over here who are watching this video are asro file so what I'm doing is I'm going to create this kind of function that's going to do this particular thing okay hey asro files I'm just trying to create every one of you now how to call this function once you have created a function how you going to call them you're creating a function to gr viewers of this video right and without any input argument uments or parameters you can call them as input arguments input parameters there are wonderful names given to the same thing over here okay now I'm going to call that function how to call that function you call the name of the function like GRE okay have this parenthesis and just run this code you're going to get an output of hey estoiles I don't need to write this kind of same thing again and again now anytime I want to call this function it's going to print a asiles for isn't it just interesting now I'm just going to go ahead and add one more magic to this function that I'm going to specifically greet some of you over here okay let's say that uh one of your name just for example is let's say let's just not give any kind of random name let's just take my name okay and let's say some of your name is also Rohan so yeah if Rohan if you're watching this particular video then I'm going to greet you specifically okay but yeah coming back to the concept what I'm trying to do over here here is uh Define a function to GRE a person whose name will be given whose name will be given as an input so now what I'm going to do over here is I'm going to first of all create a very similar kind of function but this time I'm going to have this kind of a name okay so let's say defining a function give a name let's say gr person something like this and now it takes one input argument that is name okay now this time what I'm going to print out is this a whatever is the name again because I'm using the F strings I need to use f over here hey whatever is the name I hope you are enjoying this session and learning a lot of things in Python something like this right and now if I'm going to uh run this code to create this function now again call that function okay now how it's going to work see that I'm going to call this great person and give a name of let's say Rohan okay so yeah hey Rohan I hope you are enjoying this session and learning a lot of things in Python yes I am okay thank you but yeah anyway moving moving on to the next part so yeah this is what I'm trying to show you that now I can just call this function with different different names okay call this function with different name okay now I'm going to again call this function person and let's say that I don't know this name came up into my mind out out of nowhere let's use Curren okay I'm lying he is my best friend so yeah anyway so hey current I hope you it's going to print the same thing just that wherever now there is a name variable it's going to replace it like this you are trying to create some bunch of different formulas for function not actually the formulas but specific code that will be repeated with some kind of different inputs that you give to a function so yeah this is how this kind of functions work in Python but now that's not all do this kind of things okay now I'm feeling a bit sad that I'm not wishing all of you over here so what I'm going to do is I'm going to call this function for one more time call this function to gr everyone to gr every one here watching the video I can simply call this great person but instead of just greeting one of you guys I'm going to greet everyone of you so what I'm going to do is let's just call this as everyone okay and now I'm going to run this it says hey everyone I hope you are enjoying this session and learning a lot of things in by now this is good right so yeah that's about this thing but yeah now moving on to some more advanced concepts of python that you must know because these are very essential you will be using a lot of inbuilt functionalities in Python and different libraries in python in the upcoming modules you need to know these things that I'm going to teach you right now so please pay attention mention very properly over here okay now what I'm going to do is I'm going to talk about two things that are keyword arguments uh and the default arguments and also the position of the arguments okay now this concept is really very important a default or I should say first of all I'm going to talk about position arguments and I'm going to talk about keyword arguments and also about let's just talk about uh these things right now so that I'm not confusing you guys with a lot of stuff so what happens over here is that if you are giving two inputs okay you're not giving only one input you're giving two inputs to the function for example one that is the name and then you can give some kind of a greeting message okay now you cannot just have I hope you are enjoying the session you can have some kind of different message also if you want okay so I'm going to give this kind of uh functionality to my users who is going to use the function that I'm creating in Python so that they can give any kind of message they want okay this is just some examples that comes into my mind right now so what I'm going to do is I'm going to again create a function I'm first of all going to talk about position arguments okay I'm also deleting the keyword arguments so if I'm greting and I'm passing let's say I'm creating a function called greting passing name and message and then I'm saying that print name okay I'm giving this FST string print name and then message something like this is what I want okay I want to print my name first and then I want to print some message or else I could literally play around with these things properly I can say hey name and then some kind of a message something like this right it up it's up to you how you create your function so let's say I'm creating it like this and this time if I'm trying to call this function by placing the input arguments in the same order while building it so I'm going to call my function that is greting I'm going to give a name again let's say I'm going to just play around with the names I'm going to play with let's say l and then I'm writing a message um are you an asile something like this right and now if I run this it's giving hey Lea are you an asile this kind of question has been asked right and if you can see this exclamation is also getting printed so if I don't want that if I'm just again calling this okay so yeah this time see what's happening I'm not getting that kind of exclamation mark now this time what I have done I place this l in place of name in place of message I put this now what happens if I'm going to shift call the function by Shifting the positions of the arguments of the function right so I'm going to call the same function again but now change this kind of message with name right and then like this and now if I enter this hey are you an estoile comma lus it does not make any kind of sense right so that's the thing that I'm talking about the position of the arguments whenever you are defining a function you always look into what kind of uh way what what is the position of each and every arguments if name argument is kept first you always go ahead and give your this kind of name is equal to uh something okay there is L yeah you don't give this kind of message over here whatever is the first input argument that respective input should what go over here okay because now it's thinking python is thinking that hey this is the first argument so this should go in the place of name so that's something that you are learning over here with respect to the position arguments but now what happens if I'm again having the same kind of uh thing but I'm specifically saying that this is my name argument and this is my message argument okay now call this function with keyword arguments so what I am doing over here is I'm giving some kind of argument keyword before passing just the arguments I'm also having its respective keyword that I have used to define that argument so this is called keyword arguments okay that now even though the position I have changed but now because I'm giving a specific keyword now python understands that this should go for the message argument and this should go for the name argument and therefore you are getting this as an output I hope these things are making sense to you okay now one more thing that you can study in functions that is very common is default arguments that is while creating this kind of a function okay while creating this kind of a function let's say greting with default argument something like this is what I'm defining the name of the function and now what I'm saying is if someone is not giving any kind of name or if they are not giving any kind of message by default what kind of message they should uh be seeing uh welcome to this program on astronomy visualization something like this right visualiz a something like this is what I want to uh give them a message and I want to print hey name and then the message Okay now what's going to happen always remember your keyword arguments that you will be giving will always come later on first the position arguments will come if you're having mixture of like you know keyword arguments with the position arguments always remember whenever you will be calling a function you first need to pass in the position arguments because the order matters over there and at the end you can change this kind of uh keyword arguments order that's fine at the end of the function what I'm trying to say over here is that first of all I'm going to call this function call this function uh without passing message argument and see what happens so greeting with default arguments and now I'm giving the name of let's say ran I'm coming back to because I'm not in the mood to think about new name you can say that and now if I'm running this see it's it's giving me an error the reason it's giving me an error is because I haven't run this code right it's giving me that this this thing is not defined only so how can you how are you running this and now if I'm running this you can say that hey Rohan welcome to this program on astronomic visualization right it by default took this argument whatever was written over here and it gave me over here now what would happen if I'm giving my message variable first uh and then giving my name okay I'm saying message equal to uh WhatsApp something like that okay and then now see what's going to happen in the first position that should be name okay but in place of that name you are already giving this message variable I mean message keyword now this keyword is already taking this kind of value now in the second position there should be a message now that is already exist over here that's why you're getting this kind of red line and obviously you're going to run into an error position for arguments follows keyword argument so always write your position arguments first and then the keyword arguments okay so over here I could have written this as like you know our name that is Rohan and then the message this is fine just write XL right even while defining the functions if you are having this message first and then the name like this see what happens it's going to throw an error non-default argument follows the default argument just like in the keyword and the position if you are not having any kind of default values you always keep them first okay that's something that you must know while creating your own functions okay now all of these things that you have learned over here is going to be pretty much very useful whenever you'll be implementing these ideas in the uh upcoming modules that you will be learning okay but now one last thing that I want to describe over here is I'm going to create a function create a function that will either add subtract multiply or divide two input numbers okay so I'm going to come up with a very basic calculator with the help of functions okay and I'm going to show you that how you can do all these kind of things create a function that will either add it's not wether it's either add subtract multiply or divide on any two numbers that has been given as an input okay so let's say I'm creating a function called basic calculator okay and now I'm giving some kind of inputs of two numbers that is number one number two and then what kind of operation I want to have for example let's just call that as an operation add multiply subtract or divide something like that okay I'm trying to demonstrate that if else if and else kind of statements okay so now let's say uh if if operation dot again I'm using this kind of lower functionality so that if if anyone is also giving capital A D even that's going to find in order to compare so if the user input is ADD I want to return something now this is again a new thing we are learning in functions it's not always about printing right if you want to give something as an output just like in the mathem iCal function if you're giving some input it's going to give you some kind of specific output it's going to return some outputs so you can get something out of this calculator or the function that you are creating by calling a keyword called written anything that you write after written will be the output of the function when you call this whole function with some input arguments okay you will understand this in a while so let's say I want to written what do I want to written I want to written N1 + N2 whatever is the output of this N1 plus N2 is what I want to written now if I run this code and test this basic Keli giving my first number as two second number as three and then operation is ADD and then run this see the output is five how did I get this output five because I'm returning this value I can store this value in a variable now I can store this in say uh addition something like this and then also print this and I can use this kind of addition somewhere else in the code right addition so that's the first thing that we have done now the second thing that we are going to do is we going to say that if else if operation. lower is to subtract okay then return what return nerse minus N2 just like that else if operation. lower is to multiply multiply then what you do return N1 s symbol is used for multiplication and then else if operation. lower is to divide then you're going to return what N1 divide by N2 right else if anything else is given as an input apart from add subtract multiply or divide you're going to say that print I'm going to create my f state with F string you can either in your operation Operation input can either take either take add multiply subtract or divide you give what whatever was the like you know the operation that has been given by the user you give this try again this kind of message is what I'm trying to print okay and now if I run this code see how it's working if this is the condition then do this else if if this is condition then do this else if this is the condition do that else if this is the condition do this and if it's nothing like that then do this that's the proper if else if and else block that we have created over here okay so now if I run this it's giving me five as an output right now let's say if I want to do some kind of multiplication and I'm storing it in the multi multi multiply something like that right now I'm going to create this kind of basic Kelsey function and give this kind of uh thing that uh first number is three the second number is three and then multiply okay and uh print the value of multiply also print multiply 3 * 3 is 9 we expect the output of N9 right you can go Ahad and test for all these things okay what happens if I'm trying some random input and I'm not going to store it I'm just going to try to see what's the output that we are able to fetch 3 comma 3 and some random okay and then if I run this it's going to give operation uh input can either take add multiply subtract or divide you give this try again right so this is this is the thing that is giving output I can shift this to capital O and I can also give some kind of uh like you know uh information over here with the help of multiple strings over here I can say that parameters I can first of all give the kind of like you know an idea of what this kind of function is doing this is a really very good way of documenting your functions okay I'm describing what this kind of code is doing okay this function is doing um create creates a basic calculator that takes first that takes N1 and N2 in the same order and performs either of addition subtraction multiplication mul multiply and divide they can perform either of this right and then you can give parameters and then you can have this kind of parameters that uh N1 first number then N2 is your second number like this you can just give all the kind of proper information and then operation Operation is any of the operations mentioned above for our basic calculator that is add subtract multiply or divide and then it's going to also return what it's going to written uh what is it going to return it's going to WR let's check what is it written yeah either the output of the curency the output of the operation done N1 and N2 so you can also give an example over here if you want but yeah that's pretty much about how you can describe a function so that if someone else is going to use your function they already know how to like you know give some kind of inputs while uh calling your own function that you have created right so yeah that's about the functions that you should know and uh over here these are some kind of pretty much things that you should know if you know about all of these things you are now having enough idea just to advance yourself into Python and learn a lot of uh beautiful things in terms of how you can create different visualizations in astronomy by using some new things itself but at the same time now you're aware about a lot of things in Python that's for sure not going to make you think like a lot of overwhelming stuff going on okay so yeah make sure that you are going through all the kind of quiz questions that we have given just to ensure that you are now having a proper idea about all of these Concepts that we have taught uh before you advance to module two hi everyone welcome to the second module I hope that by now from the module one your concepts of basics of python are clear because all of those Concepts will be now implemented in module 2 that will be helping us to convert a tabular data of real stars out there in universe and create some amazing visualizations out of it and do some observations get some observations out of it do some kind of analysis and then whatever kind of visualizations we will be creating we'll also be saving it into our system so all of these kind of things we'll be doing in this particular module and specifically what type of graphs we are going to generate from this tular data of stars we are going to generate the bar graphs we're going to generate the box plot we're going to create the line plot also the pair plot and finally at the end of this particular module you will also be creating an HR diagram now this HR diagram if you're not aware about it it's completely fine because by the end of this video you will be knowing this everything and you will also be coding for the same thing okay it's one of the most amazing things that you will be seeing whenever you are dealing with the star data okay so let's get started with this particular module hey everyone welcome to the second video of module 2 and here I'm going to give you a quick sneak peek on the data set that you will be using throughout this particular module so this is basically about some real stars out that in universe and yep without spoiling any of your excitement let's get into the video let's go ahead and try to understand what kind of astronomical data that we are using in order to create some of our first visualizations in this program with respect to that astronomical data and then not only that how you can take this kind of visualizations that you are going to create in Google collab and save it into your system so that later on whenever you are doing your research work in order to give support to whatever kind of work that you are writing in your research to support that work you can always add this kind of visualizations right so how you can extract this kind of visualizations from Google collab into your system and then obviously you can uh attach this kind of visualizations into your research paper or maybe report or whatever kind of research work that you might be doing so all of these things will be covered in this particular module and uh specifically the data that we're going to deal with is stored in in the format of the CSV file in this particular Google Drive Link so we're going to ly export this data from the Google drive into this Google collab and then we are going to explore this kind of data set step by step and then create this visualizations that's the whole idea the main goal is to create some kind of different visualizations from the data set and the data set is all about different stars that are existing out there in space and then all of the stars are given with its respective properties of absolute magnitude then surface uh temperature spectral type and also the luminosity and at the end we are also going to create this kind of a hers sprung russle diagram or in short you can also call it as a CHR diagram which helps astronomer classify any kind of a star based on its properties of this absolute magnitude spectral type surface temperature and the Luminosity so that's the whole kind of idea that we are going to deal with throughout this particular module and I'll see you next in the upcoming video where we are going to deal with exploring of this data set hello hello everyone welcome to the third video of module and here we are going to go ahead and import the libraries so what kind of libraries are we going to import or what kind of libraries are we going to use throughout this module two you're going to understand each one of them as in why are we importing them and then yes as you can see on the screen find out what are this kind of libraries and why are we going to use them so let's get into it now in order to explore this kind of data set that we are having in the format of Cs that is stored in the Google Drive and also create visualizations on top of that what we'll be doing doing is we won't be coding everything from scratch we going to use some of the existing libraries that's going to help us so that we can save our time and at the same time use this kind of libraries to create some kind of beautiful visualizations after exploring them so for that I'll have to import these libraries which will help us throughout in this particular module so what I'm going to do is I'm going to go ahead and import the libraries that are going to first of all help us explore the data set in a proper way so I can do this with two of the libraries that is Port OS okay how exit it will be helping you will get to know in the upcoming videos but yeah OS is one of the library that is going to help us to let's say for example create a directory where we are going to save all of our visualizations and also it's going to be useful for some other purposes that will be same apart from that if you want to open the CSV file and explore it step by step the main popular library that we are going to use is pendas so I'm going to import pendas as PD the reason I'm calling it as p PD over here so that because I don't want to write pandas again and again okay I just want to use PD in short so that I don't have to write pandas again and again continuously right it's up to you you can just simply import pendas and use all the functionality of pendas Library by calling it completely by calling it as pendas not PD it's your choice okay I can have also import pendas as let's say for example my name is Rohan so I can have also import this thing as import pendas as ran but now it does not make sense right it's almost pretty much same letters that are having so a short form that we use in the python Community for pandas is PD just like that you will also maybe needing some kind of a way through which you can create an array from this kind of a CSV file okay so from the CSV file you want to generate some sort of array for that he will require a library called as numpy so I'm going to import numpy Library as NP so now I have imported all of these libraries that are going to help us explore the data set now in order to visualize this kind of data you will require visualization libraries so for that what kind of things I'll importing I'll be importing the first thing that is c bond again because the there are a lot of characters in this particular word I'm going to import it as SNS again a short form that we use in Python Community for cbon and then we are also having one more one of the most popular libraries for visualization that is met plot Li so I'm going to import met plot lib and specifically P plot uh and I'm going to import it as PL again a short form to call all of these things together right so these are the libraries that we are going to use majorly to create some kind of different visualizations after exploring it with the help of os pendas and numai so that's the whole idea and now from the next video we are going to go ahead call the data from that link and finally start exploring it hey everyone welcome to the fourth video of of module 2 and now that you are already having a quick idea of what is the data set all about let us try to explore this data set with the help of python we going to convert the CSV data into Panda's data frame with the help of pendas library and then summarize this whole information that we are able to fetch from this particular data frame about the Stars so let's get started now what we are going to do is we are going to take that uh CSV data I'm going to Simply copy this link and use this particular link or part to the CSV file read that CSV file with the help of pendas library and create a pendas data frame so what does this mean so I'm going to use pendas functionality so I'm using PD and then dot to refer to any kind of functionality that is present in pendal and now because I want to read the CSV file I'm going to write this command rore CSV and then it expects this path in the format of string to that CSV file so I'm going to Simply give this kind of a quotation mark and paste that link now you don't have to download this particular data from this link and then upload it somewhere to basically read the CSU file this link is sharable for everyone so you simply go ahead copy that link paste it over here and simply press control enter to run this code and you will be seeing that the whole data of that CSV file is now expressed into this kind of a table that is your pendas data frame now how do I know that this is a pendas data frame so whatever code we have written and whatever it is generating for us I can always check its type by simply writing the type and whatever command that I'm getting over here if I'm running this and you can see that we are getting this pendas data frame right so what I'm going to do is I'm going to store this pendas data frame into some of the variable so that we don't have to again and again read the CSV file so I'm going to store it in a variable called let's say star DF what it means it's a data frame uh which is having the information of stars right so you can name it the way you want this is what I have choosen okay now let's say if you want to visualize top three rows of this data how you can do it you call that data frame that you have created and then on top of that what kind of functionality you can use you can use the functionality of head this head automatically gives you if you don't put any kind of input over here it gives you first five rows of data that is present in your CSV file now let's if I want to visualize top three I can just give this three and yeah you can get this kind of three first values that is present in our CSV file as you can see there are some different properties of the stars and there are some different respective stars that we are having over here so zero is a star that is present on our first particular row then the second star is present on index one so on and so forth right so that's the kind of idea that we are having now what if I want to visualize some 10 random samples of the stars that are present in this data so for that we use some different functionality of the data frame that is sample the sample allows you to get some random samples from this data frame by simply passing in the number for example let's say I want to visualize 10 different samples from this data frame as you can see that now on the left side the index values are completely different it's not starting from 0 1 2 3 like that it's some random index so it is indicating that we are trying to display some random 10 data points that are present in the CSV file right and each and every Star is having the properties with respect to its temperature Luminosity radius absolute magnitude of that star what is the star type if you can see the star type is given in the format of some numerical data there is some kind of a reason behind that I'll be explaining it to you in a while and then there's also a star color and a spectral class this is the kind of data that we are having right and all of this kind of stars are having this kind of properties and by using these properties we are going to create some of the visualizations that we'll be seeing throughout this module right now let's say this is the overall data that we have seen right now if you want to get let's say a generic information from this data frame then how you can do it you can do it with the help of you again call the data frame whose generic information you are trying to look for to get it some of its functionality you press this Dot and the functionality that we looking forward to is the information of that data frame and that command is do info you don't need to give any kind of inputs over here you simply run this and you're going to get an overall general information that is stored for this particular data frame it is giving you that there are total of 240 different stars that are present in your data frame whose index are starting from zero and goes all the way up to 239 okay and then there are some different seven columns for each and every row that is present in our data and what is the name of these columns we can also find that over here that my first column that is present on my index zero is temperature as you can see over here that's my first column on index zero this is index one index two index three four five and six in total there are total of seven different columns like that and respective uh name of the column has been given over here and then there are also information with respect to nonnull count what it means if there are any kind of data point in this whole data frame which is missing for example if this was missing then what would happen in a radius there is one missing value so over here in radius you would have got 239 nonnull out of 240 there are 239 data points which are not missing which are not null but there is one point which is missing so this kind of nonnull count column is giving you an idea with respect to how many uh data points are missing as you can see that out of 240 all of this 240 are nonnull it means every data is complete now the reason the data is complete like this in real life you don't get this kind of complete data you have to perform some of the techniques called as feature engineering handling the missing values and all these kind of things so that you can use this model for a proper analysis that's the whole idea and that's again one of the reason why we have converted the star type into numerical type because at the end this data was used to create some of the machine learning models but now because that's not part of this particular program we are not going to talk about that I'm simply going to tell you that let's say uh zero means let's say some kind of a dwarf star I mean some kind of a super giant star all this kind of information I'll be giving you at the end of this particular video but yeah just know that all of this file that you are seeing right now it wasn't like this from the beginning it was made perfect so that we can perform this kind of visualizations on top of this kind of given data right because our aim is not to uh handle this kind of missing values do some kind of feature engineering and create some kind of machine learning models our job is to take the data set which is complete and then create visualization on top of that that's the whole idea of this particular program right so let's focus on that particular part so now we are having 240 Nal contents for every columns that is existing along with that we are also having that for each and every column what is the data type in which this information has been stored so overall summary is present over here that out of seven columns three are of Flo type which means there are some kind of decimals involved over here then there are two columns with integer type and then there are two object type object type you can call it as like you know some kind of a text data that is present over there something like that is what you can assume as of now in a very like you know lay and language and the total memory consumption for this kind of data is 13.2 plus KB so yeah that's also giving you the kind of idea with respect to the memory that has been used to store this particular data so as you can notice for the temperature all of this values are in the format of integers but now if you talk about Luminosity it's having this kind of decimals which are involved right and now that's why it's also given this luminosity in the format of float don't worry about this kind of numbers okay this numbers are basically giving you the Precision of the way of writing that particular number let's not got let's not go into the this kind of technical details as of now right uh let's focus on this kind of this is a float type this is also a float type this is again a float type because again some kind of numbers with this decimals but then star type is integers and Then star color and spectral class are both having some kind of Text data so now again that are appearing over here in the format of the object data type of this pendas data so here that's an overall observation that we are able to make by importing this data from this uh particular Google drive to Google collab looking into some of its random samples and then also getting some kind of generic information on top of that if you want to look into its overall observation here is I have written in a complete detail okay there are 240 rows with six independent features and one dependent feature that is the target column again this is mentioned with respect to let's say a machine learning data set that you are trying to classify the star type based on other six properties okay so that's that's the kind of idea about this data set but again we are not going to do any kind of machine learning thing over here we are simply going to create visualizations okay and here are all the kind of information about The Columns right this is the target class the star type right but anyways you don't need to get into that particular information and what is the meaning of Lo and r o that is L and R not these are the average values of Luminosity of the Sun and radius of the Sun so all this information that you are seeing with respect to the luminosity and radius now that is with comparison to the Sun that compared to Sun what is the Luminosity of this star compared to the radius of sun what is the radius of this particular star so it gives you some kind of a comparison directly that okay yeah this star is less luminous as compared to our own sun and also its radius is small as compared to our own Sun so yeah that's the kind of idea that we are having apart from that yes there are star color and spectral class which are categorical features which means it's in the format of some kind of categories there are some kind of different categories of of colors there are some different categories of spectral class right so this is the kind of data that we are having over here and then this is what I was trying to look after right this is something that I was trying to look after that this information about the star type the integers that were mentioned right originally it was having some kind of a name to it zero stands for brown dwarf one stands for red dwar two stands for white DWF three is standing for the main sequence four is for super Giants and five is for hyper Giants now we are going to create some kind of visualization at the end of this module that is going to display this whole uh information of the Stars into an HR diagram and finally we'll be able to classify it like this hyper Giants Super Giants white dwarves right red bars this kind of things is what we are going to expect at the end of this module this is one final visualization that we are going to create so yeah that was the idea with respect to exploring this kind of data set uh uh so far after this what we are going to do is in AUD to create a visualization and then save it somewhere we going to create a directory uh in the next video so stay tuned hey everyone welcome back once again to the module 2 and in this video we are going to understand that where exactly are we going to save the visualizations that we'll be creating in the upcoming videos of module 2 so for that you're going to understand that how you can create a directory in Python and then how you can get the path of the directory so that we can use it in order to save all the kind of beautiful visualizations that we'll be creating in some of the upcoming videos so let's understand how we can create a directory and get a path of it in this particular video let's get into it now before we go ahead and create any kind of visualizations we need to save it somewhere so for that I'm going to create one directory or you can call it as a directory or a folder whatever you want so for that I'm going to first of all give the name to that folder so let me create a variable called as folder name that I might change maybe later on in future so yeah I'm just giving it as a folder name over here as star plots you can give whatever name you want over here and then I'm also going to create a folder now of this particular name right now I just created a variable I haven't created any kind of folder now how can I create that folder over here now if I show you over here this is what is called as the session storage space of the Google collab where by default this kind of sample data exists for every notebook okay so we haven't created anything from our side it is already existing if you will check it will be existing for you as well now my job is to create one more folder whose name is star plots and the way that I can do this is I just come to the next uh line and write OS because that's the library that we have imported in our previous one of the previous videos and I'm going to use a specific functionality of this OS that's going to help me create a directory and that is called as make directories make de is the command and now it expects two of this uh inputs the first input is the name of the folder so I'm going to give this as a folder name at the same time it expects uh us to give exist okay and we are going to set this to true what it means it means that if this kind of folder already exist in your space then it's not going to recreate the folder or something like that if it's existing it's not going to do any kind of changes if it's not existing as of now we don't have this kind of file then it's automatically going to create a directory for us now if I run this code now the code has ran successfully and if I refresh this part you can see this directory has been created for us now the main idea is to whatever kind of visualizations that you will be creating you need to create a path that will store it within this particular location so for that what I need to do is I need to Simply get the path of this folder I can do this by clicking on this three dots over here and click on copy path and I can create a base directory path over here which simply means that any kind of visualizations that you are creating you will be storing in this base directory and now I'm going to equate this to the string of this path and now I'll just make this path Dynamic just in case uh we are having some different folder name in future if I want to change I don't have to change this base directory path I'm going to use F string for that that's what we had learned in our first module right so uh I'm going to write folder name over here instead of star plots right so I just can change the name of the folder if I want and automatically this will be changing right so that's the whole idea and after this there is one more slash I need to give it means that if I'm concatenating my this particular path with any kind of files that we are generating of visualizations I'll be simply concatenating it on top of this base directory so in order to connect them we need a slash just like how you can see there is a slash over here right whatever session storage you are seeing of collab over here is referred to this kind of content that you are seeing then inside this space you are having this specific folder that you are trying to extract over here and that's why because this folder is existing in this space you are giving this slash over here and now then you are giving this kind of star plots and then to store any kind of data within this directory right then you are giving this kind of a slash again and now once you will concate it with let's say uh example.png some file that you have created so you just need to concatenate this name of the file that you have created and attach it with the base directory that's it and your path of that new visualizations that you will be creating uh will be stored over here and the image will be generated over here right so that's the whole idea that we are having uh as in why we are having this base directory over here okay if it's not making any kind of sense as of now don't worry as you'll be going ahead in this particular module you will be getting a lot of ideas with respect to what is the need of this particular base directory all right now in the next video we're going to go ahead and visualize the count of stars for each type of star like you know we are having varieties of star so we are going to visualize what are the different counts in in what quantity are this kind of stars present right so stay tuned for that I'll see you in the next video hey guys welcome to the sixth video of module 2 and here you're going to create your first visualization for this data on Stars so you're going to create your bar graph and it will be very basic visualization that we'll be having with the help of map. library and in the upcoming videos you are also going to customize it and look at just amazing okay so for now let's create at least basic version of the bar graph that's going to give us some of the information about the data set so let's get into it now let's go ahead and create our first visualization that is in order to see that out of 240 stars that are available in our data set how many of them belong to brown dwarf how many of them belongs to redw so on and so forth for all the kind of different categories that are present in our star type column okay so what you will have to do is first of all you will will have to fetch this kind of a account with the help of pendas data frame and then you can on top of that use this functionality of M plotti in order to visualize it so what we are doing first of all I'm just going to copy the name of this column so that we can extract all of this data that is present within this column of the data frame and how I can do it I can come back to that particular code cell over here and I can simply type stard DF to access the data frame and now to access any specific column of the data frame you need to pass in this square brackets and then I paste the name of that particular column but now in the format of strings okay and now if I just run this over here you can see that there are different star types of category zero all the way up to five right as you can see over here zero stands for br W five stands for hyper Giants and everything within that is going to be stored into this particular column now if I want to get this kind of a count that how many zeros are present how many ones are present so on and so forth I have a particular command for that that exists in the pandas data frame I need to go and type Valore counts with this parenthesis so what what's happening it's giving us all these kind of counts that there are 40 zeros that are present or I should say 40 Brown Wes present then 40 red veres present similarly like that all of this are as you can see is 40 40 40 so out of 2 40 stars in total 40 of them are for each and every category that you are seeing over here 40 main sequence stars super giant stars all of this are having 40 40 type of count of stars out of 240 so now if you want to visualize this kind of a data in let's say format of bar plot or bar chart whatever you want to call what you can do is you can simply come over here and use this functionality of plot over here on top of whatever you have got and then give this kind of input as what kind of plot you want do you want a bar plot so you give this kind of input as kind and set it to bar that hey go ahead take this kind of data that that's what you can see and create a bar plot out of it and now in order to visualize this I can simply have PLT Dosh show I'm using the M PL Li functionality to display the graph that I will be creating over here okay and now if I can run this code you can see that this is the output that we have got okay it's a very plain output we haven't customized it that is the goal of the next video that is like you know we're going to customize the above plot and then finally save it right now this is the very basic graph that I have created that is indicating that okay now for different categories here are the respective counts that you can see it's a perfectly balanced data for us and yeah now in the next video you will be seeing how we can customize this plot and make it look very very beautiful as compared to what you are seeing right now hi students welcome to the sth video of module 2 here we going to take the graph that we have created in our previous video we going to customize it we are going to make it look much more beautiful as compared to what it was in our previous video and then once we are satisfied with the output we are also going to save it in that directory that we had created earlier in the fifth video of this module so let's get started all right guys so get ready to see the whole different magic we are going to take this kind of basic default looking graph and beautify it by using this kind of customizations that I have written down I'm going to take this basic graph and convert it into something really very beautiful okay so let's go ahead and try to do it together so first of all I'll need this kind of basic graph on top of which we are going to build everything so I'm just going to copy paste this code and run this so yeah here we are having the same kind of graph the first thing that I'm going to do is I'm going to adjust the size of the figure according to my convenience okay so let's say some of you might like a bigger size of this figure I would personally go for a smaller size so how can I adjust the size of this figure I can do this with the help of a PLT command and what kind of command I need to use I need to use the command called Figure now this is going to give me the axis of this whole figure on which we are having this AIS on which we are having this graph okay so we are having one whole figure in that figure there is one AIS that this kind of square that you are seeing and now on that axis we are drawing this bar graph so what I'm doing is I'm trying to get the access to this figure and now inside this figure there is an option called as figure size that is fix size fig SI i z now over here you can give how much amount of uh width and height you want to give to this particular uh graph or plot whatever you want to call let's I'm changing this to 5 comma 5 and see how it looks like so yeah that's the the kind of output that I'm having I guess I would still like to decrease some of the size let's say I'm doing something like 4.3 4.3 hopefully this is fine this time yeah this is looking a much more better okay for some of you you might like uh very huge graph you might try to increase the figure size in that case but I guess for me uh it's convenient for me to use this particular figure size so we are done with the first customization we are trying to adjust the figure size that's SU able to right we are done with this part now the second part is to add the value of the counts on top of the bars it simply means that for each and every category okay at times what can happen that some of the bar the count is less let's say somewhere in between 20 to 25 now if I want my readers to exactly know the count for this particular bar so we can add the count on top of this kind of bar and that's exactly what I'm going to do in this particular case it could be like you know our users or our readers might be confused that like you know if this bar is exactly at 40 or 39 or 41 what whatever it is right so this kind of skills is necessary for you to have that whenever you're drawing a bar chart if you want to show this label on top of this bar you can what you can do is first of all see we were having this kind of figure inside figure we are having this AIS on which we are drawing this bar graph right so I'm going to label this AIS because I want to use some of the properties of this exis and that is I want to set bar labels I can do it with this command ax. bar label what I'm doing on this axis where I'm drawing this kind of bar gra I'm getting its property called bar label and now there is something which we give an input called containers containers con what is the spelling containers right and now I'm going to access the values of each and every bar by using this zero index and now if I run this code see now we are having this kind of 40 40 count right it will be really very useful the moment let's say any kind of bar count is like you know somewh somewhere it's at 40 somewhere it is 35ish 30ish somewhere in between it's going to be very much useful also you'll be seeing this in the second visualization that we'll be creating where the level of bar are not equal okay but yeah that's how you basically do this particular thing after this let's say I also want to change the color of this I'm not satisfied with this kind of black color I can simply change the color by giving the input argument of bar label as color and set it to let's say for example red see now it's much more better right we decreased the size of the figure then we took the AIS on which we were having the bar graph we took the labels of each and every bar with the help of ax. container Z Z and simply displayed it with the help of this functionality of this axis that is barcor lead so that's what we have done so far the next thing is to set the background to dark now it's again your choice okay if you think you like darker backgrounds then you go for the darker backgrounds or else you can stay with this kind of lighter versions also whatever is suiting you the best right I personally like the darker background so what I'm going to do is I'm going to use this PLT do style. okay this is the command through which you can set a particular background there are again multiple backgrounds that you can choose the one that I'm going to choose is called Dark underscore baground okay and now if I run this okay there is some kind of an error the error is saying that dark backgrounds is not available I guess I've done some kind of a typo it should be dark background and see now this is the output now it's looking something weird right I cannot say the x is Mark what I can do is I can simply run it again because that's the like you know this kind of issue is there with Google collab that if you are changing the style okay then you will have to run it twice so yeah that's how it's looking like right now automatically this color of this AIS has changed from black to white that's the property of darkcore background right now if I want to change this to default I can also use this kind of default style and maybe I'll have to run it twice to make it look better see I'll have to run it twice so hopefully we're getting back from where we started see yeah that's how it's looking like right so what I'm going to do is I I'm personally a fan of dark background so I'll be changing this to dark background now at the same time what I'll be doing is I'll also be changing the color of each and every bar so right now it's a plain Canan kind of looking bar right I'm going to change each and every color for this bar okay for this what I can do is I can simply come onto this particular graph and uh give one more input instead of uh just having just kind is equal to bar I give color property and now I just have don't have only one bar to change the color for example if I change this to let's say brown see what happens it's changing all of them to brown right I don't want this I want to create a list for each and every color that I'll be giving to this bars so let's say I'm choosing let's say brown red red white right all these kind of colors are coming into my mind what I'm going to do is I'm going to create a list okay I'm going to store all of this colors in the format of list let's say first is brown right then the second one is red then I'm giving white you can choose this colors the way you want then let's say uh yellow and some kind of different colors that's that's existing in the mat. li. PIP blot let's say there is light blue and maybe uh the last one I would choose as orange okay so I guess we are done 1 2 3 4 5 6 1 2 3 4 5 6 so I guess this should work let's see yeah see now we are having multiple colors in the bars right brown red white yellow light blue and orange so yeah that's how you can change the colors of each and every bar right I hope this is making sense to you now after this let's say I want to describe that what is this plot giving us like you know what kind of title we want to add to this plot so for this what I can do is I can give this command pl. title and set any kind of title that I want for example I can give let's say a visualize star count per star type right visualize star count per star type and also I can give a color to it for let's say by default what is the color that we get so this is the kind of output that we're getting we can also set this whole font to let's say bold okay I can also change the color of it let's try to do this kind of things you can also change the font size you can try to decrease the size increase the size whatever suits you the best let's say the first input that I'm giving is the color and I'm choosing the color as royal blue okay how do I know this kind of things exist how do I know this dark background exist how do I know this kind of colors exist right because I've gone through the documentation of each and every command you can simply go to its official documentation by searching on Google I can simply copy this command go to Google and search for it off official documentation and you can get all these kind of things or nowadays you're also having access to chat gpts right so you go to chat GPT and ask for what kind of different styles I can use in this pl. style. use it's going to give you multiple different suggestions right so I'm going to set this color to Royal Blue I'm also going to change the weight of this font to bold and I guess uh F phont size is looking good to me I'm going to run this I guess this is looking pretty much good right so we are done by setting a title now I'm also going to add a y label and also change the color of this y takes this kind of things are called y takes this is called as X takes so first of all what I'm going to do is I'm going to add my y label I'm going to do this with the help of PLT doy label and give some kind of name like you know whatever this is describing for example let's say number of stars count of stars right I can give a hashtag for that that is representing number of something so number of stars right and I'm also going to set a color to this let's say I am I am choosing a color called pink okay let's see how the output looks like see this is the kind of pink color that I've got but now the font size is pretty much small I want to increase the font size how I can do this I can give the input parameter called font size itself that's the name of the parameter and change this parameter size to let's say 13 let's see how it looks like I guess this is better but now it's like you know even much more as compared to this so maybe I would like to decrease to 11 and see how it looks like I guess yeah this is better this is much more better now how I can take this y Tak and change its color to let's say some different kind of pink let's say tab pink this is the color that I want okay so let's go ahead and try to do this I can get access to this y TI by again using PLT and use white white TI okay now I'm going to set color parameter to this as let's say tabular pink again T pink is one of the color that is available in M.L so I guess yeah this is looking much much more good right obviously you can play with this kind of colors the way you want I guess I am comfortable with what I'm having right now maybe I can try to change this um color to let's say white not pink obviously you take this thing change it the way you want yeah I guess yeah this is much more great now one more thing that I would like to do is I would like to replace all the X sticks from 0 1 2 3 4 five to its respective names that are shown over here so what I'm going to do is I'm going to Simply copy these things and come over here and paste it it over here and then this is in the same order that I want to right so I'm just going to delete this part I don't want this kind of part okay and I also want to uh arrange this into a proper kind of way through which I can change the X scks all the 0 1 2 3 4 5 uh that we are having over here right 0 1 2 3 4 5 I want this to be changed to the labels that I want in place of this 0 to 1 two 5 okay so what I can do is because I want to change this XT I can give this PLT do xti and now what kind of things I want to change so these are called the ticks that are present inside X ticks so I can give it as a part of list it is 0 to five right so 0 1 2 3 four and five now I want to get replace this t with the labels okay the first input is Tes the second input is labels right and now I'm going to give again a list of all of these things that we have written over here okay let's say brown dwarf is the first thing I'm going to give it in the format of string and then I'm going to do it for Red Bar r w after that we are having white barve and then main sequence main sequence after that we are having super Giants and Hyper joints super joints and Hyper joints okay so I guess this is good let me just try to run this and see okay I guess we have to dedit this we don't need that thing anymore and now if I run this hopefully it's changing yeah see now this is what I am getting Brown bar red bar but I don't want this kind of things okay I want to rotate this things let's say some some degrees and I also want Brown to be in the first line dwarf to be in the second line righted to be in the first line white I mean dwarf in the second like that right so what I can do is I can give a new line character between this brown and valve similarly for red and wve right similarly for this main sequence and then there is only one one word so I don't need to convert them but now what I can do is I can just bring this down so that it's visible to everyone and then I'm going to give one more parameter called rotation I can give let's say 10Β° of rotation let's see how it looks like it's it's a bit cluttered right so what I can do is I can maybe try to uh rotate it to let's say 45 deges or something let's see how it looks like right after changing this to 45 I guess 45 is going to look good yeah this is looking much better right I guess yeah this is much more better now let's say I want to change the color of this as well I can again give the property of color to this XT and change this color to let's say maybe line let's see how it looks like this is looking good right so yeah that's what we are having that's that's what we are going to get by replacing the ticks of x from 0 to 5 and giving it its respective label that is brown dwarf red DF white dwarf so on and so forth so yeah that's what we have done over here and after this we are going to save this particular plot in the base directory that we had created I want to store it within this thing so now how can I do this right I guess the plot that we have created is far more beautiful as compared to what we had seen over here right I can maybe uh try to again change this to Super in the first line then Giants in the second line I could have done that but I guess this is fine now in order to save this thing what I can do is I can simply come over here here and give this command PLT do save fig now what is this thing going to do it's going to allow us to give the path where I want to save this figure so the first thing is I want to give the base directory right the base directory is the directory that we have created for this starcore plots now if you remember this base directory wherever we have created we have given the slash so I just need to concatenate the name that I want to give to this plot let's say uh we are giving this name in order to Conca it we can use the plus operator and then let's say give this as barplot star count something like that barplot star count. PNG you can also save it as JPEG if you want but yeah let me just go ahead and try to do this and hopefully we are getting this output over here if I yeah see that's there if I double click on this or here we can see that this is the kind of output that we have got right now I'm simply going to close it and uh close this also and yeah we are done with this first plot okay this is the first plot that we have saved after creating it after beautifying it that's what we have done now in the second upcoming video what I'll be doing is I'll be creating one more visualization it would be a bar graph only but with the help of cbor and now see that with the help of cbor how we can do the same kind of and that is much more convenient as compared to using mat plot L all of this reasoning will be getting clear once you look into the second video or the upcoming video hey everyone welcome to the eighth video of module 2 and here we are going to visualize some different part of the data set again in the format of a bar graph but we'll be creating it with the help of cbond library and you're going to see that how easier it is in order to create some amazing bar graph with the help of c bond as compared to met plot La so let's get started now what we're going to do is we're going to go to the top part to that uh data frame that we had created and take a look onto the star color we are again going to create a bar graph but now with the help of cbor you will see the power of cbor that with just one line of code you are able to achieve something like this color for different bars and all of these kind of things you will see that so so now what I'm doing is first of all I'm trying to visualize the star color count that is present for each and every color so for this what I'll have to do I'll have to go to Star DF inside that star DF there is a column called a star color I should give it with the help of strings and then I can check the value counts with this so as you can see that there are red stars the count is 116 for blue it's 56 for blue white it's 41 by default it's coming into the descending format starting from the highest and going to the lowest and now if I want to get access to this values this red blue and all these kind of things now this is present in the position of index so I can take this command on top of this command I want to grab its index so I'm going to give this command do index so here is the whole index red blue blue white and all of these things so now what I want to do is on the xaxis I want to plot this colors that are this index and on the y- axis I want to get this particular uh values okay if I grab the first value that is present over here it will be 116 see it's 116 now if I want to grab the value present on the first index it will be the second value 56 right so I want to plot this data on my y- Axis and I want to plot this colors on the x-axis so what I can do is I can use use uh SNS do barplot I'm trying to create a barplot with the help of cbond library on the x value on the x value I am giving this whole thing with index do index that's the color name and on Y what I want to see I want to see the value counts so I'm going to copy this part I'm going to copy this much part and save it in y and let's just try to run this and see how the out looks like see this is the kind of output if I don't want to have this kind of extra labeling that is there on top of the graph I'll have to use the command PLT do show I'm trying to use both met plotly and cbond to come up with one final output so by using this PLT do show this AIS will be going away so yeah this is the kind of graph that we are having see now again we can have any more customization see by default it's not coming out as a white background right now because we have already changed it once you change it it will be like this okay it will not going back to white color you will have to go and switch this style do Ed to default in order to have this kind of white background but I guess black black background is quite comfortable but now you can see that I don't even have to set this kind of colors manually it's coming automatically without myself doing anything over here now what I can do is I can just uh come over here and give one more thing that is called pallet I hope I have given the correct spelling again there are multiple pallets that are available this uh vies is my favorite one so this is looking much more beautiful right so yeah that's that's about it now I can again go ahead and customize it the way I want right I can change this uh color for this Y axis I can change this colors of the T and everything I can do this right so what I'll be doing is I'll simply be going ahead and doing this kind of visualizations okay I guess the figure size is looking pretty much good I'll be changing the tix of the x-axis pl. X TI give a rotation I guess of 15Β° or 10Β° 15 I guess let's try 15 and I'll give the color as orange and see how it's looking like this is good now what about star color I'm going to take the Y label see it's coming by default I didn't even give this thing it's coming by default it's all because c bond is is built on top of met plot by default within this bar plot they are giving this kind of Y label that is the title of the column that's what they're giving by default I didn't even set it and if I want to change its color I can use PLT do let's say y label and give some kind of color let's say white can also change the font size to let's say 13 let's see how it looks like it's giving me some kind of an error y y label okay y label is missing some kind of an argument okay maybe we are trying to oh yeah we are missing the Y label we need to give this kind of uh command that is star color okay we'll have to give this if you want to change this y label you will have to give this kind of name only then it will be working fine see yeah now it's working fine right so yeah I given this kind of things I can also change the colors of the whex if I want PLT do whex this uh color is equal to tab pink this is my favorite one for the y- axis that's what I use frequently so yeah I can also have the title of this plot that we have visualizing pl. title we try to basically give title on the top because we know like you know this is the kind of order first we give first we draw the plot after drawing the plot we give the title this kind of order is not something that you need to follow TI T right now visualizing the count of star colors something like this maybe color is equal to Royal Blue for title again I prefer this if I'm having the dark background and font size let's say I'm setting it to 15 two more than what I am having for this I can also set this to weight equal to bold I can also uh for the X uh T I can try to change the font size if I'm able to do this I can take this write font size change this to let's say 11 hopefully it changes yeah it's changing right so I guess this is pretty much great now I can also add like you know this kind of containers to this bar and the same way I'll be doing I'll be changing this to a because I'm trying to get AIS of the AIS right and then I'll be doing ax. bar label and then ax. containers zero and then maybe I can give a color of red and I can also maybe change the weight of this thing to bold and see how it's looking like first of all the main thing I really wanted to show you is that by doing this just one line of code it's giving us the Y label it's giving us everything even different colors of the bar with the help of pallet right so all of these kind of things we are doing it in just one line so that's the power of like you know using C Bor it's built on top of matte BL Li so it's it's just easy to customize it the way you want as you can see that star color was already existing even before giving this y leg but now if I want to change some of its property I can do it it because cbon is built on top of Med so yeah that's that's about like you know how you can visualize a different kind of bar plots and now in the next video let's try to visualize something else hey everyone welcome to the ninth video of module 2 where you will be visualizing the outliers present in our data set and one of the ways through which we can do this is by creating the box plot on all of these kind of features that we are having in the data set and we are going to visualize them side by side with the help of a subplot so what is subplot and everything will be covered in this particular video so let's get into it now let's go ahead and try to create some different type of visualization apart from the bar plot now what we are going to do is called box plot now it's typically used to visualize the outliers that might be present in any of your numerical feature so the main idea behind box blots is that like you know you're are going to have this kind of variation of numeric feature in front of you it's going to give you the idea of the median it's going to give you the idea of the upper quartile lower quartile and also the outliers right and for the outliers visualization we typically use the box plots and finally just save it into this particular folder that we have created and I guess we did not save this particular code so let's go ahead and try to save this figure save fig and the name that I'm going to give you not give you but yeah give this particular graph is base directory plus let's say visualize or just start star colors star Colors v.png Let's go ahead and also try to cross check if it is done yeah it's done I'm going to see it so yeah that's the beautiful plot that we have created and saved right anyways yeah we are also going to save this kind of box plots that will be be generating all right so that's the whole idea that we're going to look into so now what I have done is I already created one this kind of get a gist of data by checking the first five rows of the data so over here we can see that temperature Luminosity radius and absolute magnitude are what are your numeric features all of the last three features are your categorical feature it's some kind of categories now we use box blots to visualize this kind of numeric features so now what I'm going to do is with respect to all the star typee that is 0 to five for all the star types what is the variation of temperature what is the median what is the interqual range what is the outlier if at all they are present in any of the star type category with respect to the temperature I am also going to do this for Luminosity radius and absolute magnitude so I'm going to create multiple plots for all these numeric features with respect to Star type you can also do this for Star colors and also the spectral classes it's your choice right now I'm going to show you any one visualization and I'm going to do it with respect to the star type that if my let's say my star type is um white dwarf so for with respect to white dwarf what is the variation of data for radius what is the variation of data for Luminosity this is the kind of thing that I'm going to generate so what I'm going to do I'm going to come over here and uh get this boxplot with the help of SNS do boxplot it requires what want to display on xaxis what you want to display on y- axis and lastly I'll be also showing this pl. show and on X what I want to show is the star type right and on the y- axis let's say I'm giving for example only one thing as of now that is temperature so SNS dobox plot on X what am I giving star DF star type and on by what I want is start de uh it is temperature right I'm just going to copy the whole thing but a better way would be to not copy this instead use iog feature it's giving you the location on the basis of index now it takes two things in the input the rows and the column I want to plot all the rows and the First Column that is present in the stard D okay all the rows of the First Column now First Column is present on index zero right so I can get it use with the help of this zero okay remember this kind of column that we have given over here that column is giving you this idea that everything everything that is present in rows you grab that part but now only for index zero column so now if I go ahead and visualize this let's see what kind of output do we get see this is the kind of output that has been generated I have got 0 1 2 3 4 5 all the different star types which are corresponding to this kind of names and now if you see there are no much of outliers except this zero right this kind of diamond this diamond is basically highlighting the presence of outlier for the class zero and if we are talking with respect to only one numeric feature that is temperature now what I want to do is I want to generate the same thing now in place of zero I can change this to one and see the output the output this time is for Luminosity see I don't have to change the column Name by default for by manually I don't have to do this thing okay it's happening automatically but now instead of plotting this one by one I want to plot it all together in one figure and then save it and that's where this kind of concept of box plot comes into the picture right so what we are trying to do over here is this is one whole figure now from that one figure we are creating six different axes how we are creating the six different AES by giving the command of PLT do subplot providing the values of rows and columns I'm giving two different rows and three different columns and then the first axis over here is starting from position one the second axis is on position two the third axis is on position three so on and so forth so that's how you can create the subplot and try to visualize this thing over here so what I can do over here is I can do PLT do subplot and give one let's say I want to create four different graphs in one row so 1 comma 4 and I want to first of all look into my position one and then I want to see how the output looks like let's see how it's looking like see this is on the first position now if I'm uh just trying to change this to zero and copy this whole code come down over here and just change this to one and but at the same time I'll also have have to change the position of this to two see now I'm having this kind of prop but it's very much cluttered right so to I'll have to manage the figure size accordingly and I'll also do some kind of uh one more command that you will see of M plot lip to adjust the layout that we are seeing right now if it's getting cluttered like this then we know how to do this I'll be showing you that okay but the whole idea is I want to create this kind of subplots but now just imagine if there are multiple subplots that I want to create it's not a very good thing to like manually change this kind of indexes so what I'm going to do is I'm going to create a for Loop over here so what I'm going to do I'm going to create for Loop but how am I going to create the for Loop right that's something important that you want to understand so in this for loop I am going to create four different x's on index 1 2 3 and four or I should say on position 1 2 3 and four so for I in range of four so it's going to go from 0 1 2 and 3 right and now I want to also give indentation indentation over here okay I'll remove this PLT do show command as of now okay and now I want to change the position with respect to I because I is starting from index 0er I'll add one to it so that we get 0 + 1 is 1 because we know that subplot always starts from position one not from position zero so that's the reason I've done this kind of thing and now at the same time I'll also change this to I it's going to take the zeroth column first then the First Column then the second index column and then the third index column so that's how I'm going to create my uh subplots let's see how it's going to look like see that's how it's going to look like as of now right I also like to change the background it's not black is not looking good for this one so what I'll do is I'll first of all change this style to default and you know you must do it twice to get a proper output okay this is for the first time that we have got this this is for the second time and I guess this will be this time it's good it's still cluttered because we did not change the figure size so PLT do figure what kind of command we give we give fig size right fig size and let's say I'm choosing 20 by 8 20 by 8 so I'm going to get 20 spread and eight in terms of height so I guess now this is better right this is much more better so we are getting this for temperature over here we getting for Luminosity but still there are some kind of cluttering that that's what I can see so to adjust this cluttering what I can do is I can maybe see first of all uh get rid of this y label completely and instead of that I can have a title for each and every plot okay I'll be removing this kind of things and have a title on top of that that's the kind of thing I want to do so what I will do is I'll say PLT doy label and convert it to nothing and at the same time I'm going to set title and what is the title title is the column name so how do I get access to the column name so for this there is one simple code that is stdf do columns that's it if I run this see I'm getting access to each and every columns right so now what I'm going to do is I'm going to go and call these columns one by one with the help of itation index I so PLT do title star DF do columns and then I'm going to give an index I'm also going to set a color to red and now see how it looks like see now it's it's better right I cannot see any kind of cluttering anymore if you want you can also expand this by let's say changing this 20 to 25 right even that's fine but I guess this is much more better right but now what is this indicating if I want to give a title on top of this whole subplot that I have done I have created I can use something called as subtitle see Su I can again get its access with the help of PLT see this is what is called subtitle now what kind of title am I giving I'm going to say that visualizing outliers in numeric features of star data so visualizing the outliers that's what I'm doing in what in numeric features of star type now after this what I want to do um I want to give color to this I want to give weight to this and also font size to it so I'll be giving color equals to let's say a black color let's say a black color is going to work well if not I'll be changing this I'll also try to change the font size not the phont wa to bold and lastly I'll be uh also playing with the font size is 15 hopefully it works perfectly fine yeah this is good right maybe I can change this to some different color but I guess this white and black combination looks good it's pretty much simple and straightforward I guess I'll be going with this right again if you want to add any kind of different kind of visualizations according to you you can surely go ahead and try to change anything you want okay but I guess this is fine for me so I'll be simply going ahead and save this figure pl. saave fig and say that this is boxplot dop PNG and also give this box plot with respect to start time and now run this and hopefully we'll be getting this saved over here I'll refresh this okay yeah I'll refresh this okay see it's coming out of this particular directory why because I did not give the base directory right it's going by default on the session storage I don't want to do that so I'll delete this file come back over here and give base directory and then concatenate it with this thing and I I guess now it will be working fine so this kind of things will happen with you also if you're coding it's just that you need to minimize any kind of error that you might be seeing and get the things done the way you want right and now let's go ahead and visualize the box plots that we have created just in order to check everything is fine see yeah that's the kind of output that we are getting right so that's what we have got for the box plots and uh yeah that's pretty much about this particular video now in the next video what we are going to do is we're going to look into one more type of graph called as line graph or line chart so I'll see you in that particular video so far we have seen how we can create a bar graph and also the box plot now let's look into some different type of visualization which is called as line plot so it basically takes some of the data points in your data and simply connects them with a line okay so it's going to be helpful for Us in order to visualize some of the patterns that are present in all the kind of numeric features that we are having in our data set so let's get into the video and understand how we can get these things done all right so now let's assume that we want to create the line plots for each and every numeric feature so what we are trying to do is uh in the outlier what we did with respect to Star type what's the distribution of the temperature Luminosity radius and absolute magnitude we got this kind of median values for each and every classes and also the interqual range and all of this kind of outliers that we wanted to spot right you can surely now go ahead and remove this kind of outliers if you want but our purpose is just to create some visualizations and find some observations on top of that so from this box blot we can say that in the Luminosity we are having most of the outliers so you need to uh try to like you know remove this outliers or try to do something through which you can minimize the effects of outliers right but now what I'm trying to do with the help of my line plot is to connect let's say for temperature only okay we are not talking about anything else let's just focus on temperature I want to connect my this point with this point then this point with this point with a line and then see try to observe if any kind of pattern is being formed or not that's the kind of logic that I want to build now again I want to do this for all the kind of uh data that we are having that is a numeric type so for this numeric features I want to create this line plots again I'll be using a for loop with the help of of subplot but now at the same time I'll also be showing you that how you can use function in order for anyone who is reading your code or even for that matter if you are reading your code after some time it's much more readable and more convenient to your eyes okay it's better that we use a function all of this you'll be understanding over here so let's get started with this so what I'm trying to do over here is I'm trying to create a simple line plot I can do this with respect to PLT do plot okay next thing is spare plot we are going to do that in the next video but right now let's focus on this PLT do plot now what do I want to plot let's say for example I want to plot the temperature so star DF and now I can give the dot iog I want all the rows that is present in the First Column that is my temperature column and simply plot it let's see what kind of output do we get also I can do pl. show so that we are not getting this kind of output I can hide those outputs by using pl. show all right so yeah let's just wait for a while this is the kind of output see this is the kind of pattern that we're getting okay now it depends on some kind of task our job is to create visualizations and give some observations then how let's say in data science in machine learning how can people use this kind of uh observations and create something out of it create some kind of automation stuff with respect to machine learning deep learning any kind of data science project for that matter right so this is the kind of pattern that we want to get for each and every numeric column temperature radius and all of those right so what I'm going to do is I'm again going to take the help of subplot and now this time what I'll be doing I'll be having four different rows and one column so four comma 1 and I'll also be changing the index with the help of I I'll be again having this kind of for Loop for I in range of four so it's going to go from 0 to three I'll also select this thing and press tab to give this kind of indentation over there and uh yeah we have given an indent we are having the space everything looks good I need to change this zero to I I guess everything is going to be fine I need to remove this BL do show I'll bring out of this for Loop and see how it looks like okay this is the kind of thing it's looking like as of now uh I can also change this kind of colors for every graph I can give a title to this and I can customize it the way I want but a very basic graph I have in front of me right so I can give this kind of PLT do title the same way that we had done in our previous code that is stard DF do columns and then uh I and I can also give a color to this kind of title let's say red and at the same time I can also adjust the figure size PLT do figure what kind of figure size do I want let's try fix size is equal to 15 comma 8 let's say what what happens so I guess this is good right in terms of visualization this is looking good but now if I want to do one more magic over here with the help of subplot what I can do is I want to adjust the layout that I'm having I can use PLT do tight layout and then if I try to look it hopefully it's going to give us a better layout as compared to what we are having currently okay it's automatically see going to adjust the spaces between this kind of AIS that we have drawn and that's how it's looking now at the same time I also want to change the colors of each and every plot that we are seeing so for that what I can do is I can create a list of colors over here okay let's say color equals to now let's say because I'm having four different plots to uh draw I want to understand that what kind of colors I can use now again you need to have this kind of idea with respect to what kind of colors that mat plot lab is giving you I'll be using again some of my favorite colors like royal blue gold San green something like that okay you can choose your own colors royal blue let's say gold then again green is not something that I like I like lme okay so lime andan is something that I'll be having lme andan I could have also drawn magenda Nan anything that you like I'm just trying to give you some different kind of colors that are available now in place of this plot I'm going to give this kind of parameter of color is equal to colors of I so what it's going to do in every time in every iteration the value of I is going to start from zero and all the way up to three so when there is a okay there is some kind of an error automatic saving fail don't worry click on this show diff and click on Save changes and it's going to automatically save everything for you the weight should be all right yeah great so now what this is doing it's trying to get access of the royal blue when the value of I is zero is going to get the excess of gold when the value of I is one similarly lime when I is 2 and three when uh sorry and magenta when the I is value three okay so that's the kind of thing that I want and now if I try to see how it works let's see hopefully everything is good okay it's giving me an error what's the error menta okay there is a wrong spelling hopefully this is the correct spelling yeah see now how beautiful this plot is looking like right I can also give a subtitle if I want I can give it anywhere okay it's not compulsory I give it on the top I could give it anywhere pl. subtitle visualizing the distribution of numeric features something like this let's say I'm giving a color of black the same thing that we did above okay I like this kind of black and white combination if I'm choosing that then font size is let's say 15 and uh let's see if I want to give anything else after running this code yeah I also change this to bold right the weight of this text to bold weight is equal to bold maybe I can also try to increase the font size if I want okay I guess this is looking pretty much cool maybe I can try to decrease this 15 to 12 maybe that can be giving us a better visualization so yeah this is this is much more better right so yeah this is the kind of output that we have received this is the kind of pattern that we are having line by line for the temperature Luminosity radius and absolute magnitude now it's job of machine learning engineers and data analysts that like you know they find something useful from this and get something done for any kind of application they're trying to build right now in this program we are trying to focus how to develop this kind of visualizations and yeah that's about this particular thing but now let's say I want to convert this whole thing into what I want to convert this thing into a function now how can I do this how can I convert this in the format of functions I can simply cut this thing come up over here let's say I'm defining a function called line subplot it's going to take some kind of inputs and I'm going to paste everything over there okay see first of all I am giving this I so I'm going to give I at the same time I'm also giving my star DF right so I'm going to give Star DF also to as an input I'm also giving uh colors as input so let's say that I'm giving colors over here as input I guess all of this is going to work fine so I've defined a function that's going to give me a subplot it's going to give me a plot for different values of I from the iog also give me a title and I guess everything is going to look good so over here I'm going to Simply call line subplot and give the input of star DF then what was it colors and I the value of I right and hopefully we are getting the same output I guess there is some kind of a yeah spelling mistake subplot yeah now if I'm running this I hope everything is working the way we had got in the previous step yes it's just the same right let's if you want to have some kind of a gap between this of things how you can do it you can do that with the help of let's say a new line character over here okay and yeah see now you're having a good amount of gap between that so this is the kind of thing that you have done in this video now I'll see you in the next video and we'll be creating some kind of pair plots hi guys welcome to this video of module 2 where I'm going to teach you the concept of pair plot and how you can easily create that with the help of cbond Library so let's get into it all right guys now what we are going to do is we are going to learn about one more visualization and understand what kind of information we can fetch out of that kind of visualization and again save it like what we have been doing for the above plots I guess I again forgotten to save this anyway I'll be doing it very quickly I'll be giving Bas directory and the name let's call it as line subplot PNG okay and it's always our duty guys that we go ahead and always cross check the output over here okay if I just open this at times it might be that like you know it's looking very good over here but it's not looking good over here so you need to cross check before uh extracting all this kind of information all right so this looks good and again once again if I'm just trying to open this see it properly actually this is looking just incredible okay to be very honest this is the kind of power of python by writing only this few lines of code okay this few lines of code you have created some beautiful things right with the help of this few lines of code and now one more thing that I want you guys to pay attention to is that I am not giving any kind of comments as of now because I am explaining you these things while coding along right so what I want you to do is different person will be able to comment a particular code in a different way so what I'm going to do is I'm going to provide a code that is this whole notebook with the proper comments but I want you to go ahead and comment it by yourself on the basis of your understanding what do you understand by this particular line what was the purpose of creating uh this kind of function one person can simply go ahead and write that it's improving the readability of the code so it's better that we convert this whole kind of step into a function like we did not do this for the previous step over here we did not change it like this right now you can also go ahead and try to convert this into a function right it's going to improve the readability of this code but all of that things is up to you and even for this function you can give a very good description with the help of multi-line comments give the information about what this kind of function is doing then give the information with respect to the input arguments and what is it going to return at the end so all these kind of things you can mention in this uh multiple line comments right so yeah that's how how we are using all the kind of things that we have learned in our first module and implementing it over here isn't it just amazing yeah anyway coming now back to pair plot let's try to understand what is it all about okay so what is the main purpose of creating a par plot or was it it what it's going to do let's say that I'm going to take temperature for example what it's going to do par plot it's going to take a temperature column and it's going to compare with all all the respective other AES that with respect to temperature how Luminosity is weing with respect to temperature how radius is weing and all the other columns that we are having okay for that matter how temperature is weing with temperature even that kind of data we'll be getting with the help of pair plot and by default you are going to get this kind of relation in the form of scatter plot you are just going to get dot dot dot dot dot if you want you can also create a line plot but by default pair plot is going to be in the format of scatter plot okay all of this information I have written over here and now because you are seeing that there are a lot of kind of combinations that we are creating right temperature with all the kind of other columns including itself the Luminosity with all the other columns itself so there are multiple subplot that we'll have to get right multiple axis in a subplot now a good thing about pair plot of c bond is that it's going to get you rid of all this kind of pain of creating subplot and all these kind of functions and these kind of things that's the power of using c bond it's going to do it by default for us and we are just going to enjoy the output that we are getting but at the same time it's also having some of the drawback and the drawback is that if there are a lot of columns just imagine the type of like you know combinations that you will be getting and then you will be creating it into a subplot right and then you'll be getting a plots it would be a really timec consuming task but thankfully for our data we are just having seven columns it's still going to take some significant amount of time but not as compared to like you know how it will take for let's say 30 columns 20 columns right so that's one thing you need to keep in mind so now let's first of all go ahead and try to visualize the uh PA plot with the help of cbone uh PA plot is something I want now I just need to give the whole data frame because it's going to take each and every column and do everything by itself okay let's see the output that we're going to get and I'm also going to show this thing let's see what kind of thing do we get okay as you can see itself right now it's it's taking a lot of time to create this plot right because still there are seven different columns and it's taking all these kind of possible combinations okay so this is the kind of output that we are getting the temperature column is getting compared with its same temperature thing then temperature thing is also getting compared with Luminosity then just like that temperature is also getting compared with the radius absolute magnitude and star type okay all of this numeric column okay it won't be taking uh this kind of categorical column which is of the type object it's just going to take the numeric type of data that is either integer or float okay it's not going to take into account of this last two columns that we were having in the object type okay so yeah this is the kind of correlations that we are able to fetch that let's say with respect to temperature let's say what is this particular column this is absolute magnitude right so for this you can see that we can clearly see that as absolute magnitude will increase the temperature is going to fall this is some kind of observation that we are able to make right so yeah this is the kind of output that we get with the help of pair plot now one more thing that I can do is I can visualize this data point with respect to let's say some kind of U what it means this kind of parameter that I can give over here in subplot let's say I just need to give the name of column over here spectral class okay what it's going to do there are again multiple categories within the spectral class so where is each and every category going to belong to this kind of PA plot all of this kind of things you will be able to see you can go ahead and create this kind of PA plot with respect to different kind of use present in the data see now that's that's what I was talking about there is a Class M Class B Class A this kind of data and see all of these kind of points are being marked differently wherever there is purple it's with respect to class wherever that you can see the dark yellowish kind of thing that's Class B so that's the power of U you can change this kind of U with any kind of different categorical data that you are having uh okay and maybe star color is something that you would like to go ahead and look forward to so yeah that's what we are seeing right in the same data because we did not count let's say spectral class over here we are giving that kind of data with the help of U parameter That's The Power of cbor Now again what I'm trying to see over here is I'm trying to change I'm trying to change this whole background lt. style. use to dark dark background okay and then see how the output is looking like and maybe I would like to also see the previous graph if how this would look like in a dark uh output okay and I also change this color to let's say some different kind of thing but right now let's say how the out is going to look like okay that's the output that we are having I can maybe run this one for one more time because you know right while changing the style we need to run our code twice and what I'll do is I'll also go ahead and run this code I don't need to again set the background to dark because it's already set for me right now okay I don't need to change it again to dark background so yeah I guess this is the thing that we have saved I'll again uh cross check it by saving it okay I haven't saved saved it so PLT do saave fig what am I going to do I'm going to save it in base directory and the same thing you know right the name of this plot will be what it will be pairplot PNG right now there is a parameter over here in par plot again called kind okay this kind by default is set to scatter as you can see over here it's highlighted you can change this to the different kind of like you know plot that you would like to see okay scatter is fine for me so I guess I'll just keep it as it is I won't be changing but yeah that's something I wanted to show you guys but now let's just goe and save this figure and then also look into the output if it's done in a proper way or not all right guys so yeah these are this kind of beautiful visualizations that you are creating with the help of python that's literally something that you can go ahead patch it out from this Google collab and attach into your research papers or reports that you are creating you can mention about this kind of details your observations and give evidence to that with the help of this kind of visualizations that you have created right so yeah we are done with this let's look into this thing yeah P plot is created hopefully there are no errors it's looking good right it's looking beautiful yeah you can see this kind of plots right for the same columns like for example radius versus radius is giving this kind of thing right Luminosity versus Luminosity is giving this kind of thing similarly like over here star type and star type so yeah that for the middle part that's the type of output that you're getting and everywhere else you're getting the scatter plot this is really very beautiful to be honest so yeah that's that's about the pair plot and I'll also go ahead and try to run this once or I should say twice not sure let's go ahead and check I guess this is looking even more much more better right as compared to to previous white one and I also change the color of this to white or let's say t pink let's see how it's looking now hopefully better yes it's just amazing just amazing great so I'll also go ahead and cross check this one line plot line of plot and see if the changes have been saved yes this is much more better man this is just amazing so yeah now I'll be seeing you in the next video where we are going to create this kind of a plot called HR diagram okay something like this so yeah stay tuned for that hey everyone so welcome to one of the most lengthiest video you will see in this entire program so in this particular module this is the final ultimate visualization that you are creating with respect to this star data that we are dealing with so this is about creating an HR diagram what is HR diagram I'll be talking about that in this particular video but then how you can create this with the data set that you are having and compare it with the actual HR diagrams so that you are able to appreciate that what kind of skills that you have learned over here indeed the video is going to be super lengthy but it's going to worth each and every minute that you're going to spend on it so let's get into it guys all right so this is my particularly favorite part to create the HR diagram the reason behind that is I personally love this kind of diagram okay uh it's because like you know how amazingly we are able to categorize or like you know classify this kind of different Stars depending on its properties that is temperature absolute magnitude spectral class and also the Luminosity right now you need to understand one thing that all the kind of previous graphs that we have created or the visualizations that we have created all of them can be always created if you're having this kind of tabular data now we are able to create an HR diagram because we are having the data of star and its respective properties that is temperature and absolute magnitude right now we are going to use both of this to create this kind of a diagram so now because we are having access to this two data only then we are able to create the HR diagram you won't always be able to create this diagram unlike all the other graphs you will always be able to create this kind of graphs right so that's something that you need to know before we get started okay so yeah keeping this kind of things in mind that because over here we are dealing with the star type data set and that's the reason because it's properties that is temperature and absolute magnitude is available to us of real stars that's why we'll be able to create something like this okay so let's get into it now because I want to plot temperature on the x-axis and the absolute magnitude on the y- axis we be requiring its values from the data frame so how we can fetch this values from the data frame so what what I can do is I can create a variable called as temperature and from the start DF I can store all the values of temperature okay in this temperature variable how can I do it by calling dot values on top of this column okay so on on the left side of this dot what are we doing from the Star DF we are fetching this column of temperature and now all the values that are present in that column I'm using dot values so what it's doing let's go and try to print it's going to create an array of these values that are present in this column as you can see over here array what is array array is just one of the other data structure that we have in Python that's used to store this kind of data like this okay just like list as you can see right but now how do I know if this is a list or an array I can just go ahead and type this type functionality on this temperature and we can see that it's a numpy array n dimensional array right for now you just need to know that it's just a kind of a list you can think of but with more much more functionalities okay but anyway now we have uh extracted the values of temperature just like that I'm also going to do it for absolute magnitude and star DF absolute magnitude dot values okay now because I'm having access to both of these values I can simply go ahead and create a scatter plot now what is the reason of the scatter plot if I show you this in this HR diagram you are trying to plot a specific Star by giving its x coordinate and y coordinate for each and every Star you just need x coordinate and y coordinate and you simply plot it so for that what I am doing is the functionality is called scatter okay if you use PLT do plot it's going to give you a line plot okay just like what we did over here if you try to use this PLT dotplot okay what is it going to do it's going to create this kind of lines we don't want to connect the Stars we just want to plot the stars as it is and that's what we are using that is scatter plot on x-axis I'm giving temperature and then on y- axis I'm giving absolute magnitude and then I'm just using PL show to Simply get the output without any kind of text written on top of the figure so hopefully everything is working the way we want and see the output no it's not working right now there is a specific reason behind that okay we wanted some kind of parts to be there on the top part as because we can see over here the hyper Giants and the super Giants are existing over here right but there is nothing over here it's completely empty the reason behind that is look at the the temperature and the absolute magnitude axis this values of temperature are starting from a higher value and going all the way down to a lower value similarly like that we are also seeing in the absolute magnitude we are starting from a higher value and then going up by decreasing the value that's completely opposite to what we are seeing in our M lab output we are starting from a smaller value going all the way up to a higher value and just like that in our y- axis we are starting from a negative value going all the way up to positive value so in order to get this kind of nature of the graph I need to invert my Axis okay I need to invert my x-axis as well as the y axis and the way that we can do it with the help of met plot Li I can use PLT and then GCA what is GCA it's giving me get current AIS okay so whatever we are doing right now is on an axis right so we are getting this current axis and then there is a property called Inver and then x-axis and then I can also copy this line paste this for y- axis and let's see now how it looks like see this is what we expect this is where the main sequence stars are then on the bottom part we are having red wve Brown wve over here we are having wide barves then on the top we are having super Giants and the hyper Giants this is what we expect right now there is one thing that is really very different we are not adding any kind of colors we are not adding any kind of sizes but now to add this kind of functionalities in your graph what you will need for each and every Star there are some unique properties right some unique values of X some unique value of y and along with that it's going to have some respective color depending on what type of star it is it's also going to have a specific size and also a label given to that particular Star as for example white bar so what I'm going to do over here is I'm going to create a whole lot of a python Dictionary what is python dictionary it's another data structure that exist in Python just like list just like array there is one more thing that is called as python dictionary now what is the reason like you know what's the main reason we are using this python dictionary you will be understanding in a while it's going to take a lot of time for me to like you know show you the whole dictionary so what I'm doing is I'm simply uh pasting that part that I have copied and simply uh having it over here okay I'm also going to get rid of this values because Ive also pasted it over over here okay so on the top this this two lines basically temperature and absolute magnitud you already know how did we get this but now what is the star type right so there is a column called star type right in our data frame and I'm simply converting this into the values it means if I try to visualize star type okay if I go ahead and print this it's going to be the list of the Zer 1 0 1 4 4 all these kind of things right we know that zero stands for brown valve one stands for red valve five stands for hyper giant so on and so for so now I have also created this kind of an access to all of the specific data points that are present in our data frame so now our main motive is we are going to take each and every individual star that are from one from the first star all the way up to the 240th star we are going to itate 1 by one we going to get access to X and Y coordinates at the same same time what is the star type of that particular star Now by getting an exess of what kind of star it is is it of type zero type 1 type two type three type four or type five I have created a whole python dictionary form that so let's say if the star type is zero then these are its respective properties if the star type is one then here are its respective properties this is what we create in Python in dictionaries actually it is python dictionaries are made of key value pairs what it means this is the key and this is the value of that keyy so in order to get exess of the value you need key so what I'm trying to say is that if I want to see Star types okay and now in this St R types if I'm giving zero so now zero is the key right if I run this it's going to give me its respective value right now again the value is in the format of dicture if you can see there is a curly brackets right and then there is a key and a value Associated to that there is a key and a value key and a value so I have created a dictionary within a dictionary right so the reason behind that is let's say that the first star is of class zero okay type zero now I'm going to call this as the property of star zero star type zero and now if I want to get an idea what is the label of the star I simply need to pass this key it's going to give me BR bar if I want to check what is the color that we are going to give to this particular star class that is brown what is the size that we are going to use to plot this kind of dwarves it's going to be size of 30 and then what is the marker that we're going to use to display on the graph what are this markers over here you are getting this kind of circles by default okay you could have changed this to cross you could have changed this to a DOT right you could have done a lot of different markers that are available in M plotly currently we are choosing only two types of markers if it's a dwarf star we are going to use marker as a DOT if it's a main sequence star or any kind of giant star then we are going to use a marker as o that's the kind of idea that we are having by default marker is O as you can see okay but now the whole idea that I want you to understand is that let's say in the it region out of all the 240 Stars we are on let's say index two so what are what is the star type on index 2 let's check that it's zero but now let's see if I'm on index 100 let's see over there the star type is four so now what I'm going to do is I'm going to change this zero to the star type of 100 that is 4 in short right and now if I take a look into its property of marker it's going to be o right and if I take a look into its label it's going to be super Giants see just like that if I want to get an exess of the color I can just do this by passing in the color and that's more than enough I guess you might have understood what I'm trying to say I'm trying to come up with a logic that if I'm trying to create a scatter plot and for each and every individual point that I'll be plotting I want to give this color label size and marker how can I do it with the help of this python dictionary that we have created for Star types that's exactly how we are going to do that okay so again if I want to show you what is the length of the star type it must be 240 right so in this star type there are 240 different values right starting from zero star type let's just visualize it for one more time see 0 0 0 1 1 1 so all of these things are for 240 times so I'm going to itate from the first index all the way up to last index and then whatever is the value of star type I'm going to get its respective properties with the help of this syntax so that's the idea that I'm going to implement with the help of a for Loop so what I'm going to do is I'm going to create a for Loop in the range of this 240 values okay so l of star type because we know that length of star type is what 40 right 240 I mean right so now let's say in future if someone is updating this CSV file if we are having a lot more data as compared to 240 Stars it will be very Dynamic for us to write this length of star type instead of 240 right so that's the reason that I have written this length of star so now what's going to happen the value of I is going to start from zero and go all all the way up to 239 right and now I'm going to plot this scatter diagram for each and every Star so the temperature on the index zero and its respective value of absolute magnitude on index Z is the first St that I'm going to plot then when the value of I will change to one it will be temperature one comma absolute magnitude one so H and every Star that I'm going to extract from the temperature and the absolute magnitude I creating this XY coordinate and then I'm simply going to plot it in the scatter plot but now at the same time I'm also giving the properties of the size color marker and the label okay now I can extract this properties just like how I have explained over here so I'm going to copy this part and store it into a variable called as properties okay but now I need to change this to I because I don't want Star type that is present on index 100 I want to automatically change if the value of I is changing so when the value of I is zero it means on the first row what is the star type with respect to that give me the properties right and then when the value of I is 100 at that particular Point what is the star type get me its respective properties right so that's the kind of idea that we have done and after that if you want to call its respective properties of size color marker and label how you can do it I I'm going to give properties and I'm going to write size over here right size color marker label right I'm just going to copy this code paste it for color change this size to color and for marker again I'm going to paste this change this to marker and for the label again paste it and change this to label so our idea is done hopefully everything is going to work fine let's go ahead and try to test this okay I'm just going to get rid of this extra things because we don't require it anymore and if I go ahead and look into this output I don't need any kind of Extra Spaces I'll get rid of this right so see this is the kind of output that we're getting right all the hyper giant super Giants are getting colored then this are the kind of mean sequence Stars these are the red veres these are Brown dves These are white dves all of them are what we expect in the HR diagram it's in the same exact way right that's what we expect right but now there is one thing that we are not able to give any kind of label right we are not able to see any kind of label that this is a white bar this is a main sequence star right we are not able to see these kind of things the reason behind that is because we haven't given Legend in met. Li you give this Legend in order to display this label so if I run this code just stick around with me because there are quite some more things we are doing in this specific video because there is a problem associated with this command okay I'll be explaining that to you see that's the problem I was talking about now for each and every Star that is for 240 Stars whatever is the star type it's going to give a label to it and assign in the graph itself now that's not something that I'm looking forward to if my brown dwarf has appeared once I don't want to label it again because I know that this kind of stars are going to be brown W then this type of stars are my red valves right if it has appeared once I don't want to appear it for more than one time so now I am going to come up with a very good logic that's going to help me solve this issue okay now the reason that I'm able to explain all of these things very fluently it's not that because I'm a very good programmer everything comes to me in just a second it's not like that it's years of practice at the same time I have already done this kind of I have already solved this problem okay took me some time it's not that on the spot I got this things okay so it's completely fine it's not that everyone is going to get it on the spot if you are especially a beginner it will take some time right so try to digest the things that I'm going to explain right now okay so so see what I'm going to do is I'm trying to create two things this requires some kind of an idea of how Legend works okay so let me explain you that first Legends basically take one input called as handles what are these handles these handles are nothing but each and every plot that you're trying to give okay so let's just call this thing as X's okay and I'm just also going to press tabs to shift it to the right and I guess one space back should do right this is looking good uh yeah this is looking better yeah now what I'm going to do is in place of this handles I'm going to write labels now what is this labels I again not created any kind of labels so I'm going to create a set called labels labels is equal to set at the same time I'm going to create exess empty list so what what I have done I have created two empty data structures one that is a list and one that is a set the unique concept about the set is that if there are more than one thing that is repeated okay there is a one thing that is repeated for more than one time it's going to consider it for only one time so what I'm trying to say is let's say I'm having set of 1 comma 1 comma 1 see what is the output going to be okay it's going getting this kind of an error because we we have done a syntax problem I'm going to come out of this and then I'm going to give this see the output is only one output is only one no matter how many times one is repeated it will always give the output of one so that's the kind of logic that we are having over here okay we will be keeping on adding the labels over here and make sure that labels are appearing only once okay and then for which plot I want to give this AIS label okay for whichever plot I want to give this label I'll be adding that data point to this particular AIS and labels it might be getting a bit overwhelming so let me go ahead and show you what I'm trying to say okay what I have done till now I have created this kind of a scatter plot and that's what you are seeing but now this kind of Legends are looking very ugly right so we are trying to sort that problem okay by calling these two things now I'm going to give an if statement now what is this if statement all about if the label that we are getting for the star type okay so from this properties if the label value if the label value is not present in labels okay only then you are going to give this x ax is equal to this kind of graph and then after that what you are going to do is this is really important you are going to add this AIS to this AIS and then also add the label because it was not present in this particular set because it's not present you are going to add it okay so what I'm doing is I'm going to first of all add this ax to this AIS list how can I do it I can do it with this AIS command that get me that list which I'm trying to add some new Val values so in the list you can add some new data point with the help of this upend command okay the upend command that you can see okay for some reason I'm not able to click it yeah anyway I'm successful in clicking it anyway so now exist the in empty list I want to append what this ax this is the handle okay this is the not the handle actually but the x's and the handles are the labels labels that I want to display so what am I appending over here I am appending this ax okay so what's going to happen for every iteration if the label that is present for the respective star type is not already present over here then what you do you create this axis and that axis what you're going to do you're going to pass it onto this particular uh list that we have created that's an empty list and after that what you're going to do is you're going to add a label to this set how am I going to do this I'm going to achieve this with the help of labels dot not append anymore it's going to be add directly that's how this kind of functions are built okay foret it's add for L it's append and now I'm going to add the label that is properties and label I hope the idea is getting clear it will be clear once the output is in in front of you okay now let's say if this label already exists in label then I don't want to add label to this kind of set then I I don't want to add okay then I don't even want to create this kind of exis in that case what I want to do is I'm going to give this else block and simply create my scatter plot without adding any kind of x's or any kind of that stuff okay so yeah that's the kind of logic that we have created I'm going to press shift tab shift tab yeah this is looking good so now we are expecting the output to be very decent it's not going to be as ugly as what we had seen okay we we have got an error let's try to look into the error it's saying that string object has no attribute get underscore label let's see where did we got this error this error is over here right it's because the labels right it should be labels let me check this to AIS and see how it works if the x is going to work then yeah I would have done an error yeah I would have I had done an error actually we had to store the AIS okay what is happening so this axis is giving you this kind of an command that okay for this particular point that you have plotted you want to display this label right and that Legend is automatically having this kind of labels right that's the kind of mistake that I was making Legend is already having access to all the labels that's the reason why we were seeing Brown WF multiple times red WF multiple times right so that's not a problem the problem is that if the AIS is present over here if I show you the AIS list let's go ahead and see it see now all of this is a path collection for each and every point there might be six 1 2 3 3 4 5 six what is the reason of this six because we are having six different categories right so for each and every point we are having this kind of AIS now what I'm trying to do is I want to show the label of Legend only for those respective AES or else I don't want to show it so that's the kind of thing that we have done over here and hopefully now it's making sense and now obviously you can beautify this plot by customizing by like you know adding uh xais y axis and all that kind of stuff and uh I can simply go ahead and copy paste this thing because I've already done this for a lot of times I copied that data and I'm simply going to paste it over here okay and let's see now how the output looks like and now let's see if you're also interested to add the data of sun okay in this whole thing I guess the diagram is pretty much small I'll also increase the Fig figure size over here figure size how I can do this with the help of PLT right figure and then fix size I'm giving my figure size as let's say 10 comma 6 I guess this is going to be fine okay now I just want you to realize that even after having a lot of experience in Python this kind of problems happen okay you need to go to the documentation and make things fine as a python developer it's our duty to go Ahad and make things right depending because we having access to all the kind of documents okay but right now I was able to solve this error because of the like you know the output of the error that we had got anyway the important part that I want to convey is that you should not be ever be frightened if you're getting errors okay if you're getting errors it's okay you should know how to solve those errors that's it if you are good at that you are good to like you know encounter any kind of problems in your life specific to uh at least the Python Programming questions okay but anyway uh if we are talking about this I'll just ignore this thing it's quite yeah disturbing yeah anyway this is the kind of output that we have got right for the HR diagram now one last thing is let's try to add the data for the Sun and see that where exactly on this HR diagram that Sun is going to be looking like okay so for that what I'll be doing is I'll be copying this data that I'm having for the Sun and simply add it into our code so I'm coming back to our code I'm going to give this kind of a title I mean the comment adding data for sun now what is this I'm creating one more xes specifically for sun because I also want to append this kind of thing and visualize in my output this is the temperature value I've gone to Google and got this kind of values this is temperature this is uh absolute magnitude this is the size that I'm keeping color is yellow marker is O and label is sun right and I'm simply also adding this AIS that we have created for the Sun and I'm also appending this labels as Sun okay now that's the whole point you will be automatically seeing that somewhere over here in the main sequence we know that sun is a mean sequence star so somewhere along this part our sun should be added just like this whatever kind of star you are interested to know about right you go and find its property on Star and try to plot it and see where it's going to be in the graph for us sun is over here right that's where the sun is and even in the legend you are able to see that sun has been added separately apart from all of this we are also adding a data point of sun isn't it just amazing how we have created this kind of whole thing by getting ideas of python that we have learned in our first module and then again some few things that I have taught in this particular video about how you can create an empty list and empty set and then how you can add data to it the whole idea over here was this thing okay if you don't know how this kind of things work then you will need some kind of experience of how set and this kind of list works but the only thing that you need to know over here is that we have created this kind of empty list and empty set to store the exis that is with respect to the plot that we are making over here we are trying to store it over here so that with respect to that plot I'm able to show the label that is present in the legend command in this Legend Command right so yeah that's the end of this particular video I hope you have enjoyed creating your own uh HR diagram right for the 240 Stars if you can see I have also given this kind of a dynamic way of writing this so that in future if star type is uh changing its length let's say we are adding more data to this existing CSU file then you will be able to create for let's say 500 Stars if there are more addition to the data right so yeah these are all the kind of plots that we have generated but I have not saved it right my common not common common so my common mistake is I always forget to save the figure size I mean the figure right that we have generated so save figure how am I saving it I'm giving my base directory and the name HR diagram yeah finally running this and I'll be also checking this before we end this video if this has been done fine or not coming over here looking into the star plots this is HR diagram close this see the beautiful plot right in front of you right the reason I haven't shown you how to do the title X label and Y label because you have been doing this for a couple of above plots right in the Y label I have added the absolute magnitude on the X label temperature given respective font size and the color as you know my favorite one is stab pink so that's the color that I given for them and for the title I'm giving the HR diagram title and a dynamic way of writing the title by giving the F string font size is 15 and the color is royal blue another my favorite color okay so yeah that's about this particular video guys I hope you have enjoyed this one hey guys so welcome to the last video of this particular module where you are going to understand that how you can download this visualizations that you have created in module 2 and saved it into a particular directory so now how you can save that directory into your system from Google collab notebook so all of these things we'll be learning in this particular video so let's get into it all right guys so now let's understand that how we can go ahead and download this star plots all the kind of visualizations that we have created over here from very Basics to very advanced level of visualizations you can do this with the help of because we are using see Google collab there are some specific ways in Google collab through which you can do this the one that we are going to do is I'm going to follow this method that you can see it right now on the screen okay the whole idea is that from this google. cab I I'm going to import files what are these files these are the same files that you can see over here everything that is over here we are going to get access to this with the help of this files right now what I'm doing over here the logic that has been implemented is that I'm going to create a zip file out of this folder okay if I just click on this option there is no option to directly download this folder right there is no option like that so what I'm going to do instead is to create a zip file off it because zip files are downloadable in Google collab so what I'm doing I'm creating this ZIP command and then I'm giving two things which folder I want to zip I'm just taking that particular folder pasting that same thing over here and just passing zip on top of that that hey in this particular path this is called content path in which the star plots exist so in this particular path I want to create a zip file that's it and once the zip file will be created it will automatically be downloaded by giving this kind of input to this download command Okay so this download functionality exists in this file okay so whatever is the file if you give the path to download that file it will be downloaded if I show it to you what's going to happen so if I run this code you will be able to see that a zip file will be generated and now you are giving this path in the download and automatically you are seeing that this kind of files have been zipped for us and also downloaded into my system I simply need to click on this and if I show this to you this is the content folder right inside which we are having the star plots folder and see here are everything that we need to know okay ignore this particular thing for example this is the star colors visualization that we had generated right if you want you can also obviously increase the size and everything right and then here is the HR diagram my favorite diagram right it took the most amount of time in the whole video program overall program not just one video right but yeah that's the that's the kind of output that we have generated so yeah now you can simply attach this kind of thing in any kind of research work that they're doing that was the whole point that with the help of a tabular data how you can create this kind of visualizations in Python with the help of Google colab and also extract it into into your system all right guys so it's time to buid a farewell to our module 2 so over here we used a tabular data set on Stars data and created some amazing visualizations with the help of mat lli and seone Library we looked into some of the different types of visualizations like bar graph box plot line plot pair plot and then eventually created a HR diagram with respect to the scatter plot and then how can we save this outputs that we are creating and download it into our particular system so all of these things we have done so far and I hope that you are enjoying each and every bit of this particular program now in the next module we going to jump into some image visualizations and do some amazing stuff over there so stay tuned for that I'll see you in that next module hey guys I welcome you all to the third module of this program here you're going to take one step forward where in the second module you had performed the visualizations on the tabular data now we going to create visualizations on the image data and therefore to start with in this module we are going to explain you what is the concept of an image then what is fits file because this is the file type through which you are going to access the astronomical images which you're going to perform some kind of visualizations on top of that then what is Sky View form how you can fetch the data of Andromeda Galaxy from astronomical surveys like sdss gmen and DSS2 blue then how you can Implement some of the pixel scaling methods on this anoma galaxy visualize the pixel distribution and lastly what is the concept of Z scale interval in a library called as astropy and why are we specifically using it for this particular program all of this is covered in this particular module guys so let's get into this module and I'll see you in the next video where we are going to talk about image hey guys welcome to the second video of module 3 where I'm going to explain you the concept of digital images in the format of pixels what are grayscale images colorful images and a lot more so let's get into it all right guys so let us go ahead and try to understand this concept about an image so what is an image I'll be first talking about how this kind of images are formed and then what are some kind of different things you need to understand about it so talking about how these kind of images are formed it's kind of a puzzle if you think about it okay let's say that you you are having different kind of pieces of puzzles which you are going to combine together to form this kind of an image that's the same kind of logic that we are going to use in order to understand how this kind of images are formed so this kind of puzzle pieces which are like you know coming together and forming this kind of one final image this puzzle pieces are nothing but the pixels this pixels are combined together to form what we see as an image over here so now what is this kind of pixels right we know about the puzzle pieces that there are some kind of pieces which are joining together to form this image but how do we know what is a pixel so for that what I have done is I just zoomed into this particular image as much as possible but not over here because Google cab is not allowing me to zoom any further than this okay so what I have done I have captured this image I have pasted it into the paint and on the paint I was able to zoom in much further as compared to what Google cab is allowing me so I got some kind of information like this okay so this particular part is being representing the top left part of the image okay so I'm zooming into it as much as possible and this kind of small small squares you are seeing right this is a small square this is a small square this is a small square so all of the small squares are nothing but the pixels and see how these kind of different pixels are there and all of these pixels which are coming together let's say you're just talking about the first row of the small squares all of these pixels are coming together to define the width of this image just like that there are also pixels over here which are stacked up together in this kind of a vertical line which is giving us the information about the height of this image at the same time they are having some kind of different shades of colors which are stored within it some kind of bluish color is over here some kind of very darker shade of blue as compared to what are there in the nearby pixels and similarly over here it's talking about the brownish colors over here it's talking about the dark green kind of color right so all of the small squares are hiding the information about what kind of shade of color is represented on that particular location of an image so I hope a very basic idea about how this kind of images are formed is clear this kind of images are the combination of this kind of pixels and each of these pixels are having some kind of information about what is the shade of color represented over here to show it into the output of the image right so let's say this is a piece of puzzle which is storing this kind of detail this is a piece of puzzles which is storing this kind of color of that particular detail all of these pieces of puzles are nothing but the square shape but now based on this kind of information of the shades of color you're are going to create an image that is something like this right now they can combine together to get the width and the height of the image at the same time how do we know about this kind of intensities of colors now for that we need to understand how these kind of images are form but I hope the part of the pixel is clear that how these kind of pixels come up together to like you know what we see right now in this particular image right now if we talk about how this kind of intensities of colors are coming into the picture how do we know that what kind of shade will be represented by what kind of part in the image so to understand that particular part we need to talk about the sensor that sensor is nothing but the camera that I was talking about when I started this particular video so let's say we are having this camera and in this camera we are having three different filters one to capture the red light coming from whatever is the source which sensor is trying to capture similarly whatever is the greenish kind of part that is being captured will be done with the help of green band filter and similarly for a blue color whatever is the bluish part over here you can see there's some kind of a blue part there is a blue part over here and also a blue part over here so all of the light hitting to the sensors coming from this kind of bluish part will be filtered out with the help of the green sorry the blue band filter right so now what's going to happen we know that typically all of these colors that we see different kind of shades of colors that we see are the formation of like you know different kind of mixes of red green and blue we know these things from our very primary classes in school right or in the art school art classes right so now this kind of different combinations of red green and blue will be captured from this particular image with the help of the S set that is camera and how with the help of this kind of green band filter Red Band filter and the blue band filter now the whole logic over here is the way that it is being captured is with the help of what kind of wavelength of light is contributing to the red part of the visible spectrum now I'm going into much more technical terms let's not go into that particular direction and talk about in a very simple terms whatever light that you are seeing over here is being coming to the Sor if it's falling into the red kind of region then that will be filtered out with the help of Red Band filter similarly for the green light and the blue light and the output of this is representated always into this kind of a grayscale image okay now if we talk about the image that we are going to deal with throughout this whole module is an 8bit integer image now different kind of bit of pixels uh stores different amount of information okay so let's say I'm having a comparison of an 8bit pixel to a 16bit pixel more this kind of 8 Bit And 16bit pixels more the combination of shades of colors it can represent that's a very simple idea about like you know 8bit image and a 16bit image in 16bit images you'll be able to represent a particular color with a more amount of Shades okay more amount of depth basically you'll be able to get from an image right so if I talk about the image that is an 8bit image that we are going to deal with in this whole module let's talk about that so in that 8bit image all these pixel values are going to range in between 0 to 255 to represent any kind of information let's about the Redlight coming from this particular image I mean from this particular part and hitting on the C answer if it's coming from the red uh sources red light sources it's going to be representated into different 256 sides and the values are going to be in between 0 to 255 that's the whole concept so 255 being the lighter part of the whole image and the part which is represented darker are closer towards the zero side so what does this kind of number 0 to 255 indicate so 8bit integer image is going to give you 256 different shades of a color maybe red green or blue right so now if you going to combine them red green and blue so 256 into 256 into 256 these are the possible Shades you can get and form a whole colorful image that you can see over here okay if you increase this bits let's say 16 bits per pixel then you are having 2 to ^ of 16 multiplied by three times to basically get even more shades of colors as compared to an 8bit image okay so that's that's an idea with respect to this but now let's try to observe that if I talk about this kind of bluish part this is a blue part of an image this is another blue part of an image this is another blue part of an image and now if I talk about blue band filter it should be able to filter all of this things and give a very high value to it that is 255 the lighter part of the blue band filter should be representing the blue part so I'm having this kind of uh blue part that is like you know surrounded by potatoes over here then on top of this kind of apples we are having this right so if I try to show you the output of the blue band you can see that this part is light this part is light right this whole part is light as compared to the above images in green band this part is darker this part is darker in the Red Band see even this part is darker and this part is darker right so that's what I I was trying to show you that because with the help of blue band filter that is stored in the sensor that is camera it is able to get this kind of blue light and give a high value to it that is 255 closer to 255 similarly if I talk about let's say greenish part in this images which are this kind of grapes right this kind of melons right if I show you them over here you can see that they are again expressed in the lighter pixels that are values closer to 255 as compared to this one see how darker they are closer to the zero right the darker pixels are closer to zero so how these kind of things are representated by a darker color right similarly if you talk about this kind of red Parts in the images you can see these are kind of apples which are red these are tomatoes that are red right if I try to show them over here see how dark it is in the green band filter but if I talk about the Red Band filter see how lighter these kind of things are all of this information are represented by the pixels which are closer towards like you know 200 255 kind of side right so that's the whole idea now you might be wondering that potatoes that are given over here are yellow in color right then why in the green band and the Red Band we are having the lighter pixels so if you think about a yellow color It's a combination of the red color and the green color now that's the reason by even in the green part and the red part you are able to see this lighter part in the image now what is the exact shade of red what is the exact shade of green out of the possible 256 combinations they're going to come together and finally form this kind of a yellowish image in the final output if I show you that potato in the blue part you will see it's a darker color as compared to the green and the red you are seeing that this part is darker right anyway there are again some kind of blue pixels that are also there some kind of shades of blue let it be a darker part right all these kind of things are coming up together and give you this exact color that you are seeing over here so to just summarize the whole concept of an image we first understood the idea about what are the pixels because with with the help of this kind of small small squares that you are able to see these small small squares are coming up together and giving you this kind of the like you know this kind of how what is the width of the image what is the height of the image and if we talk about the intensities of the colors that are represented by this kind of small small squares is dependent on how much amount of uh shade of red is present what is the shade of green is present what is the shade of blue is present at the time of capturing that particular image and depending on that based on this red band green band and blue band filter we are getting some kind of respective outputs and all of these values are stored in the range of 0 to 255 255 being the lighter part zero being the darker part of that specific output of the filter then you combine all of these three images with respective shades of green red blue and finally whatever are the shades that you can create is the final output of this image so wherever there was a bluish part right all of these pixels came together join are combined together stacked on top of each other and this part where the blue is present this kind of color will be there on this specific location what is the output of the blue filter what is the output of the green band filter what is the out of the Red Band filter combination of all of this three because the bluish part is higher in color that's why this kind of pixel is given some shade of blue by combining this RGB possible combination that we are getting from the sensor this is the color that we are able to fetch so I hope I'm able to convey the ideas with respect to like you know what are this images how are they formed because this are the building blocks that we are talking about about this module as we go ahead we are going to actually represent all of these images into the format of pixel how are you going to do do this you will you will be seeing this in the upcoming vide so stay tuned for that hey everyone welcome to the third video of module 3 and now that we are going to deal with the astronomical images they are typically saved in the format of fits file so it's essential for us that we understand what exactly is this fits file and what kind of things it typically contains so let's get into it and understand about all of this information so now let's try to have a very quick idea about what are Fitz files so in the Astronomical Society this is one of the very popular way in order to store the data that we are getting from these telescopes in order to load it into our system and let's say we are uh doing some kind of image processing on top of that and doing some amazing research analysis of what kind of information is stored in this kind of images captured by the telescopes now that's exactly what we'll be doing in the upcoming few videos and that's the reason why I am explaining you over here about the Fitz file because you are going to fetch the data from one of the astronomical surveys that is the Andromeda galaxy it's not going to look like this at all it's a very raw image that you'll be getting from the telescope and then how you able to get that image it's stored in the format of Fitz file so what are the components of the Fitz file let's try to understand that so Fitz file is having multiple different header units at the same time all of these header units are also coming up with some kind of a data now this data could be in the form of images it could be in the format of uh different tables Etc right so right now because we're going to focus on the image data let's just understand what are these kind of two main components you need to know about the Fitz file the first thing is the header unit and all of the Fitz file will come with the primary header unit for sure and then some kind of extension header units that are going to reveal about some more information about that specific image that we are trying to talk about so typically this kind of header units are storing some kind of metadata which is revealing the information about let's say for example what was the telescope used to capture that specific uh astronomical object what is the location of that astronomical object out there in space for example what is the uh right Ascension what is the declination these are nothing but the space Celestial coordinates that we are having to get an exact precise location of the astronomical body out there in space right so we are able to get all of this kind of information with respect to the header unit I'm going to show this kind of live demonstration for this kind of uh Andromeda galaxy by the way this is the closest galaxy to the Earth if you don't know right it's going to be really very amazing thing we are going to do in the few upcoming videos for this module right so we're going to study about this kind of header units and all of these header units might have some kind of data we're going to also extract this data and do some image processing on top of that to reveal some of the amazing Beauties about this androma galaxy right now obviously you are seeing a very highly detailed processed image we not going to get anything very close to this but yet do some kind of research work in terms of doing some kind of image processing and get some kind of of analysis as in like you know you can see there is some kind of a small Galaxy over here right on top of that huge Galaxy right we'll be able to get all of this information by doing some kind of image processing right so all of these things you'll be seeing in the upcoming few videos so stay tuned for that hey everyone welcome to the fourth video of module 3 so far we have just covered this kind of theoretical understanding of what is an image and because we are going to deal with the astronomic iCal data and typically it's going to be in the format of fits file so we have also covered that so far but now it's time to start the coding process and as usual you know we going to import the libraries and if it's not pre-installed in Google collab we are going to first install it and then import it so let's get into the video now as we are going to perform some of the image processing tasks throughout this module on this astronomical data called as anoma Galaxy uh so how we can collect this data from lot of astronomical surveys and call it into our Google collab notebook we can do this with the help of a library called as asro query so now like matplot Li this is not pre-installed in the Google collab environment so you will have to manually install it by using this command called as pip install and the name of the library that is Astro query and you simply run this code and it's going to take some seconds and simply install it for us in this Google collab environment now the moment this is done you will require one more Library through which you will be performing the visualizations and as you might have guessed it is M plot so I'm also going to import matplot lib along with that pip plot as PLT now it's not that we are just going to use m. Li okay as I also installed this kind of Astro query you're are also going to use some of the functionalities of this particular library in order to call that image as I mentioned about the androm Galaxy and along with that there's one more Library called as astropy even that is the one that you're going to use in upcoming videos but for now there were only two basic steps that I really wanted to show you that with the help of what library you will be calling this image of entoma Galaxy into your Google collab notebook and then obviously in order to visualize it what is the library that we are going to use that is met plot now in the next video you are going to see some of the amazing things uh through which you are just going to be completely shocked like you know these kind of things we can do in Python so stay tuned for that hey guys welcome to the fifth video of module 3 and here we are going to take a look onto the internet's virtual telescope with the help of Sky View form so what exactly is this form and how we can get the image of the anoma Galaxy out of this let's look into that in this particular video so let me introduce you all to this interesting form called as Sky View query form now with the help of this form you're going to get this access of this Andromeda galaxy so if I just click on this particular link it's going to redirect me to that particular site where I can access the sky view query form so what is this form all about as you can see it is the internet's virtual telescope so with the help of this particular query form you can query about any kind of image that you're looking forward to that is M3 31 in our case that is Andromeda galaxy so for the Andromeda Galaxy from all the possible available surveys over here we just need to give some of the selections that we want to visualize our M31 in so the telescope that we are going to use is the sdss and DSs and both of them are in the optical range and uh with the help of sdss I'm going to perform some of the uh image processing task and with the help of DSs I'm going to show you the whole output of how this kind of Galaxy looks like in Python okay we're going to do all these kind of things in the upcoming videos but for now let's see if I want to visualize this data in this form itself without using python how can I do it so for example if I'm clicking on this SD SSG and click on enter because I have already pre-selected this particular object as or source as M31 that's the entoma Galaxy and I'm using this particular survey called sdss of gband is going to give us this particular output now what is this this is the extreme center of the Andromeda galaxy or I should say the core of the Andromeda galaxy so if I just have to show you over here the extreme core over here this kind of like you know this kind of bright part you are seeing this bright part so that bright part if you are trying to just dim that thing and look exactly into the center that Center is nothing but what is visualized over here just in case if I really want to show you what this means this is very zoomed in version of what's going on in the center of this particular core of Andromeda galaxy and we are going to perform our all the kind of image processing on top of this particular output but now what if I want to like you know just zoom zoom out a bit and show you with respect to some other uh survey that is the S DSS and let let let me select this DSS2 blue and uh I'll just what I'll do one thing I'll clear every survey sections and then again select this blue and this time I'll just change the setting of image size pixels from 300 to 600 and now if I submit this request see this is the kind of output that we are seeing I have zoomed out only by a bit I have doubled the pixel size so I'm getting much more output as compared to what we were seeing for a much larger output but now it's still like you know if I just compare it with the original image over here it's this kind of part that you are able to visualize if I just zoom in say I'm not able to zoom in any further than this but now this is the power of the telescope images that we are having this is visualizing at the extreme center now over here in this specific image you are not able to look into that extreme core because we are we have zoomed out a bit however you are able to see some of this kind of bands or of this particular Galaxy and this bands are nothing but the bands that you are seeing over here so this is a very zoomed in image now what I'm going to perform over here for you guys in the upcoming videos is that with the help of this uh DSS2 blue we are going to try to visualize this whole Li uh not library but the image the whole image of this uh Andromeda galaxy I'm going to try to visualize this kind of thing for you uh with the help of a DSS2 blue and then with the help of sdss G that 300 by 300 pixels that we had seen we are going to perform image processing over there and try to decode what all kind of structures we are able to find out of that simple looking thing that we had seen earlier this thing okay I guess oh I selected two surveys this is the first survey and this is the second survey right this was the first DSS2 blue and this is the second one that was the main reason why I primarily went away over here and clicked on uh clear survey selections because I could I don't want to see both the things I just wanted to see one but anyway these are both the surveys over here uh on with respect to DSS2 the zoomed out version 600 by 600 and over here this is 300x300 focusing extremely on the core of this particular Galaxy so now in the upcoming video we are going to call this data of Sky View query form with the help of Astro query Library into python so it will be really interesting to see how we can do this so stay tuned for that hey guys welcome to the sixth video of module 3 and here we are going to use the Astro query library in order to get the access of the sky view that we had seen in our previous video and from there we are going to fetch this data of Andromeda Galaxy from a particular survey that is sdss specifically gband okay all these things you will be understanding in this video but the output of this will be of Fitz file and now that you are also aware about the Fitz file it will have two types of information header and data so header will consist of metadata and data will have some kind of image present over there so we going to take that image data and visualize the output of the anoma Galaxy and just compare it with the actual view that we had for the anoma Galaxy using the sky view form so now that you are aware about what is this Sky View query form where you can give in the information about the source that you want to visualize with respect to any of this available survey options right now we have already visualized with respect to Optical sdss and DSs but now specifically if I let's say want to visualize this sdss G in my python so basically what I'm trying to do is I'm trying to I hope this is yeah this is sdss gband so I'm trying to visualize this particular information with respect to python so how we can do this with the help of Astro query Library let's try to look into that so for that what I have to do is first of all I need to get this Sky View functionality in Python and I can do this with the help of estro query library with this command EST from estro query. Sky View I need to import Sky View class so with the help of this Sky View class we are going to use one of the method of this Sky View class through which we can fetch this data of M31 of this particular server and I can do this with this command sky view the moment I press this dot it's going to give me all the possible methods associated with this Sky View class and now because we are interested to get this images I'm going to click on that and now let's see what kind of inputs we can give to this particular method so I'm just pressing the parenthesis and I'm just waiting for a while and now this is the kind of popup that I'm able to see automatically on Google collab and the first input is going to expect is the position which is nothing but the M31 in our case the second input that is expecting is the survey which is going to be SD SSG in our particular attempt that we are trying to visualize something all the kind of other information you can keep it as of whatever it is I'm not going to change anything and we are going to do a lot of different stuff on top of that that's why I'm not changing any kind of things as of now and uh so yeah let me give the input of M31 as the position and the survey as SD SSG and the moment I run this I am getting a list within a list right I'm getting this kind of square brackets which is called as a list and inside that I'm having one more list and inside that inner list I having this kind of a file now what is this file this is a file which is called as a fits file that we had talked about ear earlier in this particular module we had talked about how this kind of fits file is created it is having some information about a primary header for sure and some of the metadata associated with that now along with that it might or it might not have this kind of extension uh headers and the data associated with that so in our case as we are seeing only one primary header it's basically indicating that we are having information about the primary header and with respect to that what is the metadata with it and any kind of extension information is not given to us and that's the reason why we are having only one information within this kind of main list now that's exactly what we are going to fetch out of this list and get this hdu file from it how we can do this first of all I'm having this kind of the original list the main list inside which there is one list so let's get access to that inner list I can do this with the help of this index zero because I know that this particular list is present on the zeroth index now if I run this code and show you the output let's see what do we get so as expected we are now into the inner list now inside this inner list we also again see that this hdu file is present in the zeroth element on the first position basically so I again need to pass this zero and now we are successfully going to get this hdu file that we are looking forward to and now this is is nothing but the primary hdu so I'm just going to store it in a variable called as hdu now always remember HD is coming with two different type of information one is the metadata which is going to give us all the kind of details with respect to the Fitz file who has created it when was it created the information about the telescope and the survey that was used to fetch this particular data every kind of information will be stored as a metadata in the format called as header now along with header there is one more kind of thing we call as data now that data as I explained earlier could be in the format of an image could be a tabular data right all this kind of information could be there so now let's try to understand first of all the metadata that is associated with this primary hdu now I can do this with this function called as header of this hdu so hdu do header this is the only command that I'm typing to get all the metadata information associated with it now as you can see that this is the file written by the sky view Thursday December 14 uh with this particular uh time and everything the information when this particular file was written after that we are also having this particular idea that it is containing a twood dimensional image as well what is the width of the image 300 what is the height of the image 300 if you remember in the sky view form itself by default it was having 300 pixels if I don't write this if I just refresh this by default it was giving us this 300 and that's the exact reason why we are having this 300 by 300 I can surely go ahead and manually change this to 600 if I want but I'll be doing this for the other Optical survey that is the DSs survey right uh this particular survey DSS 2 I'll be showing that in the upcoming videos but let's now focus on this particular part see by default the pixel size is set to 300 so that's the reason why we are again saying this kind of 300 by 300 so all of this information with respect to this see again there's a comment with respect to Sky View survey metadata right then all the respective information the copyright information survey information uh projection information coordinates information uh Epoch information all of this particular thing is given over here in the sdss there are multiple data releases this is part of data release 9 dr9 again this kind of information is there so obviously it will take a lot of time for me to explain each and every part of this metadata you get used to it once you're having more and more practice with respect to like you know dealing with the fits file specifically the astronomical data but right now the key takeaway for you is that in this Header information of the hdu file you get this kind of basic information right you can just keep on scrolling and get any kind of respective useful information for for you so that was about with respect to metadata now what about because we know that it's also containing some kind of image how can I fetch that image out of this particular HDO file so for that I'll just scroll down and see here I also written the comment that get the pixel data that is present from this hdu now I simply need to do hdu do data how I did hd. header for the metadata just like that I need to to do hd. data in order to get this pixel information and as we had seen it's in the format of float 32 where we had seen this uh if I just scroll up this is where we had seen this now it's like you know it's also including some kind of negative numbers and it could have positive numbers and it's of a float 32 type it's a floating Point numbers of array and is a float 32 type again in the beginning of this particular module i x explained about this images all of this kind of pixels so this pixels are in the range of 0 to 255 or a uh uint 8 image but right now we are dealing with the float 32 Type image and it's a like you know the sign is also playing an important role it means it might have some kind of negative data some kind of positive data okay don't worry about all these kind of things I'm not going to go into any kind of uh further technical details but see now we are having this kind of a data and it's of a type float 32 even this kind of information was present in the metadata so over here this is nothing but the M31 pixels data I'm going to sh store this particular thing as the M31 pixels data because this is a format of an array so this array is nothing but in the format of an image and now check the type of uh this particular M31 pixels that we have created now I have already told you that it's a array now how do you know it's a nump array you can use this functionality of type and just pass in this M31 pixels if I run this it is a numpy array numpy array and dimensional array basically okay now what is the shape it must be 300 by 300 by 300 as we had checked in the metadata so let's even try to check that M31 pixels dot shape it must be 300 by 300 if not then we are doing some kind of mistake see it's 300 by 300 the exact same thing that we had seen in the metadata right now the next thing that we are going to do is to visualize this particular image now how we can do this I can do this with the help of pl. IMO in order to visualize any kind of numpy array any kind of array data associated with num Pi ARR if you want to visualize it you use this PLT and then I am sure now with respect to that you given the information of the array that you are trying to visualize and you just hit uh run this particular code cell and let's see what kind of output you get this is the kind of output you are getting currently right by default the color map that we are able to see this is VAR it is okay if I show you C map is equal to vus so by default mat plot lab is going to get this color map of vus see you can see there is no change because by default color map that was used for this 2D image 2D image means a gray scale image okay so I can also convert this into a gray color if I want even that is fine because this is the kind of some kind of similar output that we had seen over here now let me tell you that there is some kind of pixel scaling that has been done on top of this image that's why you are seeing much more information as compared to this raw data we are seeing over here and that's exactly what we are going to do in some of the upcoming videos so stay tuned for that but for now what I'm really uh interested to show you over here is that our data is starting from 0 to 300 but on the y axis it's going in the opposite way zero is on the top so we need to bring down this particular origin over here so how we can do that I can can simply pass in the command of origin is equal to lower inside this IM show itself so now if I run this you will be seeing that now the origin is uh over here and now this is the kind of the center that we are seeing over here and how we can reveal a lot more other information as you can see over here of course I can give some of the uh input parameters like you know I can just change some of the input parameters while calling this uh image get image but I'm not going to do all that kind of stuff I'm going to show you manually how you can try a lot of different ways of pixel scaling in some of the upcoming videos okay right now in this video I just wanted to show you that out of these two survey that we are going to use how I can show you at least one of the survey so that you are able to appreciate that yes with the help of this Astro query Library we have imported this class called sky view from this sky I there was an method called as get images now this is going to give us the fits file that is written with the help of estrop Library not estr query but estrop Pi okay again estrop is one of the library in Python which is associated with this estro query also so with the help of that estrop Pi we are writing that fits file so because it was in the format of a list we are extracting this kind of list data and getting h from that and once we got that hdu out of it we are looking into the metadata and any kind of data Associated along with that metadata and for us it was image uh in this particular case it's not always image just remember that over here we were having the image data we took we took a look onto the what type of that uh D array was it's a numpy array basically and we can check this kind of shape on top of that that is 300 by 300 and also we have visualized this by Shifting the origin to the lower so that this kind of z0 is matched now in some of the upcoming videos you will be seeing that with the help of the pixel scaling techniques how we can convert this kind of raw data into something like this okay and along with that I'm also going to show you in some of the upcoming videos in this module that how you can visualize this kind of overview I'm not going to add any kind of color information okay I'm not going to do any kind of that kind of uh color processing I am just going to show you that with the help of this Sky View how you can look into this kind of bigger output also a zoomed out version also okay so I'm going to give you all of this information in the upcoming few videos so again just stay tuned for that hey guys welcome to the 7th video of module 3 and here I'm going to show you one another survey with respect to which again we are going to fetch the data of Andromeda galaxy but this time we are also going to tweak in some of the parameters so that we are able to not just see the core of the Andromeda galaxy rather the overall Galaxy that you must be seeing on the internet all over whenever you are searching for the Andromeda galaxy so that's the kind of output that I'm looking for not in terms of colors but at least the image which is clearly showing you that yes this is the Andromeda galaxy so that's something that we're going to do in this video so let's get started so now that we were able to fetch this information of the Andromeda Galaxy from the uh s dssg Optical survey that we were having now we are going to go ahead and call this DSS2 blue and visualize the output in a much more zoomed out fashion as compared to what you are seeing over here okay how can I do this with in Python let's try to understand that so again what I'm going to do is first of all I'm going to copy this this part of the code and come down over here and uh call this but now at the same time I'm going to change this to DSS to Blue right now along with that now because I want to see the zoomed out version of this I need to pass in further more arguments over here in the get images so one thing that I can give apart from the position and this survey is the pixels now inside this pixels information what all kind of things I can give I can give by default it is 300 by 300 I can let's say give 600 but now at the same time I'm also going to increase the radius of it so that we are able to see much more wider view of what we are seeing over here okay over here also 600 by 600 is still giving us a little bit zoomed out version but I want to expand the radius of this particular image so that we are able to see a lot more information in this 600x 600 so for that I need to say let's say for example 150 now I need to convert this into arc minutes okay I need to convert this into arc minutes how can I do this I can do this with this Library called astropy that I talked about in the previous video so from astropy dot or I should say import estrop do units as U and this U that is the units will help us convert this 150 into the arc minutes how I'm going to multiply this uh into U do AR mean that is Arc BS and now if I try to just run this particular cell okay it's giving me some kind of an error the spelling of pixels is incorrect no problem now if I run this I'm going to sort that out it's going to take a little bit more time as compared to what we had seen in our previous video to fetch the hdu file because it's taking a lot more pixels and also the radius is very uh like you know we have increased the radius and therefore now if I go ahead and try to get only the pixels data from this hdu data okay and this is nothing but the like you know M31 with respect to DSS2 blue pixels and now if I try to just run this code and look into the shape of this M31 DSS 2 blue pixels do shape it's going to be 600 by 600 but now just look into the magic the moment I'm doing PLT do IMO of the same thing giving the color map as gray and at the same time I'm also uh doing origin is equal to lower I run this now see this is the kind of image that we are seeing the same image that we are having over here very similar to this we are able to see that there is one more Galaxy near the Andromeda galaxy this is the satellite galaxy of the Andromeda this messia 32 is one more satellite Galaxy to this Andromeda and this galaxies are going to like you know come and collide with the Earth right in some billion years ahead and form a combination of Andromeda and Milky Way We also call it like you know as milkomeda there is this kind of name that we have given to this like you know when this kind of collision will happen between the Andromeda galaxy and the Milky Way galaxy we will call it as mil omeda and milk droma something like that okay there are some weird names we have given that is the combination of both of these galaxies but anyway see now we have exactly got this data that we were looking into I'm not going to add any kind of color information just look into the moment I have changed this kind of uh particular survey we are able to get this kind of output the whole anoma galaxy you are able to see over here this is M Messier 110 this is year 32 all of this information we are able to see even over here there is a star cluster even that information is visible so we have done all of this with just one line of code over here but now this is not what I really want to do obviously we've got all of this things this is really very cool right but now let's do some of the image processing with respect to this score of this Andromeda Galaxy now that's something that we'll be doing in some later part of the uh module before that let me show you because we are having a lot of information with respect to a Header information even this kind of image information if you want to create your own fits file just like how these guys are creating this fits file if you want to create your own fits file like this how you can create it after that we'll be jumping onto all the kind of image processing and interesting stuff before that this one part that I really want to show to the people who are really interested to know how this kind of fits file are made so for that just watch the upcoming video and you're going to get a good idea about how you can create your own particular fits file hey everyone I welcome you to this eighth video of module 3 where I'm going to teach you how you can create your own fits file so obviously we don't have our own telescope like you know that's going to capture all of these kind of things and get our metadata and also get the the image so what we are going to do is we are going to use the same header and the image that we have obtained in one of our previous videos of the Andromeda galexy use that as the dummy data and create our dummy fits file okay so how exactly we can create it is what I'm going to show you in this video and once it is created we are also going to test it and see if it's working just fine as we expect it to work right so let's get into it so let's try to understand that if you're having this kind of metadata information and this kind of image data information with you then how you can create your own fits file just like how we had seen Above So for that I'm going to use this Library called as astropy just like what I had shown you in the upcoming uh I mean in the previous videos that over here the hdu file is in the like you know format of astropy do. fits so to create your fits file you need to import this particular thing in Python first of all so that's exactly what I'm going to to do in the first step over here I'm going to say that from astropy import I should say from astropy doio import fits so now it's going to give me the liberty of creating the fits file and you had seen that it was in the format of a list right within a list there was the hdu file that we were having the primary hdu file so we are going to take the same exact metadata dat that we had seen over here right and I'm going to store this metadata over here as let's say M31 Header information okay and at the same time we are also having the information about the pixels so I'm going to add the same data into my separate hdu file that I'm creating because obviously I'm not having any kind of existing metadata or the image data so I'm going to use the same information to create uh complete fits file from scratch so for this what I have to do first of all I'm going to initiate this kind of empty list that I'll be creating with the help of fits and I can do this with this command fits. hdu list it's going to help us store different hdus within that list and I'm going to call this as the hdu list okay like this now the second thing is to create the primary hdu the moment you are creating this empty list you need to pass in some kind of hdu information so the one that I'm going to create is the primary hdu okay uh it's not dhu it's hdu and how we can do this again I'm going to use this fits but on top of that I'm going to use primary HD now what this is okay first of all let me show you what this is this will be an empty list and in this empty list I'm going to pass in this hdu file that I'm going to create I'm going to copy this also I'm going to paste that over here so see this is again an astropy i. fits file it's going to give us the primary hdu but now what if I'm trying to let's say give this uh as some kind of a name called HD1 for example okay and now if I'm trying to look into HD1 do data if I'm just doing this it's it's not having any kind of information as of now in the primary hdu it's completely empty even for the header it will have some of the basic information that like you know it's uh conforming uh to fit standard then it's a array data type it's not currently having anything number of Dimension is zero right so we are going to fill all of this kind of information over here with respect to M31 metadata that is the M31 header and in place of data we are going to pass in the pixel values that we were having so let's try to do that first of all we are going to add the pixel data how we can do this we can say that hdu one that we had created because now it's a primary hdu it's coming in uh with this functionality of data and what is this data this is the M31 pixels that we had created earlier similarly that like that I can also add HD1 do header what is this M31 header that we just created a few seconds back so now what I'm doing I had created a primary hdu in that primary hdu I adding some kind of data information I'm assigning this M31 pixels to this HD1 data which was initially empty when I had showed you over here right and after that I'm also filling in the information about the header assigning this M31 header that we had gone above now once this uh hdu file is ready once this hdu one file is ready if I run this code now and I show this hdu one. data now now it will have this kind of information see even the Header information it will have because I assigned this kind of uh data to the HD1 that's why now it is having the data now our duty is to pass this uh primary hdu into the list that we had created that is going to finally create one fits file for us right it is having some list within this list we are having this hdu so how you can do this we know that we can add any kind of data to the list with the help of append function so what I'm going to do is I'm going to call hdu list. append and what kind of information I want to add it's the hdu one information which is nothing but the primary hdu that we had created over here that's it so our fits file is ready now in order to download this fits file or to write this write this fits file what I'm going to do there is a functionality called as right two right two is going to help us finally save this fits file so what I can say let's say hdu list that's the main fits file right a list within that list we are having the primary hdu so hdu list I want to write to this particular list as the fits file we can call it as a dummy dummy fits file Dain fits file and that is in the format of fits so do fits right so HD list. WR to and giving it a name this if I run this code and if I look into this file storage you can see that this fits file has been created for us the same fits file that we were importing from the sky view uh query you are now able to save the same information into the fits file and now you can like you know also do a lot of different things with this but right now that's something that I really wanted to show you that if you want to create your own fits file how you can do this with the help of astropy library now that we are uh creating this particular hdu file for the primary header I mean primary hdu like this you can create extend uh extension headers also if you're having the information you just do a fit. extension header and you give some kind of data to it give some header to it and append that particular hdus that you are creating in the HD list and then again do this right to for that list that you have created and you will be having even the extension headers if if you are having okay so yeah it's something that you really want to experiment by yourself uh if you're having multiple header and its respective data information so you can create multiple extension uh to the hdu file or the fits file okay so now let's try to open this fits file that we have have generated how we can do this I can do this with the help of fits. open if you are having access to the fits file you copy this path you give this path as an input to this where it went it's over here you give it in the format of a string let's say I'm calling this as some kind of like you know again let's say my bit something like that okay my bits is equal to this if I'm running this okay let's uh look at into this particular let's say what is my fits so it will be a list and within a list there is this kind of hdu primary hdu that we had created right so now what is present inside the first index of this bits obviously this thing so my fits of zero is having what it's having this kind of primary hdu file that you had created with the help of estrop py. i. fits now if you want to check this header information so you do my fits of zero. header you could have also saved it into some kind of a variable called uh dummy hdu and then you can take dumy hd. header even that is fine so you can see now there is a header you can also do uh this for the data part the pixels part my fits 0. data right again now you can store it as a variable let's say this is uh dummy data variable and I'm saving uh this data over here and then I'm taking checking the shape of this Dy data variable. shape so because M31 was the sdss from that particular sub we had got that data it's by default 300 by 300 so that's why we getting that particular shape and if you want to get the type of the variable you do type of the that dummy uh data variable check this it will be a numpy array right so as you can see I've also cross checked this particular thing the moment we were creating it and even after creating it once we are saving it I am also importing it back with the help of fits. open command and checking all of this if it's working in a proper way or not and yes that's how you can create your own fits file if you're having access to the Header information uh as well as the data information so that's what that was about how you can create your own fits file now in the upcoming video we are going to talk about the pixel scaling that we were mentioning about before this particular video and that's where the fun begins guys hey everyone I welcome you all to this ninth video of module 3 where I'm going to show you the distribution of pixels with the help of an histogram but before that I'll also be showing you the summary statistics of the pixels that we are having of the Andromeda galaxy and after that I'll be showing you the visualization so let's get into this video so first of all what I'm trying to do over here is to get the summary statistics of the numpy array that we had created for the M31 pixels what is this M31 pixels if I just give you a very quick summary of this so M31 pixels was the uh value of the image data that we had captured from the fits file that we had seen for the uh slow digit Sky survey gband so from this we had fetched this particular information of the numpy array which is nothing but the array of pixels which is eventually forming this kind of output I'm going to set the color map is equal to Gray and also set origin is equal to lower for the same reasons that you had seen in the previous videos and the output that you'll be seeing over here is like this a plane output which is just highlighting the center part of the Andro Roma Galaxy like this but everything else is just black as compared to what you are seeing over here this is a much more detailed output that we can see as compared to at least what we are having over here so how we can get this kind of outputs by doing what changes on the pixels we can get this kind of output that's something that we going to look ahead to but now for that we need to understand what's wrong with this particular image so for that we need to do some kind of basic study on the pixel values which is able to give us this kind of an output so for that we need to check the summary statistics of this particular pixels so how we can do this I'm going to Simply use numpy that's the reason I have imported the numpy over here which I haven't as of now so import nump as NP so yeah now let's go ahead and try to uh print summary statistics of M31 pixels and excuse me me if my uh spellings are incorrect because I'm not good with them but now the first thing that I'm trying to print over here with the help of F string is the minimum value that is present in this whole array of pixels out of all of this 300 by 300 image that we are having where we are having or I should not say where but what is the minimum value of the pixel that we are having so let's say minimum is uh NP do mean of the pixel that I'm trying to find I mean of the array that we are trying to find if I just run this code you can see that the minimum pixel value is 5.35 something right and just like this because I want to find the maximum value also what is the average value of the pixel what is the spread of the pixel I'll also be needing the maximum mean and the standard deviation values of this particular array so after minimum I'm going to look for maximum I'm going to look for average value that is the mean and the spread basically basically uh over here is referring to the standard deviation okay so don't worry if you're uh looking into this kind of uh terms for the first time it's completely fine STD now let's look into the overall summary Statistics over here the minimum value is 5359 of the pixel the maximum value of the pixel in this array of M31 pixels is 178 now if you talk about on and a average on an average in this M31 pixels array what is that value of pixel it is 13. 329 something so on an average the pixel values that you will be seeing will be more towards the minimum side it's not exactly in the center it's very much skewed towards the left hand side uh of the pixels that is towards the minimum side so if you want to get more sense of this particular data we can also visualize this and look into the reason of like you know why we are having this kind of 178 because minimum is 5.35 and the average is about 13 something then how come maximum is 178 over here so it could be there is some kind of noise that is present uh over here in this image I can also prove you this with the help of what is the pixel value that is at the brightest spot that we can see over here that is exactly at the center because remember that this kind of uh images that we are having is directly from the telescope who is focusing or I should say which is focusing at the extreme Center of that Andromeda galaxy and with the help of uh the metadata I can literally show you what is that reference pixel okay so if I just scroll up so over here now we can see over here see X reference pixel is 1 15.5 and the Y reference pixel is again 1 15.5 so it basically means that this is the center which was focused by the telescope in order to generate this particular image so that's where we expect the maximum value of the pixel to be there so again if you want to just cross check that part you can do this with the help of um M31 pixels located at 150 comma 150 because we cannot give any kind of uh float values over here to get the location of the pixel so it is 148.5 what what about 150 1 and 151 oops yeah let's check this value it's 126.5 so both of these values are again far away from 178 so it basically means there is some kind of noise that we are having in this particular data and again we can go ahead and visualize this I can also first of all give this particular thing as a comment as uh visual or printing the value of pixel at the center of androma Galaxy right so yeah that's something that we are having over here and now let's try to visualize the distribution of these pixels with the help of histogram now you can again create a histogram with the help of M plot Li so what I'm going to do is I'm going to say PLT do hist for histogram I'm going to give the M31 pixels to get the distribution of the pixels of this thing so for example let's say we are having 300 by 300 pixel values uh over there whatever is the pixel that is present how many times you were able to see this in the array so that kind of distribution you will be seeing with the help of this uh histogram okay now I guess there is some kind of an indent problem so I'm just going to delete that part yes and now after this I'm going to uh also give one information called as bins what is this bins you will understand it in a while okay I'm for I'm just giving a value as 50 but now if you remember this is a 2d array it's a 2D image now in order to quickly visualize this particular thing I'm just going to convert it into a 1D kind of format using this flat operation so this flat on top of this numpy array is going to convert this into a one it's going to treat it as an Itor as a one dimension so it's quickly going to help us visualize this histogram basically okay if I don't use this flat command it's going to take a lot of time to get us an output so that's why I'm using this flat and quickly we are having this kind of an output now if you look into this kind of steps that we are having right you can play around with the steps by increasing or decreasing this beans value let's so what happens if I'm just using one so this is the kind of output that we are having in between 5 to 178 we are having just this kind of one bar so if you want to have a lot of proper visualization just increase the value of Bin to let's say for example 100 it's going to give you much more better distribution as compared to what you were seeing and if you still want to get a refined version of this you can still increase the ban values let's say for example 300 and now look into the output see again output is pretty much similar so I guess we are fine with this one and now clearly we can see that this is that the pixel distribution is completely skewed to the left hand side so clearly we can see that there were some kind of pixel values in the array which is not appearing for a lot of time so it might it must be some kind of noise that's something that we are expecting right so this is the kind of observation that we were able to get over here now in the upcoming videos you will be seeing what are some kind of different pixel scaling techniques through which we can transform our this kind of pixels to some new type of pixels such that in a hope we get a lot more better information from this particular output as compared to what you are seeing currently so yes that's exactly what we'll be doing in the upcoming few videos hi everyone welcome to this video of module 3 where we're going to start our journey of pixel scaling with the first method that we have over here is minmax scaling so to start with this video I'm going to show you some of the helper functions that we'll be creating that will be eventually helping us to generate some visualizations for the comparison or just a normal image with some of the functionalities added to that particular function after that we're going to again create one more function that's actually going to implement the minmax scaling on the given input pixel array and once this kind of output we are able to generate from this function we are going to compare the visualization of the original image and the scaled image so that's the whole idea that we're going to cover in this video so let's get started so the first pixel scaling that we are going to look into is the intensity normal normalization or also called as minmax scaling or linear scaling the idea over here is that we take the whole array of pixels we do a subtraction with the minimum value that is present in that array the minimum pixel value in that array and then divide it with the range or you can also call it as the difference between the maximum pixel value and the minimum pixel value in that are and the output you get the output of the array will be same shape but now the values will be scaled that's the whole concept of this intensity normalization or whatever kind of thing you want to call it and let's see how we can achieve this so I'm going to create a function for that over here I'm going to Define it as uh let's say mean Max scaling and what input it takes it takes only one thing the main array of pixel let me just call it as pixel area something like this now it is divided into two parts numerator and the denominator so let me call it as over here uh numerator is equal to the pixel array pixel array minus the minimum value of this pixel array and then denominator let me just call this DN what is this it is the maximum value of this pixel array minus the minimum value np. minimum of the pixel array that's it now the output of this should be what again an array but how it's the division of this numerator and denominator simple as that so our function is ready if we are going to pass in the data of M31 pixels it's going to give us the output in the format of minmax scaling and we are going to hope to see some better information uh as compared to what we are are seeing over here we are not sure it will be better we are just hoping that we get a better output so coming back to this what I'm going to do is first of all I'm going to uh create Min minmax scaled array or I can just say minmax array right and I can do this with the help of minmax scaling that I have created on top of M31 pixels and now before I go ahead and visualize this what I'm going to do is I'm going to create a common function that will help us visualize this kind of output because it's going to have some kind of common things the title of it then once we are showing this kind of array this kind of cmap equal to gray origin equal to lower all of this kind of code will be repetitive so for that what I'm doing is I'm just uh converting this into a function so that in just one line of code we can do all of this task so let's say I'm defining again one more function and calling it as let's say plot underscore pixels something like this right so the first thing that I'm going to give is the pixel data or pixel array after that what kind of title I want to give what kind of color I want to set for the title some kind of this information the first thing would be to display the array that is pixel array and keep the same color map that is gray always for now and uh after that I'm also going to set the origin to lower and then I'm also going to do PLT do um title going to set title to the title that is given as an input and also set a color to it color is equal to the color given by the user of this function and uh also I'm going to use PLT doxis and turn it off so that the output is not giving us this kind of exis okay we are just getting the output in the format of the image without the exis okay it's going to look much more better I guess so yeah that's something that I'm trying to do and also after this I'm trying to get PLT do Sho to avoid any kind of external text information that it may display on top of the image like this okay over here we did not use pl. Sho so it is showing me this kind of output I'm not really looking forward to this kind of things so that's why I have given this kind of pl. show and that's it our function is ready so not every time after converting uh I mean after scaling down our pixels to some values we don't have to plot this multiple lines of code I'm just going to use this plot pixels give the array of the pixel change the title change the color and get the output that's it again I can do some more interesting thing I can give the weight uh of this pixel as bold and uh yeah that's it I guess this is fine I'm just going to rerun this code and because we have have already created this kind of a minmax scaler right what I'm going to do I'm going to plot pixels for minmax areay now the title I'm going to set is um minmax scaling color that I want to give to this is royal blue and yeah that's it so let's see what kind of output do we get by just okay I guess we are having some kind of an error the error says that the text. set got an unexpected keyword called weight the spelling of weight is incorrect again don't mind my spelling guys I'm really poor at spellings run this going to run this again yeah it's giving us this kind of an output now um again what I'm trying to do is I'm trying to do I'm trying to compare this with the original uh image over here right so what I'll do is I'll also create a comparision over here okay I'll be Crea creating one more function to compare the scaling so compare pixels it's going to take two data original M31 data original array at the same time I'm going to give scaled array okay and I'm going to create a subplot over here PLT do subplot so the first uh subplot that I'm going to give is one two one one row two columns on the first position I'm going to plot the original array and I can do this with the help of the above function that we have created plot pixels I'm just going to remove this pl. show as of now I'm going to have uh plot pixels and I'm going to first of all pass in the original array right and after doing this I'm going to have multiple titles uh over here so the for the first one I'm going to give the title as TI as original image and I'm going to give color is equal to Black okay and after this I'm also going to use subplot at 1 comma 2 comma 2 plot pixels I'm just going to copy this whole thing and paste it over here and it will be the scaled array scaled array the title will be um let's say let's just skip it a title over here as title only okay I'll be passing the title whatever is the title that I'm trying to give and uh again the color will be just a color I'm just going to give this as a input and let me create this kind of thing and now let me try to compare these things so what I'm going to do is I'm going to scrap this part and instead I'm going to uh do I'm also going to do pl. show at the end pl. show okay now if I come over here and do compare what was the name of the function compare pixels the original data is nothing but the M31 pixels the output is minmax array then the title of this plot that I want to set on the second one is the Min minmax scaled and the color that I want to give to that is Royal let's say or I can also fix this color over here as Royal view because that's the only one that I want as an output so I'll also remove this part over here and uh now I can just give this as this only and hopefully it gives us the output the way we want yes so this is the kind of output put that we want in terms of comparision now because we are having some kind of gapping in between I can improve this kind of gaps I hope you know the command the command is nothing but PLT do tight layout and I can also adjust the figure size if you want to have a larger size of this image and any kind of that kind of thing but I guess I am satisfied with the output that I'm getting on the left we are having the original image on the right we are having the minmax scaled image right so over here I don't see that major difference over here it's pretty much similar so we didn't get any kind of useful information with the help of minmax scaled output now in the next video I'm going to show you one more type of scaling call is standardization or Zed scaling and it has been done with the help of this formula so I'll explain you this whole concept in the upcoming video hey guys I welcome you all to this video of module 3 where I am going to show you some other pixel scaling methods apart from the minmax scaling namely standard scaling log and square root normalization so once we are done getting the outputs of this scaled version of the M31 data we are going to visualize them by utilizing the functions that we had created in our previous video and then just compare out of all of the scaling methods which one is performing best in terms of visual appearance which is revealing most information about the core of the Andromeda galaxy and then we are simply going to take that output which is revealing the most information and get its pixel distribution with the help of the histogram just like how we did in one of our previous videos right so yes let's get started and look into all of this kind of things guys so let us understand this particular formula what is this about so this is the actual array we are subtracting it from the mean of the array and dividing it with the the standard deviation so now you already know how we can take this mean and standard deviation that's what we had seen in some part of codes earlier somewhere over here see so we're going to use this kind of numpy functionality in order to get a standardized output okay the kind of Technique we call to this particular formula that you are seeing is either standardization or Zed scaling whatever you want to call so if you have studied normal distribution you will be understanding the actual meaning of what this is but let me not go into the very technical concept and talk about Z skill Z skill array or Z scale only just Z scale let's just say that this is Z scale again I'm going to give pixel array as an input and uh the way that I'm going to code again I'm going to have a numerator that is the pixel array the whole array I'm going to subtract the mean of this pixel array and the denominator part is just the standard deviation so again I'm just going to have this kind of denominator as np. STD standard deviation of that pixel simple as that and written numerator by denominator as an output so our function is ready for the scaling and the output that we are going to visualize now will be straightforward so scaled array or I should also call this the Z scaled array Zed scaled array is equal to Z scale on top of M31 pixels and now if I just go ahead and call compare pixels on M31 pixels okay again now see because this M31 is common I don't want to give this input again and again so I'm just going to give in the scaled array only as an input I'm going to keep this as m 31 pixels by default okay I'm not going to change this one it is always the same so I'm going to run this code and even in this image I'm just going to take this part out run this part yes and now I'm going to do the exactly same thing over here I don't need to pass M31 pixels over here now anymore I just need to pass in The Zed scaled array and the title title will be um let's say Zed scaled image let's see the kind of output that we get I guess we have created an error the error is uh num. Den okay yeah it's because of this particular thing no problem let's fix that up hopefully no errors this time yes again not a lot difference that we are expecting over here even with with the help of Z scale output it's pretty much similar to what we see in the original image don't worry it's not that we aren't doing anything perfectly or there is some kind of a problem with the Skilling techniques this is pretty much obvious okay at times you won't be able to see a lot of difference but now the next thing that we are looking into is the log normalization what is this uh whole concept of the log normalization you take the log of all the pixel values that you are having in your data simple as that so what I'm going to do is I'm going to create a function for that def log normalization or normal log scaling whatever you want to give input is a pixel array and it's going to Simply return the log np. log of this input pixel array simple as that so this is the array that we have created and if you want to visualize this so log Norm array is equal to log normalization of M31 pixels and compare pixels of log Norm array title is equal to log normalized image now you will be able to see some of the visual difference as compared to what we were having in the initial image now see how we are getting this particular output they seeing a lot more details some kind of see uh some kind of part that we see in the around the core of the Andromeda galaxy all of these things are now visible this is the center part this is this is what we see which is not visible over here see that's the power of like you know scaling uh your particular pixel values to some different scale right right now we have implemented log on all the pixel values with the help of np. log now if I just compare this with this output see how how well it is able to give us this kind of outputs of all this kind of if I show you the Stars over here right all this kind of information see even over here I can see that the output is revealing much more information but yes we are having this kind of output so far that we have achieved now on top of this there are again some more uh normalization and scaling techniques that you can do for sure but now before that what I'm going to do is I'm because we got a slightly better output over here I'm going to create a histogram distribution of the pixels of this particular output okay how can I do this I'm going to do PLT doist of this log Norm array do flat going to let's say set bins to 300 and look at the output with the help of pl. show okay so see now this is the kind of output the spread in the data is much more as compared to what we were having initially and this is the kind of output that we have achieved so far okay and I can also show you the shape over here uh that is uh log Norm array. shape it must be the same okay that's something that I wanted to show you that the shape is just the same right so over here we got the uh I guess uh the log normalization was already done so I just got the image of the log distribution of the log normalization over here and that's what we had to do over here so I just scrap this part but at the same time I'm trying to show you one more type of um normalization let me just call this as the fifth part of this scaling technique square root okay so what I'm going to do over here is I'm going to create a code two code cells one to define the square root function again I can do it with the help of numpy So Def let's say square root scaling giving the pixel arrays and uh it's going to return return this thing NP do sqrt of pixel that's it going to run this uh I'm going to create uh square root scaled or square root are just like that and I'm going to call sqrt scaling on top of this M31 pixels and uh compare pixels and I'm going to compare this with square root array title will be square root scaling let's see what kind of output do we get so this is the kind of output this is one more way you can see that there are some more information that has been revealed over here right as compared to what we see on the left so just like this there are a lot of different scaling techniques that you can use so far we had seen that a lot more information we were uh able to get with respect to the log normalization so we stick with that and said that like you know let's create a histogram out of it a histogram distribution of it and that's that's how we can see how the pixel values are distributed now right so yeah that's something that I really wanted to show you that with the help of this pixel scaling how you can reveal a lot more information like this now in the upcoming video what you will be seeing is one more technique which is called as a z skill interval okay now with the help of this again I'll be showing you some more information and then we are going to use any of the scaled output and perform some of the image processing techniques as we go ahead in this particular moduel so stay tuned for all of these kind of interesting things coming up for you guys so welcome to this last video of module 3 where I'm going to talk about the Z scale interval class that is present in the astropy library okay so what is it all about and why are we using it all of these things you'll be seeing in this particular video so let's get right into it so now let us discuss about the Z scale interval I'm not going to go into the logic behind like you know how this is coming up with I'm just going to tell you what it is going to do and how it can be useful for us okay so for the demonstration purpose let us try to create a demo array 1 2 3 4 5 6 7 8 9 and 10 okay now the whole idea of the Z scale interval is to give you an interval that means give one minimum value and one maximum value so let's say mean and Max now this mean and Max are not 1 and 10 there are some different values that you'll be getting for example let's say minimum we got as three and the maximum we got as let's say eight right now the whole idea over here is to take this original array and clip it according to this particular interval any values in this array that is less than three should be converted to three and any values that is greater than eight beyond8 should be converted to eight that's what we call it as a clipping of an array between a particular values so now because we know that the minimum value this array can take is three so wherever you see any value less than three convert that to three convert this to three similarly if you seeing a value greater than eight convert that to eight convert that to eight and that's it once we are done with this kind of conversion we are having a whole new way of visualizing the respective image that we'll be creating so we are going to follow the same exit process and the way through which we can do this in Python is with the help of estrop Library so what I'm going to do is from astropy there is a module called as visualization so I'm going to call visualization visualization yeah UT Zed scale interval going to run this code and now okay I guess there's a spelling oh no not a spelling mistake there is a problem with the space over here yes it's working fine so now we are going to create the object of this particular class CL Z scale interval and what is the whole idea of creating this object because this is the object through which you will be able to fetch out the limits on the any of the image that you want okay in our case you can choose let's say for example square root scaling original image for that matter I can also choose this kind of uh log normalized image because this was performing the best I'll be simply uh copying this part and go down and I'll be simply calling this kind of limits with the help of Z scale interval on top of this particular array right now how we can do do this particular thing you call this Zed you press that dot it's going to give you this particular method called as get limits so it is because of this object that you have created of Z scale interval you are getting access to this method now this method takes the array whose minimum and maximum value you want uh that you have got with the help of Z scale interval technique so if I'm having this over here and if I know that it's going to written two things minimum and maximum so let's call Z1 as minimum Z2 as maximum so we're going to get some kind of outputs and let's just check it with the help of print command F string let me just say that uh minimum is Z1 and like that print F maximum is equal to Z2 I run this code so the output that we are having over here the minimum value after clipping uh we should have is 1.688 9 okay we haven't clipped as of now but the minimum value after uh applying the clipping should have 1.6 8889 nothing less than this so if I show you in the original array of log Norm array what is the minimum value np. minimum of that array if I'm just uh running this okay it's saying that oh yeah because we haven't defined y not array it's array anyways so yeah the minimum value that we are having in the log Norm array is 1. 6788 and after implementing this G limits uh on the Z scale interval we got that the minimum value should be 1.688 so obviously we can see that there are some values which are less than this so all the values in this array that we we are having for the log Norm array all of these values including this will be converted to 1. 6889 any values less than this will be converted to that and just like that if I try to see the maximum value and if I run this code it is 5.18 17837 and over here after implementing the get limits of Zed interval on the log Norm array the maximum value that we are getting is 44 4.44 79 so any values Beyond this as we can see clearly that yes there is at least one value that is beyond this so any such values present in this log Norm array we want to convert it into all 1.5 5.18 17 all these kind of values that has been written right so yeah I was trying to print this to show you that this minimum and maximum is not equal to the minimum and maximum pixel of this particular array it's different right so now that we are having this kind of an idea let's try to visualize this data by clipping this array of log Norm array how we can do this I can use PLT do IMO and now over here I'm trying to call this log Norm array but now I'm going to use two different parameters which is going to help me clip the values between these values so V mean is the minimum value that is Z1 and Vmax is the maximum value which is Z2 and cmap as you know is our gray and the origin is equal to lower we know this kind of settings we have been using this since the start of this notebook and now I can simply do PLT do show hopefully the code Works without any kind of error and now the output that you will be seeing will be significantly different than what you have seen over here okay you can see this it's kind of a bit a blurry kind of thing B paint kind of thing the stars are not that highlighted even this kind of uh the center part of the androma Galaxy is like this now just look into the output that we get over here after applying the Z scale interval see it's a bit more highlighted right you are having a much more brightness in that part as compared to the smaller part so now this is the kind of output that we are having okay it's not that you need to specifically apply this method it's just that I'm trying to implement one more method so that you guys know that this kind of techniques also exist okay what have I done I just got two values the limits now from the help of this limits I have clipped my array I haven't done any kind of transformation as such just clipped the array such that any values less than that particular value and any value Beyond this value are converted to its respective values that's something that I have done and this is the kind of output that I have achieved now according to your research according to your whatever is the objective the problem statement that you're working with you come up with a specific technique and you carry for forward your any kind of image processing or any kind of information that you want to with respect to whatever you're comfortable with it could be the square root scaling image it could be original image it could be this log normalized image and not this one specifically right it's completely your choice according to the problem statement now because I want to demonstrate something in the uh upcoming videos so what I'm going to do is I'm going to take any one of this image let's say this particular image that we got over here but now is this an image yes it's an image but what is the pixel representation of this if I am trying to uh clip this particular values I haven't clipped log Norm array over here right I'm using this IM am show in order to clip this values with the help of this arguments so now how can I convert this into numpy array or any kind of array so for that I'll have to store this whole image as a variable first of all and now let's try to visualize what kind of output it is giving us okay it is the matplot libs image it's not a pixel representation it's an met plot Libs image so it's not giving us any kind of array over here so how we can convert this image into a its pixel representation I can do this with the help of a command called as make image okay now one input that it takes is called as renderer r n d e r e r now I am going to choose by default whatever they are having in the back end of M plot Li by simply giving the command of none okay now I'm going to run this it's going to give us the 8bit integer form of IM image so from this kind of float 32 we are converting this into uh unsigned integer 8bit image basically right so this is the kind of output that we have got but now along with this output it's throwing some other things also out but we are just carrying for the first part of the output that is the image array so I'm going to extract this first part that is present on zero index and now this is the array that I'm looking forward to and you can see that it's a d type equal to U in8 unsigned integer 8 right so that's something that we were looking forward to and now uh let me just store this into an array image array let's say and now let me go ahead and try to check the shape of this so image aray do shape it is 370 370 and 4 original shape was 300 300 that's it so we need to think about this we need to convert this into 300 by 300 not this shape so first of all how did we get this 370 so so over here I just need to pass in one more argument called as unsampled is equal to true now by using this particular command or argument unsampled is equal to true it's going to keep the dimensions as it is if I run this again and uh again run this particular code you will be seeing that 300 by 300 has been achieved right so we have decreased our shape back to 300 by 300 that's something that we wanted now what about this four channels what it means so four channels basically mean let me just write a note over here so the four Channel basically is indicating to us that it is uh having red green blue and Alpha channels uh makes up a four Channel image typically if it's in the format of RGB so the first three channels will be RGB and the last one will be Alpha Channel now what is Alpha Channel it is with respect to the opacity of the image okay the values again are in between 0 to 255 0 means completely opaque and 255 means the opposite of that so yeah that's the idea with respect to the four Channel output now how we can convert this four Channel output into only one channel that is gray scale now that's something that we going to look into into with the help of CV2 Library which is nothing but the open CV Library I can import it with the help of import CV2 command and by default it is already present in the Google collab so you don't need to pre I mean again install it over here so I'm simply using this command of UT CV2 and importing my open CV Library over here now how we can remove the fourth channel of the opacity and basically just convert this into and convert it into gray scale okay I should have written remove four channels or just um convert four scale uh four Channel image to gray scale image now how we can achieve this with the help of CV2 so in open CV Library there is some a method called as CVT color right now the input that is uh it's going to take is the image array whose uh channels are four so I'm going to pass it over here and along with that it's going to take a flag what is this flag the flag that is going to convert this four Channel image into a gray scale Now by default in CV2 that is open CV it's not going to read as uh the first channel as red second as green third as blue it's going to be the opposite of that on the first channel we will be having blue on the second it will be green and on the third it will be red and then on the fourth it will be Alpha so it's BG this four Channel if you're are using CV2 right so if you're using CV2 the four CH will be in the format of BG a and now that BG needs to be converted to gray I can do this with the help of CV2 do color underscore BG a to Gray that's it and let me just St store it as gray image gray array and now let me just go ahead and cross check if the shape is correct hopefully it is yes it's correct and now just to visualize if we have lost some information or it's uh just like what we are seeing over here let me just again plot this thing so I'm going to plot it with the help of the uh plot pixels function that we had created above right it's going to take in the input of the array that is the gray array then I guess it was taking the title also title would be let's say Zed scale interval gray scale let's something like this and color let's say is royal blue hopefully this is not giving any errors I hope that the these are the parameters okay we got an error so error is TIY oh never mind t t l is the spelling yeah so this is the output that we have got and it's just the same image that we were having over here exactly the same right you can also try to like you know plot it side by side with the help of that comparison function that we had created but anyways I am happy that yes the output is just the same and we are going going to carry forward with this particular thing right uh the gray area right that's the kind of conclusion that we have made so far now let's also look into the histogram visualization of this so PLT doist going to pass in the gray array and flat use flat to convert it into an 1D Itor and then passing the bins is equal to usual as usual 300 and look into the output as you can see that we getting some kind of a display of array I'm just going to use pl. show and it's going to just uh show me the output of the image nothing else so now this is the kind of output that we are able to achieve and the pixels are ranging from somewhere from zero all the way up to 255 why what is the reason behind that the logic is that because we have converted our float image into 8bit image and in 8bit image as I I explained earlier the values are in between 0 to 255 so that's the reason why we are having this particular range right so yeah this is the histogram visualization that we are having and uh now in order to apply any kind of image processing on this particular image uh what I'm going to do is I'm also going to convert this gray scale uh array into some good name so that we can use it further let's say I'm giving some unique name to it as um gray scale or gray scale Z interval Z int array is equal to gray array so I'm just giving a meaningful name to this because we were just doing some kind of experimentation over here and because everything is working fine so I'm just saving it in a very good name so that we can use it in the uh upcoming videos right so the whole whole idea that we have seen over here is that with the help of Z scale interval we got two values for the interval and we use this IM show in order to clip the value between these two values that we had got Z1 and Z2 so from this we St we stored it into this image variable which was nothing but the M plot lip image type so from that we converted it into its pixel representation with using this particular function we give this to inputs we fetch the array part of it and the output will be 8bit integer image and but the output now was having four channels so whenever you're trying to perform the image processing and because see the output is just the same over here and over here so why take four different channels and perform image processing on that it's going to take much more time as compared to what it will take in only one channel output is just the same so that was the whole concept why we took this four channels and converted it into single Channel or gr Channel image right and we did it with the help of computer vision or I should say open CV Library CV2 library in the CV2 we are having this option of CV2 color CVT color which is helpful to take the image array and with the help of this flag BG a to gray we can convert it into gray scale image if you want to let's say convert it into three Channel image you you use BG to BGR even that is fine but now that will be three scaled image I mean three Channel image because eventually we wanted a gray scale image I directly converted that four scale into uh four channel into one channel and here is the proof of that it has been converted successfully and uh yeah here is the final output that we have got and here is the pixel distribution of this in between 0 to 255 right so yes with all this being said we are done with this uh whole idea of pixel scaling and looking into some different ways through which you can come up with an array and finalize something that we are going to use for the upcoming sessions on or I should say upcoming videos on image processing after doing some kind of pixel scaling on this right so stay tuned for that guys hey guys I welcome you all to this last module of this program where our Focus will be to understand how we can Implement some different type of filters on the existing image and get some kind of features extracted out from that particular image so starting with we'll be understanding the concept of the convolution operation then we going to take an image from our previous module and apply the Gan denoising technique with the help of Gan kernel to remove some of the noise in the data after that we are going to implement measuring and setof filter in order to enhance the features in the image and lastly we are going to use some of the features of the SK image Library where we are going to take corner fener and multi- basic featur features to extract this kind of features with respect to this algorithms how this kind of uh techniques are working everything will be covered in this particular module guys so yes without any further Ado let's get into this module hey everyone welcome to the second video of module 4 and here we're going to learn about the convolution operations so what exactly are these convolutions why do we need it over here and then what is some kind of practical demonstration in terms of visualizations so that you are able understand okay yeah that's exactly what is convolution so that's something that we're going to cover in this video so let's get right into so now that we are aware about that we are going to use this particular image in order to get some kind of features out of this image and uh do some cool stuff uh in the upcoming videos one thing that we need to do is to remove any kind of noises present in this image before we actually go ahead and get those kind of features out of this image so so we can do this with a technique called as Gan smoothing which is nothing but denoising the image with the help of gajan smoothing technique how it works it is simply working on the principle of convolution so how this convolution works so it will require one kernel you can also call it as a filter in our case it will be a Goan filter right now this is just a demo filter just to explain how the convolution works and it will also require one image now this image in our case will be this one image so on this image we are going to place our gajen kernel and do some convolution operation then slide that filter one unit to the right do convolution operation again slide it to the right do that convolution operation until you are sliding across every pixels uh step by step now that's the whole idea of the convolution that you are going to perform with the help of a gan kernel on the full image so let us try to understand with this uh GF that I'm having over here this light blue part that you are seeing is the image it's a 5x5 image as you can see now on top of which we are going to pass this kernel size 3x3 okay so now what is the convolution so wherever you are seeing Zero I'm going to pass this zero of this kernel on top of that now whatever this is a second zero I'm going to multiply that with minus one then this 0 will be multiplied with this zero then this 0 will be multiplied with minus1 60 will be multiplied with 5 113 will be multiplied with ne1 0 will be multiplied with this zero 73 will be done uh multiplied with minus1 and 121 finally will be multiplied with the zero after multiplying all these numbers I'm going to sum them up together and that summation output is nothing but the thing that you are seeing over here as an output right so if you want to visualize what I'm trying to say I have already WR WR this particular thing for you that you do 0 into 0 then 0 into 0 like 0 into minus one just map this values of the kernel on top of this first 3x3 part of the image multiply it respective uh Elements which are coming on top of each other and after multiplying simply add them up together you will be ending up with the value called as 144 for the first place just like that you slide your kernel by one unit to the right and now it will be on this 00 6113 56 73 121 154 again to the same process the output will be 328 so one time if you're doing this that is one convolution like that you are going to do multiple convolutions with this kernel on top of this image and you're going to finally get the convoluted or convolved image with the help of Goen gel right now as I mentioned this is a dumy kernel to give you this explanation of how these things work but yeah that's that's the whole idea of convolution operation in our case this light blue kind of thing that you are seeing is nothing but the original image that we had uh stored over here this will be the image on top of which we are going to create a Goen kernel how we can create it what are some what are its properties we are going to discuss about that in the upcoming video but yeah that's the whole logic but now you might be wondering that what is this kind of z0 on top of this right so whenever you will be implementing the convolution operation you will always decrease the size of the output now to keep the same size that is like you know 5x5 over here as an input uh we also want the output as 5x5 so for that specific reason I am adding a layer of padding and this padding is nothing but a zero layer padding it means all the values over here are 0 0 0 0 0 now there are other ways through which you can fill up this values you can also use this kind of a reflect kind of padding which which means that this 85 will be reflected over here 128 will be reflected over here let's say this 131 will be reflected over here so even that kind of thing is possible so in short there is one padding layer so if we are having a padding layer this image size will be what now it will be 1 2 3 4 5 6 7 so it's a 7 by S thing so from that 7 by S thing after the convolution is over you are getting this 5x5 however the original image was 5x5 So eventually what we are getting is that input was a 5x5 image output is a 5x5 image so for that particular reason we are having a padding layer so I hope the concept of padding is clear at the same time what you are seeing over here that the sliding of this kind of Kernel on top of the image different different part this sliding is called as a stride this is called as a stride St r i d e so over here we are having the stride value of one that's why it is moving one one unit to the right and then one unit to the down if the stride value was two it will skip two columns and then start from this particular then again skip two columns and start from the next particular available part so that's how it's going to work all right so yeah that's the concept of padding and strides uh that is associated with the concept of convolution now in the next video you will be seeing that how we can create a kernel for Goan smoothning and apply it with respect to the image that we are having over here and then Denise this image and after that later on how we can Implement some of the filters or some of the feature extraction techniques to get something out of this particular image so stay tuned for that guys hey everyone welcome to this third video of fourth module and now we are going to discuss this concept of Goan denoising as in terms of implementation I'm going to take one of the image from the output of module 3 implement the Gan kernel on top of that and see how the output looks like after doing this kind of formulation operation so for this you will also need to understand what are the properties of this Gan kernel only then you'll be able to appreciate this whole idea so this is exactly what we'll be discussing in this video so let's get into it so basically this convolution operation with a gsen kernel applies a weighted average to the neighboring pixels with the higher values at the center which are gradually decreasing towards the edges of the filter so the filter that you are seeing over here won't be like this it's a very special type of filter where the values in the center are high and at the edges the values are going to be low okay so this process is effective in reducing the high frequency noise and preserving important image details so how we can create this kind of a filter and then how we can do this kind of convolution operation on that image that we are having over here so let's try to understand that part so we will require the convolution 2D filter from the CPI signal module how we can do this I'm going to say that from scipi scipi is again a library that is pre-installed over here in the Google collab so you don't need to uh install it so from scipi do signal I'm going to import conall 2D and uh after this I'm am going to generate my own filter that is not at all Associated to the cion filter and the way that I'm going to create this is with the help of np. ons now what is the whole purpose of the np. ons so let me first of all explain that to you so np. On's if I'm let's say doing it 5 by five okay I'm passing it in inside a tuple uh so what is this going to be so it's a 5x five of 1es now I am just going to divide all of these values by four okay or I should say 25 not four Why by 25 so that the summation of all of this values is equal to one now by doing this particular thing it's going to preserve the range of the pixels in a way that it's going to be a better output basically whenever you are having this kind of summation equal to one right so that's the reason why am I dividing this with 25 so because I'm having five five cross 5 of one ones so total in short the summation is 25 right there are 25 * 1 in the array so that's why I'm dividing this with 25 so that now if I take the summation of all of this the output will simply be one right so that's for that specific purpose I have done this thing and now let me just store it into Kel k r NL is equal to this okay now uh let's go ahead and uh actually we have already looked into that but still I'll just paste it over here so that yeah you are having the output now we are going to create a gan kernel so let me just give a name to it Gan Kern I'm going to create it with this np. array method now what I'm going to pass over here I'm going to pass this kind of values 1 by 16 1X 8 1X 16 then come to the second row and now in the second dra I'm having 1X 8 then 1x4 again by 8 try to look into the pattern that I'm trying to create over here okay and the last L again will be very similar to the first line or I should say exactly the same 1X 16 1X 8 and 1 by 16 now as you can see that in the center part we are having the maximum value present over there and as we are going to the edges you are seeing that the values are even smaller so now this is going to follow the property of the Gan kernel and even the summation will be equal to zero if you are going to go ahead and check it okay and even you can check it with respect to the graph that we are having over here that in the center we are having 1x4 and at the edges we are having the values of 1x 8 and 1X 16 right as you can see so this is a 3X3 kernel that we have created over here I have created 5x5 again over here if you want to create a 3 by3 kernel you can create it by simply doing this 3x3 over here also and uh now because 3x3 in total there are nine values so I need to divide this by nine in that case so even this is fine okay there is one kernel that we have created like this uh where it is 3x3 so the output of this will be a total of nine ones so the summation of that will be nine so I just divide that with nine so that overall summation of all of this values will simply be adding up to one so I have created two different kernels one that is a simple kernel and one that is the Gant kernel now I am going to show you how we can convolve this with the help of a con Tod uh thing that we have imported from ci. signal and show how the output looks like with respect to this kernel and the Gant kernel and again we are going to see it in two images one that is the M31 pixels by default and the second one is this particular image so let's try to go ahead and visualize it so get the convolution done with our normal kernel now how we can can do this we can simply call Con convolve 2D now what kind of input it takes it takes the original image on top of that it takes the filter and after filter it takes some kind of padding right so I'm going to say that uh M31 pixels is the first thing that I want to choose and then the normal kernel I want to give as an input and the padding I can give with the help of the command mode now this mode I'm going to keep same keep same padding means the shape of the output should be same as the input that's what this means okay and this will be the output of the convolution so let's we call it as convolved convolved image and we are storing in this right and we are running this now and the same thing we are also going to implement with respect to the Gan kernel so Gan G EX the same steps have been repeated there are no changes at all and now I'm simply going to visualize both of this output one with the convol image and one with the uh let's say because I have given the same name over here let me just call this as Goin conal image but I guess there is a problem okay let me check what is the Cal that I have selected over let me just run this code I'll copy this come over here paste it again just in case to check if the spelling is correct and now I'll run this so yeah we are having two images and now we are going to first of all visualize the first con uh convolution output so I'm going to do PLT do IMO of the same thing right so I'll be using the blot pixels and what kind of input I want to give this is the input title is normal colal convolution and color should be let's say maroon so this is the kind of output that we are able to see right now in the normal uh kernel convolution right now what I can do is I can also go ahead and visualize the Gan G I'm going to copy this code see how useful that kind of function is that we had created in only one line of code we are able to get all these things done and now this is Gan kernel convolution so now again as such we are not able to see that level of uh output you can see there's some kind of like you know some kind of circle circles you are able to see over here and similarly over here also you able to see a similar kind of output right over here because we are having some information uh maybe it's done in this particular way what about this image yeah over here it's done in that same fashion so as such we are not able to see any kind of uh such difference now what I'm going to do is I'm going to do the same thing on the gray scale uh output that we had created over here this one I'm just going to copy this come down using gray scale to convol and this gray scale Z int going to convol 2D going to pass Goan kernel keep the mode is equal to C and I'm going to store this into some kind of output what kind of output we can give just try to think about that let's just say uh convolved gray scale gray scale right let's this I hope the spelling is correct over here Co n v l v it seems correct let me just run this Con Tod never mind you know my spellings ah con 2D going to copy this going to paste it over here okay now let's see how it looks like um again I'm going to copy this paste it and now I'm going to copy this name paste it over here and give it as Gan kernel convolution gajan kernel on Zed scale interval let's see how the output looks like now so this is the kind of output that we are having as compared to the original image okay as compared to this image this is the kind of output that we are having so if it is having some kind of noises it has simply removed it by adding some kind of a blurring effect right so yeah this is what we have done so far now we are also going to fetch out the histogram before we go ahead and Implement any kind of image processing techniques uh in terms of fil applying filters and feature extraction techniques so PLT doist on this particular output that is the convol gray scale I'm going to pass. scale and uh bins is equal to uh not scale do flat and bins is equal to 300 pl. show let's see now the distribution of the pixels that we are able to fetch after doing this kind of like you know convolution with the Gan K now this is the kind of output see this is the kind of output that we have got from this from this you can see there was some kind of gaps in between now we are having this kind of uh continuous kind of output that we are seeing over here right all the web to 255 so yes I guess this is a better output and now we are going to get all the kind of features apply different kind of filters in the upcoming videos with respect to this convol grayscale output hi guys I welcome you all to this fourth video of module 4 and here we are going to take the image output that we had got from our previous video that is the convol denoised image basically and enhance the features present in it by implementing two different type of filters measuring and Sato now both of this we are going to import it with the help of SK image so let's get into the video so now that we have decided that we are going to use this convol gray scale output that we have got by uh doing the gajan blurring uh we going to come over here and enhance the linear features on this M31 data and I'm going to visualize this in multiple different color maps and therefore I'm defining this particular list over here called as spectral list and all of these are nothing but the color map that in which we are going to see the output after implementing two different type of filters which is going to enhance this kind of linear features that is measuring and setof filter and I'm going to import them from SK image itself so from SK image. filters import I don't know the spellings properly to be honest I'm just going to copy this and paste it over here remove the end part and just give a comma that's it so this filters have been imported and now we simply have to go ahead and do the convolution I mean uh implement the measuring filter and the set set of filter on this grayscale output so what is this gray scale output I'm just going to copy that this one copy this array come back and let's say this is a majoring filter is equal to this oh not this actually it should be maing of this and for CTO filter CTO output I should say right measuring output in the the set output so let me change this to Output as well and set this to Seto and paste this part so after running this particular code what I should be getting is the array with the uh filter that we have implemented on this particular image now what we are going to do for every color map that we are seeing over here we are going to uh create the output for the measuring filter first and then for the Seto filter and try to see that which of this color map is combined with this measuring filter giving us the best result so that's the kind of thing that we are trying to do over here and now we can achieve this with the help of PLT do IM Sho of what I'm trying to show measuring output May I'm just going to copy this and paste it over here I want to show this with what color map I want to show the color map I'm going to create a for Loop over here so for color map in spectral list I'm again going to copy this you know the reason yeah so this I'm going to give an indentation over here so that we are not having any kind of errors and now instead of C map I'll be giving color map that I am fetching from the spectral list and after doing this I'm also going to do this kind of origin is equal to lower and give a title to this PLT title TI tle e and with the F string what I'm going to do is I'm going to give the name of the color map and I also tell that this is a majoring plus this particular thing right so this is something that I'm trying to give and let's say measuring M31 plus this color map I guess this is good and I'm also going to hide the exis okay and now after this I'm also going to do PLT do show and now I'm going to run this hopefully it is working the way I expect if not we'll be modifying this code okay again we got a name error spectral list is not defined oh because we haven't run this code no problem no problem no problem run this again hopefully no errors fingers crossed yes we are getting the outputs now see how we are getting this outputs over here we can clearly see this kind of objects are present over here 1 2 3 here over here also some kind of dull objects we can we are able to see over here also some kind of object is being formed and here is the core of the androma right now I can just scroll down and try to see some kind of different features that we are able to extract over here if you're able to find something different over here and whatever kind of color map that you are liking that is giving you the lot of information you simply use it for any kind of further analysis Okay the reason I have printed a lot of uh color Maps over here is just for your understanding that we can do this kind of things now according to your problem statement whatever it is you choose the best image that you think According to which is giving the best result according to me it's the nip spectral color map which is giving most of the information about the image right now according to whatever is the hypothesis that you must create and to prove that hypothesis you can do this kind of image processing by implementing different kind of filters and get this kind of outputs and test your hypothesis right for example you might have said that there are some kind of stars at the uh edge of this kind of image uh near the galaxies there are this kind of uh formation of this kind of uh shapes that we can see near the core of the Galaxy by default we were not able to see this kind of information if I just show you over here we were not able to spot that well this information as well as this information but now after implementing this kind of filters we are clearly able to uh see this kind of things and trust me guys this kind of uh thing if you're able to create a subplot out of it you can literally extract the subplot download it and use it in your research paper the outputs like this how you are able to describe it it all depends on your skills of like you know explaining a visual appearance in front of you right so I hope you have now understood that how we are able to get this particular thing done for the measuring filter now I can simply go ahead and look into the Seto filter and look into the output over here with respect to that so this is my set output uh this is my Seto M31 plus color Maps again same color Maps I'm using and see the output over here now see this one is I guess much better compared to what we got with respect to measuring again we are able to highlight all this kind of information near the core of the Galaxy even this side part but this is much visually it's more appealing as compared to the previous output that we had got right so yes according to this kind of outputs according to your problem statement according to your understanding whatever kind of image you can describe the best you choose that and use it in your research work right so I hope this kind of idea with respect to how you can Implement different filters I have just shown two examples like this there are bunch of filters you can uh get with respect to SK image. filters I can show you the documentation over here SK image. filters documentation okay and I'm also going to add this part in your uh notebook also so that you can just uh take a look into different kind of filters that are available uh take a look take a look onto different available filters in SK image okay I'm giving this link over here guys all right so yeah you can explore any kind of filter that you want to see how it is working with respect to the astronomical data that you're dealing with you just need to know how this kind of for example this is the filter how it works what kind of input it's it's taking and based on this input you try to get some kind of outputs like this right so yes guys that's it for this particular video and now in the next video I'll be telling you that how you can extract some kind of features with uh SK image itself so stay tuned for that hi guys welcome to this fifth video of module 4 and here I'm going to show you that how you can take SK image and go to its any kind of feature available in their documentation and Implement to get some of the outputs on top of the input image so the one that I'm going to show you first is the corner fer so what exactly this is and how we can use it in Python with the help of the SK image documentation of the features that's exactly what I'm going to explain in this video so let's get into it so now let's take a look into the feature detection and extraction with the help of SK image feature so just like how we are having SK image. filters like this we can also have feature if I just look into that so here is the documentation again I'll copy this link and paste it into our particular file okay I'll also just create this SK image different features you can use any one of them by understanding how to implement that now that's exactly what I'm going to show you that how you can use one of the uh feature that is corner for how we can use it so what you do is you go to their official documentation and search for for that the one that I'm looking forward to is over here so if I click on this it's telling me that it's going to take one input of image and sigma and the output will be two things okay this is output will be two things image is an input shape of M comma n row comma column and sigma is nothing but the standard deviation used for the Gan C by default we'll keep it as one only for our case as of now but surely you can play around with this particular value but the output that we are going to get over here is w and Q the first output basically that we are going to get is the error ellip sizes and the second output that you're going to get is the roundness of error lips so if you're not understanding this kind of technical terms no problem let's try to go ahead and try to implement uh how this kind of uh SK image. feature of uh corner forner is working okay I'm just going to copy this name come over here and first of all UT this so import okay I should say from SK image. feature import this going to run this now you can pass this on any kind of image that we had created above I'm again going to use the same image that we had used over here right you can also use on top of this set output also if you want okay but for now I'm just going to implement it on that uh this one convolved gray scale okay so let's go over here and implement this corner forer on what gray scale oh I should say convolved gray SC right yeah now if I just run this and if I check the length of this I should get two different outputs right I should have two outputs let me check yes I am indeed having two different outputs so now what I'm going to do is let me just store it as only one output as of now let's say I'm calling this as a feature output and this feature output is actually having two different things so check the output of the feature image so feature output zero the first output that we are having over here is with respect to actually uh the error the error ellipse sizes and the second output is roundness of error elips okay so this is the first uh this is the second right now what exactly it's going to dip it we are only going to understand once we are going to visualize them right and if you want to check the type of this output that we are getting uh the type of this actually it will be in the format of a tle because it's throwing two different values right so type of this let's check and again length we have already checked that it will be two now we are going to Define two we are going to split this kind of thing into two parts Parts one is for the error ellipse and one is for the roundness of error ellipse so you can just give any kind of variable name that you are okay with right whatever kind of name you're okay with but what I'm going to do is I'm not really going to Define this as of now I'm just going to delete this part and color list we have also already defined as the spectral list just let me see spectral yeah let me see if it's still working yeah we are having all of this we are just going to use the same uh color maps and now we are going to create the visualization so what how I'm going to do I'm going to Simply say that for color map in spectral list now what I'm going to do U on the left hand side I want to visualize the first output of the feature output and on the right hand side I'm trying to visualize the output of the roundness of error okay one is error and one is roundness of error so how I can do this I can achieve this with the help of pl. subplot now I want to give 1 comma 2 comma 1 now on the first what I want to show PLT do IM show of feature output of zero right now any kind of color map I can give but because I'm using a for Loop I'm going to give this color map and origin is equal to lower yes I guess this much is fine I can give a PLT do title as what what kind of title we can give we can say that this is error image plus the respective color map and I just need to pass this in the F string and also turn off the AIS PLT XIs off now I'm just going to copy this code over here and repeat the steps for 1 2 2 but now this will be feature output one this is roundness of error roundness right and I guess we are good to go and I'll just have PLT do tight layout because we are plotting the subplot and then PLT do show hopefully this is going to work in the way that we expect let's see how it's going to work yes first of all we are having the gray see on the left we are having nothing thing on the right we are able to see this kind of circular or ellipse kind of shapes that is it's being detecting so yeah this is the kind of features that you are extracting over here in the format of an array and this arrays is what you are visualizing over here right so you extracted this kind of features and now you are visualizing them in different color Maps right so error image plus prism roundness of error plus prism then error image with respect to nipp spectral and this is with respect to the roundness of error image with nippy Spectrum so yeah that's it with respect to what we are doing uh with Corner Foster I hope this is making sense that this is one of the example that we have fetched from this SK image. feature like this you can go and check any kind of different feature like this in the next video you will see that we are going to try one more feature extractor actually and that is multiscale basic features the local features so I'll talk about that in the next video and over here you can surely go ahead and try to check out some different feature by yourself try to implement it and just note that you need to know how it is working by looking into its documentation if you are able to look into that if you're able to do your research properly you can use any kind of feature for a specific task that you're looking forward to all right guys I'll see you in the next video hi everyone welcome to this last video of this particular particular module and here we are going to go ahead and understand how we can implement this skmh feature called as multiscale basic feature by following its documentation and just like what we did in our previous video the same stuff we'll be implementing over here and see what type of outputs we are able to achieve so let's get started so now let's try to look into one more feature that is present in the SK image that is uh known as multiscale basic features so I'm going to press contr F to search this multiscale I had already searched for that but I'm yeah that's where it is so over here it's going to take all of these kind of different parameters you can read its respective information for now I'm just going to pass the image and keep everything as default I'm not going to change anything obviously it's up to you how you want to change it and get the outputs the way you want and the output will be uh an array of the shape of whatever is the row and column plus some nend features so as you can clearly see that it's trying to detate multiscale basic features it's going to give us the uh local features for a single or multi- Channel end dimensional image right and it's going to be actually the intensity gradient intensity and local structure are computed at different scales thanks to gajan bluring so all of this kind of information is what we are having and what we are able to understand from this is that from a given image it it can give us multi Channel output and in each of the channel that we are going to get each channel will have one kind of feature that has been extracted so if I'm trying to implement this first of all I need to import this particular thing so I'm going to say that import this feature so from SK image do multiscale basic features oh I should say do feature import this name I'm just going to copy this very quickly and paste it over here and going to run this and now I'm going to create a featured let's say a feature image I'm going to call this with the help of this and I'm going to pass in the conval gray scale okay so this is the kind of input that I'm passing in and now I'm going to run this now let's say what is the type of this thing that we have got previously we had got tle right now let's see what do we get now it's a nump AR because that's what we expect over here as an output it's going to return an array so that's why we are seeing an array type in the return of this now let's look into the shape that's something important so this do shape is what so we got 300 by 300 and there are 24 local features that has been extracted and each of the channel is having some different types of extraction of this features and has been stored over with the respective channels over here now what we are going to do is we are going to extract each and every channel out of this and uh create a list out of it basically how we can do this I'm going to use CV2 functionality of split and I'm going to pass this featured image spit featured image I'll be creating a list of all the outputs that we get if I'm running this it's going to give us a total of uh if I check the length of this output it must be 24 the split means what it's going to split all the channels and it's going to give us as an output each and every channel and all the channels will be of the shape 300 by 300 so that's the kind of output that we are going to get so first of all I'm just going to like you know store it in P1 P2 P3 P4 and everything that's exactly what I'm going to do so I'm not going to write everything and make you guys bored what I'm going to do is I'm copy that part paste it over here say that this is equal to that if you notice because I was having 24 different outputs I'm having P1 all the way up to p24 if I want to check this P1 and also looking into the shape of that it must be 300 by 300 right just like that I can also check p24 do shape and yes because everything looks fine I'm going to go ahead and create a list out of this okay I'm simply going to go ahead and create a list out of this and call it as pixels different pixels that I have created right and my goal is to visualize all of this uh features that we have extracted uh in a particular color map any kind of of color map that you like I'll be choosing a color map called U I guess if I'm not wrong I'm going to choose pixel prism okay I hope it is present over here somewhere yeah this prism right so I'm just going to copy that where it is where it is where it is it's over here so I'm going to copy this come back where we were yeah and now finally visualize this kind of pixels in only one color map and uh there will be 24 different outputs so what I'm going to do is for feature in pixels what I want to do PLT do IMO of uh feature right I want to use color map only one color map that is this one prism color map and uh origin is equal to lower and PLT do title I can say that um this is feature one feature two like that I can give this kind of things I can also use enumerate over here enumerate so what is this enumerate going to do it's going to give me two things index values as well as the feature that is like what is present inside this pixels so with this I I'm going to so what is feature that is it feature one feature two right so it is Feature Feature then i+ one because index will start from zero so feature one all the way to feature 24 that's the kind of title that I'm giving and then PLT doxis I'm going to turn it off as usual and PLT do show so if I run this hopefully it's going to be running the way that I am expecting yes it is indeed feature four like this you will just see that the output we are getting over here we got feature 11 12 13 14 15 16 17 see how in all this image we are getting different kind of features that has been extracted right see all these kind of things all these kind of different features that are associated to this 24 outputs that we have got all of this we are able to visualize that and now we are able to visualize that in one color map that is called as prism right you can also do this with the help of DP SP also gray scale whatever you are comfortable right so yes these are the kind of outputs that we have got we can see this kind of uh all these kind of different features right and currently because we haven't defined any specific hypothesis that what exactly we are trying to look forward to so that we cannot prove anything over here it's just that I'm trying to show you that how with the help of this kind of feature extraction techniques that is present in SK image you are able to fetch this kind of information now any image that you are seeing over here any output whichever you think is describing the thing that you're looking for you look for that specific image and then write about that particular part in your thesis research work internship report whatever it is whatever you are working on right so yes guys that's the whole process let me just try to visualize this in nippy spectral I'm assuming that is going to look much better yeah this is my personal favorite guys okay nipp spect yes indeed it's giving us a good result right wherever there are this kind of spots the Stars we can clearly see that here is the nucleus of our particular anoma Galaxy over here also we are able to see something right so all this kind of information over here we also able to spot this kind of stars in the background right even this kind of feature over here this feature over here all of them are highlighted so yeah that's the beauty about this kind of feature extractors and obviously I'm not going into the details of what all kind of things you can extract let's say if your image is having some kind of jets coming out from the center of the uh Galaxy it might be indicating that it's coming from some kind of a like you know x-ray sources and that x-ray sources are nothing but indicating a presence of black hole or something that is ejecting this kind of high energy uh x-ray beams right so with respect to that whatever kind of particles you can associate with you can create your hypothesis and uh work on that so yes guys that was about how you can use different image processing techniques once you are importing the image I have shown you how you can apply different type of image uh processing techniques by implementing two different filters and also two different feature extractors so yes guys that was about this particular video all right guys so with this being said over here we are finally done completing each and every module of this program now I'll be creating one more video after this to conclude everything in just one video from the start till the end and what are some kind of further steps that you can take in order to continue your journey in terms of astronomical image processing or some of the other stuff that can help you from the programs that we have uploaded on udm itself so stay tuned for that hi everyone I welcome you all for one final time in this program on astronomic research data analysis first of all I congratulate each and every one of you to successfully complete all the four modules of the program now let's go ahead and conclude this whole program that we had conducted so to start with in the module one we looked into the very basics of python that you need in order to create cre some amazing visualizations that you have created by the end of module 4 in each of these modules you were creating some kind of different types of visualization so yeah for those things we uh understood some basic uh of the Python after that we moved on to module two where we took the tabul boring kind of data of stars and converted some amazing visualizations on top of that we created the bar plot we created the line chart we created a lot of different visualizations including the HR diagram then we moved on on to module 3 over there we took the data from the astronomical surveys like sdss DSS and then did some pixel scaling on the image that we have got in order to find some interesting things that you can see in that particular image then in module 4 we use the output from module 3 in order to enhance the features that were present in that image which we couldn't see till module 3 but in module 4 we saw a lot of things depending on some kind of feature extraction techniques that we had seen from the SK image so by now you must be having this kind of an idea that whatever type of visualization you want to create in Python you are now eligible to do that you can save this visualizations and use this in any kind of your research work that you are doing uh or maybe internship report or even the thesis work all of these kind of things you can surely go ahead and use this so with all these things being said I'll Bid Farewell to all of you guys and I hope to see you anytime soon in future thank you guyslearn how to use Python to analyze astronomical data this is a great real world use case to help you improve your data analysis skills the course offers a practical Hands-On approach to simplifying complex Concepts in data analysis making it great for beginners you'll journey through modules covering python Basics tabular and image data visualization and advanced image processing techniques all focused on real world astronomical applications yeah ash from spart official Innovations developed this course hi everyone I first of all like to welcome each and every one of you to this program on astronomy research data analysis where you are going to learn to create some amazing beautiful looking visualizations that you can create from a boring looking CSV data or a tabular data and even from the raw data from the astronomical surveys how you can take that images and extract some amazing features fees present in those images so all of this kind of work you are going to do in this particular program and then whatever kind of visualizations that you will be generating you can extract from python into your particular system and then later on use it for your research work thesis work or internship report right so that's the kind of thing that we are going to deal with in this program so this whole program is divided into four different modules to make these things very easier for you guys okay but before I go ahead explain any of this let me quickly introduce to you all myself so I am Rohan and I'm currently working at SP artificial as a machine learning engineer and I'll be the one who's going to guide you throughout this whole program and I'll promise you guys that you are just going to simply enjoy this program and you just need to code along with me that's one thing that is really important if you don't code along with me it's just going to be boring for you okay especially if you are new to python you need to code along with me because each and every code that I'll be writing in the uh upcoming uh modules I'll be writing from scratch so I'm 100% willing that you all are going to code along with me okay so now let's talk about each and every module that we are having over here so the first module we are going to start from extreme scratch even if you are very new to python it's completely fine in the first module I have covered each and every basics of python that you will require to create some amazing uh visualizations with the help of python okay so module one is compulsory for you guys just in case if you are new to python if you're already aware about the python then you are good to go ahead and move to module two in module two you are going to deal with a CSV tabular data that data will be based on some kind of real stars out there in Universe now from that tabular data you are going to create some beautiful visualizations including an HR diagram if you're not sure about what is HR diagram it's completely fine okay we are going to learn about that in module two then in module three we are going to go to the astronomical surveys where we are having this raw images taken from multiple different telescopes and from that surve we are just going to fetch an image of Andromeda galaxy and then do some of the uh pixel scaling and all this kind of basic visualizations with respect to an image data and finally in the fourth module the last Model you are going to take that Andromeda galaxy and do a bit advanced level of image processing and I going to teach you that if you want to implement any kind of filter if you want to extract any kind of features that how you can do it with the help of python so that's exactly what we are going to cover in all of this upcoming four modules for this particular program and I hope that you are just going to enjoy this okay so let's get started with the first particular module that is basics of python from the next video hey guys welcome to the second video of module one and here I'm going to introduce you to Google collaboratory notebooks or in short you can also call them as Google collab notebooks okay so for those who are not aware about it already we use them in order to code in Python without actually installing anything in our system isn't it just great so that's exactly what we'll be doing throughout this whole particular program so what exactly are this Google collab notebooks how it works all of this kind of information you'll be getting in this particular video so let's get into it right away so let's understand that how we can use this kind of python notebooks that are available online in order to code in Python the one that we are going to use is specifically called as Google collab notebooks okay so you go to Google and search for Google collab and now if you come on to the second link you just click on that it will redirect you to this page where you are getting this option of creating a new notebook so let's go ahead and click on that new notebook and now I don't need that first TP so I'll just close that up now the whole idea about this kind of notebooks which we also call as interactive python notebooks in short ipynb as you can see over here also right these files are basically used in order to have the mixtures of Tex cells along with the code cells so what you are seeing right now on my screen this particular cell which is getting blinked like that this is called the code cell I can create multiple code cells by clicking over here right and I can do my specific task I want to do over here here here and get my outputs done you will be using this a lot as we go ahead in this program but yeah this is a very very basic introduction with respect to this code let's say you writing some kind of a code in Python over here if you want to run it you simply come over here and click on this or else you can also see there is a shortcut that is control enter you click on control enter and this code is going to run okay and let's if you want to go to the next cell by running this cell you click on shift enter it automatically shifts your cursor to the next code cell or any kind of cell let's if I want to create a text Cell between both of this code cell i h my mouse in between two cells and over here I'm getting the option of text I click on that and I get this option of this Tex cell now the purpose of the Tex cell over here in this kind of ipy andb notebooks uh is to give you some kind of description of what will be done in this following code C that we are writing so in this kind of interactive python notebooks you are getting this kind of facilities to decorate your notebook the way you want so that if anyone who is going to look into this notebook or for that matter let's say even yourself who are going to look into this notebook after let's say some months you need to know that if your documentation is good and Visually appealing then it's very easy to find out a lot of stuff and it's going to be interesting to like you know scroll through this whole notebook and get to the exit point where you want want to find out some kind of information so it all depends on to like you know how much decorative notebooks you want to create how much kind of information in text you want to add and then how much kind of code things you want to code over here and get your job done now here that was a very quick introduction about the Google collab notebook and pretty much uh things that you need to know about Google collab is I guess enough over here some of the things that we can do to start over here before moving on to the second video would be let's say by naming this notebook I'll change this notebook name to Let's the basics of python okay any kind of name that is going to describe what kind of content is present within this notebook and then I can also create a text cell and give a heading with the help of this hash and let's say because this kind of uh whole program is dedicated for astronomy visualizations and Analysis from that visualizations what we can do is we can give a good name like python basics for astronomy something like this whatever you you the best right and then after this we can start coding ourself for the first thing in Python let's say just like everyone does in Python like or any kind of programming language here let's say we are going to print hello world right so if I'm writing hello world like this and then I'm just going to pass this kind of hello world within print this is going to be our first code that we have written in Python print hello world and that's exactly being printed over here so now in this video I've have shown you how you can create this kind of text cells give headings or not just headings you can give images over here you can add links to a specific word you want to add like you know you want your people to redirect to some stuff you can have bold ital like and all this kind of stuff after that I've also shown you how you can start using this kind of code cells in Python and obviously if you did not understand what have I written over here why did I specifically have this kind of uh quotation mark everything will be covered in the upcoming videos so stay tuned hello everyone welcome to the third video of module one and here we are going to talk about python commands so what exactly are these python commands why do we need them and what are some kind of different ways to actually create them all of these kind of things we are going to discuss in this video so let's get into it all right so now that we have written a specific code in Python now let's say I want some kind of a way through which I can describe what I have written over here or what is the purpose of writing this kind of code I can do this with the help of python comments okay for that again I'll have to use this kind of hashtag and then I just give any kind of description that describes what is the purpose of writing this code what does it explain so now because this was the my first code that I have shown you in python I can give this kind of a comment like my first code in Python you can also write this thing for yourself right so what is the main purpose of writing this kind of commments so whenever you are writing some kind of a logic of your code if you're are having this kind of comments that you are writing to describe your logic that how did you come up to this particular logic to solve a particular problem then what happens that even after let's say one year two years if you're coming onto this notebook and now because you having this kind of descriptions in Python that is describing what you have done it's giving you a hint a some kind of this kind of a click to your brain that okay now I remember why I had coded this specific thing in this way maybe because after two years of time if you're coming onto this concept which you haven't touched in a while let's say you're trying to apply for an interview you want to take a project that you have created over here and explain it to them so if you are trying to revise something which you haven't used in quite a while now so if you will be having this kind of comments in Python that will help you to revise this kind of things very quickly because this kind of comments is going to click your brain that okay now I remember what was the reason that I had done this kind of code in this specific way right so that's the whole idea with respect to python commands but now that's not the only one way through which you can have the comments in Python okay because over here we are having only one line of comment what if I want multiple lines of comment right for that what I'm going to do is I'm going to create one more text cell over here first of all and just introduce to that my the first thing that I'm teaching you guys is about comments okay and I can also give this into this way of heading okay three hashes and now you can clearly see that this kind of text is much more smaller in size as compared to this so this looks good right but yeah now what I'm going to do is I already explained the first thing about the comments over here now let's if you want want to have multiple line comments okay so what I can do is I can use three quotation marks I either I can use three single quotation marks or three double quotation marks both of them is going to work just the same okay so I am having my first three uh double quotations like this and three double quotations at the bottom now anything that I'm going to write within this quotation marks is going to be like a comment your python is not going to execute as in the format of you know some kind of a code it's going to do something it's just some kind of a description that you are going to mention over here let's say some kind of huge description you want to write have okay as compared to just a single line then obviously you can go ahead and use this kind of things let's say this is my first line of comment this is my second line of comment I'll be showing you this that I'll be using this when I'm going to teach you the concepts of functions at that times I'll be using this kind of multi-line comments now again let's say that you you are having bunch of lines that you you want to write let's again this is my first comment this is my second comment now let's if you want to comment all of this thing with the help of this hashtag only you don't want to use this kind of uh quotation marks then what you can do is let's say how many lines how however how many lines I am having it doesn't matter the important thing is that I'm going to select the whole text and then press control+ forward slash and automatically it's going to give me this kind of hashes by itself I didn't do anything I just press control and the forward slash what did I do I selected the text below and pressed what control plus this by doing this together you can either comment all of this kind of code or maybe DEC comment it by again pressing the same thing that's simple that it gets for the comments so for a quick revision what we have done over here is now you know how to create print statements in Python obviously not like you are not aware about this that what why did we use this kind of quotation marks what happens if we don't use it I'll be explaining all of that thing in the following videos but yeah for now you know how this kind of print statement Works in order to print something and then what are the kind of need of writing com for your code now in the next video I'm going to talk about what are variables and constants that we need in Python hey guys welcome to the fourth video of module one and here we are going to understand the concept of variables and constants in Python what is the difference between them and when and how should we use them all of these things you'll be getting in this particular video now one thing that I really want to make sure over here is that I hope that you all are coding along with me that's the whole fun about this particular program that you are going to code along with me and it's going to give you live experience instead of just watching the video all right so if you haven't begun it till now this is the right time to get started with it okay so let's get into the video so now what I'll be doing is I'll be just uh commenting this whole thing because like you know it's looking very ugly what is the reason behind that you will be understanding right now in this video so what you are studying right now is called as variables and constants okay so before I write any kind of code I'll be giving a text that describes that I'm going to explain about variables and constants okay now what I'm doing over here is just remember your classes of mathematics you know that we give this kind of things like X is equal to 3 Y is equal to 5 or any kind of number six whatever it is right you know that you do these kind of things so so what we are doing over here is essentially we are saying that X is a variable that is going to take the value of three it's just like that Y is a variable that is going to take the value of six now what is the whole purpose of having these kind of variables in your code for example let's say that I'm writing a lot of huge code and somewhere I want to use the idea of that data that I assigned to that letter x I want to use that again and again for example I'm giving you a very short example let's say I'm having uh value of three that I want to add to a value of three itself let's say 3 + 3 now if I want to write let's say 4 + 4 what I'll have to do is I'll have to change this to 4 + 4 manually now like this let's say I'm having a huge chain four five then again four then again five like this okay and now I saying that I want to change this values of all fours to threes I'll have to change this manually and fives to twos I'm doing all of this change manually and let's say that this kind of code is pretty much long and you are having multiple times you have to change these things so it does not make sense to write these things again and again in every kind of lines so what we do is we try to store this kind of data in a variable for example x equal 3 Y is equal 2 and now I just need to type x + x + y + x + y That's it now if I want to see so you can see that this is 3 + 3 why because X is having the value of three now in place of two we know we are giving y because we know that Y is equal to 2 and similarly again x + y now let's if I again want to change this to 4 4 545 I just need to change x value to four y value to five as simple as that so that's the power of having variables in Python now just like that there's also a concept of constants okay what I'm going to do is I'm going to Simply go ahead and first of all print this to show you the outputs how it looks like so you are having this kind of 22 over here directly it's the summation of this 4 + 4 + 5 + 4 + 5 so that's how this kind of thing is working now one difference between this variables and constants in Python is what you are having if you're trying to Define a variable you're always going to Define it with the help of lowercase letter you are always going to Define it in the lowercase letter and the moment if you want to convert this into a constant you define it into an uppercase letter now this uppercase letter is going to indicate anyone who is reading your code in Python that okay yeah now I know that this X is never going to change throughout your code whereas your variables can go ahead and change any kind of data that you want to store in the variable because the name variable itself means that it is varying right it's not constant right so that's the idea what I'm trying to say is that in my next code over here I can change the value of y to some other value for example one but because I have mentioned X in the upper case we are simply saying that okay yeah this x will always be four it will never be changed no matter how deep codes I'm writing X will always be four so that's a very common difference between variables and constants in variables you try to assign any kind of data in form of uh small or lowercase letters and if you want to store the value of constance what you do is you assign any kind of value and uh give a uppercase letter to that so now both of them are now stored in in the format of what constants all right as you can see there are this kind of lines that are appearing that are giving you this kind of yellow yellow lines what it indicates it's simply indicating that X is not defined Y is not defined why it's not defined because I have removed that part of code I have removed that part of code but at the same time it's also stored in the memory of this notebook it is also stored in the memory of this notebook what I'm trying to say is if I comment out this code and now I run this even though I haven't defined XX YX y anymore it's still giving me the output why because initially while explaining you the code over here I had started with small X and small y so now that small X and small Y is by default stored into the memory of this notebook so make sure these kind of things are not uh repeated in your notebook or else you're going to run into some kind of Errors okay but here was a very quick description with respect to what are variables and what are constants and when you should use what variables can change its data that it's trying to store and constant will try to have a very constant value it will never change throughout the whole code that's the whole idea now I'll see you next with respect to what is strings in Python hey guys so welcome to the fifth video of module 1 and here you are going to understand what are some basic data types available in Python we are not going to talk about all of the data types just some of them including string integer and Float okay and also when I'm going to start the video I'm also going to talk about the concept of runtime in Google collab it's really important guys that you understand this particular concept so I'm just going to start with this concept in this video so let's get into it so now now let's look into the strings so what I'm going to do is I'm going to create one text cell give a heading as strings okay and now if I press shift enter it automatically creates a code cell for me now one thing okay before I'm starting the explanation of the concepts of strings I really want to show you what really happens if you try to click on this runtime and let's say for example you want to restart your notebook okay so what you do is you click on restart runtime it saying that whatever kind of memory that was stored in this notebook everything will be reset and if I let's say click on yes and now if I try to run this code see what's going to happen it's going to throw an error this time because XX YX y this small X and small y variables are gone because I deleted all the memory by restarting my run time so that's one thing that you need to keep in mind okay if you want to uh Define this X and Y and if then removing it and changing it to some other thing then you should be cautious about that thing so now moving on to the strings and uh the concepts with respect to that so what is the whole idea behind the strings right so let's if you're having some kind of a numeric data you know how you can assign it to some kind of variable or constants that's fine but now what you if you're having some kind of a text data that you want to assign to a variable for example let's say I'm trying to create some sort of variables create variables to store the information about a planet in our solar system let's say the first thing that I'm trying to store is the name of the planet so I need to assign some kind of variable to that particular name of the planet that I'm going to use so for that again I'll have to create a variable right so let's say I'm going to call it as a planet name something like this you can also call it as a name underscore Planet anything that you like now over here if I want to give a name as Venus like this it's not going to work why because there is nothing like Venus that we have defined anywhere just like for this X and Y that we had seen in our previous video and even for that matter in the starting of this video we if we did not defend this small X small y it's going to give you this kind of uh yellow kind of of line below that thing that hey you haven't given me any kind of value that we need to give to Venus so it's going to run into an error that Venus is not defined if I go ahead and run this it's going to say that name Venus is not defined because we haven't given any value to this so if you want to assign a text data to some kind of a variable you always do it with the help of this kind of quotation marks now this quotation marks is going to ensure that okay now this is a string this is called as a string in Python and now if you run this it is storing this kind of Text data in the variable called planet name now if I want to go ahead and print this thing let's say I'm trying to print the name of this planet by calling the variable in which I have stored it and now you will be seeing that it's printing the Venus value what happens if I'm going to print like Venus without uh even defining what is Venus right like this it's again going to throw an error that Venus is not defined because in itself you have not defined Venus as a variable over here planet name was a variable which we have defined earlier before printing it and that's why this is running without any kind of Errors unlike this thing that you are seeing over here and the same kind of concept has been used over here in order to print hello world I need to pass it in the format of this kind of quotation marks so that it is converting this kind of data into string and now python understands automatically that go ahead and print this string data it's not a variable anymore if you don't give this kind of quotation marks it expects this hello to be a uh some kind of a variable you can again see there is some kind of automatic yellow line appearing right because we haven't defined this hello if I run this it's going to run into an error right so that was the reason why I was having even the quotation mark in in the first code that I had shown you guys to print hello world so that's how you can define a string uh in Python with the help of this quotation marks now it's not that you always use this kind of double quotation marks you can use single quotation mark I can do the same thing by giving this kind of single quotation mark this is also a string I can go ahead and print the same thing it's going to be Venus this time right I'm going to Del this code and now I can also use let's say three quotation marks either of single type or double type even that is fine again this is pretty much useful when you want to create a string which is of multiple lines so let's say I want to give a description line by line let's say this is Venus right and now I want to give this information that planet name is Venus okay now I want to give this kind of information this is the second planet in our solar system first is mercury second is Venus right so this kind of information if I'm giving over here if I want to store it in multiple lines for that I'll required to have this kind of three quotation marks either of single type or double type okay I can change this to double also three double quotations even that will be fine okay but before I run this code cell before I go ahead and run this code cell I'm going to print it see this is how you getting multiple lines of text right now if I run this code and again I run this you will see there is no change because essentially it's happening the same thing but now what happens if you trying to have this kind of multiple lines of code with either single uh quotation or double quotation like this it's not going to work it's only capable of taking this kind of multiple text by using using three quotation marks of either single or double type so yeah that's the idea with respect to Strings now you can store as many kind of information with respect to this kind of planet for example name of the planet is Venus I want to give Venus to it then let's say uh like you know if I want to store the age of the planet approximately Venus is about 4.6 billion years old so Planet age is um 4.6 B million years right I can write this kind of information over here can also write uh let's say what is the index of this planet planet index what do you mean by this planet index that on the first index we are having Mercury on the second index we are having Venus on the third index we are having earth right so Venus comes on the second index so you can store this value is equal to two right now let's say uh in Python if I talk about indexes if I be very specific with respect to indexes in Python we start from index zero we don't start with index one that's one thing you need to keep in mind I'll also give a comment over here indicating that in Python index starts from zero hence Venus is on index one after Mercury on index zero if I wanted to store the information with respect to Mercury I would have written the planet index equal to zero because it's the first planet we are having in our solar system right so that's the reason why uh we'll be indexing that as zero now Venus because it's the second planet we'll be calling it as an index one now one more interesting thing that you can do over here is for if if I'm just going to run this code and now if I print this information that is uh name of the planet and uh Planet age and also the planet index okay now if I going going ahead and running this code it's printing me all of this respective information now if I want to check the type of the data if it's a string type if it's a integer type or if it's a float type now what is the meaning of float if you're having a number in decimals okay if you're having any kind of numbers in either fractions or decimals then you simply call call it as a float number so if I'm trying to check the type in Python what I need to do is along with printing them variable I also want to check the type of the variable so what I do is along with printing this variable name I'm giving one more command in Python called type and now what is this type going to do it's simply going to reveal what is the data type that has been stored in the respective variables that's the thing that I'm trying to look after and now if I simply run this code you can see that the first two things are of class string it means that this planet age and the planet uh name both of them are storing a data that is in the format of strings when I talk about planet index now that is not a string that that is an integer okay now just because I also discussed about the float let's say I'm creating one more variable let's say any random variable for that matter Z and I'm giving some number to it 3.2 now I explained that any kind of decimal number or a number that you are able to express in fraction you can call them as a float type so if I go ahead and print the type of variable Zed see what happens you'll be seeing that it's coming out as a float so yeah this was a very quick introduction with respect to what are strings and not only strings we have also discussed about integers and floats so these are some basic data types that you must know in order to go ahead in this particular program now in the next particular video I'll be explaining you with respect to what are some kind of ways through which you can play around with this string strings and do some more beautiful stuff when it comes to Strings hey guys welcome to the sixth video of module one and here I'm going to discuss about one of my personal favorite Concept in Python known as F string so we're going to talk about what are these F strings how to use them and when should we use them and by the end of this video I'll also be talking about what is the concept of string concatenation and how you can achieve it with the help of F string as well so let's get into it let's try to do something really unique with the strings okay it's going to be some kind of a magic let's try to go ahead and explore what I'm uh talking about but before that I can also call this as like you know basic data types this is looking a very big I'll just change this to basic data types okay I'm going to change this to basic data types okay and this data types are what strings uh float and integers these are the data types that we have discussed about now uh I'm going to talk about F strings okay I'm going to talk about F strings okay now what does this mean for example let's say I want to print some kind of a statement uh which is saying that how many moons does a Jupiter have Okay so let's say I'm trying to print a statement now because I want to print a statement I'm going to give it within a quotation that planet Jupiter has or not Jupiter I should say Saturn because I'm looking forward for Saturn not Jupiter so planet Saturn has um 146 moons the reason I have choosen Saturn is because I just looked onto Google that yeah currently as of June 2023 there are 146 moons that have been confirmed for our planet Saturn right so I'm writing this detail as of now now as you might be knowing that as the astronomers are having much and much more information about this kind of gaseous Giants that we are having in our solar system they are keeping on updating the values of the moons once they are discovering new moons right so now what happens in future if uh we want to update this kind of values let's say we found out that Saturn is now not having 146 moons instead it's having 150 moons right so I'll have to manually change this value to 150 to print this kind of thing right so now what I'm going to do is I'm going to create a variable called as Saturn moons okay and I'm also going to change the name of the planet I'm also going to store that what if I want to print the information for a different planet right so I'm also going to store this thing as a name of planet and I'll change this not certain and moons let's say moons of Planet something like this whatever makes sense to you give a very good name so that if anyone is reading it uh everyone is able to make a sense of what's going on so name planet Moon's Planet so I can give the name of this planet as Saturn as of now and I can give that currently it's having 146 moons now what I want to do is I want to print the variable as it is if I'm changing this variable the print statement should Auto automatically change okay for example if I want to replace this set with this variable what I need to write is I need to write name planet similarly over here I will change this thing to Moon's Planet but now if you notice if I run this it's going to print the same thing as it is it's going to print the same thing as it is right it's going to print the name underscore planet and moons underscore Planet instead of the Saturn 146 what is the reason behind that it is because we are not giving any sort of an information to the string that hey you need to take the information from this uh variable and not print literally the string that we are giving over here so that's the purpose of f strings you are giving F over here and then writing this thing within this kind of curly braces okay I'm giving all the variables that might change into this curly braces and now if I run this you can see that planet Saturn has 146 moons now let's say in future if this changes to 150 you can see that planet Saturn has 150 moons you don't have to go to let's say I'm having multiple print statements with this planets uh Saturn with uh moons of planet Saturn basically when multiple print statements I don't need to manually go ahead and change this 150 150 150 okay I just need to make a change to this variable and everywhere else in the code it will automatically be updated to 150 because we are having the change in the variable that's something you need to keep in mind that's the power of f strings that's completely a magic okay it is also used like you know if you want to let's say uh concatenate two strings if you want to join two different strings even then you can use this kind of f strings there are multiple methods but let's stick to a very specific method because this is a universal method that always works so let's stick to this particular method I can also give a name over here uh describing the code I should say comment not name and I should describe it like uh understanding the power of f strings right over here also I could have given this kind of commment checking the type of variables obviously for me I already know what kind of this kind of things is but for someone who is a beginner who is going to look into this kind of notebooks for them to understand what are the things that we are doing over here right anytime let's say in future they're going to get referring to this particular notebook they want to know what they have done over here so for that we are giving comments that this is uh displaying the data values for H variables so this kind of comments are always recommended you can go ahead and give this kind of variables uh some of commments okay all right so now let's talk about string concatenation what is the spelling of concatination let me check it's um string concatination right I am very bad with spellings but yeah coming back to this thing now let's see if I'm having two strings okay that Earth is the only planet with life let's I'm going to store it in a string one variable and I'm going to have this kind of either double quotation or a single quotation and I'm going to store Earth is the only planet with live okay and after this I'm giving another statement string two or maybe not maybe not right something like this so if I want to print and attach the strings together I want to create a statement out this now there are again multiple ways that you can do a very straightforward way would be to join them with the help of plus operator I can have print of my string one plus string two and now if I run this it's going to create a error because if you can see I have written string to without the underscore now if I give underscore and run this now it's saying that Earth is the only planet with life with full stop but now there is no space in between so so for that you can create one more string in between string one and string two that is the space string this was a string this is also a string and this is also a string right and now you can see that thanks to that space we are having the space between this first sentence and the second sentence you could have also achieved this by having a manual space over here and then write string one plus string two even that is fine but now let's say if I want to do it with the help of f strings how can I do it very simple I'm calling my string one variable and then string two variable with a space in between again it's going to run into an error because of the underscore so yes see that's how it's going to work how we can do it with the help of F string right you will look into its power as we advance our program uh in order to go ahead and do astronomical visualization and Analysis but for now this is how you can play around with the F strings and now in the next uh particular video we'll be discussing about A New Concept Al together that is how you can get an input from the user in Python hey everyone welcome to the sth video of module one here you are going to understand this concept of how you can take user inputs in your code so let's you are writing a code and there is some kind of a problem where you need to take some kind of inputs from anyone who is running your code and save that data in some kind of variable so for that what is the command in Python through which you can achieve these kind of things and by default what is the data type of the output by using this kind of input command we are going to learn about these things in this video so let's get started now I'll just create one more code cell I mean sorry teex cell give a heading as uh user inputs okay so what we are trying to do over here we are going to run a command in Python that is going to allow users to give some kind of input okay so what's going to happen I'm going to use a command called input and now that input if I'm going to run see it's creating this kind of a text box where you can give any kind of input that you want and store it in a particular variable if you want okay okay for now I'm not storing it anywhere I just trying to get an input it's not going to do anything so I'm going to stop this run okay I just clicked on this it's saying keyboard interrupt because I manually stopped it by myself okay now what I'm going to do is I'm going to store it uh with some kind of a variable over here okay for example let's say I'm trying to ask name of the user so I can give a this kind of a variable name username okay now if I'm going to write this kind of input it's going to give an empty text box now if I want to give some kind of description so that users are able to understand what kind of data to give then you can have this kind of a string information that enter your name like this and now if I go ahead and run this code see how beautiful it's asking for the name now user can simply go ahead and give for example my name is ran I'm going to give R and press enter and now if I look into I'll just give a comment over here use input to take user inputs and just like this I could have also come over here and check the type of variables by using type Command right this kind of descriptive uh comments are always like you know recommended now user uh name has been given as Rohan if I want to check how it looks like if I'm trying to print this it's simply going to take this username equal to Rohan that's what we have done that's all about it right and now what if I check about the data type can you go ahead and guess what kind of type is this kind of username going to have because it's a text data we expect this to be a string it's as expected that we got a string now what happens if I'm going to code and ask user to input their favorite number okay I'm again going to give a comment to this code first of all that is displaying the variable and its type given by the user now asking user to input their favorite number so again let's say I'm creating some kind of a variable to store this information User fave number something like this and ask asking as an input I am asking let uh give or enter your favorite number okay I run this so again it's asking user to give their favorite number let's say they are giving seven because my favorite number is seven and I assume most of your lucky number might be seven as well right I don't know why seven is very lucky I'll just hit enter and now again go ahead and display the variable and its type given by the user and now if I'm printing first of all my user Fame number it should display seven and after this uh if I'm going to print the type of this user fave number look into uh the output it's still a string so what is happening over here the way that we are calling this input command that is inbuilt in Python it automatically converts any kind of data that is given by the user into a string format it automatically converts any kind of input given by the user in that text box into the string format even if it's a number we just looked into that so let's say if you want this number to be converted into some kind of a numeric format either let's say integer or a float what you do is you try to convert this kind of data type into integer format or a float format how we can do this I'll explain that in the next video hey guys welcome to the eth video of module one and here we are going to talk about that how you can take a particular data type and convert it to some other data type for example if I'm having a float how can can I convert that into string so all these kind of data type conversions you are going to understand in this particular video so let's get into it so now let's go ahead and understand that how we can take this particular data type that is in the format of string the seven how you can convert that into a numeric data type that is either integer or float or maybe let's say both of them so for that what I'm going to do is I'm going to create a heading which says that data type conversion you're going to learn about how you can convert any data type into some other data type if it's possible to convert or else you'll be getting an error so the commands that you need to know commands to convert if you want to convert any kind of thing into a string any kind of data it could be a integer it could be a float it could be any kind of data type okay we have cover only three of them but let's say it could be any kind of data type if you want to convert that into a string the command in Python is is the string any kind of input that you give to the string that input if it's possible to convert that into a string it's going to convert it into the string just like that in order to convert any kind of input into integers you are having this command of in integers so any kind of input that you pass to this int within this kind of parenthesis it's going to convert that input in the format of integers if it's possible to convert that input in that integer for example let's say if I'm having 3.5 if I try to convert that into an integer it's not going to it's not going to convert that 3.5 into an integer because 3.5 is the format of float however there is some interesting thing that's going to happen if I'm going to run this kind of code you will be understanding it in a while now just like that if you want to convert any kind of input into the float format you call the float that is available in Python itself and then you give some kind of input that's how it works okay and now I'm going to give one more comment after giving one empty line that convert a string data into integer and Float so uh we know that this seven is currently existing in the type of string I can again cross check it by simply typing this uh type and user fave number and this time I'm not writing any kind of print in top of that because in Google column what happens is if I'm going to run this the last line doesn't require print statement to print the output okay but if I giving let's say I'm just copying this thing and printing it again over here it should have been printing twice for me right if I run this code but it's going to print only once why because it's going to give me the print of the last statement automatically I don't need to give print command if I want to print both of them I need to give print print for both this lines okay that's something thing that we need to know okay but anyways coming back to our discussion that is we already know that now this user F number is in the format of string right so now I'm doing is converting a string to integer how I'm passing this int and then passing in this user fave number and uh simply running this code by pressing control enter and I'm also trying to print the type of this string to int and see if that thing has converted and at the same time I'm also going to print the string to int variable that we have created as you can see now the output is again seven see how the seven are looking just the same it's the change in this data type now from the string we have converted it officially into an integer now this string to integer variable is having the value of integer 7 right we how did we do it by just using this kind of inbuilt command in Python of integer I gave an input to it because we know that the seven can be written in the format of integers we are having this kind of an data now what if I let's say for example give a string like this string like this and ask to convert this string into an it's not a number how will this be converted into an integer it's not possible you're are getting this kind of a value error that hey I'm not able to convert this string into an integer invalid literal for this integer it's not possible to convert this into an integer so make sure that you are giving these inputs that are able to be converted into an integer now at the same time now what happens if I'm giving 3.5 now this time you might expect that it can give you an error because now it's in the format of decimals and even 3.5 in itself is not an integer right so what's going to happen over here it's not going to give you an error instead it's going to round it down to the nearest integer so if I'm having 3.5 it's converting to three if I'm having 3.9 it's still going to convert it to three so yeah that's how this kind of integer works so make sure if you want to have 3.9 let's say if this was in the format of string and now if I run this this time it's giving me an error because string cannot directly be converted into an integer that is having a float data with within itself so I need to convert that 3.9 first of all into float so so that this 3.9 that is existing in a string is first of all converted into a float and now that float will be converted into an integer and now it should work perfectly see how that 3.9 string got converted into a float that is 3.9 and now that 3.9 if I'm giving as an integer of this 3.9 it's converting into three right so that's how it's basically uh working the in 3.9 the integer part is that's what essentially we are getting right so yeah coming back to like you know going uh breaking this whole thing into a stepbystep format uh this was user fa number okay and let's say I'm also having the string to integer or let's say yeah string to integer now in is already done right we about to change it to float so now we are having float of user fave number remember this user fave number is already defined over here we haven't done any kind of changes to it so it's still in the format of and string okay it's just that this variable is now given this value that is integer of that string data okay so again if I'm uh first of all printing what is the type of user fave number it won't change it will just be the same because I haven't done any kind of changes to that variable right that variable is still the same okay it's giving me some kind of an error it's giving me a name error that S type is not defined oh yeah because I done a type over here see now it's still you can see it's uh the last this is the last print statement it's saying that it's still a string right now let's say I'm trying to convert that string into a float how we can do it right I'm going to print this thing string to float and also print the type of it see that's how it's working it's converting that 7 into 7.0 and now that decimal indication is saying that it's uh basically float type again I've done some kind of a type over here I should have not written float I should have written string to float right string to float like this because float is a function right it's not some kind of a variable so yeah as you can see now it's giving you the output of float the type of the string to float variable that we have created is is a flute now let's say if I want to get user input of two different integers and add them together how can I do it so what I'll do is I'll take number one as an input I'll ask them to input their number give any integer number okay and then after that I'm going to give another variable that is input give one more integer all right and then if I'm going to add these numbers together and print it N1 plus N2 or else let's say we are having a very feny way to give this kind of a statement by using FST string I'm going to say that uh the sum of N1 variable and N2 variable is the summation of them that is N1 + N2 now remember I am not converting this into integers right because we know that by default this input is going to expect the numbers in the format of what strings so let's if I'm running this as of now and giving let's say seven and another integer is let's say my another favorite number is nine so so 7 + 9 should be what 13 9 10 11 12 13 14 15 16 okay my bad again my very basic mathematics is also very wrong but anyway 9 + 7 whatever is the value okay 9 plus 7 you can do it in KY it it won't be 79 right so now what's going to happen the reason we are getting this 79 is because that this N1 and N2 is a string and we are concatenating them this kind of string with the help of this plus variable I mean plus operator and that's the reason why the seven and N are getting concatenated we are joining the strings together with the help of that plus like how we did over here while uh before this F statement I F string I had given you a way through which you can do it by simply converting this into this plus and there is also no uh quotation marks and if I print this it was giving this right how they were joined this two kind of strings and then we had given this kind of space and everything so yeah that's exactly the same thing that I'm showing you over here okay this is string to just converting it back to what it was and yeah that's uh typically uh what we are going to do over here that because it's in the format of string it's concatenating them now if I want to convert this into an integer I need to pass this int on top of this why because I'm converting the string into an integer and I know user is going to give me an input of an integer it's going to convert it automatically into the format of integers and let's say my mathematics is really very big I'm giving the value of seven and 9 and this value of 16 is now accurate right so yeah that's how it's going to work how you can take inputs from the user if it's a numeric data and if you are sure it's going to be an integer no other data you directly give this input of int on top of this input that you're getting from the user it will automatically convert it into the integers and then you can do any kind of sorts of things you want so yeah that was about how you can uh do the data type conversions convert one kind of data into some different type hey guys welcome back once again to the first module and here is the ninth video of it where I'm going to teach you the concept of control flow in Python now this is the heart of programming if you don't know this concept you are not a good programmer at all not that other concepts are not important they are equally important but as I mentioned this is the heart of this programming language so we're going to start with the looping part specifically we're going to look into the for Loop and while loop once you understand what are this kind of looping why do we use them how to use them we are going to move on towards the condition statements where we're going to understand about if statements if else statements and also if L if L statements and again there are a lot more things that we need to cover in this video so let's get started now let's go ahead and talk about what is control flow in Python okay let me Define this as control flow and the whole idea that you're going to learn over here is I'm just going to cross check if that's the seven yeah that's the seven okay the whole idea we going to learn over here is with respect to for Loop and while and then you're going to learn about some condition statement okay and the main idea over here is that if you are having some kind of a code which is repeating okay and you don't want to manually type all these kind of things for example if I'm writing print zero and then after that print Z I'm also writing print one and then print two then print three right I'm knowing that this kind of integers are giving like being printed starting from zero then 1 2 3 like this let's if I want to do this for 100 times for some reason okay this is just for an example as we'll be going in the upcoming modules in this program you will see the power of all of these things okay right now I'm just trying to teach you that these kind of things exist okay so if I want to do this kind of things if I want to automate this kind of things how can I do it because I know that there is some kind of certain kind of things which are keep on repeating itself in a specific way I can transform this whole idea into for loops or maybe while Loops I'll be first talking about for Loop okay so what happens is if I'm trying to initiate my for loop I need to give the keyword called for then for what so for some kind of index that is present in some Itor now what is the meaning of it rator Itor is nothing but some kind of a storage where you are having multiple values that one can take okay that index can take okay so let's say if I'm having list of numbers so in Python you can create a list with the help of the square brackets okay again this is not important thing to discuss as of now but let's say that you know about this kind of list and I'm storing let's say 0 1 2 3 4 this kind of values in the list now what's going to happen automatically this index is going to be like acting like a temporary variable you can call that as a temporary variable that's going to take one by one values that is present inside this iterator list is an iterator where you are storing multiple different values and uh this index is going to take this values one by one starting from zero in the first loop after the first Loop is over it's starting the second loop it's going to take the value of one this index will keep on changing its value starting from zero then the next value that is one then next two 3 four like that until this kind of last value is been uh taken by this Index this kind of for Loop will keep on running okay so what I'm going to do is I'm simply going to print index as you can see the first time this code ran the index was taking the value of zero that's why it print the value of zero similarly now the first Loop is over it's entering the second Loop it took the value of index uh as one that's why is printing me the output of one so that's how you can uh it rate through this kind of it readers and list is just one of the example let's if you want to create a list of 100 numbers and then you want want to iterate you cannot manually go ahead and create this kind of a list of 0 to 100 or 0 to 99 for that matter right so the way through which you can do this is something by using range okay now what is range the way it works is it takes the start value it takes the ending value and then it takes the skip value if I show you let's if I'm giving first of all range of just any number 10 so it's going to give me integers that are present in between 0 to 10 that's the purpose of range in order to prove you that what I'm going to do is I'm going to convert this into range of 10 and then run this so it's going to give me the values 10 values in between 0 to 10 so starting from zero it goes all the way up to 9 as you can see after 9 there is no output because this are first 10 numbers starting from zero and yeah we are ending at nine one value that is less than this okay now let's if I don't want to start from the index zero I want my first integer that is present in the range to be let's say minus5 so I can start with minus5 because I know that I can give that kind of a syntax start and then end if I'm just giving one number it's just taking the value of end at where you want to end a value before that actually and now if I run this you can see that now it's starting from minus 5 not zero it's going till 10 by default the value is set to zero for the start if you not giving any specific input to it now it's going to take the value of minus5 okay so if I change this 10 to minus5 and then if I run this okay I did a mistake I should have written - 5 comma 10 and now if I run this say starting from - 5 -4 -3 it's going to go all the way up to nine until that 10 until that 10 is achieved you keep on going to it rate okay so it's not like you are going to get only 10 values no anything in between minus 5 to 10 you're going to get that as an output minus 5 is inclusive 10 is exclusive okay just keep that in mind but typically let's say uh we want some kind of numbers to start with one and then go all the way up to 10 in that case I need to go from 1 to 11 so I hope this kind of things are making now a good sense of how to play around with this range to get your things done right it's now going to start from 1 to 10 now 11 is exclusive remember that that's why it's getting printed to 10 right that's the whole idea one more thing that I can write over here is start is ex inclusive and end is exclusive it simply means that the value of end is the actual value one before that end that we are defining that's what range is going to take all right and now what is the meaning of the skip let's if I want to skip right now it's currently by default skipping one one numbers right after one it skipped one value it went to two 1+ 1 is two right then 2 + 1 is 3 if I want to have this plus two instead of plus one I can let's say have this comma two so now after printing one it's going to add two numbers to it it's going to go to three directly without getting this two as an output so it will be like 1 3 5 7 and N okay why stopped at 9 because 9 + 2 is 11 the moment I reach 11 it's not going to give that as an output right that's not not how it works so yeah that's how it's going to be after 9 because the next index value is 11 it's not going to run for that index so yeah that's about how you can uh use for Loop to do some kind of specific thing right now I given a very simple logic that if you want to print some numbers between let's say 1 to 10 and if you want to skip uh two two values starting from one then skip two values you get to three skip two values from three you get to five that's how you do it so that's the concept of for Loop now if I want to do the same thing with the help of while loop how can I do it I can do this by giving while keyword and then a condition I need to provide some kind of a condition and this kind of column is again very important I did not explain you over here but this column is very important this column is going to indicate that whatever you're going to write within this kind of space okay this space is also important which we call as an indentation so if I'm going to delete that space and run this it's going to give me this indentation error why it's giving me this indentation error because the space is missing the for Loop expect this kind of space so that any kind of code that is written within that space that's going to be the part of the loop if I'm going to print some value over here let's say five and run this see it's at the end also printing the value of five but now that Pi is not printed for this many times if I have this kind of space in between so after every number five will be printed after every number five will be printed see after one five is printed after three five is printed so that's the power of this kind of indentation if you're going to give this indentation over here it's going to assume that print five is to be supposed to be there within the for Loop if you don't want to have that indentation then now it's fine it's not going to give an error because it's having at least one line to run within the for Loop and if I skip that thing now it's going to give an error because it needs at least something to run right but now let's if you don't want to get an error like that you can simply use pass keyword okay now this pass keyword what it does you can try to think and uh like you know you can think about the whole logic of the loop uh for that time you can use this pass keyword and if you try to run this if you're thinking about some kind of logic this pass keyword is a very good way to like you know just don't write anything with the for Loop right now just write initiate the for Loop go and do the second part of the code and then come back later on over here so for that you can use pass okay but anyways coming back to where we were okay I'm going to remove this thing and also remove the whole line and come onto the while loop okay so in while loop it expects some kind of a condition that you need to run this Loop until this happens until this condition occurs okay and then over here also automatically if I keep enter if I press enter after the column it gives me this kind of indentation automatically and now over here I can give any kind of way through which I can Loop into this Loop any kind of thing I want to do until a certain kind of condition is met it's simply going to run okay for example let's say I am asking a user I want to create this kind of loop where it's asking user to enter their favorite celestial object okay and every time they are giving the inputs I'm going to also keep a track of an like you know this index I I'll also be updating the index after every iteration so that I'm having like you know favorite celestial object one is this then favorite celestial object two is that so that's kind of stuff that I want to create and uh after that the condition to break this for Loop is again something that I'll be giving and that's how this while loop will be over for the for Loop what's happening in the for Loop we are automatically ending it once the iterators are over like once you're not having anything to itate for it will be over right so once you are hitting that value of 11 you are not going to have anything else to itate so that's about the for Loop but in the while loop it's going to run forever if the condition is not made so it's compulsory for us to write a condition in a way if you want to stop your Loop that condition should be satisfying a certain kind of thing through which you can stop the loop you can break the loop okay so what I can do is I can come up with this kind of a logic that always run this thing okay I'm not giving any kind of specific logic over here I'm just saying that go ahead run this Loop Forever at the same time I'm also having some kind of counter okay I'm having some kind of index that I'm going to track that how many times this kind of iterations are happening and now I'm also asking user to give some kind of input okay let's say enter their favorite Celestial body so let's say I'm going to store this in the variable called object that is obj asking for the input enter your favorite celestial object and then I want to ask them that this is the first thing that they are inputting right CT + 1 because CT by default is zero so I'm just going to write ct+ one over here and then have this F string and this is also typo so I'll convert that into input and now what's going to happen in the for Loop okay if I run this as of now see what's happening it's asking that enter your favorite celestial object one I'm going to say earth now again it's saying enter your favorite celestial object one why because we are not updating the value of the CT and it will keep on asking me because I'm not giving any kind of condition to stop this while loop right so for now I'm manually stopping this over here so let's talk about how we can update this counters I can once I'm done asking this kind of input from the user I'm going to update the value of CT and say that CT is equal to the previous value + one you could have also written this uh as like you know City Plus equal to 1 it's essentially doing the same thing it's taking the previous value of city and adding one to that okay so 0 + 1 is 1 okay and now uh 1 + 1 will be 2 right so that's how this is going to become 1 + 1 2 right so it will ask enter your favorite celestial object when the CT value will be one this 1 + one will be two or by default you could have started this with one and like you know you could have remove this one over here because it will start with one and then automatically it will be two in the next iteration whatever it's up to you right how you code your specific logic so yeah that's what I have done and I'm also going to give the condition that if if user is going to input something that is asking to stop that yeah that's it I don't have any kind of favorite celestial bodies apart from what I have given as an input so if the object input that has been given by the user is equal to let's say something called quit okay then what I'm going to do is I'm going to break the for Lo there are multiple new things that you learning over here that is this if statement along with the break statement so what's happening so until the user is going to write quit it's going to run this F Loop and the moment they are going to type quit it's going to break the for Loop so this is called as condition statement that is if condition if this condition happens then you're going to terminate the for Loop by using this kind of break keyword and then let's say if this is not the quit you can continue the code so you don't need to do anything if this is the condition that is met then break the loop okay and I can also give this kind of a print statement over here that type uh quit type quit to exit right this kind of uh hint is something that I'm trying to write over here so that user knows how you can escape this kind of loop when to St okay right so now let's see what kind of things uh happen if I'm running this code so see how it's coming type quit to exit so now let's say that favorite Celestial body is for example Earth then let's say black hole this kind of inputs now I'm tired I want to give quit but now I give it like this it's not quitting why because I give this Q as capital right I give this Q as capital I need to write small q ID the lowercase Q it only then it will stop so now to tackle this kind of conditions what you can do is you can take the user input and convert it into this kind of lower case the way you can do it by passing this lower function that exist in Python for string so if I want to demonstrate that I'm going to write a commment convert any string into lower case how you can do it let's say I'm having a string demo is equal to uppercase or any kind of combination of letters is upper case just like this okay now if I print this string demo it's going to be as it is upper case now if I want to convert that into a lower case what I'm going to do is my string demo. lower is what I'm going to print now this lower is converting this any kind of upper cases anything to a smaller case if it's existing it will convert into a lower case if it's already a lower case it's not going to do any kind of changes to that so now by applying this even if it's writing capital Q UI even still that is fine okay so if I run this and uh now if I am writing Earth black hole right and then UI let's say capital T also for that matter see it's still quitting why because the power of this lower functionality that is implemented to the string there are again bunch of different methods that you can apply to a string but because we don't have to learn everything in Python only some specific things that you will require in order to do some kind of astronomical visualizations and Analysis then this much amount of information is quite okay for now okay as we'll be going ahead you will be learning a lot of different stuff in Python over here I'm just giving you a warmup so that you are understanding a lot of things in Python and you're not just getting confused of some basic stuffs right so yeah that's about like you know we have talked about how you can have this kind of for Loop you can have while loop then also talk about some kind of conditions like this let's say if uh if this is the condition then do this else if object lower equal to some different thing let's say um Capital quit then do what then let's say print type smaller quit smaller or lower C quit or else it's not going to make any sense as of now so what I'm going to do is I'm simply going to delete this okay I'm just going to keep it as of now over here I'm not going to complicate the things if there will be something where you will be requiring to understand the elsf condition also over that specific time I'll be understanding you like I'll be explaining you okay for now all of these things are again quite a lot of thing to understand in just video so yeah I'm going to end this video over here and in the next video what we are going to learn about is functions and I'll try to incorporate this kind of f else block over there uh with lsf condition also right so stay tuned for that hey guys welcome to the final video of module one and here I'm going to teach you the concept of function in programming so to start with we'll be talking about what is the need of the functions in programming and I'm sure by the end of this program you will be appreciating that you have learned this particular concept so we'll also learn about how you can create your own function in Python then in order to use it how you can call these functions and then at the end of this video you will also be creating a function that's going to work like a very simple basic calculated to perform some kind of addition multiplication subtraction and all that kind of stuff so let's get started with this video now let's understand the concept of function in Python I'm going to create a Texel give heading now the whole concept of the functions in Python is very similar to again what we do in mathematics if you are giving some sort of inputs to a function now that function can take any kind of formula right now if you're giving some kind of inputs to that formula let's say you're having f ofx is equal to 3xΒ² + 2x + two something plus three something like this so now if you're going to give the value of x as two or automatically this x will be taking the value of two and whatever is the output of 3 into 2 s + 2 into 2 + 3 that will be the output of this function now the very similar idea is what we are following in Python also we create this kind of functions to repeat some kind of block in Python okay just like what we did for the for Loop or Y Loop but over there you are continuously iterating one by one but now what if you want to use same block of code in this code cell but then after let's say two three Cod cell again you want to use that again after one two code cells you want to use that so for that you create functions right now how do we create this functions in Python you use this kind of keyword called def for defining the function then you give name to the function now let's say that I'm trying to create a function to GRE everyone of you over here who are watching this video So Def greet I'm giving this random name that came to my mind and then you need to give some kind of input arguments to this function right now I'm not giving any kind of arguments and now again this kind of column is given so that python understands that yeah now anything that is given below this kind of colum with this indentation it's all going to be the part of the function let's say that I'm trying to print the value or not the value but the string called he estro files I'm assuming most of you over here who are watching this video are asro file so what I'm doing is I'm going to create this kind of function that's going to do this particular thing okay hey asro files I'm just trying to create every one of you now how to call this function once you have created a function how you going to call them you're creating a function to gr viewers of this video right and without any input argument uments or parameters you can call them as input arguments input parameters there are wonderful names given to the same thing over here okay now I'm going to call that function how to call that function you call the name of the function like GRE okay have this parenthesis and just run this code you're going to get an output of hey estoiles I don't need to write this kind of same thing again and again now anytime I want to call this function it's going to print a asiles for isn't it just interesting now I'm just going to go ahead and add one more magic to this function that I'm going to specifically greet some of you over here okay let's say that uh one of your name just for example is let's say let's just not give any kind of random name let's just take my name okay and let's say some of your name is also Rohan so yeah if Rohan if you're watching this particular video then I'm going to greet you specifically okay but yeah coming back to the concept what I'm trying to do over here here is uh Define a function to GRE a person whose name will be given whose name will be given as an input so now what I'm going to do over here is I'm going to first of all create a very similar kind of function but this time I'm going to have this kind of a name okay so let's say defining a function give a name let's say gr person something like this and now it takes one input argument that is name okay now this time what I'm going to print out is this a whatever is the name again because I'm using the F strings I need to use f over here hey whatever is the name I hope you are enjoying this session and learning a lot of things in Python something like this right and now if I'm going to uh run this code to create this function now again call that function okay now how it's going to work see that I'm going to call this great person and give a name of let's say Rohan okay so yeah hey Rohan I hope you are enjoying this session and learning a lot of things in Python yes I am okay thank you but yeah anyway moving moving on to the next part so yeah this is what I'm trying to show you that now I can just call this function with different different names okay call this function with different name okay now I'm going to again call this function person and let's say that I don't know this name came up into my mind out out of nowhere let's use Curren okay I'm lying he is my best friend so yeah anyway so hey current I hope you it's going to print the same thing just that wherever now there is a name variable it's going to replace it like this you are trying to create some bunch of different formulas for function not actually the formulas but specific code that will be repeated with some kind of different inputs that you give to a function so yeah this is how this kind of functions work in Python but now that's not all do this kind of things okay now I'm feeling a bit sad that I'm not wishing all of you over here so what I'm going to do is I'm going to call this function for one more time call this function to gr everyone to gr every one here watching the video I can simply call this great person but instead of just greeting one of you guys I'm going to greet everyone of you so what I'm going to do is let's just call this as everyone okay and now I'm going to run this it says hey everyone I hope you are enjoying this session and learning a lot of things in by now this is good right so yeah that's about this thing but yeah now moving on to some more advanced concepts of python that you must know because these are very essential you will be using a lot of inbuilt functionalities in Python and different libraries in python in the upcoming modules you need to know these things that I'm going to teach you right now so please pay attention mention very properly over here okay now what I'm going to do is I'm going to talk about two things that are keyword arguments uh and the default arguments and also the position of the arguments okay now this concept is really very important a default or I should say first of all I'm going to talk about position arguments and I'm going to talk about keyword arguments and also about let's just talk about uh these things right now so that I'm not confusing you guys with a lot of stuff so what happens over here is that if you are giving two inputs okay you're not giving only one input you're giving two inputs to the function for example one that is the name and then you can give some kind of a greeting message okay now you cannot just have I hope you are enjoying the session you can have some kind of different message also if you want okay so I'm going to give this kind of uh functionality to my users who is going to use the function that I'm creating in Python so that they can give any kind of message they want okay this is just some examples that comes into my mind right now so what I'm going to do is I'm going to again create a function I'm first of all going to talk about position arguments okay I'm also deleting the keyword arguments so if I'm greting and I'm passing let's say I'm creating a function called greting passing name and message and then I'm saying that print name okay I'm giving this FST string print name and then message something like this is what I want okay I want to print my name first and then I want to print some message or else I could literally play around with these things properly I can say hey name and then some kind of a message something like this right it up it's up to you how you create your function so let's say I'm creating it like this and this time if I'm trying to call this function by placing the input arguments in the same order while building it so I'm going to call my function that is greting I'm going to give a name again let's say I'm going to just play around with the names I'm going to play with let's say l and then I'm writing a message um are you an asile something like this right and now if I run this it's giving hey Lea are you an asile this kind of question has been asked right and if you can see this exclamation is also getting printed so if I don't want that if I'm just again calling this okay so yeah this time see what's happening I'm not getting that kind of exclamation mark now this time what I have done I place this l in place of name in place of message I put this now what happens if I'm going to shift call the function by Shifting the positions of the arguments of the function right so I'm going to call the same function again but now change this kind of message with name right and then like this and now if I enter this hey are you an estoile comma lus it does not make any kind of sense right so that's the thing that I'm talking about the position of the arguments whenever you are defining a function you always look into what kind of uh way what what is the position of each and every arguments if name argument is kept first you always go ahead and give your this kind of name is equal to uh something okay there is L yeah you don't give this kind of message over here whatever is the first input argument that respective input should what go over here okay because now it's thinking python is thinking that hey this is the first argument so this should go in the place of name so that's something that you are learning over here with respect to the position arguments but now what happens if I'm again having the same kind of uh thing but I'm specifically saying that this is my name argument and this is my message argument okay now call this function with keyword arguments so what I am doing over here is I'm giving some kind of argument keyword before passing just the arguments I'm also having its respective keyword that I have used to define that argument so this is called keyword arguments okay that now even though the position I have changed but now because I'm giving a specific keyword now python understands that this should go for the message argument and this should go for the name argument and therefore you are getting this as an output I hope these things are making sense to you okay now one more thing that you can study in functions that is very common is default arguments that is while creating this kind of a function okay while creating this kind of a function let's say greting with default argument something like this is what I'm defining the name of the function and now what I'm saying is if someone is not giving any kind of name or if they are not giving any kind of message by default what kind of message they should uh be seeing uh welcome to this program on astronomy visualization something like this right visualiz a something like this is what I want to uh give them a message and I want to print hey name and then the message Okay now what's going to happen always remember your keyword arguments that you will be giving will always come later on first the position arguments will come if you're having mixture of like you know keyword arguments with the position arguments always remember whenever you will be calling a function you first need to pass in the position arguments because the order matters over there and at the end you can change this kind of uh keyword arguments order that's fine at the end of the function what I'm trying to say over here is that first of all I'm going to call this function call this function uh without passing message argument and see what happens so greeting with default arguments and now I'm giving the name of let's say ran I'm coming back to because I'm not in the mood to think about new name you can say that and now if I'm running this see it's it's giving me an error the reason it's giving me an error is because I haven't run this code right it's giving me that this this thing is not defined only so how can you how are you running this and now if I'm running this you can say that hey Rohan welcome to this program on astronomic visualization right it by default took this argument whatever was written over here and it gave me over here now what would happen if I'm giving my message variable first uh and then giving my name okay I'm saying message equal to uh WhatsApp something like that okay and then now see what's going to happen in the first position that should be name okay but in place of that name you are already giving this message variable I mean message keyword now this keyword is already taking this kind of value now in the second position there should be a message now that is already exist over here that's why you're getting this kind of red line and obviously you're going to run into an error position for arguments follows keyword argument so always write your position arguments first and then the keyword arguments okay so over here I could have written this as like you know our name that is Rohan and then the message this is fine just write XL right even while defining the functions if you are having this message first and then the name like this see what happens it's going to throw an error non-default argument follows the default argument just like in the keyword and the position if you are not having any kind of default values you always keep them first okay that's something that you must know while creating your own functions okay now all of these things that you have learned over here is going to be pretty much very useful whenever you'll be implementing these ideas in the uh upcoming modules that you will be learning okay but now one last thing that I want to describe over here is I'm going to create a function create a function that will either add subtract multiply or divide two input numbers okay so I'm going to come up with a very basic calculator with the help of functions okay and I'm going to show you that how you can do all these kind of things create a function that will either add it's not wether it's either add subtract multiply or divide on any two numbers that has been given as an input okay so let's say I'm creating a function called basic calculator okay and now I'm giving some kind of inputs of two numbers that is number one number two and then what kind of operation I want to have for example let's just call that as an operation add multiply subtract or divide something like that okay I'm trying to demonstrate that if else if and else kind of statements okay so now let's say uh if if operation dot again I'm using this kind of lower functionality so that if if anyone is also giving capital A D even that's going to find in order to compare so if the user input is ADD I want to return something now this is again a new thing we are learning in functions it's not always about printing right if you want to give something as an output just like in the mathem iCal function if you're giving some input it's going to give you some kind of specific output it's going to return some outputs so you can get something out of this calculator or the function that you are creating by calling a keyword called written anything that you write after written will be the output of the function when you call this whole function with some input arguments okay you will understand this in a while so let's say I want to written what do I want to written I want to written N1 + N2 whatever is the output of this N1 plus N2 is what I want to written now if I run this code and test this basic Keli giving my first number as two second number as three and then operation is ADD and then run this see the output is five how did I get this output five because I'm returning this value I can store this value in a variable now I can store this in say uh addition something like this and then also print this and I can use this kind of addition somewhere else in the code right addition so that's the first thing that we have done now the second thing that we are going to do is we going to say that if else if operation. lower is to subtract okay then return what return nerse minus N2 just like that else if operation. lower is to multiply multiply then what you do return N1 s symbol is used for multiplication and then else if operation. lower is to divide then you're going to return what N1 divide by N2 right else if anything else is given as an input apart from add subtract multiply or divide you're going to say that print I'm going to create my f state with F string you can either in your operation Operation input can either take either take add multiply subtract or divide you give what whatever was the like you know the operation that has been given by the user you give this try again this kind of message is what I'm trying to print okay and now if I run this code see how it's working if this is the condition then do this else if if this is condition then do this else if this is the condition do that else if this is the condition do this and if it's nothing like that then do this that's the proper if else if and else block that we have created over here okay so now if I run this it's giving me five as an output right now let's say if I want to do some kind of multiplication and I'm storing it in the multi multi multiply something like that right now I'm going to create this kind of basic Kelsey function and give this kind of uh thing that uh first number is three the second number is three and then multiply okay and uh print the value of multiply also print multiply 3 * 3 is 9 we expect the output of N9 right you can go Ahad and test for all these things okay what happens if I'm trying some random input and I'm not going to store it I'm just going to try to see what's the output that we are able to fetch 3 comma 3 and some random okay and then if I run this it's going to give operation uh input can either take add multiply subtract or divide you give this try again right so this is this is the thing that is giving output I can shift this to capital O and I can also give some kind of uh like you know uh information over here with the help of multiple strings over here I can say that parameters I can first of all give the kind of like you know an idea of what this kind of function is doing this is a really very good way of documenting your functions okay I'm describing what this kind of code is doing okay this function is doing um create creates a basic calculator that takes first that takes N1 and N2 in the same order and performs either of addition subtraction multiplication mul multiply and divide they can perform either of this right and then you can give parameters and then you can have this kind of parameters that uh N1 first number then N2 is your second number like this you can just give all the kind of proper information and then operation Operation is any of the operations mentioned above for our basic calculator that is add subtract multiply or divide and then it's going to also return what it's going to written uh what is it going to return it's going to WR let's check what is it written yeah either the output of the curency the output of the operation done N1 and N2 so you can also give an example over here if you want but yeah that's pretty much about how you can describe a function so that if someone else is going to use your function they already know how to like you know give some kind of inputs while uh calling your own function that you have created right so yeah that's about the functions that you should know and uh over here these are some kind of pretty much things that you should know if you know about all of these things you are now having enough idea just to advance yourself into Python and learn a lot of uh beautiful things in terms of how you can create different visualizations in astronomy by using some new things itself but at the same time now you're aware about a lot of things in Python that's for sure not going to make you think like a lot of overwhelming stuff going on okay so yeah make sure that you are going through all the kind of quiz questions that we have given just to ensure that you are now having a proper idea about all of these Concepts that we have taught uh before you advance to module two hi everyone welcome to the second module I hope that by now from the module one your concepts of basics of python are clear because all of those Concepts will be now implemented in module 2 that will be helping us to convert a tabular data of real stars out there in universe and create some amazing visualizations out of it and do some observations get some observations out of it do some kind of analysis and then whatever kind of visualizations we will be creating we'll also be saving it into our system so all of these kind of things we'll be doing in this particular module and specifically what type of graphs we are going to generate from this tular data of stars we are going to generate the bar graphs we're going to generate the box plot we're going to create the line plot also the pair plot and finally at the end of this particular module you will also be creating an HR diagram now this HR diagram if you're not aware about it it's completely fine because by the end of this video you will be knowing this everything and you will also be coding for the same thing okay it's one of the most amazing things that you will be seeing whenever you are dealing with the star data okay so let's get started with this particular module hey everyone welcome to the second video of module 2 and here I'm going to give you a quick sneak peek on the data set that you will be using throughout this particular module so this is basically about some real stars out that in universe and yep without spoiling any of your excitement let's get into the video let's go ahead and try to understand what kind of astronomical data that we are using in order to create some of our first visualizations in this program with respect to that astronomical data and then not only that how you can take this kind of visualizations that you are going to create in Google collab and save it into your system so that later on whenever you are doing your research work in order to give support to whatever kind of work that you are writing in your research to support that work you can always add this kind of visualizations right so how you can extract this kind of visualizations from Google collab into your system and then obviously you can uh attach this kind of visualizations into your research paper or maybe report or whatever kind of research work that you might be doing so all of these things will be covered in this particular module and uh specifically the data that we're going to deal with is stored in in the format of the CSV file in this particular Google Drive Link so we're going to ly export this data from the Google drive into this Google collab and then we are going to explore this kind of data set step by step and then create this visualizations that's the whole idea the main goal is to create some kind of different visualizations from the data set and the data set is all about different stars that are existing out there in space and then all of the stars are given with its respective properties of absolute magnitude then surface uh temperature spectral type and also the luminosity and at the end we are also going to create this kind of a hers sprung russle diagram or in short you can also call it as a CHR diagram which helps astronomer classify any kind of a star based on its properties of this absolute magnitude spectral type surface temperature and the Luminosity so that's the whole kind of idea that we are going to deal with throughout this particular module and I'll see you next in the upcoming video where we are going to deal with exploring of this data set hello hello everyone welcome to the third video of module and here we are going to go ahead and import the libraries so what kind of libraries are we going to import or what kind of libraries are we going to use throughout this module two you're going to understand each one of them as in why are we importing them and then yes as you can see on the screen find out what are this kind of libraries and why are we going to use them so let's get into it now in order to explore this kind of data set that we are having in the format of Cs that is stored in the Google Drive and also create visualizations on top of that what we'll be doing doing is we won't be coding everything from scratch we going to use some of the existing libraries that's going to help us so that we can save our time and at the same time use this kind of libraries to create some kind of beautiful visualizations after exploring them so for that I'll have to import these libraries which will help us throughout in this particular module so what I'm going to do is I'm going to go ahead and import the libraries that are going to first of all help us explore the data set in a proper way so I can do this with two of the libraries that is Port OS okay how exit it will be helping you will get to know in the upcoming videos but yeah OS is one of the library that is going to help us to let's say for example create a directory where we are going to save all of our visualizations and also it's going to be useful for some other purposes that will be same apart from that if you want to open the CSV file and explore it step by step the main popular library that we are going to use is pendas so I'm going to import pendas as PD the reason I'm calling it as p PD over here so that because I don't want to write pandas again and again okay I just want to use PD in short so that I don't have to write pandas again and again continuously right it's up to you you can just simply import pendas and use all the functionality of pendas Library by calling it completely by calling it as pendas not PD it's your choice okay I can have also import pendas as let's say for example my name is Rohan so I can have also import this thing as import pendas as ran but now it does not make sense right it's almost pretty much same letters that are having so a short form that we use in the python Community for pandas is PD just like that you will also maybe needing some kind of a way through which you can create an array from this kind of a CSV file okay so from the CSV file you want to generate some sort of array for that he will require a library called as numpy so I'm going to import numpy Library as NP so now I have imported all of these libraries that are going to help us explore the data set now in order to visualize this kind of data you will require visualization libraries so for that what kind of things I'll importing I'll be importing the first thing that is c bond again because the there are a lot of characters in this particular word I'm going to import it as SNS again a short form that we use in Python Community for cbon and then we are also having one more one of the most popular libraries for visualization that is met plot Li so I'm going to import met plot lib and specifically P plot uh and I'm going to import it as PL again a short form to call all of these things together right so these are the libraries that we are going to use majorly to create some kind of different visualizations after exploring it with the help of os pendas and numai so that's the whole idea and now from the next video we are going to go ahead call the data from that link and finally start exploring it hey everyone welcome to the fourth video of of module 2 and now that you are already having a quick idea of what is the data set all about let us try to explore this data set with the help of python we going to convert the CSV data into Panda's data frame with the help of pendas library and then summarize this whole information that we are able to fetch from this particular data frame about the Stars so let's get started now what we are going to do is we are going to take that uh CSV data I'm going to Simply copy this link and use this particular link or part to the CSV file read that CSV file with the help of pendas library and create a pendas data frame so what does this mean so I'm going to use pendas functionality so I'm using PD and then dot to refer to any kind of functionality that is present in pendal and now because I want to read the CSV file I'm going to write this command rore CSV and then it expects this path in the format of string to that CSV file so I'm going to Simply give this kind of a quotation mark and paste that link now you don't have to download this particular data from this link and then upload it somewhere to basically read the CSU file this link is sharable for everyone so you simply go ahead copy that link paste it over here and simply press control enter to run this code and you will be seeing that the whole data of that CSV file is now expressed into this kind of a table that is your pendas data frame now how do I know that this is a pendas data frame so whatever code we have written and whatever it is generating for us I can always check its type by simply writing the type and whatever command that I'm getting over here if I'm running this and you can see that we are getting this pendas data frame right so what I'm going to do is I'm going to store this pendas data frame into some of the variable so that we don't have to again and again read the CSV file so I'm going to store it in a variable called let's say star DF what it means it's a data frame uh which is having the information of stars right so you can name it the way you want this is what I have choosen okay now let's say if you want to visualize top three rows of this data how you can do it you call that data frame that you have created and then on top of that what kind of functionality you can use you can use the functionality of head this head automatically gives you if you don't put any kind of input over here it gives you first five rows of data that is present in your CSV file now let's if I want to visualize top three I can just give this three and yeah you can get this kind of three first values that is present in our CSV file as you can see there are some different properties of the stars and there are some different respective stars that we are having over here so zero is a star that is present on our first particular row then the second star is present on index one so on and so forth right so that's the kind of idea that we are having now what if I want to visualize some 10 random samples of the stars that are present in this data so for that we use some different functionality of the data frame that is sample the sample allows you to get some random samples from this data frame by simply passing in the number for example let's say I want to visualize 10 different samples from this data frame as you can see that now on the left side the index values are completely different it's not starting from 0 1 2 3 like that it's some random index so it is indicating that we are trying to display some random 10 data points that are present in the CSV file right and each and every Star is having the properties with respect to its temperature Luminosity radius absolute magnitude of that star what is the star type if you can see the star type is given in the format of some numerical data there is some kind of a reason behind that I'll be explaining it to you in a while and then there's also a star color and a spectral class this is the kind of data that we are having right and all of this kind of stars are having this kind of properties and by using these properties we are going to create some of the visualizations that we'll be seeing throughout this module right now let's say this is the overall data that we have seen right now if you want to get let's say a generic information from this data frame then how you can do it you can do it with the help of you again call the data frame whose generic information you are trying to look for to get it some of its functionality you press this Dot and the functionality that we looking forward to is the information of that data frame and that command is do info you don't need to give any kind of inputs over here you simply run this and you're going to get an overall general information that is stored for this particular data frame it is giving you that there are total of 240 different stars that are present in your data frame whose index are starting from zero and goes all the way up to 239 okay and then there are some different seven columns for each and every row that is present in our data and what is the name of these columns we can also find that over here that my first column that is present on my index zero is temperature as you can see over here that's my first column on index zero this is index one index two index three four five and six in total there are total of seven different columns like that and respective uh name of the column has been given over here and then there are also information with respect to nonnull count what it means if there are any kind of data point in this whole data frame which is missing for example if this was missing then what would happen in a radius there is one missing value so over here in radius you would have got 239 nonnull out of 240 there are 239 data points which are not missing which are not null but there is one point which is missing so this kind of nonnull count column is giving you an idea with respect to how many uh data points are missing as you can see that out of 240 all of this 240 are nonnull it means every data is complete now the reason the data is complete like this in real life you don't get this kind of complete data you have to perform some of the techniques called as feature engineering handling the missing values and all these kind of things so that you can use this model for a proper analysis that's the whole idea and that's again one of the reason why we have converted the star type into numerical type because at the end this data was used to create some of the machine learning models but now because that's not part of this particular program we are not going to talk about that I'm simply going to tell you that let's say uh zero means let's say some kind of a dwarf star I mean some kind of a super giant star all this kind of information I'll be giving you at the end of this particular video but yeah just know that all of this file that you are seeing right now it wasn't like this from the beginning it was made perfect so that we can perform this kind of visualizations on top of this kind of given data right because our aim is not to uh handle this kind of missing values do some kind of feature engineering and create some kind of machine learning models our job is to take the data set which is complete and then create visualization on top of that that's the whole idea of this particular program right so let's focus on that particular part so now we are having 240 Nal contents for every columns that is existing along with that we are also having that for each and every column what is the data type in which this information has been stored so overall summary is present over here that out of seven columns three are of Flo type which means there are some kind of decimals involved over here then there are two columns with integer type and then there are two object type object type you can call it as like you know some kind of a text data that is present over there something like that is what you can assume as of now in a very like you know lay and language and the total memory consumption for this kind of data is 13.2 plus KB so yeah that's also giving you the kind of idea with respect to the memory that has been used to store this particular data so as you can notice for the temperature all of this values are in the format of integers but now if you talk about Luminosity it's having this kind of decimals which are involved right and now that's why it's also given this luminosity in the format of float don't worry about this kind of numbers okay this numbers are basically giving you the Precision of the way of writing that particular number let's not got let's not go into the this kind of technical details as of now right uh let's focus on this kind of this is a float type this is also a float type this is again a float type because again some kind of numbers with this decimals but then star type is integers and Then star color and spectral class are both having some kind of Text data so now again that are appearing over here in the format of the object data type of this pendas data so here that's an overall observation that we are able to make by importing this data from this uh particular Google drive to Google collab looking into some of its random samples and then also getting some kind of generic information on top of that if you want to look into its overall observation here is I have written in a complete detail okay there are 240 rows with six independent features and one dependent feature that is the target column again this is mentioned with respect to let's say a machine learning data set that you are trying to classify the star type based on other six properties okay so that's that's the kind of idea about this data set but again we are not going to do any kind of machine learning thing over here we are simply going to create visualizations okay and here are all the kind of information about The Columns right this is the target class the star type right but anyways you don't need to get into that particular information and what is the meaning of Lo and r o that is L and R not these are the average values of Luminosity of the Sun and radius of the Sun so all this information that you are seeing with respect to the luminosity and radius now that is with comparison to the Sun that compared to Sun what is the Luminosity of this star compared to the radius of sun what is the radius of this particular star so it gives you some kind of a comparison directly that okay yeah this star is less luminous as compared to our own sun and also its radius is small as compared to our own Sun so yeah that's the kind of idea that we are having apart from that yes there are star color and spectral class which are categorical features which means it's in the format of some kind of categories there are some kind of different categories of of colors there are some different categories of spectral class right so this is the kind of data that we are having over here and then this is what I was trying to look after right this is something that I was trying to look after that this information about the star type the integers that were mentioned right originally it was having some kind of a name to it zero stands for brown dwarf one stands for red dwar two stands for white DWF three is standing for the main sequence four is for super Giants and five is for hyper Giants now we are going to create some kind of visualization at the end of this module that is going to display this whole uh information of the Stars into an HR diagram and finally we'll be able to classify it like this hyper Giants Super Giants white dwarves right red bars this kind of things is what we are going to expect at the end of this module this is one final visualization that we are going to create so yeah that was the idea with respect to exploring this kind of data set uh uh so far after this what we are going to do is in AUD to create a visualization and then save it somewhere we going to create a directory uh in the next video so stay tuned hey everyone welcome back once again to the module 2 and in this video we are going to understand that where exactly are we going to save the visualizations that we'll be creating in the upcoming videos of module 2 so for that you're going to understand that how you can create a directory in Python and then how you can get the path of the directory so that we can use it in order to save all the kind of beautiful visualizations that we'll be creating in some of the upcoming videos so let's understand how we can create a directory and get a path of it in this particular video let's get into it now before we go ahead and create any kind of visualizations we need to save it somewhere so for that I'm going to create one directory or you can call it as a directory or a folder whatever you want so for that I'm going to first of all give the name to that folder so let me create a variable called as folder name that I might change maybe later on in future so yeah I'm just giving it as a folder name over here as star plots you can give whatever name you want over here and then I'm also going to create a folder now of this particular name right now I just created a variable I haven't created any kind of folder now how can I create that folder over here now if I show you over here this is what is called as the session storage space of the Google collab where by default this kind of sample data exists for every notebook okay so we haven't created anything from our side it is already existing if you will check it will be existing for you as well now my job is to create one more folder whose name is star plots and the way that I can do this is I just come to the next uh line and write OS because that's the library that we have imported in our previous one of the previous videos and I'm going to use a specific functionality of this OS that's going to help me create a directory and that is called as make directories make de is the command and now it expects two of this uh inputs the first input is the name of the folder so I'm going to give this as a folder name at the same time it expects uh us to give exist okay and we are going to set this to true what it means it means that if this kind of folder already exist in your space then it's not going to recreate the folder or something like that if it's existing it's not going to do any kind of changes if it's not existing as of now we don't have this kind of file then it's automatically going to create a directory for us now if I run this code now the code has ran successfully and if I refresh this part you can see this directory has been created for us now the main idea is to whatever kind of visualizations that you will be creating you need to create a path that will store it within this particular location so for that what I need to do is I need to Simply get the path of this folder I can do this by clicking on this three dots over here and click on copy path and I can create a base directory path over here which simply means that any kind of visualizations that you are creating you will be storing in this base directory and now I'm going to equate this to the string of this path and now I'll just make this path Dynamic just in case uh we are having some different folder name in future if I want to change I don't have to change this base directory path I'm going to use F string for that that's what we had learned in our first module right so uh I'm going to write folder name over here instead of star plots right so I just can change the name of the folder if I want and automatically this will be changing right so that's the whole idea and after this there is one more slash I need to give it means that if I'm concatenating my this particular path with any kind of files that we are generating of visualizations I'll be simply concatenating it on top of this base directory so in order to connect them we need a slash just like how you can see there is a slash over here right whatever session storage you are seeing of collab over here is referred to this kind of content that you are seeing then inside this space you are having this specific folder that you are trying to extract over here and that's why because this folder is existing in this space you are giving this slash over here and now then you are giving this kind of star plots and then to store any kind of data within this directory right then you are giving this kind of a slash again and now once you will concate it with let's say uh example.png some file that you have created so you just need to concatenate this name of the file that you have created and attach it with the base directory that's it and your path of that new visualizations that you will be creating uh will be stored over here and the image will be generated over here right so that's the whole idea that we are having uh as in why we are having this base directory over here okay if it's not making any kind of sense as of now don't worry as you'll be going ahead in this particular module you will be getting a lot of ideas with respect to what is the need of this particular base directory all right now in the next video we're going to go ahead and visualize the count of stars for each type of star like you know we are having varieties of star so we are going to visualize what are the different counts in in what quantity are this kind of stars present right so stay tuned for that I'll see you in the next video hey guys welcome to the sixth video of module 2 and here you're going to create your first visualization for this data on Stars so you're going to create your bar graph and it will be very basic visualization that we'll be having with the help of map. library and in the upcoming videos you are also going to customize it and look at just amazing okay so for now let's create at least basic version of the bar graph that's going to give us some of the information about the data set so let's get into it now let's go ahead and create our first visualization that is in order to see that out of 240 stars that are available in our data set how many of them belong to brown dwarf how many of them belongs to redw so on and so forth for all the kind of different categories that are present in our star type column okay so what you will have to do is first of all you will will have to fetch this kind of a account with the help of pendas data frame and then you can on top of that use this functionality of M plotti in order to visualize it so what we are doing first of all I'm just going to copy the name of this column so that we can extract all of this data that is present within this column of the data frame and how I can do it I can come back to that particular code cell over here and I can simply type stard DF to access the data frame and now to access any specific column of the data frame you need to pass in this square brackets and then I paste the name of that particular column but now in the format of strings okay and now if I just run this over here you can see that there are different star types of category zero all the way up to five right as you can see over here zero stands for br W five stands for hyper Giants and everything within that is going to be stored into this particular column now if I want to get this kind of a count that how many zeros are present how many ones are present so on and so forth I have a particular command for that that exists in the pandas data frame I need to go and type Valore counts with this parenthesis so what what's happening it's giving us all these kind of counts that there are 40 zeros that are present or I should say 40 Brown Wes present then 40 red veres present similarly like that all of this are as you can see is 40 40 40 so out of 2 40 stars in total 40 of them are for each and every category that you are seeing over here 40 main sequence stars super giant stars all of this are having 40 40 type of count of stars out of 240 so now if you want to visualize this kind of a data in let's say format of bar plot or bar chart whatever you want to call what you can do is you can simply come over here and use this functionality of plot over here on top of whatever you have got and then give this kind of input as what kind of plot you want do you want a bar plot so you give this kind of input as kind and set it to bar that hey go ahead take this kind of data that that's what you can see and create a bar plot out of it and now in order to visualize this I can simply have PLT Dosh show I'm using the M PL Li functionality to display the graph that I will be creating over here okay and now if I can run this code you can see that this is the output that we have got okay it's a very plain output we haven't customized it that is the goal of the next video that is like you know we're going to customize the above plot and then finally save it right now this is the very basic graph that I have created that is indicating that okay now for different categories here are the respective counts that you can see it's a perfectly balanced data for us and yeah now in the next video you will be seeing how we can customize this plot and make it look very very beautiful as compared to what you are seeing right now hi students welcome to the sth video of module 2 here we going to take the graph that we have created in our previous video we going to customize it we are going to make it look much more beautiful as compared to what it was in our previous video and then once we are satisfied with the output we are also going to save it in that directory that we had created earlier in the fifth video of this module so let's get started all right guys so get ready to see the whole different magic we are going to take this kind of basic default looking graph and beautify it by using this kind of customizations that I have written down I'm going to take this basic graph and convert it into something really very beautiful okay so let's go ahead and try to do it together so first of all I'll need this kind of basic graph on top of which we are going to build everything so I'm just going to copy paste this code and run this so yeah here we are having the same kind of graph the first thing that I'm going to do is I'm going to adjust the size of the figure according to my convenience okay so let's say some of you might like a bigger size of this figure I would personally go for a smaller size so how can I adjust the size of this figure I can do this with the help of a PLT command and what kind of command I need to use I need to use the command called Figure now this is going to give me the axis of this whole figure on which we are having this AIS on which we are having this graph okay so we are having one whole figure in that figure there is one AIS that this kind of square that you are seeing and now on that axis we are drawing this bar graph so what I'm doing is I'm trying to get the access to this figure and now inside this figure there is an option called as figure size that is fix size fig SI i z now over here you can give how much amount of uh width and height you want to give to this particular uh graph or plot whatever you want to call let's I'm changing this to 5 comma 5 and see how it looks like so yeah that's the the kind of output that I'm having I guess I would still like to decrease some of the size let's say I'm doing something like 4.3 4.3 hopefully this is fine this time yeah this is looking a much more better okay for some of you you might like uh very huge graph you might try to increase the figure size in that case but I guess for me uh it's convenient for me to use this particular figure size so we are done with the first customization we are trying to adjust the figure size that's SU able to right we are done with this part now the second part is to add the value of the counts on top of the bars it simply means that for each and every category okay at times what can happen that some of the bar the count is less let's say somewhere in between 20 to 25 now if I want my readers to exactly know the count for this particular bar so we can add the count on top of this kind of bar and that's exactly what I'm going to do in this particular case it could be like you know our users or our readers might be confused that like you know if this bar is exactly at 40 or 39 or 41 what whatever it is right so this kind of skills is necessary for you to have that whenever you're drawing a bar chart if you want to show this label on top of this bar you can what you can do is first of all see we were having this kind of figure inside figure we are having this AIS on which we are drawing this bar graph right so I'm going to label this AIS because I want to use some of the properties of this exis and that is I want to set bar labels I can do it with this command ax. bar label what I'm doing on this axis where I'm drawing this kind of bar gra I'm getting its property called bar label and now there is something which we give an input called containers containers con what is the spelling containers right and now I'm going to access the values of each and every bar by using this zero index and now if I run this code see now we are having this kind of 40 40 count right it will be really very useful the moment let's say any kind of bar count is like you know somewh somewhere it's at 40 somewhere it is 35ish 30ish somewhere in between it's going to be very much useful also you'll be seeing this in the second visualization that we'll be creating where the level of bar are not equal okay but yeah that's how you basically do this particular thing after this let's say I also want to change the color of this I'm not satisfied with this kind of black color I can simply change the color by giving the input argument of bar label as color and set it to let's say for example red see now it's much more better right we decreased the size of the figure then we took the AIS on which we were having the bar graph we took the labels of each and every bar with the help of ax. container Z Z and simply displayed it with the help of this functionality of this axis that is barcor lead so that's what we have done so far the next thing is to set the background to dark now it's again your choice okay if you think you like darker backgrounds then you go for the darker backgrounds or else you can stay with this kind of lighter versions also whatever is suiting you the best right I personally like the darker background so what I'm going to do is I'm going to use this PLT do style. okay this is the command through which you can set a particular background there are again multiple backgrounds that you can choose the one that I'm going to choose is called Dark underscore baground okay and now if I run this okay there is some kind of an error the error is saying that dark backgrounds is not available I guess I've done some kind of a typo it should be dark background and see now this is the output now it's looking something weird right I cannot say the x is Mark what I can do is I can simply run it again because that's the like you know this kind of issue is there with Google collab that if you are changing the style okay then you will have to run it twice so yeah that's how it's looking like right now automatically this color of this AIS has changed from black to white that's the property of darkcore background right now if I want to change this to default I can also use this kind of default style and maybe I'll have to run it twice to make it look better see I'll have to run it twice so hopefully we're getting back from where we started see yeah that's how it's looking like right so what I'm going to do is I I'm personally a fan of dark background so I'll be changing this to dark background now at the same time what I'll be doing is I'll also be changing the color of each and every bar so right now it's a plain Canan kind of looking bar right I'm going to change each and every color for this bar okay for this what I can do is I can simply come onto this particular graph and uh give one more input instead of uh just having just kind is equal to bar I give color property and now I just have don't have only one bar to change the color for example if I change this to let's say brown see what happens it's changing all of them to brown right I don't want this I want to create a list for each and every color that I'll be giving to this bars so let's say I'm choosing let's say brown red red white right all these kind of colors are coming into my mind what I'm going to do is I'm going to create a list okay I'm going to store all of this colors in the format of list let's say first is brown right then the second one is red then I'm giving white you can choose this colors the way you want then let's say uh yellow and some kind of different colors that's that's existing in the mat. li. PIP blot let's say there is light blue and maybe uh the last one I would choose as orange okay so I guess we are done 1 2 3 4 5 6 1 2 3 4 5 6 so I guess this should work let's see yeah see now we are having multiple colors in the bars right brown red white yellow light blue and orange so yeah that's how you can change the colors of each and every bar right I hope this is making sense to you now after this let's say I want to describe that what is this plot giving us like you know what kind of title we want to add to this plot so for this what I can do is I can give this command pl. title and set any kind of title that I want for example I can give let's say a visualize star count per star type right visualize star count per star type and also I can give a color to it for let's say by default what is the color that we get so this is the kind of output that we're getting we can also set this whole font to let's say bold okay I can also change the color of it let's try to do this kind of things you can also change the font size you can try to decrease the size increase the size whatever suits you the best let's say the first input that I'm giving is the color and I'm choosing the color as royal blue okay how do I know this kind of things exist how do I know this dark background exist how do I know this kind of colors exist right because I've gone through the documentation of each and every command you can simply go to its official documentation by searching on Google I can simply copy this command go to Google and search for it off official documentation and you can get all these kind of things or nowadays you're also having access to chat gpts right so you go to chat GPT and ask for what kind of different styles I can use in this pl. style. use it's going to give you multiple different suggestions right so I'm going to set this color to Royal Blue I'm also going to change the weight of this font to bold and I guess uh F phont size is looking good to me I'm going to run this I guess this is looking pretty much good right so we are done by setting a title now I'm also going to add a y label and also change the color of this y takes this kind of things are called y takes this is called as X takes so first of all what I'm going to do is I'm going to add my y label I'm going to do this with the help of PLT doy label and give some kind of name like you know whatever this is describing for example let's say number of stars count of stars right I can give a hashtag for that that is representing number of something so number of stars right and I'm also going to set a color to this let's say I am I am choosing a color called pink okay let's see how the output looks like see this is the kind of pink color that I've got but now the font size is pretty much small I want to increase the font size how I can do this I can give the input parameter called font size itself that's the name of the parameter and change this parameter size to let's say 13 let's see how it looks like I guess this is better but now it's like you know even much more as compared to this so maybe I would like to decrease to 11 and see how it looks like I guess yeah this is better this is much more better now how I can take this y Tak and change its color to let's say some different kind of pink let's say tab pink this is the color that I want okay so let's go ahead and try to do this I can get access to this y TI by again using PLT and use white white TI okay now I'm going to set color parameter to this as let's say tabular pink again T pink is one of the color that is available in M.L so I guess yeah this is looking much much more good right obviously you can play with this kind of colors the way you want I guess I am comfortable with what I'm having right now maybe I can try to change this um color to let's say white not pink obviously you take this thing change it the way you want yeah I guess yeah this is much more great now one more thing that I would like to do is I would like to replace all the X sticks from 0 1 2 3 4 five to its respective names that are shown over here so what I'm going to do is I'm going to Simply copy these things and come over here and paste it it over here and then this is in the same order that I want to right so I'm just going to delete this part I don't want this kind of part okay and I also want to uh arrange this into a proper kind of way through which I can change the X scks all the 0 1 2 3 4 5 uh that we are having over here right 0 1 2 3 4 5 I want this to be changed to the labels that I want in place of this 0 to 1 two 5 okay so what I can do is because I want to change this XT I can give this PLT do xti and now what kind of things I want to change so these are called the ticks that are present inside X ticks so I can give it as a part of list it is 0 to five right so 0 1 2 3 four and five now I want to get replace this t with the labels okay the first input is Tes the second input is labels right and now I'm going to give again a list of all of these things that we have written over here okay let's say brown dwarf is the first thing I'm going to give it in the format of string and then I'm going to do it for Red Bar r w after that we are having white barve and then main sequence main sequence after that we are having super Giants and Hyper joints super joints and Hyper joints okay so I guess this is good let me just try to run this and see okay I guess we have to dedit this we don't need that thing anymore and now if I run this hopefully it's changing yeah see now this is what I am getting Brown bar red bar but I don't want this kind of things okay I want to rotate this things let's say some some degrees and I also want Brown to be in the first line dwarf to be in the second line righted to be in the first line white I mean dwarf in the second like that right so what I can do is I can give a new line character between this brown and valve similarly for red and wve right similarly for this main sequence and then there is only one one word so I don't need to convert them but now what I can do is I can just bring this down so that it's visible to everyone and then I'm going to give one more parameter called rotation I can give let's say 10Β° of rotation let's see how it looks like it's it's a bit cluttered right so what I can do is I can maybe try to uh rotate it to let's say 45 deges or something let's see how it looks like right after changing this to 45 I guess 45 is going to look good yeah this is looking much better right I guess yeah this is much more better now let's say I want to change the color of this as well I can again give the property of color to this XT and change this color to let's say maybe line let's see how it looks like this is looking good right so yeah that's what we are having that's that's what we are going to get by replacing the ticks of x from 0 to 5 and giving it its respective label that is brown dwarf red DF white dwarf so on and so forth so yeah that's what we have done over here and after this we are going to save this particular plot in the base directory that we had created I want to store it within this thing so now how can I do this right I guess the plot that we have created is far more beautiful as compared to what we had seen over here right I can maybe uh try to again change this to Super in the first line then Giants in the second line I could have done that but I guess this is fine now in order to save this thing what I can do is I can simply come over here here and give this command PLT do save fig now what is this thing going to do it's going to allow us to give the path where I want to save this figure so the first thing is I want to give the base directory right the base directory is the directory that we have created for this starcore plots now if you remember this base directory wherever we have created we have given the slash so I just need to concatenate the name that I want to give to this plot let's say uh we are giving this name in order to Conca it we can use the plus operator and then let's say give this as barplot star count something like that barplot star count. PNG you can also save it as JPEG if you want but yeah let me just go ahead and try to do this and hopefully we are getting this output over here if I yeah see that's there if I double click on this or here we can see that this is the kind of output that we have got right now I'm simply going to close it and uh close this also and yeah we are done with this first plot okay this is the first plot that we have saved after creating it after beautifying it that's what we have done now in the second upcoming video what I'll be doing is I'll be creating one more visualization it would be a bar graph only but with the help of cbor and now see that with the help of cbor how we can do the same kind of and that is much more convenient as compared to using mat plot L all of this reasoning will be getting clear once you look into the second video or the upcoming video hey everyone welcome to the eighth video of module 2 and here we are going to visualize some different part of the data set again in the format of a bar graph but we'll be creating it with the help of cbond library and you're going to see that how easier it is in order to create some amazing bar graph with the help of c bond as compared to met plot La so let's get started now what we're going to do is we're going to go to the top part to that uh data frame that we had created and take a look onto the star color we are again going to create a bar graph but now with the help of cbor you will see the power of cbor that with just one line of code you are able to achieve something like this color for different bars and all of these kind of things you will see that so so now what I'm doing is first of all I'm trying to visualize the star color count that is present for each and every color so for this what I'll have to do I'll have to go to Star DF inside that star DF there is a column called a star color I should give it with the help of strings and then I can check the value counts with this so as you can see that there are red stars the count is 116 for blue it's 56 for blue white it's 41 by default it's coming into the descending format starting from the highest and going to the lowest and now if I want to get access to this values this red blue and all these kind of things now this is present in the position of index so I can take this command on top of this command I want to grab its index so I'm going to give this command do index so here is the whole index red blue blue white and all of these things so now what I want to do is on the xaxis I want to plot this colors that are this index and on the y- axis I want to get this particular uh values okay if I grab the first value that is present over here it will be 116 see it's 116 now if I want to grab the value present on the first index it will be the second value 56 right so I want to plot this data on my y- Axis and I want to plot this colors on the x-axis so what I can do is I can use use uh SNS do barplot I'm trying to create a barplot with the help of cbond library on the x value on the x value I am giving this whole thing with index do index that's the color name and on Y what I want to see I want to see the value counts so I'm going to copy this part I'm going to copy this much part and save it in y and let's just try to run this and see how the out looks like see this is the kind of output if I don't want to have this kind of extra labeling that is there on top of the graph I'll have to use the command PLT do show I'm trying to use both met plotly and cbond to come up with one final output so by using this PLT do show this AIS will be going away so yeah this is the kind of graph that we are having see now again we can have any more customization see by default it's not coming out as a white background right now because we have already changed it once you change it it will be like this okay it will not going back to white color you will have to go and switch this style do Ed to default in order to have this kind of white background but I guess black black background is quite comfortable but now you can see that I don't even have to set this kind of colors manually it's coming automatically without myself doing anything over here now what I can do is I can just uh come over here and give one more thing that is called pallet I hope I have given the correct spelling again there are multiple pallets that are available this uh vies is my favorite one so this is looking much more beautiful right so yeah that's that's about it now I can again go ahead and customize it the way I want right I can change this uh color for this Y axis I can change this colors of the T and everything I can do this right so what I'll be doing is I'll simply be going ahead and doing this kind of visualizations okay I guess the figure size is looking pretty much good I'll be changing the tix of the x-axis pl. X TI give a rotation I guess of 15Β° or 10Β° 15 I guess let's try 15 and I'll give the color as orange and see how it's looking like this is good now what about star color I'm going to take the Y label see it's coming by default I didn't even give this thing it's coming by default it's all because c bond is is built on top of met plot by default within this bar plot they are giving this kind of Y label that is the title of the column that's what they're giving by default I didn't even set it and if I want to change its color I can use PLT do let's say y label and give some kind of color let's say white can also change the font size to let's say 13 let's see how it looks like it's giving me some kind of an error y y label okay y label is missing some kind of an argument okay maybe we are trying to oh yeah we are missing the Y label we need to give this kind of uh command that is star color okay we'll have to give this if you want to change this y label you will have to give this kind of name only then it will be working fine see yeah now it's working fine right so yeah I given this kind of things I can also change the colors of the whex if I want PLT do whex this uh color is equal to tab pink this is my favorite one for the y- axis that's what I use frequently so yeah I can also have the title of this plot that we have visualizing pl. title we try to basically give title on the top because we know like you know this is the kind of order first we give first we draw the plot after drawing the plot we give the title this kind of order is not something that you need to follow TI T right now visualizing the count of star colors something like this maybe color is equal to Royal Blue for title again I prefer this if I'm having the dark background and font size let's say I'm setting it to 15 two more than what I am having for this I can also set this to weight equal to bold I can also uh for the X uh T I can try to change the font size if I'm able to do this I can take this write font size change this to let's say 11 hopefully it changes yeah it's changing right so I guess this is pretty much great now I can also add like you know this kind of containers to this bar and the same way I'll be doing I'll be changing this to a because I'm trying to get AIS of the AIS right and then I'll be doing ax. bar label and then ax. containers zero and then maybe I can give a color of red and I can also maybe change the weight of this thing to bold and see how it's looking like first of all the main thing I really wanted to show you is that by doing this just one line of code it's giving us the Y label it's giving us everything even different colors of the bar with the help of pallet right so all of these kind of things we are doing it in just one line so that's the power of like you know using C Bor it's built on top of matte BL Li so it's it's just easy to customize it the way you want as you can see that star color was already existing even before giving this y leg but now if I want to change some of its property I can do it it because cbon is built on top of Med so yeah that's that's about like you know how you can visualize a different kind of bar plots and now in the next video let's try to visualize something else hey everyone welcome to the ninth video of module 2 where you will be visualizing the outliers present in our data set and one of the ways through which we can do this is by creating the box plot on all of these kind of features that we are having in the data set and we are going to visualize them side by side with the help of a subplot so what is subplot and everything will be covered in this particular video so let's get into it now let's go ahead and try to create some different type of visualization apart from the bar plot now what we are going to do is called box plot now it's typically used to visualize the outliers that might be present in any of your numerical feature so the main idea behind box blots is that like you know you're are going to have this kind of variation of numeric feature in front of you it's going to give you the idea of the median it's going to give you the idea of the upper quartile lower quartile and also the outliers right and for the outliers visualization we typically use the box plots and finally just save it into this particular folder that we have created and I guess we did not save this particular code so let's go ahead and try to save this figure save fig and the name that I'm going to give you not give you but yeah give this particular graph is base directory plus let's say visualize or just start star colors star Colors v.png Let's go ahead and also try to cross check if it is done yeah it's done I'm going to see it so yeah that's the beautiful plot that we have created and saved right anyways yeah we are also going to save this kind of box plots that will be be generating all right so that's the whole idea that we're going to look into so now what I have done is I already created one this kind of get a gist of data by checking the first five rows of the data so over here we can see that temperature Luminosity radius and absolute magnitude are what are your numeric features all of the last three features are your categorical feature it's some kind of categories now we use box blots to visualize this kind of numeric features so now what I'm going to do is with respect to all the star typee that is 0 to five for all the star types what is the variation of temperature what is the median what is the interqual range what is the outlier if at all they are present in any of the star type category with respect to the temperature I am also going to do this for Luminosity radius and absolute magnitude so I'm going to create multiple plots for all these numeric features with respect to Star type you can also do this for Star colors and also the spectral classes it's your choice right now I'm going to show you any one visualization and I'm going to do it with respect to the star type that if my let's say my star type is um white dwarf so for with respect to white dwarf what is the variation of data for radius what is the variation of data for Luminosity this is the kind of thing that I'm going to generate so what I'm going to do I'm going to come over here and uh get this boxplot with the help of SNS do boxplot it requires what want to display on xaxis what you want to display on y- axis and lastly I'll be also showing this pl. show and on X what I want to show is the star type right and on the y- axis let's say I'm giving for example only one thing as of now that is temperature so SNS dobox plot on X what am I giving star DF star type and on by what I want is start de uh it is temperature right I'm just going to copy the whole thing but a better way would be to not copy this instead use iog feature it's giving you the location on the basis of index now it takes two things in the input the rows and the column I want to plot all the rows and the First Column that is present in the stard D okay all the rows of the First Column now First Column is present on index zero right so I can get it use with the help of this zero okay remember this kind of column that we have given over here that column is giving you this idea that everything everything that is present in rows you grab that part but now only for index zero column so now if I go ahead and visualize this let's see what kind of output do we get see this is the kind of output that has been generated I have got 0 1 2 3 4 5 all the different star types which are corresponding to this kind of names and now if you see there are no much of outliers except this zero right this kind of diamond this diamond is basically highlighting the presence of outlier for the class zero and if we are talking with respect to only one numeric feature that is temperature now what I want to do is I want to generate the same thing now in place of zero I can change this to one and see the output the output this time is for Luminosity see I don't have to change the column Name by default for by manually I don't have to do this thing okay it's happening automatically but now instead of plotting this one by one I want to plot it all together in one figure and then save it and that's where this kind of concept of box plot comes into the picture right so what we are trying to do over here is this is one whole figure now from that one figure we are creating six different axes how we are creating the six different AES by giving the command of PLT do subplot providing the values of rows and columns I'm giving two different rows and three different columns and then the first axis over here is starting from position one the second axis is on position two the third axis is on position three so on and so forth so that's how you can create the subplot and try to visualize this thing over here so what I can do over here is I can do PLT do subplot and give one let's say I want to create four different graphs in one row so 1 comma 4 and I want to first of all look into my position one and then I want to see how the output looks like let's see how it's looking like see this is on the first position now if I'm uh just trying to change this to zero and copy this whole code come down over here and just change this to one and but at the same time I'll also have have to change the position of this to two see now I'm having this kind of prop but it's very much cluttered right so to I'll have to manage the figure size accordingly and I'll also do some kind of uh one more command that you will see of M plot lip to adjust the layout that we are seeing right now if it's getting cluttered like this then we know how to do this I'll be showing you that okay but the whole idea is I want to create this kind of subplots but now just imagine if there are multiple subplots that I want to create it's not a very good thing to like manually change this kind of indexes so what I'm going to do is I'm going to create a for Loop over here so what I'm going to do I'm going to create for Loop but how am I going to create the for Loop right that's something important that you want to understand so in this for loop I am going to create four different x's on index 1 2 3 and four or I should say on position 1 2 3 and four so for I in range of four so it's going to go from 0 1 2 and 3 right and now I want to also give indentation indentation over here okay I'll remove this PLT do show command as of now okay and now I want to change the position with respect to I because I is starting from index 0er I'll add one to it so that we get 0 + 1 is 1 because we know that subplot always starts from position one not from position zero so that's the reason I've done this kind of thing and now at the same time I'll also change this to I it's going to take the zeroth column first then the First Column then the second index column and then the third index column so that's how I'm going to create my uh subplots let's see how it's going to look like see that's how it's going to look like as of now right I also like to change the background it's not black is not looking good for this one so what I'll do is I'll first of all change this style to default and you know you must do it twice to get a proper output okay this is for the first time that we have got this this is for the second time and I guess this will be this time it's good it's still cluttered because we did not change the figure size so PLT do figure what kind of command we give we give fig size right fig size and let's say I'm choosing 20 by 8 20 by 8 so I'm going to get 20 spread and eight in terms of height so I guess now this is better right this is much more better so we are getting this for temperature over here we getting for Luminosity but still there are some kind of cluttering that that's what I can see so to adjust this cluttering what I can do is I can maybe see first of all uh get rid of this y label completely and instead of that I can have a title for each and every plot okay I'll be removing this kind of things and have a title on top of that that's the kind of thing I want to do so what I will do is I'll say PLT doy label and convert it to nothing and at the same time I'm going to set title and what is the title title is the column name so how do I get access to the column name so for this there is one simple code that is stdf do columns that's it if I run this see I'm getting access to each and every columns right so now what I'm going to do is I'm going to go and call these columns one by one with the help of itation index I so PLT do title star DF do columns and then I'm going to give an index I'm also going to set a color to red and now see how it looks like see now it's it's better right I cannot see any kind of cluttering anymore if you want you can also expand this by let's say changing this 20 to 25 right even that's fine but I guess this is much more better right but now what is this indicating if I want to give a title on top of this whole subplot that I have done I have created I can use something called as subtitle see Su I can again get its access with the help of PLT see this is what is called subtitle now what kind of title am I giving I'm going to say that visualizing outliers in numeric features of star data so visualizing the outliers that's what I'm doing in what in numeric features of star type now after this what I want to do um I want to give color to this I want to give weight to this and also font size to it so I'll be giving color equals to let's say a black color let's say a black color is going to work well if not I'll be changing this I'll also try to change the font size not the phont wa to bold and lastly I'll be uh also playing with the font size is 15 hopefully it works perfectly fine yeah this is good right maybe I can change this to some different color but I guess this white and black combination looks good it's pretty much simple and straightforward I guess I'll be going with this right again if you want to add any kind of different kind of visualizations according to you you can surely go ahead and try to change anything you want okay but I guess this is fine for me so I'll be simply going ahead and save this figure pl. saave fig and say that this is boxplot dop PNG and also give this box plot with respect to start time and now run this and hopefully we'll be getting this saved over here I'll refresh this okay yeah I'll refresh this okay see it's coming out of this particular directory why because I did not give the base directory right it's going by default on the session storage I don't want to do that so I'll delete this file come back over here and give base directory and then concatenate it with this thing and I I guess now it will be working fine so this kind of things will happen with you also if you're coding it's just that you need to minimize any kind of error that you might be seeing and get the things done the way you want right and now let's go ahead and visualize the box plots that we have created just in order to check everything is fine see yeah that's the kind of output that we are getting right so that's what we have got for the box plots and uh yeah that's pretty much about this particular video now in the next video what we are going to do is we're going to look into one more type of graph called as line graph or line chart so I'll see you in that particular video so far we have seen how we can create a bar graph and also the box plot now let's look into some different type of visualization which is called as line plot so it basically takes some of the data points in your data and simply connects them with a line okay so it's going to be helpful for Us in order to visualize some of the patterns that are present in all the kind of numeric features that we are having in our data set so let's get into the video and understand how we can get these things done all right so now let's assume that we want to create the line plots for each and every numeric feature so what we are trying to do is uh in the outlier what we did with respect to Star type what's the distribution of the temperature Luminosity radius and absolute magnitude we got this kind of median values for each and every classes and also the interqual range and all of this kind of outliers that we wanted to spot right you can surely now go ahead and remove this kind of outliers if you want but our purpose is just to create some visualizations and find some observations on top of that so from this box blot we can say that in the Luminosity we are having most of the outliers so you need to uh try to like you know remove this outliers or try to do something through which you can minimize the effects of outliers right but now what I'm trying to do with the help of my line plot is to connect let's say for temperature only okay we are not talking about anything else let's just focus on temperature I want to connect my this point with this point then this point with this point with a line and then see try to observe if any kind of pattern is being formed or not that's the kind of logic that I want to build now again I want to do this for all the kind of uh data that we are having that is a numeric type so for this numeric features I want to create this line plots again I'll be using a for loop with the help of of subplot but now at the same time I'll also be showing you that how you can use function in order for anyone who is reading your code or even for that matter if you are reading your code after some time it's much more readable and more convenient to your eyes okay it's better that we use a function all of this you'll be understanding over here so let's get started with this so what I'm trying to do over here is I'm trying to create a simple line plot I can do this with respect to PLT do plot okay next thing is spare plot we are going to do that in the next video but right now let's focus on this PLT do plot now what do I want to plot let's say for example I want to plot the temperature so star DF and now I can give the dot iog I want all the rows that is present in the First Column that is my temperature column and simply plot it let's see what kind of output do we get also I can do pl. show so that we are not getting this kind of output I can hide those outputs by using pl. show all right so yeah let's just wait for a while this is the kind of output see this is the kind of pattern that we're getting okay now it depends on some kind of task our job is to create visualizations and give some observations then how let's say in data science in machine learning how can people use this kind of uh observations and create something out of it create some kind of automation stuff with respect to machine learning deep learning any kind of data science project for that matter right so this is the kind of pattern that we want to get for each and every numeric column temperature radius and all of those right so what I'm going to do is I'm again going to take the help of subplot and now this time what I'll be doing I'll be having four different rows and one column so four comma 1 and I'll also be changing the index with the help of I I'll be again having this kind of for Loop for I in range of four so it's going to go from 0 to three I'll also select this thing and press tab to give this kind of indentation over there and uh yeah we have given an indent we are having the space everything looks good I need to change this zero to I I guess everything is going to be fine I need to remove this BL do show I'll bring out of this for Loop and see how it looks like okay this is the kind of thing it's looking like as of now uh I can also change this kind of colors for every graph I can give a title to this and I can customize it the way I want but a very basic graph I have in front of me right so I can give this kind of PLT do title the same way that we had done in our previous code that is stard DF do columns and then uh I and I can also give a color to this kind of title let's say red and at the same time I can also adjust the figure size PLT do figure what kind of figure size do I want let's try fix size is equal to 15 comma 8 let's say what what happens so I guess this is good right in terms of visualization this is looking good but now if I want to do one more magic over here with the help of subplot what I can do is I want to adjust the layout that I'm having I can use PLT do tight layout and then if I try to look it hopefully it's going to give us a better layout as compared to what we are having currently okay it's automatically see going to adjust the spaces between this kind of AIS that we have drawn and that's how it's looking now at the same time I also want to change the colors of each and every plot that we are seeing so for that what I can do is I can create a list of colors over here okay let's say color equals to now let's say because I'm having four different plots to uh draw I want to understand that what kind of colors I can use now again you need to have this kind of idea with respect to what kind of colors that mat plot lab is giving you I'll be using again some of my favorite colors like royal blue gold San green something like that okay you can choose your own colors royal blue let's say gold then again green is not something that I like I like lme okay so lime andan is something that I'll be having lme andan I could have also drawn magenda Nan anything that you like I'm just trying to give you some different kind of colors that are available now in place of this plot I'm going to give this kind of parameter of color is equal to colors of I so what it's going to do in every time in every iteration the value of I is going to start from zero and all the way up to three so when there is a okay there is some kind of an error automatic saving fail don't worry click on this show diff and click on Save changes and it's going to automatically save everything for you the weight should be all right yeah great so now what this is doing it's trying to get access of the royal blue when the value of I is zero is going to get the excess of gold when the value of I is one similarly lime when I is 2 and three when uh sorry and magenta when the I is value three okay so that's the kind of thing that I want and now if I try to see how it works let's see hopefully everything is good okay it's giving me an error what's the error menta okay there is a wrong spelling hopefully this is the correct spelling yeah see now how beautiful this plot is looking like right I can also give a subtitle if I want I can give it anywhere okay it's not compulsory I give it on the top I could give it anywhere pl. subtitle visualizing the distribution of numeric features something like this let's say I'm giving a color of black the same thing that we did above okay I like this kind of black and white combination if I'm choosing that then font size is let's say 15 and uh let's see if I want to give anything else after running this code yeah I also change this to bold right the weight of this text to bold weight is equal to bold maybe I can also try to increase the font size if I want okay I guess this is looking pretty much cool maybe I can try to decrease this 15 to 12 maybe that can be giving us a better visualization so yeah this is this is much more better right so yeah this is the kind of output that we have received this is the kind of pattern that we are having line by line for the temperature Luminosity radius and absolute magnitude now it's job of machine learning engineers and data analysts that like you know they find something useful from this and get something done for any kind of application they're trying to build right now in this program we are trying to focus how to develop this kind of visualizations and yeah that's about this particular thing but now let's say I want to convert this whole thing into what I want to convert this thing into a function now how can I do this how can I convert this in the format of functions I can simply cut this thing come up over here let's say I'm defining a function called line subplot it's going to take some kind of inputs and I'm going to paste everything over there okay see first of all I am giving this I so I'm going to give I at the same time I'm also giving my star DF right so I'm going to give Star DF also to as an input I'm also giving uh colors as input so let's say that I'm giving colors over here as input I guess all of this is going to work fine so I've defined a function that's going to give me a subplot it's going to give me a plot for different values of I from the iog also give me a title and I guess everything is going to look good so over here I'm going to Simply call line subplot and give the input of star DF then what was it colors and I the value of I right and hopefully we are getting the same output I guess there is some kind of a yeah spelling mistake subplot yeah now if I'm running this I hope everything is working the way we had got in the previous step yes it's just the same right let's if you want to have some kind of a gap between this of things how you can do it you can do that with the help of let's say a new line character over here okay and yeah see now you're having a good amount of gap between that so this is the kind of thing that you have done in this video now I'll see you in the next video and we'll be creating some kind of pair plots hi guys welcome to this video of module 2 where I'm going to teach you the concept of pair plot and how you can easily create that with the help of cbond Library so let's get into it all right guys now what we are going to do is we are going to learn about one more visualization and understand what kind of information we can fetch out of that kind of visualization and again save it like what we have been doing for the above plots I guess I again forgotten to save this anyway I'll be doing it very quickly I'll be giving Bas directory and the name let's call it as line subplot PNG okay and it's always our duty guys that we go ahead and always cross check the output over here okay if I just open this at times it might be that like you know it's looking very good over here but it's not looking good over here so you need to cross check before uh extracting all this kind of information all right so this looks good and again once again if I'm just trying to open this see it properly actually this is looking just incredible okay to be very honest this is the kind of power of python by writing only this few lines of code okay this few lines of code you have created some beautiful things right with the help of this few lines of code and now one more thing that I want you guys to pay attention to is that I am not giving any kind of comments as of now because I am explaining you these things while coding along right so what I want you to do is different person will be able to comment a particular code in a different way so what I'm going to do is I'm going to provide a code that is this whole notebook with the proper comments but I want you to go ahead and comment it by yourself on the basis of your understanding what do you understand by this particular line what was the purpose of creating uh this kind of function one person can simply go ahead and write that it's improving the readability of the code so it's better that we convert this whole kind of step into a function like we did not do this for the previous step over here we did not change it like this right now you can also go ahead and try to convert this into a function right it's going to improve the readability of this code but all of that things is up to you and even for this function you can give a very good description with the help of multi-line comments give the information about what this kind of function is doing then give the information with respect to the input arguments and what is it going to return at the end so all these kind of things you can mention in this uh multiple line comments right so yeah that's how how we are using all the kind of things that we have learned in our first module and implementing it over here isn't it just amazing yeah anyway coming now back to pair plot let's try to understand what is it all about okay so what is the main purpose of creating a par plot or was it it what it's going to do let's say that I'm going to take temperature for example what it's going to do par plot it's going to take a temperature column and it's going to compare with all all the respective other AES that with respect to temperature how Luminosity is weing with respect to temperature how radius is weing and all the other columns that we are having okay for that matter how temperature is weing with temperature even that kind of data we'll be getting with the help of pair plot and by default you are going to get this kind of relation in the form of scatter plot you are just going to get dot dot dot dot dot if you want you can also create a line plot but by default pair plot is going to be in the format of scatter plot okay all of this information I have written over here and now because you are seeing that there are a lot of kind of combinations that we are creating right temperature with all the kind of other columns including itself the Luminosity with all the other columns itself so there are multiple subplot that we'll have to get right multiple axis in a subplot now a good thing about pair plot of c bond is that it's going to get you rid of all this kind of pain of creating subplot and all these kind of functions and these kind of things that's the power of using c bond it's going to do it by default for us and we are just going to enjoy the output that we are getting but at the same time it's also having some of the drawback and the drawback is that if there are a lot of columns just imagine the type of like you know combinations that you will be getting and then you will be creating it into a subplot right and then you'll be getting a plots it would be a really timec consuming task but thankfully for our data we are just having seven columns it's still going to take some significant amount of time but not as compared to like you know how it will take for let's say 30 columns 20 columns right so that's one thing you need to keep in mind so now let's first of all go ahead and try to visualize the uh PA plot with the help of cbone uh PA plot is something I want now I just need to give the whole data frame because it's going to take each and every column and do everything by itself okay let's see the output that we're going to get and I'm also going to show this thing let's see what kind of thing do we get okay as you can see itself right now it's it's taking a lot of time to create this plot right because still there are seven different columns and it's taking all these kind of possible combinations okay so this is the kind of output that we are getting the temperature column is getting compared with its same temperature thing then temperature thing is also getting compared with Luminosity then just like that temperature is also getting compared with the radius absolute magnitude and star type okay all of this numeric column okay it won't be taking uh this kind of categorical column which is of the type object it's just going to take the numeric type of data that is either integer or float okay it's not going to take into account of this last two columns that we were having in the object type okay so yeah this is the kind of correlations that we are able to fetch that let's say with respect to temperature let's say what is this particular column this is absolute magnitude right so for this you can see that we can clearly see that as absolute magnitude will increase the temperature is going to fall this is some kind of observation that we are able to make right so yeah this is the kind of output that we get with the help of pair plot now one more thing that I can do is I can visualize this data point with respect to let's say some kind of U what it means this kind of parameter that I can give over here in subplot let's say I just need to give the name of column over here spectral class okay what it's going to do there are again multiple categories within the spectral class so where is each and every category going to belong to this kind of PA plot all of this kind of things you will be able to see you can go ahead and create this kind of PA plot with respect to different kind of use present in the data see now that's that's what I was talking about there is a Class M Class B Class A this kind of data and see all of these kind of points are being marked differently wherever there is purple it's with respect to class wherever that you can see the dark yellowish kind of thing that's Class B so that's the power of U you can change this kind of U with any kind of different categorical data that you are having uh okay and maybe star color is something that you would like to go ahead and look forward to so yeah that's what we are seeing right in the same data because we did not count let's say spectral class over here we are giving that kind of data with the help of U parameter That's The Power of cbor Now again what I'm trying to see over here is I'm trying to change I'm trying to change this whole background lt. style. use to dark dark background okay and then see how the output is looking like and maybe I would like to also see the previous graph if how this would look like in a dark uh output okay and I also change this color to let's say some different kind of thing but right now let's say how the out is going to look like okay that's the output that we are having I can maybe run this one for one more time because you know right while changing the style we need to run our code twice and what I'll do is I'll also go ahead and run this code I don't need to again set the background to dark because it's already set for me right now okay I don't need to change it again to dark background so yeah I guess this is the thing that we have saved I'll again uh cross check it by saving it okay I haven't saved saved it so PLT do saave fig what am I going to do I'm going to save it in base directory and the same thing you know right the name of this plot will be what it will be pairplot PNG right now there is a parameter over here in par plot again called kind okay this kind by default is set to scatter as you can see over here it's highlighted you can change this to the different kind of like you know plot that you would like to see okay scatter is fine for me so I guess I'll just keep it as it is I won't be changing but yeah that's something I wanted to show you guys but now let's just goe and save this figure and then also look into the output if it's done in a proper way or not all right guys so yeah these are this kind of beautiful visualizations that you are creating with the help of python that's literally something that you can go ahead patch it out from this Google collab and attach into your research papers or reports that you are creating you can mention about this kind of details your observations and give evidence to that with the help of this kind of visualizations that you have created right so yeah we are done with this let's look into this thing yeah P plot is created hopefully there are no errors it's looking good right it's looking beautiful yeah you can see this kind of plots right for the same columns like for example radius versus radius is giving this kind of thing right Luminosity versus Luminosity is giving this kind of thing similarly like over here star type and star type so yeah that for the middle part that's the type of output that you're getting and everywhere else you're getting the scatter plot this is really very beautiful to be honest so yeah that's that's about the pair plot and I'll also go ahead and try to run this once or I should say twice not sure let's go ahead and check I guess this is looking even more much more better right as compared to to previous white one and I also change the color of this to white or let's say t pink let's see how it's looking now hopefully better yes it's just amazing just amazing great so I'll also go ahead and cross check this one line plot line of plot and see if the changes have been saved yes this is much more better man this is just amazing so yeah now I'll be seeing you in the next video where we are going to create this kind of a plot called HR diagram okay something like this so yeah stay tuned for that hey everyone so welcome to one of the most lengthiest video you will see in this entire program so in this particular module this is the final ultimate visualization that you are creating with respect to this star data that we are dealing with so this is about creating an HR diagram what is HR diagram I'll be talking about that in this particular video but then how you can create this with the data set that you are having and compare it with the actual HR diagrams so that you are able to appreciate that what kind of skills that you have learned over here indeed the video is going to be super lengthy but it's going to worth each and every minute that you're going to spend on it so let's get into it guys all right so this is my particularly favorite part to create the HR diagram the reason behind that is I personally love this kind of diagram okay uh it's because like you know how amazingly we are able to categorize or like you know classify this kind of different Stars depending on its properties that is temperature absolute magnitude spectral class and also the Luminosity right now you need to understand one thing that all the kind of previous graphs that we have created or the visualizations that we have created all of them can be always created if you're having this kind of tabular data now we are able to create an HR diagram because we are having the data of star and its respective properties that is temperature and absolute magnitude right now we are going to use both of this to create this kind of a diagram so now because we are having access to this two data only then we are able to create the HR diagram you won't always be able to create this diagram unlike all the other graphs you will always be able to create this kind of graphs right so that's something that you need to know before we get started okay so yeah keeping this kind of things in mind that because over here we are dealing with the star type data set and that's the reason because it's properties that is temperature and absolute magnitude is available to us of real stars that's why we'll be able to create something like this okay so let's get into it now because I want to plot temperature on the x-axis and the absolute magnitude on the y- axis we be requiring its values from the data frame so how we can fetch this values from the data frame so what what I can do is I can create a variable called as temperature and from the start DF I can store all the values of temperature okay in this temperature variable how can I do it by calling dot values on top of this column okay so on on the left side of this dot what are we doing from the Star DF we are fetching this column of temperature and now all the values that are present in that column I'm using dot values so what it's doing let's go and try to print it's going to create an array of these values that are present in this column as you can see over here array what is array array is just one of the other data structure that we have in Python that's used to store this kind of data like this okay just like list as you can see right but now how do I know if this is a list or an array I can just go ahead and type this type functionality on this temperature and we can see that it's a numpy array n dimensional array right for now you just need to know that it's just a kind of a list you can think of but with more much more functionalities okay but anyway now we have uh extracted the values of temperature just like that I'm also going to do it for absolute magnitude and star DF absolute magnitude dot values okay now because I'm having access to both of these values I can simply go ahead and create a scatter plot now what is the reason of the scatter plot if I show you this in this HR diagram you are trying to plot a specific Star by giving its x coordinate and y coordinate for each and every Star you just need x coordinate and y coordinate and you simply plot it so for that what I am doing is the functionality is called scatter okay if you use PLT do plot it's going to give you a line plot okay just like what we did over here if you try to use this PLT dotplot okay what is it going to do it's going to create this kind of lines we don't want to connect the Stars we just want to plot the stars as it is and that's what we are using that is scatter plot on x-axis I'm giving temperature and then on y- axis I'm giving absolute magnitude and then I'm just using PL show to Simply get the output without any kind of text written on top of the figure so hopefully everything is working the way we want and see the output no it's not working right now there is a specific reason behind that okay we wanted some kind of parts to be there on the top part as because we can see over here the hyper Giants and the super Giants are existing over here right but there is nothing over here it's completely empty the reason behind that is look at the the temperature and the absolute magnitude axis this values of temperature are starting from a higher value and going all the way down to a lower value similarly like that we are also seeing in the absolute magnitude we are starting from a higher value and then going up by decreasing the value that's completely opposite to what we are seeing in our M lab output we are starting from a smaller value going all the way up to a higher value and just like that in our y- axis we are starting from a negative value going all the way up to positive value so in order to get this kind of nature of the graph I need to invert my Axis okay I need to invert my x-axis as well as the y axis and the way that we can do it with the help of met plot Li I can use PLT and then GCA what is GCA it's giving me get current AIS okay so whatever we are doing right now is on an axis right so we are getting this current axis and then there is a property called Inver and then x-axis and then I can also copy this line paste this for y- axis and let's see now how it looks like see this is what we expect this is where the main sequence stars are then on the bottom part we are having red wve Brown wve over here we are having wide barves then on the top we are having super Giants and the hyper Giants this is what we expect right now there is one thing that is really very different we are not adding any kind of colors we are not adding any kind of sizes but now to add this kind of functionalities in your graph what you will need for each and every Star there are some unique properties right some unique values of X some unique value of y and along with that it's going to have some respective color depending on what type of star it is it's also going to have a specific size and also a label given to that particular Star as for example white bar so what I'm going to do over here is I'm going to create a whole lot of a python Dictionary what is python dictionary it's another data structure that exist in Python just like list just like array there is one more thing that is called as python dictionary now what is the reason like you know what's the main reason we are using this python dictionary you will be understanding in a while it's going to take a lot of time for me to like you know show you the whole dictionary so what I'm doing is I'm simply uh pasting that part that I have copied and simply uh having it over here okay I'm also going to get rid of this values because Ive also pasted it over over here okay so on the top this this two lines basically temperature and absolute magnitud you already know how did we get this but now what is the star type right so there is a column called star type right in our data frame and I'm simply converting this into the values it means if I try to visualize star type okay if I go ahead and print this it's going to be the list of the Zer 1 0 1 4 4 all these kind of things right we know that zero stands for brown valve one stands for red valve five stands for hyper giant so on and so for so now I have also created this kind of an access to all of the specific data points that are present in our data frame so now our main motive is we are going to take each and every individual star that are from one from the first star all the way up to the 240th star we are going to itate 1 by one we going to get access to X and Y coordinates at the same same time what is the star type of that particular star Now by getting an exess of what kind of star it is is it of type zero type 1 type two type three type four or type five I have created a whole python dictionary form that so let's say if the star type is zero then these are its respective properties if the star type is one then here are its respective properties this is what we create in Python in dictionaries actually it is python dictionaries are made of key value pairs what it means this is the key and this is the value of that keyy so in order to get exess of the value you need key so what I'm trying to say is that if I want to see Star types okay and now in this St R types if I'm giving zero so now zero is the key right if I run this it's going to give me its respective value right now again the value is in the format of dicture if you can see there is a curly brackets right and then there is a key and a value Associated to that there is a key and a value key and a value so I have created a dictionary within a dictionary right so the reason behind that is let's say that the first star is of class zero okay type zero now I'm going to call this as the property of star zero star type zero and now if I want to get an idea what is the label of the star I simply need to pass this key it's going to give me BR bar if I want to check what is the color that we are going to give to this particular star class that is brown what is the size that we are going to use to plot this kind of dwarves it's going to be size of 30 and then what is the marker that we're going to use to display on the graph what are this markers over here you are getting this kind of circles by default okay you could have changed this to cross you could have changed this to a DOT right you could have done a lot of different markers that are available in M plotly currently we are choosing only two types of markers if it's a dwarf star we are going to use marker as a DOT if it's a main sequence star or any kind of giant star then we are going to use a marker as o that's the kind of idea that we are having by default marker is O as you can see okay but now the whole idea that I want you to understand is that let's say in the it region out of all the 240 Stars we are on let's say index two so what are what is the star type on index 2 let's check that it's zero but now let's see if I'm on index 100 let's see over there the star type is four so now what I'm going to do is I'm going to change this zero to the star type of 100 that is 4 in short right and now if I take a look into its property of marker it's going to be o right and if I take a look into its label it's going to be super Giants see just like that if I want to get an exess of the color I can just do this by passing in the color and that's more than enough I guess you might have understood what I'm trying to say I'm trying to come up with a logic that if I'm trying to create a scatter plot and for each and every individual point that I'll be plotting I want to give this color label size and marker how can I do it with the help of this python dictionary that we have created for Star types that's exactly how we are going to do that okay so again if I want to show you what is the length of the star type it must be 240 right so in this star type there are 240 different values right starting from zero star type let's just visualize it for one more time see 0 0 0 1 1 1 so all of these things are for 240 times so I'm going to itate from the first index all the way up to last index and then whatever is the value of star type I'm going to get its respective properties with the help of this syntax so that's the idea that I'm going to implement with the help of a for Loop so what I'm going to do is I'm going to create a for Loop in the range of this 240 values okay so l of star type because we know that length of star type is what 40 right 240 I mean right so now let's say in future if someone is updating this CSV file if we are having a lot more data as compared to 240 Stars it will be very Dynamic for us to write this length of star type instead of 240 right so that's the reason that I have written this length of star so now what's going to happen the value of I is going to start from zero and go all all the way up to 239 right and now I'm going to plot this scatter diagram for each and every Star so the temperature on the index zero and its respective value of absolute magnitude on index Z is the first St that I'm going to plot then when the value of I will change to one it will be temperature one comma absolute magnitude one so H and every Star that I'm going to extract from the temperature and the absolute magnitude I creating this XY coordinate and then I'm simply going to plot it in the scatter plot but now at the same time I'm also giving the properties of the size color marker and the label okay now I can extract this properties just like how I have explained over here so I'm going to copy this part and store it into a variable called as properties okay but now I need to change this to I because I don't want Star type that is present on index 100 I want to automatically change if the value of I is changing so when the value of I is zero it means on the first row what is the star type with respect to that give me the properties right and then when the value of I is 100 at that particular Point what is the star type get me its respective properties right so that's the kind of idea that we have done and after that if you want to call its respective properties of size color marker and label how you can do it I I'm going to give properties and I'm going to write size over here right size color marker label right I'm just going to copy this code paste it for color change this size to color and for marker again I'm going to paste this change this to marker and for the label again paste it and change this to label so our idea is done hopefully everything is going to work fine let's go ahead and try to test this okay I'm just going to get rid of this extra things because we don't require it anymore and if I go ahead and look into this output I don't need any kind of Extra Spaces I'll get rid of this right so see this is the kind of output that we're getting right all the hyper giant super Giants are getting colored then this are the kind of mean sequence Stars these are the red veres these are Brown dves These are white dves all of them are what we expect in the HR diagram it's in the same exact way right that's what we expect right but now there is one thing that we are not able to give any kind of label right we are not able to see any kind of label that this is a white bar this is a main sequence star right we are not able to see these kind of things the reason behind that is because we haven't given Legend in met. Li you give this Legend in order to display this label so if I run this code just stick around with me because there are quite some more things we are doing in this specific video because there is a problem associated with this command okay I'll be explaining that to you see that's the problem I was talking about now for each and every Star that is for 240 Stars whatever is the star type it's going to give a label to it and assign in the graph itself now that's not something that I'm looking forward to if my brown dwarf has appeared once I don't want to label it again because I know that this kind of stars are going to be brown W then this type of stars are my red valves right if it has appeared once I don't want to appear it for more than one time so now I am going to come up with a very good logic that's going to help me solve this issue okay now the reason that I'm able to explain all of these things very fluently it's not that because I'm a very good programmer everything comes to me in just a second it's not like that it's years of practice at the same time I have already done this kind of I have already solved this problem okay took me some time it's not that on the spot I got this things okay so it's completely fine it's not that everyone is going to get it on the spot if you are especially a beginner it will take some time right so try to digest the things that I'm going to explain right now okay so so see what I'm going to do is I'm trying to create two things this requires some kind of an idea of how Legend works okay so let me explain you that first Legends basically take one input called as handles what are these handles these handles are nothing but each and every plot that you're trying to give okay so let's just call this thing as X's okay and I'm just also going to press tabs to shift it to the right and I guess one space back should do right this is looking good uh yeah this is looking better yeah now what I'm going to do is in place of this handles I'm going to write labels now what is this labels I again not created any kind of labels so I'm going to create a set called labels labels is equal to set at the same time I'm going to create exess empty list so what what I have done I have created two empty data structures one that is a list and one that is a set the unique concept about the set is that if there are more than one thing that is repeated okay there is a one thing that is repeated for more than one time it's going to consider it for only one time so what I'm trying to say is let's say I'm having set of 1 comma 1 comma 1 see what is the output going to be okay it's going getting this kind of an error because we we have done a syntax problem I'm going to come out of this and then I'm going to give this see the output is only one output is only one no matter how many times one is repeated it will always give the output of one so that's the kind of logic that we are having over here okay we will be keeping on adding the labels over here and make sure that labels are appearing only once okay and then for which plot I want to give this AIS label okay for whichever plot I want to give this label I'll be adding that data point to this particular AIS and labels it might be getting a bit overwhelming so let me go ahead and show you what I'm trying to say okay what I have done till now I have created this kind of a scatter plot and that's what you are seeing but now this kind of Legends are looking very ugly right so we are trying to sort that problem okay by calling these two things now I'm going to give an if statement now what is this if statement all about if the label that we are getting for the star type okay so from this properties if the label value if the label value is not present in labels okay only then you are going to give this x ax is equal to this kind of graph and then after that what you are going to do is this is really important you are going to add this AIS to this AIS and then also add the label because it was not present in this particular set because it's not present you are going to add it okay so what I'm doing is I'm going to first of all add this ax to this AIS list how can I do it I can do it with this AIS command that get me that list which I'm trying to add some new Val values so in the list you can add some new data point with the help of this upend command okay the upend command that you can see okay for some reason I'm not able to click it yeah anyway I'm successful in clicking it anyway so now exist the in empty list I want to append what this ax this is the handle okay this is the not the handle actually but the x's and the handles are the labels labels that I want to display so what am I appending over here I am appending this ax okay so what's going to happen for every iteration if the label that is present for the respective star type is not already present over here then what you do you create this axis and that axis what you're going to do you're going to pass it onto this particular uh list that we have created that's an empty list and after that what you're going to do is you're going to add a label to this set how am I going to do this I'm going to achieve this with the help of labels dot not append anymore it's going to be add directly that's how this kind of functions are built okay foret it's add for L it's append and now I'm going to add the label that is properties and label I hope the idea is getting clear it will be clear once the output is in in front of you okay now let's say if this label already exists in label then I don't want to add label to this kind of set then I I don't want to add okay then I don't even want to create this kind of exis in that case what I want to do is I'm going to give this else block and simply create my scatter plot without adding any kind of x's or any kind of that stuff okay so yeah that's the kind of logic that we have created I'm going to press shift tab shift tab yeah this is looking good so now we are expecting the output to be very decent it's not going to be as ugly as what we had seen okay we we have got an error let's try to look into the error it's saying that string object has no attribute get underscore label let's see where did we got this error this error is over here right it's because the labels right it should be labels let me check this to AIS and see how it works if the x is going to work then yeah I would have done an error yeah I would have I had done an error actually we had to store the AIS okay what is happening so this axis is giving you this kind of an command that okay for this particular point that you have plotted you want to display this label right and that Legend is automatically having this kind of labels right that's the kind of mistake that I was making Legend is already having access to all the labels that's the reason why we were seeing Brown WF multiple times red WF multiple times right so that's not a problem the problem is that if the AIS is present over here if I show you the AIS list let's go ahead and see it see now all of this is a path collection for each and every point there might be six 1 2 3 3 4 5 six what is the reason of this six because we are having six different categories right so for each and every point we are having this kind of AIS now what I'm trying to do is I want to show the label of Legend only for those respective AES or else I don't want to show it so that's the kind of thing that we have done over here and hopefully now it's making sense and now obviously you can beautify this plot by customizing by like you know adding uh xais y axis and all that kind of stuff and uh I can simply go ahead and copy paste this thing because I've already done this for a lot of times I copied that data and I'm simply going to paste it over here okay and let's see now how the output looks like and now let's see if you're also interested to add the data of sun okay in this whole thing I guess the diagram is pretty much small I'll also increase the Fig figure size over here figure size how I can do this with the help of PLT right figure and then fix size I'm giving my figure size as let's say 10 comma 6 I guess this is going to be fine okay now I just want you to realize that even after having a lot of experience in Python this kind of problems happen okay you need to go to the documentation and make things fine as a python developer it's our duty to go Ahad and make things right depending because we having access to all the kind of documents okay but right now I was able to solve this error because of the like you know the output of the error that we had got anyway the important part that I want to convey is that you should not be ever be frightened if you're getting errors okay if you're getting errors it's okay you should know how to solve those errors that's it if you are good at that you are good to like you know encounter any kind of problems in your life specific to uh at least the Python Programming questions okay but anyway uh if we are talking about this I'll just ignore this thing it's quite yeah disturbing yeah anyway this is the kind of output that we have got right for the HR diagram now one last thing is let's try to add the data for the Sun and see that where exactly on this HR diagram that Sun is going to be looking like okay so for that what I'll be doing is I'll be copying this data that I'm having for the Sun and simply add it into our code so I'm coming back to our code I'm going to give this kind of a title I mean the comment adding data for sun now what is this I'm creating one more xes specifically for sun because I also want to append this kind of thing and visualize in my output this is the temperature value I've gone to Google and got this kind of values this is temperature this is uh absolute magnitude this is the size that I'm keeping color is yellow marker is O and label is sun right and I'm simply also adding this AIS that we have created for the Sun and I'm also appending this labels as Sun okay now that's the whole point you will be automatically seeing that somewhere over here in the main sequence we know that sun is a mean sequence star so somewhere along this part our sun should be added just like this whatever kind of star you are interested to know about right you go and find its property on Star and try to plot it and see where it's going to be in the graph for us sun is over here right that's where the sun is and even in the legend you are able to see that sun has been added separately apart from all of this we are also adding a data point of sun isn't it just amazing how we have created this kind of whole thing by getting ideas of python that we have learned in our first module and then again some few things that I have taught in this particular video about how you can create an empty list and empty set and then how you can add data to it the whole idea over here was this thing okay if you don't know how this kind of things work then you will need some kind of experience of how set and this kind of list works but the only thing that you need to know over here is that we have created this kind of empty list and empty set to store the exis that is with respect to the plot that we are making over here we are trying to store it over here so that with respect to that plot I'm able to show the label that is present in the legend command in this Legend Command right so yeah that's the end of this particular video I hope you have enjoyed creating your own uh HR diagram right for the 240 Stars if you can see I have also given this kind of a dynamic way of writing this so that in future if star type is uh changing its length let's say we are adding more data to this existing CSU file then you will be able to create for let's say 500 Stars if there are more addition to the data right so yeah these are all the kind of plots that we have generated but I have not saved it right my common not common common so my common mistake is I always forget to save the figure size I mean the figure right that we have generated so save figure how am I saving it I'm giving my base directory and the name HR diagram yeah finally running this and I'll be also checking this before we end this video if this has been done fine or not coming over here looking into the star plots this is HR diagram close this see the beautiful plot right in front of you right the reason I haven't shown you how to do the title X label and Y label because you have been doing this for a couple of above plots right in the Y label I have added the absolute magnitude on the X label temperature given respective font size and the color as you know my favorite one is stab pink so that's the color that I given for them and for the title I'm giving the HR diagram title and a dynamic way of writing the title by giving the F string font size is 15 and the color is royal blue another my favorite color okay so yeah that's about this particular video guys I hope you have enjoyed this one hey guys so welcome to the last video of this particular module where you are going to understand that how you can download this visualizations that you have created in module 2 and saved it into a particular directory so now how you can save that directory into your system from Google collab notebook so all of these things we'll be learning in this particular video so let's get into it all right guys so now let's understand that how we can go ahead and download this star plots all the kind of visualizations that we have created over here from very Basics to very advanced level of visualizations you can do this with the help of because we are using see Google collab there are some specific ways in Google collab through which you can do this the one that we are going to do is I'm going to follow this method that you can see it right now on the screen okay the whole idea is that from this google. cab I I'm going to import files what are these files these are the same files that you can see over here everything that is over here we are going to get access to this with the help of this files right now what I'm doing over here the logic that has been implemented is that I'm going to create a zip file out of this folder okay if I just click on this option there is no option to directly download this folder right there is no option like that so what I'm going to do instead is to create a zip file off it because zip files are downloadable in Google collab so what I'm doing I'm creating this ZIP command and then I'm giving two things which folder I want to zip I'm just taking that particular folder pasting that same thing over here and just passing zip on top of that that hey in this particular path this is called content path in which the star plots exist so in this particular path I want to create a zip file that's it and once the zip file will be created it will automatically be downloaded by giving this kind of input to this download command Okay so this download functionality exists in this file okay so whatever is the file if you give the path to download that file it will be downloaded if I show it to you what's going to happen so if I run this code you will be able to see that a zip file will be generated and now you are giving this path in the download and automatically you are seeing that this kind of files have been zipped for us and also downloaded into my system I simply need to click on this and if I show this to you this is the content folder right inside which we are having the star plots folder and see here are everything that we need to know okay ignore this particular thing for example this is the star colors visualization that we had generated right if you want you can also obviously increase the size and everything right and then here is the HR diagram my favorite diagram right it took the most amount of time in the whole video program overall program not just one video right but yeah that's the that's the kind of output that we have generated so yeah now you can simply attach this kind of thing in any kind of research work that they're doing that was the whole point that with the help of a tabular data how you can create this kind of visualizations in Python with the help of Google colab and also extract it into into your system all right guys so it's time to buid a farewell to our module 2 so over here we used a tabular data set on Stars data and created some amazing visualizations with the help of mat lli and seone Library we looked into some of the different types of visualizations like bar graph box plot line plot pair plot and then eventually created a HR diagram with respect to the scatter plot and then how can we save this outputs that we are creating and download it into our particular system so all of these things we have done so far and I hope that you are enjoying each and every bit of this particular program now in the next module we going to jump into some image visualizations and do some amazing stuff over there so stay tuned for that I'll see you in that next module hey guys I welcome you all to the third module of this program here you're going to take one step forward where in the second module you had performed the visualizations on the tabular data now we going to create visualizations on the image data and therefore to start with in this module we are going to explain you what is the concept of an image then what is fits file because this is the file type through which you are going to access the astronomical images which you're going to perform some kind of visualizations on top of that then what is Sky View form how you can fetch the data of Andromeda Galaxy from astronomical surveys like sdss gmen and DSS2 blue then how you can Implement some of the pixel scaling methods on this anoma galaxy visualize the pixel distribution and lastly what is the concept of Z scale interval in a library called as astropy and why are we specifically using it for this particular program all of this is covered in this particular module guys so let's get into this module and I'll see you in the next video where we are going to talk about image hey guys welcome to the second video of module 3 where I'm going to explain you the concept of digital images in the format of pixels what are grayscale images colorful images and a lot more so let's get into it all right guys so let us go ahead and try to understand this concept about an image so what is an image I'll be first talking about how this kind of images are formed and then what are some kind of different things you need to understand about it so talking about how these kind of images are formed it's kind of a puzzle if you think about it okay let's say that you you are having different kind of pieces of puzzles which you are going to combine together to form this kind of an image that's the same kind of logic that we are going to use in order to understand how this kind of images are formed so this kind of puzzle pieces which are like you know coming together and forming this kind of one final image this puzzle pieces are nothing but the pixels this pixels are combined together to form what we see as an image over here so now what is this kind of pixels right we know about the puzzle pieces that there are some kind of pieces which are joining together to form this image but how do we know what is a pixel so for that what I have done is I just zoomed into this particular image as much as possible but not over here because Google cab is not allowing me to zoom any further than this okay so what I have done I have captured this image I have pasted it into the paint and on the paint I was able to zoom in much further as compared to what Google cab is allowing me so I got some kind of information like this okay so this particular part is being representing the top left part of the image okay so I'm zooming into it as much as possible and this kind of small small squares you are seeing right this is a small square this is a small square this is a small square so all of the small squares are nothing but the pixels and see how these kind of different pixels are there and all of these pixels which are coming together let's say you're just talking about the first row of the small squares all of these pixels are coming together to define the width of this image just like that there are also pixels over here which are stacked up together in this kind of a vertical line which is giving us the information about the height of this image at the same time they are having some kind of different shades of colors which are stored within it some kind of bluish color is over here some kind of very darker shade of blue as compared to what are there in the nearby pixels and similarly over here it's talking about the brownish colors over here it's talking about the dark green kind of color right so all of the small squares are hiding the information about what kind of shade of color is represented on that particular location of an image so I hope a very basic idea about how this kind of images are formed is clear this kind of images are the combination of this kind of pixels and each of these pixels are having some kind of information about what is the shade of color represented over here to show it into the output of the image right so let's say this is a piece of puzzle which is storing this kind of detail this is a piece of puzzles which is storing this kind of color of that particular detail all of these pieces of puzles are nothing but the square shape but now based on this kind of information of the shades of color you're are going to create an image that is something like this right now they can combine together to get the width and the height of the image at the same time how do we know about this kind of intensities of colors now for that we need to understand how these kind of images are form but I hope the part of the pixel is clear that how these kind of pixels come up together to like you know what we see right now in this particular image right now if we talk about how this kind of intensities of colors are coming into the picture how do we know that what kind of shade will be represented by what kind of part in the image so to understand that particular part we need to talk about the sensor that sensor is nothing but the camera that I was talking about when I started this particular video so let's say we are having this camera and in this camera we are having three different filters one to capture the red light coming from whatever is the source which sensor is trying to capture similarly whatever is the greenish kind of part that is being captured will be done with the help of green band filter and similarly for a blue color whatever is the bluish part over here you can see there's some kind of a blue part there is a blue part over here and also a blue part over here so all of the light hitting to the sensors coming from this kind of bluish part will be filtered out with the help of the green sorry the blue band filter right so now what's going to happen we know that typically all of these colors that we see different kind of shades of colors that we see are the formation of like you know different kind of mixes of red green and blue we know these things from our very primary classes in school right or in the art school art classes right so now this kind of different combinations of red green and blue will be captured from this particular image with the help of the S set that is camera and how with the help of this kind of green band filter Red Band filter and the blue band filter now the whole logic over here is the way that it is being captured is with the help of what kind of wavelength of light is contributing to the red part of the visible spectrum now I'm going into much more technical terms let's not go into that particular direction and talk about in a very simple terms whatever light that you are seeing over here is being coming to the Sor if it's falling into the red kind of region then that will be filtered out with the help of Red Band filter similarly for the green light and the blue light and the output of this is representated always into this kind of a grayscale image okay now if we talk about the image that we are going to deal with throughout this whole module is an 8bit integer image now different kind of bit of pixels uh stores different amount of information okay so let's say I'm having a comparison of an 8bit pixel to a 16bit pixel more this kind of 8 Bit And 16bit pixels more the combination of shades of colors it can represent that's a very simple idea about like you know 8bit image and a 16bit image in 16bit images you'll be able to represent a particular color with a more amount of Shades okay more amount of depth basically you'll be able to get from an image right so if I talk about the image that is an 8bit image that we are going to deal with in this whole module let's talk about that so in that 8bit image all these pixel values are going to range in between 0 to 255 to represent any kind of information let's about the Redlight coming from this particular image I mean from this particular part and hitting on the C answer if it's coming from the red uh sources red light sources it's going to be representated into different 256 sides and the values are going to be in between 0 to 255 that's the whole concept so 255 being the lighter part of the whole image and the part which is represented darker are closer towards the zero side so what does this kind of number 0 to 255 indicate so 8bit integer image is going to give you 256 different shades of a color maybe red green or blue right so now if you going to combine them red green and blue so 256 into 256 into 256 these are the possible Shades you can get and form a whole colorful image that you can see over here okay if you increase this bits let's say 16 bits per pixel then you are having 2 to ^ of 16 multiplied by three times to basically get even more shades of colors as compared to an 8bit image okay so that's that's an idea with respect to this but now let's try to observe that if I talk about this kind of bluish part this is a blue part of an image this is another blue part of an image this is another blue part of an image and now if I talk about blue band filter it should be able to filter all of this things and give a very high value to it that is 255 the lighter part of the blue band filter should be representing the blue part so I'm having this kind of uh blue part that is like you know surrounded by potatoes over here then on top of this kind of apples we are having this right so if I try to show you the output of the blue band you can see that this part is light this part is light right this whole part is light as compared to the above images in green band this part is darker this part is darker in the Red Band see even this part is darker and this part is darker right so that's what I I was trying to show you that because with the help of blue band filter that is stored in the sensor that is camera it is able to get this kind of blue light and give a high value to it that is 255 closer to 255 similarly if I talk about let's say greenish part in this images which are this kind of grapes right this kind of melons right if I show you them over here you can see that they are again expressed in the lighter pixels that are values closer to 255 as compared to this one see how darker they are closer to the zero right the darker pixels are closer to zero so how these kind of things are representated by a darker color right similarly if you talk about this kind of red Parts in the images you can see these are kind of apples which are red these are tomatoes that are red right if I try to show them over here see how dark it is in the green band filter but if I talk about the Red Band filter see how lighter these kind of things are all of this information are represented by the pixels which are closer towards like you know 200 255 kind of side right so that's the whole idea now you might be wondering that potatoes that are given over here are yellow in color right then why in the green band and the Red Band we are having the lighter pixels so if you think about a yellow color It's a combination of the red color and the green color now that's the reason by even in the green part and the red part you are able to see this lighter part in the image now what is the exact shade of red what is the exact shade of green out of the possible 256 combinations they're going to come together and finally form this kind of a yellowish image in the final output if I show you that potato in the blue part you will see it's a darker color as compared to the green and the red you are seeing that this part is darker right anyway there are again some kind of blue pixels that are also there some kind of shades of blue let it be a darker part right all these kind of things are coming up together and give you this exact color that you are seeing over here so to just summarize the whole concept of an image we first understood the idea about what are the pixels because with with the help of this kind of small small squares that you are able to see these small small squares are coming up together and giving you this kind of the like you know this kind of how what is the width of the image what is the height of the image and if we talk about the intensities of the colors that are represented by this kind of small small squares is dependent on how much amount of uh shade of red is present what is the shade of green is present what is the shade of blue is present at the time of capturing that particular image and depending on that based on this red band green band and blue band filter we are getting some kind of respective outputs and all of these values are stored in the range of 0 to 255 255 being the lighter part zero being the darker part of that specific output of the filter then you combine all of these three images with respective shades of green red blue and finally whatever are the shades that you can create is the final output of this image so wherever there was a bluish part right all of these pixels came together join are combined together stacked on top of each other and this part where the blue is present this kind of color will be there on this specific location what is the output of the blue filter what is the output of the green band filter what is the out of the Red Band filter combination of all of this three because the bluish part is higher in color that's why this kind of pixel is given some shade of blue by combining this RGB possible combination that we are getting from the sensor this is the color that we are able to fetch so I hope I'm able to convey the ideas with respect to like you know what are this images how are they formed because this are the building blocks that we are talking about about this module as we go ahead we are going to actually represent all of these images into the format of pixel how are you going to do do this you will you will be seeing this in the upcoming vide so stay tuned for that hey everyone welcome to the third video of module 3 and now that we are going to deal with the astronomical images they are typically saved in the format of fits file so it's essential for us that we understand what exactly is this fits file and what kind of things it typically contains so let's get into it and understand about all of this information so now let's try to have a very quick idea about what are Fitz files so in the Astronomical Society this is one of the very popular way in order to store the data that we are getting from these telescopes in order to load it into our system and let's say we are uh doing some kind of image processing on top of that and doing some amazing research analysis of what kind of information is stored in this kind of images captured by the telescopes now that's exactly what we'll be doing in the upcoming few videos and that's the reason why I am explaining you over here about the Fitz file because you are going to fetch the data from one of the astronomical surveys that is the Andromeda galaxy it's not going to look like this at all it's a very raw image that you'll be getting from the telescope and then how you able to get that image it's stored in the format of Fitz file so what are the components of the Fitz file let's try to understand that so Fitz file is having multiple different header units at the same time all of these header units are also coming up with some kind of a data now this data could be in the form of images it could be in the format of uh different tables Etc right so right now because we're going to focus on the image data let's just understand what are these kind of two main components you need to know about the Fitz file the first thing is the header unit and all of the Fitz file will come with the primary header unit for sure and then some kind of extension header units that are going to reveal about some more information about that specific image that we are trying to talk about so typically this kind of header units are storing some kind of metadata which is revealing the information about let's say for example what was the telescope used to capture that specific uh astronomical object what is the location of that astronomical object out there in space for example what is the uh right Ascension what is the declination these are nothing but the space Celestial coordinates that we are having to get an exact precise location of the astronomical body out there in space right so we are able to get all of this kind of information with respect to the header unit I'm going to show this kind of live demonstration for this kind of uh Andromeda galaxy by the way this is the closest galaxy to the Earth if you don't know right it's going to be really very amazing thing we are going to do in the few upcoming videos for this module right so we're going to study about this kind of header units and all of these header units might have some kind of data we're going to also extract this data and do some image processing on top of that to reveal some of the amazing Beauties about this androma galaxy right now obviously you are seeing a very highly detailed processed image we not going to get anything very close to this but yet do some kind of research work in terms of doing some kind of image processing and get some kind of of analysis as in like you know you can see there is some kind of a small Galaxy over here right on top of that huge Galaxy right we'll be able to get all of this information by doing some kind of image processing right so all of these things you'll be seeing in the upcoming few videos so stay tuned for that hey everyone welcome to the fourth video of module 3 so far we have just covered this kind of theoretical understanding of what is an image and because we are going to deal with the astronomic iCal data and typically it's going to be in the format of fits file so we have also covered that so far but now it's time to start the coding process and as usual you know we going to import the libraries and if it's not pre-installed in Google collab we are going to first install it and then import it so let's get into the video now as we are going to perform some of the image processing tasks throughout this module on this astronomical data called as anoma Galaxy uh so how we can collect this data from lot of astronomical surveys and call it into our Google collab notebook we can do this with the help of a library called as asro query so now like matplot Li this is not pre-installed in the Google collab environment so you will have to manually install it by using this command called as pip install and the name of the library that is Astro query and you simply run this code and it's going to take some seconds and simply install it for us in this Google collab environment now the moment this is done you will require one more Library through which you will be performing the visualizations and as you might have guessed it is M plot so I'm also going to import matplot lib along with that pip plot as PLT now it's not that we are just going to use m. Li okay as I also installed this kind of Astro query you're are also going to use some of the functionalities of this particular library in order to call that image as I mentioned about the androm Galaxy and along with that there's one more Library called as astropy even that is the one that you're going to use in upcoming videos but for now there were only two basic steps that I really wanted to show you that with the help of what library you will be calling this image of entoma Galaxy into your Google collab notebook and then obviously in order to visualize it what is the library that we are going to use that is met plot now in the next video you are going to see some of the amazing things uh through which you are just going to be completely shocked like you know these kind of things we can do in Python so stay tuned for that hey guys welcome to the fifth video of module 3 and here we are going to take a look onto the internet's virtual telescope with the help of Sky View form so what exactly is this form and how we can get the image of the anoma Galaxy out of this let's look into that in this particular video so let me introduce you all to this interesting form called as Sky View query form now with the help of this form you're going to get this access of this Andromeda galaxy so if I just click on this particular link it's going to redirect me to that particular site where I can access the sky view query form so what is this form all about as you can see it is the internet's virtual telescope so with the help of this particular query form you can query about any kind of image that you're looking forward to that is M3 31 in our case that is Andromeda galaxy so for the Andromeda Galaxy from all the possible available surveys over here we just need to give some of the selections that we want to visualize our M31 in so the telescope that we are going to use is the sdss and DSs and both of them are in the optical range and uh with the help of sdss I'm going to perform some of the uh image processing task and with the help of DSs I'm going to show you the whole output of how this kind of Galaxy looks like in Python okay we're going to do all these kind of things in the upcoming videos but for now let's see if I want to visualize this data in this form itself without using python how can I do it so for example if I'm clicking on this SD SSG and click on enter because I have already pre-selected this particular object as or source as M31 that's the entoma Galaxy and I'm using this particular survey called sdss of gband is going to give us this particular output now what is this this is the extreme center of the Andromeda galaxy or I should say the core of the Andromeda galaxy so if I just have to show you over here the extreme core over here this kind of like you know this kind of bright part you are seeing this bright part so that bright part if you are trying to just dim that thing and look exactly into the center that Center is nothing but what is visualized over here just in case if I really want to show you what this means this is very zoomed in version of what's going on in the center of this particular core of Andromeda galaxy and we are going to perform our all the kind of image processing on top of this particular output but now what if I want to like you know just zoom zoom out a bit and show you with respect to some other uh survey that is the S DSS and let let let me select this DSS2 blue and uh I'll just what I'll do one thing I'll clear every survey sections and then again select this blue and this time I'll just change the setting of image size pixels from 300 to 600 and now if I submit this request see this is the kind of output that we are seeing I have zoomed out only by a bit I have doubled the pixel size so I'm getting much more output as compared to what we were seeing for a much larger output but now it's still like you know if I just compare it with the original image over here it's this kind of part that you are able to visualize if I just zoom in say I'm not able to zoom in any further than this but now this is the power of the telescope images that we are having this is visualizing at the extreme center now over here in this specific image you are not able to look into that extreme core because we are we have zoomed out a bit however you are able to see some of this kind of bands or of this particular Galaxy and this bands are nothing but the bands that you are seeing over here so this is a very zoomed in image now what I'm going to perform over here for you guys in the upcoming videos is that with the help of this uh DSS2 blue we are going to try to visualize this whole Li uh not library but the image the whole image of this uh Andromeda galaxy I'm going to try to visualize this kind of thing for you uh with the help of a DSS2 blue and then with the help of sdss G that 300 by 300 pixels that we had seen we are going to perform image processing over there and try to decode what all kind of structures we are able to find out of that simple looking thing that we had seen earlier this thing okay I guess oh I selected two surveys this is the first survey and this is the second survey right this was the first DSS2 blue and this is the second one that was the main reason why I primarily went away over here and clicked on uh clear survey selections because I could I don't want to see both the things I just wanted to see one but anyway these are both the surveys over here uh on with respect to DSS2 the zoomed out version 600 by 600 and over here this is 300x300 focusing extremely on the core of this particular Galaxy so now in the upcoming video we are going to call this data of Sky View query form with the help of Astro query Library into python so it will be really interesting to see how we can do this so stay tuned for that hey guys welcome to the sixth video of module 3 and here we are going to use the Astro query library in order to get the access of the sky view that we had seen in our previous video and from there we are going to fetch this data of Andromeda Galaxy from a particular survey that is sdss specifically gband okay all these things you will be understanding in this video but the output of this will be of Fitz file and now that you are also aware about the Fitz file it will have two types of information header and data so header will consist of metadata and data will have some kind of image present over there so we going to take that image data and visualize the output of the anoma Galaxy and just compare it with the actual view that we had for the anoma Galaxy using the sky view form so now that you are aware about what is this Sky View query form where you can give in the information about the source that you want to visualize with respect to any of this available survey options right now we have already visualized with respect to Optical sdss and DSs but now specifically if I let's say want to visualize this sdss G in my python so basically what I'm trying to do is I'm trying to I hope this is yeah this is sdss gband so I'm trying to visualize this particular information with respect to python so how we can do this with the help of Astro query Library let's try to look into that so for that what I have to do is first of all I need to get this Sky View functionality in Python and I can do this with the help of estro query library with this command EST from estro query. Sky View I need to import Sky View class so with the help of this Sky View class we are going to use one of the method of this Sky View class through which we can fetch this data of M31 of this particular server and I can do this with this command sky view the moment I press this dot it's going to give me all the possible methods associated with this Sky View class and now because we are interested to get this images I'm going to click on that and now let's see what kind of inputs we can give to this particular method so I'm just pressing the parenthesis and I'm just waiting for a while and now this is the kind of popup that I'm able to see automatically on Google collab and the first input is going to expect is the position which is nothing but the M31 in our case the second input that is expecting is the survey which is going to be SD SSG in our particular attempt that we are trying to visualize something all the kind of other information you can keep it as of whatever it is I'm not going to change anything and we are going to do a lot of different stuff on top of that that's why I'm not changing any kind of things as of now and uh so yeah let me give the input of M31 as the position and the survey as SD SSG and the moment I run this I am getting a list within a list right I'm getting this kind of square brackets which is called as a list and inside that I'm having one more list and inside that inner list I having this kind of a file now what is this file this is a file which is called as a fits file that we had talked about ear earlier in this particular module we had talked about how this kind of fits file is created it is having some information about a primary header for sure and some of the metadata associated with that now along with that it might or it might not have this kind of extension uh headers and the data associated with that so in our case as we are seeing only one primary header it's basically indicating that we are having information about the primary header and with respect to that what is the metadata with it and any kind of extension information is not given to us and that's the reason why we are having only one information within this kind of main list now that's exactly what we are going to fetch out of this list and get this hdu file from it how we can do this first of all I'm having this kind of the original list the main list inside which there is one list so let's get access to that inner list I can do this with the help of this index zero because I know that this particular list is present on the zeroth index now if I run this code and show you the output let's see what do we get so as expected we are now into the inner list now inside this inner list we also again see that this hdu file is present in the zeroth element on the first position basically so I again need to pass this zero and now we are successfully going to get this hdu file that we are looking forward to and now this is is nothing but the primary hdu so I'm just going to store it in a variable called as hdu now always remember HD is coming with two different type of information one is the metadata which is going to give us all the kind of details with respect to the Fitz file who has created it when was it created the information about the telescope and the survey that was used to fetch this particular data every kind of information will be stored as a metadata in the format called as header now along with header there is one more kind of thing we call as data now that data as I explained earlier could be in the format of an image could be a tabular data right all this kind of information could be there so now let's try to understand first of all the metadata that is associated with this primary hdu now I can do this with this function called as header of this hdu so hdu do header this is the only command that I'm typing to get all the metadata information associated with it now as you can see that this is the file written by the sky view Thursday December 14 uh with this particular uh time and everything the information when this particular file was written after that we are also having this particular idea that it is containing a twood dimensional image as well what is the width of the image 300 what is the height of the image 300 if you remember in the sky view form itself by default it was having 300 pixels if I don't write this if I just refresh this by default it was giving us this 300 and that's the exact reason why we are having this 300 by 300 I can surely go ahead and manually change this to 600 if I want but I'll be doing this for the other Optical survey that is the DSs survey right uh this particular survey DSS 2 I'll be showing that in the upcoming videos but let's now focus on this particular part see by default the pixel size is set to 300 so that's the reason why we are again saying this kind of 300 by 300 so all of this information with respect to this see again there's a comment with respect to Sky View survey metadata right then all the respective information the copyright information survey information uh projection information coordinates information uh Epoch information all of this particular thing is given over here in the sdss there are multiple data releases this is part of data release 9 dr9 again this kind of information is there so obviously it will take a lot of time for me to explain each and every part of this metadata you get used to it once you're having more and more practice with respect to like you know dealing with the fits file specifically the astronomical data but right now the key takeaway for you is that in this Header information of the hdu file you get this kind of basic information right you can just keep on scrolling and get any kind of respective useful information for for you so that was about with respect to metadata now what about because we know that it's also containing some kind of image how can I fetch that image out of this particular HDO file so for that I'll just scroll down and see here I also written the comment that get the pixel data that is present from this hdu now I simply need to do hdu do data how I did hd. header for the metadata just like that I need to to do hd. data in order to get this pixel information and as we had seen it's in the format of float 32 where we had seen this uh if I just scroll up this is where we had seen this now it's like you know it's also including some kind of negative numbers and it could have positive numbers and it's of a float 32 type it's a floating Point numbers of array and is a float 32 type again in the beginning of this particular module i x explained about this images all of this kind of pixels so this pixels are in the range of 0 to 255 or a uh uint 8 image but right now we are dealing with the float 32 Type image and it's a like you know the sign is also playing an important role it means it might have some kind of negative data some kind of positive data okay don't worry about all these kind of things I'm not going to go into any kind of uh further technical details but see now we are having this kind of a data and it's of a type float 32 even this kind of information was present in the metadata so over here this is nothing but the M31 pixels data I'm going to sh store this particular thing as the M31 pixels data because this is a format of an array so this array is nothing but in the format of an image and now check the type of uh this particular M31 pixels that we have created now I have already told you that it's a array now how do you know it's a nump array you can use this functionality of type and just pass in this M31 pixels if I run this it is a numpy array numpy array and dimensional array basically okay now what is the shape it must be 300 by 300 by 300 as we had checked in the metadata so let's even try to check that M31 pixels dot shape it must be 300 by 300 if not then we are doing some kind of mistake see it's 300 by 300 the exact same thing that we had seen in the metadata right now the next thing that we are going to do is to visualize this particular image now how we can do this I can do this with the help of pl. IMO in order to visualize any kind of numpy array any kind of array data associated with num Pi ARR if you want to visualize it you use this PLT and then I am sure now with respect to that you given the information of the array that you are trying to visualize and you just hit uh run this particular code cell and let's see what kind of output you get this is the kind of output you are getting currently right by default the color map that we are able to see this is VAR it is okay if I show you C map is equal to vus so by default mat plot lab is going to get this color map of vus see you can see there is no change because by default color map that was used for this 2D image 2D image means a gray scale image okay so I can also convert this into a gray color if I want even that is fine because this is the kind of some kind of similar output that we had seen over here now let me tell you that there is some kind of pixel scaling that has been done on top of this image that's why you are seeing much more information as compared to this raw data we are seeing over here and that's exactly what we are going to do in some of the upcoming videos so stay tuned for that but for now what I'm really uh interested to show you over here is that our data is starting from 0 to 300 but on the y axis it's going in the opposite way zero is on the top so we need to bring down this particular origin over here so how we can do that I can can simply pass in the command of origin is equal to lower inside this IM show itself so now if I run this you will be seeing that now the origin is uh over here and now this is the kind of the center that we are seeing over here and how we can reveal a lot more other information as you can see over here of course I can give some of the uh input parameters like you know I can just change some of the input parameters while calling this uh image get image but I'm not going to do all that kind of stuff I'm going to show you manually how you can try a lot of different ways of pixel scaling in some of the upcoming videos okay right now in this video I just wanted to show you that out of these two survey that we are going to use how I can show you at least one of the survey so that you are able to appreciate that yes with the help of this Astro query Library we have imported this class called sky view from this sky I there was an method called as get images now this is going to give us the fits file that is written with the help of estrop Library not estr query but estrop Pi okay again estrop is one of the library in Python which is associated with this estro query also so with the help of that estrop Pi we are writing that fits file so because it was in the format of a list we are extracting this kind of list data and getting h from that and once we got that hdu out of it we are looking into the metadata and any kind of data Associated along with that metadata and for us it was image uh in this particular case it's not always image just remember that over here we were having the image data we took we took a look onto the what type of that uh D array was it's a numpy array basically and we can check this kind of shape on top of that that is 300 by 300 and also we have visualized this by Shifting the origin to the lower so that this kind of z0 is matched now in some of the upcoming videos you will be seeing that with the help of the pixel scaling techniques how we can convert this kind of raw data into something like this okay and along with that I'm also going to show you in some of the upcoming videos in this module that how you can visualize this kind of overview I'm not going to add any kind of color information okay I'm not going to do any kind of that kind of uh color processing I am just going to show you that with the help of this Sky View how you can look into this kind of bigger output also a zoomed out version also okay so I'm going to give you all of this information in the upcoming few videos so again just stay tuned for that hey guys welcome to the 7th video of module 3 and here I'm going to show you one another survey with respect to which again we are going to fetch the data of Andromeda galaxy but this time we are also going to tweak in some of the parameters so that we are able to not just see the core of the Andromeda galaxy rather the overall Galaxy that you must be seeing on the internet all over whenever you are searching for the Andromeda galaxy so that's the kind of output that I'm looking for not in terms of colors but at least the image which is clearly showing you that yes this is the Andromeda galaxy so that's something that we're going to do in this video so let's get started so now that we were able to fetch this information of the Andromeda Galaxy from the uh s dssg Optical survey that we were having now we are going to go ahead and call this DSS2 blue and visualize the output in a much more zoomed out fashion as compared to what you are seeing over here okay how can I do this with in Python let's try to understand that so again what I'm going to do is first of all I'm going to copy this this part of the code and come down over here and uh call this but now at the same time I'm going to change this to DSS to Blue right now along with that now because I want to see the zoomed out version of this I need to pass in further more arguments over here in the get images so one thing that I can give apart from the position and this survey is the pixels now inside this pixels information what all kind of things I can give I can give by default it is 300 by 300 I can let's say give 600 but now at the same time I'm also going to increase the radius of it so that we are able to see much more wider view of what we are seeing over here okay over here also 600 by 600 is still giving us a little bit zoomed out version but I want to expand the radius of this particular image so that we are able to see a lot more information in this 600x 600 so for that I need to say let's say for example 150 now I need to convert this into arc minutes okay I need to convert this into arc minutes how can I do this I can do this with this Library called astropy that I talked about in the previous video so from astropy dot or I should say import estrop do units as U and this U that is the units will help us convert this 150 into the arc minutes how I'm going to multiply this uh into U do AR mean that is Arc BS and now if I try to just run this particular cell okay it's giving me some kind of an error the spelling of pixels is incorrect no problem now if I run this I'm going to sort that out it's going to take a little bit more time as compared to what we had seen in our previous video to fetch the hdu file because it's taking a lot more pixels and also the radius is very uh like you know we have increased the radius and therefore now if I go ahead and try to get only the pixels data from this hdu data okay and this is nothing but the like you know M31 with respect to DSS2 blue pixels and now if I try to just run this code and look into the shape of this M31 DSS 2 blue pixels do shape it's going to be 600 by 600 but now just look into the magic the moment I'm doing PLT do IMO of the same thing giving the color map as gray and at the same time I'm also uh doing origin is equal to lower I run this now see this is the kind of image that we are seeing the same image that we are having over here very similar to this we are able to see that there is one more Galaxy near the Andromeda galaxy this is the satellite galaxy of the Andromeda this messia 32 is one more satellite Galaxy to this Andromeda and this galaxies are going to like you know come and collide with the Earth right in some billion years ahead and form a combination of Andromeda and Milky Way We also call it like you know as milkomeda there is this kind of name that we have given to this like you know when this kind of collision will happen between the Andromeda galaxy and the Milky Way galaxy we will call it as mil omeda and milk droma something like that okay there are some weird names we have given that is the combination of both of these galaxies but anyway see now we have exactly got this data that we were looking into I'm not going to add any kind of color information just look into the moment I have changed this kind of uh particular survey we are able to get this kind of output the whole anoma galaxy you are able to see over here this is M Messier 110 this is year 32 all of this information we are able to see even over here there is a star cluster even that information is visible so we have done all of this with just one line of code over here but now this is not what I really want to do obviously we've got all of this things this is really very cool right but now let's do some of the image processing with respect to this score of this Andromeda Galaxy now that's something that we'll be doing in some later part of the uh module before that let me show you because we are having a lot of information with respect to a Header information even this kind of image information if you want to create your own fits file just like how these guys are creating this fits file if you want to create your own fits file like this how you can create it after that we'll be jumping onto all the kind of image processing and interesting stuff before that this one part that I really want to show to the people who are really interested to know how this kind of fits file are made so for that just watch the upcoming video and you're going to get a good idea about how you can create your own particular fits file hey everyone I welcome you to this eighth video of module 3 where I'm going to teach you how you can create your own fits file so obviously we don't have our own telescope like you know that's going to capture all of these kind of things and get our metadata and also get the the image so what we are going to do is we are going to use the same header and the image that we have obtained in one of our previous videos of the Andromeda galexy use that as the dummy data and create our dummy fits file okay so how exactly we can create it is what I'm going to show you in this video and once it is created we are also going to test it and see if it's working just fine as we expect it to work right so let's get into it so let's try to understand that if you're having this kind of metadata information and this kind of image data information with you then how you can create your own fits file just like how we had seen Above So for that I'm going to use this Library called as astropy just like what I had shown you in the upcoming uh I mean in the previous videos that over here the hdu file is in the like you know format of astropy do. fits so to create your fits file you need to import this particular thing in Python first of all so that's exactly what I'm going to to do in the first step over here I'm going to say that from astropy import I should say from astropy doio import fits so now it's going to give me the liberty of creating the fits file and you had seen that it was in the format of a list right within a list there was the hdu file that we were having the primary hdu file so we are going to take the same exact metadata dat that we had seen over here right and I'm going to store this metadata over here as let's say M31 Header information okay and at the same time we are also having the information about the pixels so I'm going to add the same data into my separate hdu file that I'm creating because obviously I'm not having any kind of existing metadata or the image data so I'm going to use the same information to create uh complete fits file from scratch so for this what I have to do first of all I'm going to initiate this kind of empty list that I'll be creating with the help of fits and I can do this with this command fits. hdu list it's going to help us store different hdus within that list and I'm going to call this as the hdu list okay like this now the second thing is to create the primary hdu the moment you are creating this empty list you need to pass in some kind of hdu information so the one that I'm going to create is the primary hdu okay uh it's not dhu it's hdu and how we can do this again I'm going to use this fits but on top of that I'm going to use primary HD now what this is okay first of all let me show you what this is this will be an empty list and in this empty list I'm going to pass in this hdu file that I'm going to create I'm going to copy this also I'm going to paste that over here so see this is again an astropy i. fits file it's going to give us the primary hdu but now what if I'm trying to let's say give this uh as some kind of a name called HD1 for example okay and now if I'm trying to look into HD1 do data if I'm just doing this it's it's not having any kind of information as of now in the primary hdu it's completely empty even for the header it will have some of the basic information that like you know it's uh conforming uh to fit standard then it's a array data type it's not currently having anything number of Dimension is zero right so we are going to fill all of this kind of information over here with respect to M31 metadata that is the M31 header and in place of data we are going to pass in the pixel values that we were having so let's try to do that first of all we are going to add the pixel data how we can do this we can say that hdu one that we had created because now it's a primary hdu it's coming in uh with this functionality of data and what is this data this is the M31 pixels that we had created earlier similarly that like that I can also add HD1 do header what is this M31 header that we just created a few seconds back so now what I'm doing I had created a primary hdu in that primary hdu I adding some kind of data information I'm assigning this M31 pixels to this HD1 data which was initially empty when I had showed you over here right and after that I'm also filling in the information about the header assigning this M31 header that we had gone above now once this uh hdu file is ready once this hdu one file is ready if I run this code now and I show this hdu one. data now now it will have this kind of information see even the Header information it will have because I assigned this kind of uh data to the HD1 that's why now it is having the data now our duty is to pass this uh primary hdu into the list that we had created that is going to finally create one fits file for us right it is having some list within this list we are having this hdu so how you can do this we know that we can add any kind of data to the list with the help of append function so what I'm going to do is I'm going to call hdu list. append and what kind of information I want to add it's the hdu one information which is nothing but the primary hdu that we had created over here that's it so our fits file is ready now in order to download this fits file or to write this write this fits file what I'm going to do there is a functionality called as right two right two is going to help us finally save this fits file so what I can say let's say hdu list that's the main fits file right a list within that list we are having the primary hdu so hdu list I want to write to this particular list as the fits file we can call it as a dummy dummy fits file Dain fits file and that is in the format of fits so do fits right so HD list. WR to and giving it a name this if I run this code and if I look into this file storage you can see that this fits file has been created for us the same fits file that we were importing from the sky view uh query you are now able to save the same information into the fits file and now you can like you know also do a lot of different things with this but right now that's something that I really wanted to show you that if you want to create your own fits file how you can do this with the help of astropy library now that we are uh creating this particular hdu file for the primary header I mean primary hdu like this you can create extend uh extension headers also if you're having the information you just do a fit. extension header and you give some kind of data to it give some header to it and append that particular hdus that you are creating in the HD list and then again do this right to for that list that you have created and you will be having even the extension headers if if you are having okay so yeah it's something that you really want to experiment by yourself uh if you're having multiple header and its respective data information so you can create multiple extension uh to the hdu file or the fits file okay so now let's try to open this fits file that we have have generated how we can do this I can do this with the help of fits. open if you are having access to the fits file you copy this path you give this path as an input to this where it went it's over here you give it in the format of a string let's say I'm calling this as some kind of like you know again let's say my bit something like that okay my bits is equal to this if I'm running this okay let's uh look at into this particular let's say what is my fits so it will be a list and within a list there is this kind of hdu primary hdu that we had created right so now what is present inside the first index of this bits obviously this thing so my fits of zero is having what it's having this kind of primary hdu file that you had created with the help of estrop py. i. fits now if you want to check this header information so you do my fits of zero. header you could have also saved it into some kind of a variable called uh dummy hdu and then you can take dumy hd. header even that is fine so you can see now there is a header you can also do uh this for the data part the pixels part my fits 0. data right again now you can store it as a variable let's say this is uh dummy data variable and I'm saving uh this data over here and then I'm taking checking the shape of this Dy data variable. shape so because M31 was the sdss from that particular sub we had got that data it's by default 300 by 300 so that's why we getting that particular shape and if you want to get the type of the variable you do type of the that dummy uh data variable check this it will be a numpy array right so as you can see I've also cross checked this particular thing the moment we were creating it and even after creating it once we are saving it I am also importing it back with the help of fits. open command and checking all of this if it's working in a proper way or not and yes that's how you can create your own fits file if you're having access to the Header information uh as well as the data information so that's what that was about how you can create your own fits file now in the upcoming video we are going to talk about the pixel scaling that we were mentioning about before this particular video and that's where the fun begins guys hey everyone I welcome you all to this ninth video of module 3 where I'm going to show you the distribution of pixels with the help of an histogram but before that I'll also be showing you the summary statistics of the pixels that we are having of the Andromeda galaxy and after that I'll be showing you the visualization so let's get into this video so first of all what I'm trying to do over here is to get the summary statistics of the numpy array that we had created for the M31 pixels what is this M31 pixels if I just give you a very quick summary of this so M31 pixels was the uh value of the image data that we had captured from the fits file that we had seen for the uh slow digit Sky survey gband so from this we had fetched this particular information of the numpy array which is nothing but the array of pixels which is eventually forming this kind of output I'm going to set the color map is equal to Gray and also set origin is equal to lower for the same reasons that you had seen in the previous videos and the output that you'll be seeing over here is like this a plane output which is just highlighting the center part of the Andro Roma Galaxy like this but everything else is just black as compared to what you are seeing over here this is a much more detailed output that we can see as compared to at least what we are having over here so how we can get this kind of outputs by doing what changes on the pixels we can get this kind of output that's something that we going to look ahead to but now for that we need to understand what's wrong with this particular image so for that we need to do some kind of basic study on the pixel values which is able to give us this kind of an output so for that we need to check the summary statistics of this particular pixels so how we can do this I'm going to Simply use numpy that's the reason I have imported the numpy over here which I haven't as of now so import nump as NP so yeah now let's go ahead and try to uh print summary statistics of M31 pixels and excuse me me if my uh spellings are incorrect because I'm not good with them but now the first thing that I'm trying to print over here with the help of F string is the minimum value that is present in this whole array of pixels out of all of this 300 by 300 image that we are having where we are having or I should not say where but what is the minimum value of the pixel that we are having so let's say minimum is uh NP do mean of the pixel that I'm trying to find I mean of the array that we are trying to find if I just run this code you can see that the minimum pixel value is 5.35 something right and just like this because I want to find the maximum value also what is the average value of the pixel what is the spread of the pixel I'll also be needing the maximum mean and the standard deviation values of this particular array so after minimum I'm going to look for maximum I'm going to look for average value that is the mean and the spread basically basically uh over here is referring to the standard deviation okay so don't worry if you're uh looking into this kind of uh terms for the first time it's completely fine STD now let's look into the overall summary Statistics over here the minimum value is 5359 of the pixel the maximum value of the pixel in this array of M31 pixels is 178 now if you talk about on and a average on an average in this M31 pixels array what is that value of pixel it is 13. 329 something so on an average the pixel values that you will be seeing will be more towards the minimum side it's not exactly in the center it's very much skewed towards the left hand side uh of the pixels that is towards the minimum side so if you want to get more sense of this particular data we can also visualize this and look into the reason of like you know why we are having this kind of 178 because minimum is 5.35 and the average is about 13 something then how come maximum is 178 over here so it could be there is some kind of noise that is present uh over here in this image I can also prove you this with the help of what is the pixel value that is at the brightest spot that we can see over here that is exactly at the center because remember that this kind of uh images that we are having is directly from the telescope who is focusing or I should say which is focusing at the extreme Center of that Andromeda galaxy and with the help of uh the metadata I can literally show you what is that reference pixel okay so if I just scroll up so over here now we can see over here see X reference pixel is 1 15.5 and the Y reference pixel is again 1 15.5 so it basically means that this is the center which was focused by the telescope in order to generate this particular image so that's where we expect the maximum value of the pixel to be there so again if you want to just cross check that part you can do this with the help of um M31 pixels located at 150 comma 150 because we cannot give any kind of uh float values over here to get the location of the pixel so it is 148.5 what what about 150 1 and 151 oops yeah let's check this value it's 126.5 so both of these values are again far away from 178 so it basically means there is some kind of noise that we are having in this particular data and again we can go ahead and visualize this I can also first of all give this particular thing as a comment as uh visual or printing the value of pixel at the center of androma Galaxy right so yeah that's something that we are having over here and now let's try to visualize the distribution of these pixels with the help of histogram now you can again create a histogram with the help of M plot Li so what I'm going to do is I'm going to say PLT do hist for histogram I'm going to give the M31 pixels to get the distribution of the pixels of this thing so for example let's say we are having 300 by 300 pixel values uh over there whatever is the pixel that is present how many times you were able to see this in the array so that kind of distribution you will be seeing with the help of this uh histogram okay now I guess there is some kind of an indent problem so I'm just going to delete that part yes and now after this I'm going to uh also give one information called as bins what is this bins you will understand it in a while okay I'm for I'm just giving a value as 50 but now if you remember this is a 2d array it's a 2D image now in order to quickly visualize this particular thing I'm just going to convert it into a 1D kind of format using this flat operation so this flat on top of this numpy array is going to convert this into a one it's going to treat it as an Itor as a one dimension so it's quickly going to help us visualize this histogram basically okay if I don't use this flat command it's going to take a lot of time to get us an output so that's why I'm using this flat and quickly we are having this kind of an output now if you look into this kind of steps that we are having right you can play around with the steps by increasing or decreasing this beans value let's so what happens if I'm just using one so this is the kind of output that we are having in between 5 to 178 we are having just this kind of one bar so if you want to have a lot of proper visualization just increase the value of Bin to let's say for example 100 it's going to give you much more better distribution as compared to what you were seeing and if you still want to get a refined version of this you can still increase the ban values let's say for example 300 and now look into the output see again output is pretty much similar so I guess we are fine with this one and now clearly we can see that this is that the pixel distribution is completely skewed to the left hand side so clearly we can see that there were some kind of pixel values in the array which is not appearing for a lot of time so it might it must be some kind of noise that's something that we are expecting right so this is the kind of observation that we were able to get over here now in the upcoming videos you will be seeing what are some kind of different pixel scaling techniques through which we can transform our this kind of pixels to some new type of pixels such that in a hope we get a lot more better information from this particular output as compared to what you are seeing currently so yes that's exactly what we'll be doing in the upcoming few videos hi everyone welcome to this video of module 3 where we're going to start our journey of pixel scaling with the first method that we have over here is minmax scaling so to start with this video I'm going to show you some of the helper functions that we'll be creating that will be eventually helping us to generate some visualizations for the comparison or just a normal image with some of the functionalities added to that particular function after that we're going to again create one more function that's actually going to implement the minmax scaling on the given input pixel array and once this kind of output we are able to generate from this function we are going to compare the visualization of the original image and the scaled image so that's the whole idea that we're going to cover in this video so let's get started so the first pixel scaling that we are going to look into is the intensity normal normalization or also called as minmax scaling or linear scaling the idea over here is that we take the whole array of pixels we do a subtraction with the minimum value that is present in that array the minimum pixel value in that array and then divide it with the range or you can also call it as the difference between the maximum pixel value and the minimum pixel value in that are and the output you get the output of the array will be same shape but now the values will be scaled that's the whole concept of this intensity normalization or whatever kind of thing you want to call it and let's see how we can achieve this so I'm going to create a function for that over here I'm going to Define it as uh let's say mean Max scaling and what input it takes it takes only one thing the main array of pixel let me just call it as pixel area something like this now it is divided into two parts numerator and the denominator so let me call it as over here uh numerator is equal to the pixel array pixel array minus the minimum value of this pixel array and then denominator let me just call this DN what is this it is the maximum value of this pixel array minus the minimum value np. minimum of the pixel array that's it now the output of this should be what again an array but how it's the division of this numerator and denominator simple as that so our function is ready if we are going to pass in the data of M31 pixels it's going to give us the output in the format of minmax scaling and we are going to hope to see some better information uh as compared to what we are are seeing over here we are not sure it will be better we are just hoping that we get a better output so coming back to this what I'm going to do is first of all I'm going to uh create Min minmax scaled array or I can just say minmax array right and I can do this with the help of minmax scaling that I have created on top of M31 pixels and now before I go ahead and visualize this what I'm going to do is I'm going to create a common function that will help us visualize this kind of output because it's going to have some kind of common things the title of it then once we are showing this kind of array this kind of cmap equal to gray origin equal to lower all of this kind of code will be repetitive so for that what I'm doing is I'm just uh converting this into a function so that in just one line of code we can do all of this task so let's say I'm defining again one more function and calling it as let's say plot underscore pixels something like this right so the first thing that I'm going to give is the pixel data or pixel array after that what kind of title I want to give what kind of color I want to set for the title some kind of this information the first thing would be to display the array that is pixel array and keep the same color map that is gray always for now and uh after that I'm also going to set the origin to lower and then I'm also going to do PLT do um title going to set title to the title that is given as an input and also set a color to it color is equal to the color given by the user of this function and uh also I'm going to use PLT doxis and turn it off so that the output is not giving us this kind of exis okay we are just getting the output in the format of the image without the exis okay it's going to look much more better I guess so yeah that's something that I'm trying to do and also after this I'm trying to get PLT do Sho to avoid any kind of external text information that it may display on top of the image like this okay over here we did not use pl. Sho so it is showing me this kind of output I'm not really looking forward to this kind of things so that's why I have given this kind of pl. show and that's it our function is ready so not every time after converting uh I mean after scaling down our pixels to some values we don't have to plot this multiple lines of code I'm just going to use this plot pixels give the array of the pixel change the title change the color and get the output that's it again I can do some more interesting thing I can give the weight uh of this pixel as bold and uh yeah that's it I guess this is fine I'm just going to rerun this code and because we have have already created this kind of a minmax scaler right what I'm going to do I'm going to plot pixels for minmax areay now the title I'm going to set is um minmax scaling color that I want to give to this is royal blue and yeah that's it so let's see what kind of output do we get by just okay I guess we are having some kind of an error the error says that the text. set got an unexpected keyword called weight the spelling of weight is incorrect again don't mind my spelling guys I'm really poor at spellings run this going to run this again yeah it's giving us this kind of an output now um again what I'm trying to do is I'm trying to do I'm trying to compare this with the original uh image over here right so what I'll do is I'll also create a comparision over here okay I'll be Crea creating one more function to compare the scaling so compare pixels it's going to take two data original M31 data original array at the same time I'm going to give scaled array okay and I'm going to create a subplot over here PLT do subplot so the first uh subplot that I'm going to give is one two one one row two columns on the first position I'm going to plot the original array and I can do this with the help of the above function that we have created plot pixels I'm just going to remove this pl. show as of now I'm going to have uh plot pixels and I'm going to first of all pass in the original array right and after doing this I'm going to have multiple titles uh over here so the for the first one I'm going to give the title as TI as original image and I'm going to give color is equal to Black okay and after this I'm also going to use subplot at 1 comma 2 comma 2 plot pixels I'm just going to copy this whole thing and paste it over here and it will be the scaled array scaled array the title will be um let's say let's just skip it a title over here as title only okay I'll be passing the title whatever is the title that I'm trying to give and uh again the color will be just a color I'm just going to give this as a input and let me create this kind of thing and now let me try to compare these things so what I'm going to do is I'm going to scrap this part and instead I'm going to uh do I'm also going to do pl. show at the end pl. show okay now if I come over here and do compare what was the name of the function compare pixels the original data is nothing but the M31 pixels the output is minmax array then the title of this plot that I want to set on the second one is the Min minmax scaled and the color that I want to give to that is Royal let's say or I can also fix this color over here as Royal view because that's the only one that I want as an output so I'll also remove this part over here and uh now I can just give this as this only and hopefully it gives us the output the way we want yes so this is the kind of output put that we want in terms of comparision now because we are having some kind of gapping in between I can improve this kind of gaps I hope you know the command the command is nothing but PLT do tight layout and I can also adjust the figure size if you want to have a larger size of this image and any kind of that kind of thing but I guess I am satisfied with the output that I'm getting on the left we are having the original image on the right we are having the minmax scaled image right so over here I don't see that major difference over here it's pretty much similar so we didn't get any kind of useful information with the help of minmax scaled output now in the next video I'm going to show you one more type of scaling call is standardization or Zed scaling and it has been done with the help of this formula so I'll explain you this whole concept in the upcoming video hey guys I welcome you all to this video of module 3 where I am going to show you some other pixel scaling methods apart from the minmax scaling namely standard scaling log and square root normalization so once we are done getting the outputs of this scaled version of the M31 data we are going to visualize them by utilizing the functions that we had created in our previous video and then just compare out of all of the scaling methods which one is performing best in terms of visual appearance which is revealing most information about the core of the Andromeda galaxy and then we are simply going to take that output which is revealing the most information and get its pixel distribution with the help of the histogram just like how we did in one of our previous videos right so yes let's get started and look into all of this kind of things guys so let us understand this particular formula what is this about so this is the actual array we are subtracting it from the mean of the array and dividing it with the the standard deviation so now you already know how we can take this mean and standard deviation that's what we had seen in some part of codes earlier somewhere over here see so we're going to use this kind of numpy functionality in order to get a standardized output okay the kind of Technique we call to this particular formula that you are seeing is either standardization or Zed scaling whatever you want to call so if you have studied normal distribution you will be understanding the actual meaning of what this is but let me not go into the very technical concept and talk about Z skill Z skill array or Z scale only just Z scale let's just say that this is Z scale again I'm going to give pixel array as an input and uh the way that I'm going to code again I'm going to have a numerator that is the pixel array the whole array I'm going to subtract the mean of this pixel array and the denominator part is just the standard deviation so again I'm just going to have this kind of denominator as np. STD standard deviation of that pixel simple as that and written numerator by denominator as an output so our function is ready for the scaling and the output that we are going to visualize now will be straightforward so scaled array or I should also call this the Z scaled array Zed scaled array is equal to Z scale on top of M31 pixels and now if I just go ahead and call compare pixels on M31 pixels okay again now see because this M31 is common I don't want to give this input again and again so I'm just going to give in the scaled array only as an input I'm going to keep this as m 31 pixels by default okay I'm not going to change this one it is always the same so I'm going to run this code and even in this image I'm just going to take this part out run this part yes and now I'm going to do the exactly same thing over here I don't need to pass M31 pixels over here now anymore I just need to pass in The Zed scaled array and the title title will be um let's say Zed scaled image let's see the kind of output that we get I guess we have created an error the error is uh num. Den okay yeah it's because of this particular thing no problem let's fix that up hopefully no errors this time yes again not a lot difference that we are expecting over here even with with the help of Z scale output it's pretty much similar to what we see in the original image don't worry it's not that we aren't doing anything perfectly or there is some kind of a problem with the Skilling techniques this is pretty much obvious okay at times you won't be able to see a lot of difference but now the next thing that we are looking into is the log normalization what is this uh whole concept of the log normalization you take the log of all the pixel values that you are having in your data simple as that so what I'm going to do is I'm going to create a function for that def log normalization or normal log scaling whatever you want to give input is a pixel array and it's going to Simply return the log np. log of this input pixel array simple as that so this is the array that we have created and if you want to visualize this so log Norm array is equal to log normalization of M31 pixels and compare pixels of log Norm array title is equal to log normalized image now you will be able to see some of the visual difference as compared to what we were having in the initial image now see how we are getting this particular output they seeing a lot more details some kind of see uh some kind of part that we see in the around the core of the Andromeda galaxy all of these things are now visible this is the center part this is this is what we see which is not visible over here see that's the power of like you know scaling uh your particular pixel values to some different scale right right now we have implemented log on all the pixel values with the help of np. log now if I just compare this with this output see how how well it is able to give us this kind of outputs of all this kind of if I show you the Stars over here right all this kind of information see even over here I can see that the output is revealing much more information but yes we are having this kind of output so far that we have achieved now on top of this there are again some more uh normalization and scaling techniques that you can do for sure but now before that what I'm going to do is I'm because we got a slightly better output over here I'm going to create a histogram distribution of the pixels of this particular output okay how can I do this I'm going to do PLT doist of this log Norm array do flat going to let's say set bins to 300 and look at the output with the help of pl. show okay so see now this is the kind of output the spread in the data is much more as compared to what we were having initially and this is the kind of output that we have achieved so far okay and I can also show you the shape over here uh that is uh log Norm array. shape it must be the same okay that's something that I wanted to show you that the shape is just the same right so over here we got the uh I guess uh the log normalization was already done so I just got the image of the log distribution of the log normalization over here and that's what we had to do over here so I just scrap this part but at the same time I'm trying to show you one more type of um normalization let me just call this as the fifth part of this scaling technique square root okay so what I'm going to do over here is I'm going to create a code two code cells one to define the square root function again I can do it with the help of numpy So Def let's say square root scaling giving the pixel arrays and uh it's going to return return this thing NP do sqrt of pixel that's it going to run this uh I'm going to create uh square root scaled or square root are just like that and I'm going to call sqrt scaling on top of this M31 pixels and uh compare pixels and I'm going to compare this with square root array title will be square root scaling let's see what kind of output do we get so this is the kind of output this is one more way you can see that there are some more information that has been revealed over here right as compared to what we see on the left so just like this there are a lot of different scaling techniques that you can use so far we had seen that a lot more information we were uh able to get with respect to the log normalization so we stick with that and said that like you know let's create a histogram out of it a histogram distribution of it and that's that's how we can see how the pixel values are distributed now right so yeah that's something that I really wanted to show you that with the help of this pixel scaling how you can reveal a lot more information like this now in the upcoming video what you will be seeing is one more technique which is called as a z skill interval okay now with the help of this again I'll be showing you some more information and then we are going to use any of the scaled output and perform some of the image processing techniques as we go ahead in this particular moduel so stay tuned for all of these kind of interesting things coming up for you guys so welcome to this last video of module 3 where I'm going to talk about the Z scale interval class that is present in the astropy library okay so what is it all about and why are we using it all of these things you'll be seeing in this particular video so let's get right into it so now let us discuss about the Z scale interval I'm not going to go into the logic behind like you know how this is coming up with I'm just going to tell you what it is going to do and how it can be useful for us okay so for the demonstration purpose let us try to create a demo array 1 2 3 4 5 6 7 8 9 and 10 okay now the whole idea of the Z scale interval is to give you an interval that means give one minimum value and one maximum value so let's say mean and Max now this mean and Max are not 1 and 10 there are some different values that you'll be getting for example let's say minimum we got as three and the maximum we got as let's say eight right now the whole idea over here is to take this original array and clip it according to this particular interval any values in this array that is less than three should be converted to three and any values that is greater than eight beyond8 should be converted to eight that's what we call it as a clipping of an array between a particular values so now because we know that the minimum value this array can take is three so wherever you see any value less than three convert that to three convert this to three similarly if you seeing a value greater than eight convert that to eight convert that to eight and that's it once we are done with this kind of conversion we are having a whole new way of visualizing the respective image that we'll be creating so we are going to follow the same exit process and the way through which we can do this in Python is with the help of estrop Library so what I'm going to do is from astropy there is a module called as visualization so I'm going to call visualization visualization yeah UT Zed scale interval going to run this code and now okay I guess there's a spelling oh no not a spelling mistake there is a problem with the space over here yes it's working fine so now we are going to create the object of this particular class CL Z scale interval and what is the whole idea of creating this object because this is the object through which you will be able to fetch out the limits on the any of the image that you want okay in our case you can choose let's say for example square root scaling original image for that matter I can also choose this kind of uh log normalized image because this was performing the best I'll be simply uh copying this part and go down and I'll be simply calling this kind of limits with the help of Z scale interval on top of this particular array right now how we can do do this particular thing you call this Zed you press that dot it's going to give you this particular method called as get limits so it is because of this object that you have created of Z scale interval you are getting access to this method now this method takes the array whose minimum and maximum value you want uh that you have got with the help of Z scale interval technique so if I'm having this over here and if I know that it's going to written two things minimum and maximum so let's call Z1 as minimum Z2 as maximum so we're going to get some kind of outputs and let's just check it with the help of print command F string let me just say that uh minimum is Z1 and like that print F maximum is equal to Z2 I run this code so the output that we are having over here the minimum value after clipping uh we should have is 1.688 9 okay we haven't clipped as of now but the minimum value after uh applying the clipping should have 1.6 8889 nothing less than this so if I show you in the original array of log Norm array what is the minimum value np. minimum of that array if I'm just uh running this okay it's saying that oh yeah because we haven't defined y not array it's array anyways so yeah the minimum value that we are having in the log Norm array is 1. 6788 and after implementing this G limits uh on the Z scale interval we got that the minimum value should be 1.688 so obviously we can see that there are some values which are less than this so all the values in this array that we we are having for the log Norm array all of these values including this will be converted to 1. 6889 any values less than this will be converted to that and just like that if I try to see the maximum value and if I run this code it is 5.18 17837 and over here after implementing the get limits of Zed interval on the log Norm array the maximum value that we are getting is 44 4.44 79 so any values Beyond this as we can see clearly that yes there is at least one value that is beyond this so any such values present in this log Norm array we want to convert it into all 1.5 5.18 17 all these kind of values that has been written right so yeah I was trying to print this to show you that this minimum and maximum is not equal to the minimum and maximum pixel of this particular array it's different right so now that we are having this kind of an idea let's try to visualize this data by clipping this array of log Norm array how we can do this I can use PLT do IMO and now over here I'm trying to call this log Norm array but now I'm going to use two different parameters which is going to help me clip the values between these values so V mean is the minimum value that is Z1 and Vmax is the maximum value which is Z2 and cmap as you know is our gray and the origin is equal to lower we know this kind of settings we have been using this since the start of this notebook and now I can simply do PLT do show hopefully the code Works without any kind of error and now the output that you will be seeing will be significantly different than what you have seen over here okay you can see this it's kind of a bit a blurry kind of thing B paint kind of thing the stars are not that highlighted even this kind of uh the center part of the androma Galaxy is like this now just look into the output that we get over here after applying the Z scale interval see it's a bit more highlighted right you are having a much more brightness in that part as compared to the smaller part so now this is the kind of output that we are having okay it's not that you need to specifically apply this method it's just that I'm trying to implement one more method so that you guys know that this kind of techniques also exist okay what have I done I just got two values the limits now from the help of this limits I have clipped my array I haven't done any kind of transformation as such just clipped the array such that any values less than that particular value and any value Beyond this value are converted to its respective values that's something that I have done and this is the kind of output that I have achieved now according to your research according to your whatever is the objective the problem statement that you're working with you come up with a specific technique and you carry for forward your any kind of image processing or any kind of information that you want to with respect to whatever you're comfortable with it could be the square root scaling image it could be original image it could be this log normalized image and not this one specifically right it's completely your choice according to the problem statement now because I want to demonstrate something in the uh upcoming videos so what I'm going to do is I'm going to take any one of this image let's say this particular image that we got over here but now is this an image yes it's an image but what is the pixel representation of this if I am trying to uh clip this particular values I haven't clipped log Norm array over here right I'm using this IM am show in order to clip this values with the help of this arguments so now how can I convert this into numpy array or any kind of array so for that I'll have to store this whole image as a variable first of all and now let's try to visualize what kind of output it is giving us okay it is the matplot libs image it's not a pixel representation it's an met plot Libs image so it's not giving us any kind of array over here so how we can convert this image into a its pixel representation I can do this with the help of a command called as make image okay now one input that it takes is called as renderer r n d e r e r now I am going to choose by default whatever they are having in the back end of M plot Li by simply giving the command of none okay now I'm going to run this it's going to give us the 8bit integer form of IM image so from this kind of float 32 we are converting this into uh unsigned integer 8bit image basically right so this is the kind of output that we have got but now along with this output it's throwing some other things also out but we are just carrying for the first part of the output that is the image array so I'm going to extract this first part that is present on zero index and now this is the array that I'm looking forward to and you can see that it's a d type equal to U in8 unsigned integer 8 right so that's something that we were looking forward to and now uh let me just store this into an array image array let's say and now let me go ahead and try to check the shape of this so image aray do shape it is 370 370 and 4 original shape was 300 300 that's it so we need to think about this we need to convert this into 300 by 300 not this shape so first of all how did we get this 370 so so over here I just need to pass in one more argument called as unsampled is equal to true now by using this particular command or argument unsampled is equal to true it's going to keep the dimensions as it is if I run this again and uh again run this particular code you will be seeing that 300 by 300 has been achieved right so we have decreased our shape back to 300 by 300 that's something that we wanted now what about this four channels what it means so four channels basically mean let me just write a note over here so the four Channel basically is indicating to us that it is uh having red green blue and Alpha channels uh makes up a four Channel image typically if it's in the format of RGB so the first three channels will be RGB and the last one will be Alpha Channel now what is Alpha Channel it is with respect to the opacity of the image okay the values again are in between 0 to 255 0 means completely opaque and 255 means the opposite of that so yeah that's the idea with respect to the four Channel output now how we can convert this four Channel output into only one channel that is gray scale now that's something that we going to look into into with the help of CV2 Library which is nothing but the open CV Library I can import it with the help of import CV2 command and by default it is already present in the Google collab so you don't need to pre I mean again install it over here so I'm simply using this command of UT CV2 and importing my open CV Library over here now how we can remove the fourth channel of the opacity and basically just convert this into and convert it into gray scale okay I should have written remove four channels or just um convert four scale uh four Channel image to gray scale image now how we can achieve this with the help of CV2 so in open CV Library there is some a method called as CVT color right now the input that is uh it's going to take is the image array whose uh channels are four so I'm going to pass it over here and along with that it's going to take a flag what is this flag the flag that is going to convert this four Channel image into a gray scale Now by default in CV2 that is open CV it's not going to read as uh the first channel as red second as green third as blue it's going to be the opposite of that on the first channel we will be having blue on the second it will be green and on the third it will be red and then on the fourth it will be Alpha so it's BG this four Channel if you're are using CV2 right so if you're using CV2 the four CH will be in the format of BG a and now that BG needs to be converted to gray I can do this with the help of CV2 do color underscore BG a to Gray that's it and let me just St store it as gray image gray array and now let me just go ahead and cross check if the shape is correct hopefully it is yes it's correct and now just to visualize if we have lost some information or it's uh just like what we are seeing over here let me just again plot this thing so I'm going to plot it with the help of the uh plot pixels function that we had created above right it's going to take in the input of the array that is the gray array then I guess it was taking the title also title would be let's say Zed scale interval gray scale let's something like this and color let's say is royal blue hopefully this is not giving any errors I hope that the these are the parameters okay we got an error so error is TIY oh never mind t t l is the spelling yeah so this is the output that we have got and it's just the same image that we were having over here exactly the same right you can also try to like you know plot it side by side with the help of that comparison function that we had created but anyways I am happy that yes the output is just the same and we are going going to carry forward with this particular thing right uh the gray area right that's the kind of conclusion that we have made so far now let's also look into the histogram visualization of this so PLT doist going to pass in the gray array and flat use flat to convert it into an 1D Itor and then passing the bins is equal to usual as usual 300 and look into the output as you can see that we getting some kind of a display of array I'm just going to use pl. show and it's going to just uh show me the output of the image nothing else so now this is the kind of output that we are able to achieve and the pixels are ranging from somewhere from zero all the way up to 255 why what is the reason behind that the logic is that because we have converted our float image into 8bit image and in 8bit image as I I explained earlier the values are in between 0 to 255 so that's the reason why we are having this particular range right so yeah this is the histogram visualization that we are having and uh now in order to apply any kind of image processing on this particular image uh what I'm going to do is I'm also going to convert this gray scale uh array into some good name so that we can use it further let's say I'm giving some unique name to it as um gray scale or gray scale Z interval Z int array is equal to gray array so I'm just giving a meaningful name to this because we were just doing some kind of experimentation over here and because everything is working fine so I'm just saving it in a very good name so that we can use it in the uh upcoming videos right so the whole whole idea that we have seen over here is that with the help of Z scale interval we got two values for the interval and we use this IM show in order to clip the value between these two values that we had got Z1 and Z2 so from this we St we stored it into this image variable which was nothing but the M plot lip image type so from that we converted it into its pixel representation with using this particular function we give this to inputs we fetch the array part of it and the output will be 8bit integer image and but the output now was having four channels so whenever you're trying to perform the image processing and because see the output is just the same over here and over here so why take four different channels and perform image processing on that it's going to take much more time as compared to what it will take in only one channel output is just the same so that was the whole concept why we took this four channels and converted it into single Channel or gr Channel image right and we did it with the help of computer vision or I should say open CV Library CV2 library in the CV2 we are having this option of CV2 color CVT color which is helpful to take the image array and with the help of this flag BG a to gray we can convert it into gray scale image if you want to let's say convert it into three Channel image you you use BG to BGR even that is fine but now that will be three scaled image I mean three Channel image because eventually we wanted a gray scale image I directly converted that four scale into uh four channel into one channel and here is the proof of that it has been converted successfully and uh yeah here is the final output that we have got and here is the pixel distribution of this in between 0 to 255 right so yes with all this being said we are done with this uh whole idea of pixel scaling and looking into some different ways through which you can come up with an array and finalize something that we are going to use for the upcoming sessions on or I should say upcoming videos on image processing after doing some kind of pixel scaling on this right so stay tuned for that guys hey guys I welcome you all to this last module of this program where our Focus will be to understand how we can Implement some different type of filters on the existing image and get some kind of features extracted out from that particular image so starting with we'll be understanding the concept of the convolution operation then we going to take an image from our previous module and apply the Gan denoising technique with the help of Gan kernel to remove some of the noise in the data after that we are going to implement measuring and setof filter in order to enhance the features in the image and lastly we are going to use some of the features of the SK image Library where we are going to take corner fener and multi- basic featur features to extract this kind of features with respect to this algorithms how this kind of uh techniques are working everything will be covered in this particular module guys so yes without any further Ado let's get into this module hey everyone welcome to the second video of module 4 and here we're going to learn about the convolution operations so what exactly are these convolutions why do we need it over here and then what is some kind of practical demonstration in terms of visualizations so that you are able understand okay yeah that's exactly what is convolution so that's something that we're going to cover in this video so let's get right into so now that we are aware about that we are going to use this particular image in order to get some kind of features out of this image and uh do some cool stuff uh in the upcoming videos one thing that we need to do is to remove any kind of noises present in this image before we actually go ahead and get those kind of features out of this image so so we can do this with a technique called as Gan smoothing which is nothing but denoising the image with the help of gajan smoothing technique how it works it is simply working on the principle of convolution so how this convolution works so it will require one kernel you can also call it as a filter in our case it will be a Goan filter right now this is just a demo filter just to explain how the convolution works and it will also require one image now this image in our case will be this one image so on this image we are going to place our gajen kernel and do some convolution operation then slide that filter one unit to the right do convolution operation again slide it to the right do that convolution operation until you are sliding across every pixels uh step by step now that's the whole idea of the convolution that you are going to perform with the help of a gan kernel on the full image so let us try to understand with this uh GF that I'm having over here this light blue part that you are seeing is the image it's a 5x5 image as you can see now on top of which we are going to pass this kernel size 3x3 okay so now what is the convolution so wherever you are seeing Zero I'm going to pass this zero of this kernel on top of that now whatever this is a second zero I'm going to multiply that with minus one then this 0 will be multiplied with this zero then this 0 will be multiplied with minus1 60 will be multiplied with 5 113 will be multiplied with ne1 0 will be multiplied with this zero 73 will be done uh multiplied with minus1 and 121 finally will be multiplied with the zero after multiplying all these numbers I'm going to sum them up together and that summation output is nothing but the thing that you are seeing over here as an output right so if you want to visualize what I'm trying to say I have already WR WR this particular thing for you that you do 0 into 0 then 0 into 0 like 0 into minus one just map this values of the kernel on top of this first 3x3 part of the image multiply it respective uh Elements which are coming on top of each other and after multiplying simply add them up together you will be ending up with the value called as 144 for the first place just like that you slide your kernel by one unit to the right and now it will be on this 00 6113 56 73 121 154 again to the same process the output will be 328 so one time if you're doing this that is one convolution like that you are going to do multiple convolutions with this kernel on top of this image and you're going to finally get the convoluted or convolved image with the help of Goen gel right now as I mentioned this is a dumy kernel to give you this explanation of how these things work but yeah that's that's the whole idea of convolution operation in our case this light blue kind of thing that you are seeing is nothing but the original image that we had uh stored over here this will be the image on top of which we are going to create a Goen kernel how we can create it what are some what are its properties we are going to discuss about that in the upcoming video but yeah that's the whole logic but now you might be wondering that what is this kind of z0 on top of this right so whenever you will be implementing the convolution operation you will always decrease the size of the output now to keep the same size that is like you know 5x5 over here as an input uh we also want the output as 5x5 so for that specific reason I am adding a layer of padding and this padding is nothing but a zero layer padding it means all the values over here are 0 0 0 0 0 now there are other ways through which you can fill up this values you can also use this kind of a reflect kind of padding which which means that this 85 will be reflected over here 128 will be reflected over here let's say this 131 will be reflected over here so even that kind of thing is possible so in short there is one padding layer so if we are having a padding layer this image size will be what now it will be 1 2 3 4 5 6 7 so it's a 7 by S thing so from that 7 by S thing after the convolution is over you are getting this 5x5 however the original image was 5x5 So eventually what we are getting is that input was a 5x5 image output is a 5x5 image so for that particular reason we are having a padding layer so I hope the concept of padding is clear at the same time what you are seeing over here that the sliding of this kind of Kernel on top of the image different different part this sliding is called as a stride this is called as a stride St r i d e so over here we are having the stride value of one that's why it is moving one one unit to the right and then one unit to the down if the stride value was two it will skip two columns and then start from this particular then again skip two columns and start from the next particular available part so that's how it's going to work all right so yeah that's the concept of padding and strides uh that is associated with the concept of convolution now in the next video you will be seeing that how we can create a kernel for Goan smoothning and apply it with respect to the image that we are having over here and then Denise this image and after that later on how we can Implement some of the filters or some of the feature extraction techniques to get something out of this particular image so stay tuned for that guys hey everyone welcome to this third video of fourth module and now we are going to discuss this concept of Goan denoising as in terms of implementation I'm going to take one of the image from the output of module 3 implement the Gan kernel on top of that and see how the output looks like after doing this kind of formulation operation so for this you will also need to understand what are the properties of this Gan kernel only then you'll be able to appreciate this whole idea so this is exactly what we'll be discussing in this video so let's get into it so basically this convolution operation with a gsen kernel applies a weighted average to the neighboring pixels with the higher values at the center which are gradually decreasing towards the edges of the filter so the filter that you are seeing over here won't be like this it's a very special type of filter where the values in the center are high and at the edges the values are going to be low okay so this process is effective in reducing the high frequency noise and preserving important image details so how we can create this kind of a filter and then how we can do this kind of convolution operation on that image that we are having over here so let's try to understand that part so we will require the convolution 2D filter from the CPI signal module how we can do this I'm going to say that from scipi scipi is again a library that is pre-installed over here in the Google collab so you don't need to uh install it so from scipi do signal I'm going to import conall 2D and uh after this I'm am going to generate my own filter that is not at all Associated to the cion filter and the way that I'm going to create this is with the help of np. ons now what is the whole purpose of the np. ons so let me first of all explain that to you so np. On's if I'm let's say doing it 5 by five okay I'm passing it in inside a tuple uh so what is this going to be so it's a 5x five of 1es now I am just going to divide all of these values by four okay or I should say 25 not four Why by 25 so that the summation of all of this values is equal to one now by doing this particular thing it's going to preserve the range of the pixels in a way that it's going to be a better output basically whenever you are having this kind of summation equal to one right so that's the reason why am I dividing this with 25 so because I'm having five five cross 5 of one ones so total in short the summation is 25 right there are 25 * 1 in the array so that's why I'm dividing this with 25 so that now if I take the summation of all of this the output will simply be one right so that's for that specific purpose I have done this thing and now let me just store it into Kel k r NL is equal to this okay now uh let's go ahead and uh actually we have already looked into that but still I'll just paste it over here so that yeah you are having the output now we are going to create a gan kernel so let me just give a name to it Gan Kern I'm going to create it with this np. array method now what I'm going to pass over here I'm going to pass this kind of values 1 by 16 1X 8 1X 16 then come to the second row and now in the second dra I'm having 1X 8 then 1x4 again by 8 try to look into the pattern that I'm trying to create over here okay and the last L again will be very similar to the first line or I should say exactly the same 1X 16 1X 8 and 1 by 16 now as you can see that in the center part we are having the maximum value present over there and as we are going to the edges you are seeing that the values are even smaller so now this is going to follow the property of the Gan kernel and even the summation will be equal to zero if you are going to go ahead and check it okay and even you can check it with respect to the graph that we are having over here that in the center we are having 1x4 and at the edges we are having the values of 1x 8 and 1X 16 right as you can see so this is a 3X3 kernel that we have created over here I have created 5x5 again over here if you want to create a 3 by3 kernel you can create it by simply doing this 3x3 over here also and uh now because 3x3 in total there are nine values so I need to divide this by nine in that case so even this is fine okay there is one kernel that we have created like this uh where it is 3x3 so the output of this will be a total of nine ones so the summation of that will be nine so I just divide that with nine so that overall summation of all of this values will simply be adding up to one so I have created two different kernels one that is a simple kernel and one that is the Gant kernel now I am going to show you how we can convolve this with the help of a con Tod uh thing that we have imported from ci. signal and show how the output looks like with respect to this kernel and the Gant kernel and again we are going to see it in two images one that is the M31 pixels by default and the second one is this particular image so let's try to go ahead and visualize it so get the convolution done with our normal kernel now how we can can do this we can simply call Con convolve 2D now what kind of input it takes it takes the original image on top of that it takes the filter and after filter it takes some kind of padding right so I'm going to say that uh M31 pixels is the first thing that I want to choose and then the normal kernel I want to give as an input and the padding I can give with the help of the command mode now this mode I'm going to keep same keep same padding means the shape of the output should be same as the input that's what this means okay and this will be the output of the convolution so let's we call it as convolved convolved image and we are storing in this right and we are running this now and the same thing we are also going to implement with respect to the Gan kernel so Gan G EX the same steps have been repeated there are no changes at all and now I'm simply going to visualize both of this output one with the convol image and one with the uh let's say because I have given the same name over here let me just call this as Goin conal image but I guess there is a problem okay let me check what is the Cal that I have selected over let me just run this code I'll copy this come over here paste it again just in case to check if the spelling is correct and now I'll run this so yeah we are having two images and now we are going to first of all visualize the first con uh convolution output so I'm going to do PLT do IMO of the same thing right so I'll be using the blot pixels and what kind of input I want to give this is the input title is normal colal convolution and color should be let's say maroon so this is the kind of output that we are able to see right now in the normal uh kernel convolution right now what I can do is I can also go ahead and visualize the Gan G I'm going to copy this code see how useful that kind of function is that we had created in only one line of code we are able to get all these things done and now this is Gan kernel convolution so now again as such we are not able to see that level of uh output you can see there's some kind of like you know some kind of circle circles you are able to see over here and similarly over here also you able to see a similar kind of output right over here because we are having some information uh maybe it's done in this particular way what about this image yeah over here it's done in that same fashion so as such we are not able to see any kind of uh such difference now what I'm going to do is I'm going to do the same thing on the gray scale uh output that we had created over here this one I'm just going to copy this come down using gray scale to convol and this gray scale Z int going to convol 2D going to pass Goan kernel keep the mode is equal to C and I'm going to store this into some kind of output what kind of output we can give just try to think about that let's just say uh convolved gray scale gray scale right let's this I hope the spelling is correct over here Co n v l v it seems correct let me just run this Con Tod never mind you know my spellings ah con 2D going to copy this going to paste it over here okay now let's see how it looks like um again I'm going to copy this paste it and now I'm going to copy this name paste it over here and give it as Gan kernel convolution gajan kernel on Zed scale interval let's see how the output looks like now so this is the kind of output that we are having as compared to the original image okay as compared to this image this is the kind of output that we are having so if it is having some kind of noises it has simply removed it by adding some kind of a blurring effect right so yeah this is what we have done so far now we are also going to fetch out the histogram before we go ahead and Implement any kind of image processing techniques uh in terms of fil applying filters and feature extraction techniques so PLT doist on this particular output that is the convol gray scale I'm going to pass. scale and uh bins is equal to uh not scale do flat and bins is equal to 300 pl. show let's see now the distribution of the pixels that we are able to fetch after doing this kind of like you know convolution with the Gan K now this is the kind of output see this is the kind of output that we have got from this from this you can see there was some kind of gaps in between now we are having this kind of uh continuous kind of output that we are seeing over here right all the web to 255 so yes I guess this is a better output and now we are going to get all the kind of features apply different kind of filters in the upcoming videos with respect to this convol grayscale output hi guys I welcome you all to this fourth video of module 4 and here we are going to take the image output that we had got from our previous video that is the convol denoised image basically and enhance the features present in it by implementing two different type of filters measuring and Sato now both of this we are going to import it with the help of SK image so let's get into the video so now that we have decided that we are going to use this convol gray scale output that we have got by uh doing the gajan blurring uh we going to come over here and enhance the linear features on this M31 data and I'm going to visualize this in multiple different color maps and therefore I'm defining this particular list over here called as spectral list and all of these are nothing but the color map that in which we are going to see the output after implementing two different type of filters which is going to enhance this kind of linear features that is measuring and setof filter and I'm going to import them from SK image itself so from SK image. filters import I don't know the spellings properly to be honest I'm just going to copy this and paste it over here remove the end part and just give a comma that's it so this filters have been imported and now we simply have to go ahead and do the convolution I mean uh implement the measuring filter and the set set of filter on this grayscale output so what is this gray scale output I'm just going to copy that this one copy this array come back and let's say this is a majoring filter is equal to this oh not this actually it should be maing of this and for CTO filter CTO output I should say right measuring output in the the set output so let me change this to Output as well and set this to Seto and paste this part so after running this particular code what I should be getting is the array with the uh filter that we have implemented on this particular image now what we are going to do for every color map that we are seeing over here we are going to uh create the output for the measuring filter first and then for the Seto filter and try to see that which of this color map is combined with this measuring filter giving us the best result so that's the kind of thing that we are trying to do over here and now we can achieve this with the help of PLT do IM Sho of what I'm trying to show measuring output May I'm just going to copy this and paste it over here I want to show this with what color map I want to show the color map I'm going to create a for Loop over here so for color map in spectral list I'm again going to copy this you know the reason yeah so this I'm going to give an indentation over here so that we are not having any kind of errors and now instead of C map I'll be giving color map that I am fetching from the spectral list and after doing this I'm also going to do this kind of origin is equal to lower and give a title to this PLT title TI tle e and with the F string what I'm going to do is I'm going to give the name of the color map and I also tell that this is a majoring plus this particular thing right so this is something that I'm trying to give and let's say measuring M31 plus this color map I guess this is good and I'm also going to hide the exis okay and now after this I'm also going to do PLT do show and now I'm going to run this hopefully it is working the way I expect if not we'll be modifying this code okay again we got a name error spectral list is not defined oh because we haven't run this code no problem no problem no problem run this again hopefully no errors fingers crossed yes we are getting the outputs now see how we are getting this outputs over here we can clearly see this kind of objects are present over here 1 2 3 here over here also some kind of dull objects we can we are able to see over here also some kind of object is being formed and here is the core of the androma right now I can just scroll down and try to see some kind of different features that we are able to extract over here if you're able to find something different over here and whatever kind of color map that you are liking that is giving you the lot of information you simply use it for any kind of further analysis Okay the reason I have printed a lot of uh color Maps over here is just for your understanding that we can do this kind of things now according to your problem statement whatever it is you choose the best image that you think According to which is giving the best result according to me it's the nip spectral color map which is giving most of the information about the image right now according to whatever is the hypothesis that you must create and to prove that hypothesis you can do this kind of image processing by implementing different kind of filters and get this kind of outputs and test your hypothesis right for example you might have said that there are some kind of stars at the uh edge of this kind of image uh near the galaxies there are this kind of uh formation of this kind of uh shapes that we can see near the core of the Galaxy by default we were not able to see this kind of information if I just show you over here we were not able to spot that well this information as well as this information but now after implementing this kind of filters we are clearly able to uh see this kind of things and trust me guys this kind of uh thing if you're able to create a subplot out of it you can literally extract the subplot download it and use it in your research paper the outputs like this how you are able to describe it it all depends on your skills of like you know explaining a visual appearance in front of you right so I hope you have now understood that how we are able to get this particular thing done for the measuring filter now I can simply go ahead and look into the Seto filter and look into the output over here with respect to that so this is my set output uh this is my Seto M31 plus color Maps again same color Maps I'm using and see the output over here now see this one is I guess much better compared to what we got with respect to measuring again we are able to highlight all this kind of information near the core of the Galaxy even this side part but this is much visually it's more appealing as compared to the previous output that we had got right so yes according to this kind of outputs according to your problem statement according to your understanding whatever kind of image you can describe the best you choose that and use it in your research work right so I hope this kind of idea with respect to how you can Implement different filters I have just shown two examples like this there are bunch of filters you can uh get with respect to SK image. filters I can show you the documentation over here SK image. filters documentation okay and I'm also going to add this part in your uh notebook also so that you can just uh take a look into different kind of filters that are available uh take a look take a look onto different available filters in SK image okay I'm giving this link over here guys all right so yeah you can explore any kind of filter that you want to see how it is working with respect to the astronomical data that you're dealing with you just need to know how this kind of for example this is the filter how it works what kind of input it's it's taking and based on this input you try to get some kind of outputs like this right so yes guys that's it for this particular video and now in the next video I'll be telling you that how you can extract some kind of features with uh SK image itself so stay tuned for that hi guys welcome to this fifth video of module 4 and here I'm going to show you that how you can take SK image and go to its any kind of feature available in their documentation and Implement to get some of the outputs on top of the input image so the one that I'm going to show you first is the corner fer so what exactly this is and how we can use it in Python with the help of the SK image documentation of the features that's exactly what I'm going to explain in this video so let's get into it so now let's take a look into the feature detection and extraction with the help of SK image feature so just like how we are having SK image. filters like this we can also have feature if I just look into that so here is the documentation again I'll copy this link and paste it into our particular file okay I'll also just create this SK image different features you can use any one of them by understanding how to implement that now that's exactly what I'm going to show you that how you can use one of the uh feature that is corner for how we can use it so what you do is you go to their official documentation and search for for that the one that I'm looking forward to is over here so if I click on this it's telling me that it's going to take one input of image and sigma and the output will be two things okay this is output will be two things image is an input shape of M comma n row comma column and sigma is nothing but the standard deviation used for the Gan C by default we'll keep it as one only for our case as of now but surely you can play around with this particular value but the output that we are going to get over here is w and Q the first output basically that we are going to get is the error ellip sizes and the second output that you're going to get is the roundness of error lips so if you're not understanding this kind of technical terms no problem let's try to go ahead and try to implement uh how this kind of uh SK image. feature of uh corner forner is working okay I'm just going to copy this name come over here and first of all UT this so import okay I should say from SK image. feature import this going to run this now you can pass this on any kind of image that we had created above I'm again going to use the same image that we had used over here right you can also use on top of this set output also if you want okay but for now I'm just going to implement it on that uh this one convolved gray scale okay so let's go over here and implement this corner forer on what gray scale oh I should say convolved gray SC right yeah now if I just run this and if I check the length of this I should get two different outputs right I should have two outputs let me check yes I am indeed having two different outputs so now what I'm going to do is let me just store it as only one output as of now let's say I'm calling this as a feature output and this feature output is actually having two different things so check the output of the feature image so feature output zero the first output that we are having over here is with respect to actually uh the error the error ellipse sizes and the second output is roundness of error elips okay so this is the first uh this is the second right now what exactly it's going to dip it we are only going to understand once we are going to visualize them right and if you want to check the type of this output that we are getting uh the type of this actually it will be in the format of a tle because it's throwing two different values right so type of this let's check and again length we have already checked that it will be two now we are going to Define two we are going to split this kind of thing into two parts Parts one is for the error ellipse and one is for the roundness of error ellipse so you can just give any kind of variable name that you are okay with right whatever kind of name you're okay with but what I'm going to do is I'm not really going to Define this as of now I'm just going to delete this part and color list we have also already defined as the spectral list just let me see spectral yeah let me see if it's still working yeah we are having all of this we are just going to use the same uh color maps and now we are going to create the visualization so what how I'm going to do I'm going to Simply say that for color map in spectral list now what I'm going to do U on the left hand side I want to visualize the first output of the feature output and on the right hand side I'm trying to visualize the output of the roundness of error okay one is error and one is roundness of error so how I can do this I can achieve this with the help of pl. subplot now I want to give 1 comma 2 comma 1 now on the first what I want to show PLT do IM show of feature output of zero right now any kind of color map I can give but because I'm using a for Loop I'm going to give this color map and origin is equal to lower yes I guess this much is fine I can give a PLT do title as what what kind of title we can give we can say that this is error image plus the respective color map and I just need to pass this in the F string and also turn off the AIS PLT XIs off now I'm just going to copy this code over here and repeat the steps for 1 2 2 but now this will be feature output one this is roundness of error roundness right and I guess we are good to go and I'll just have PLT do tight layout because we are plotting the subplot and then PLT do show hopefully this is going to work in the way that we expect let's see how it's going to work yes first of all we are having the gray see on the left we are having nothing thing on the right we are able to see this kind of circular or ellipse kind of shapes that is it's being detecting so yeah this is the kind of features that you are extracting over here in the format of an array and this arrays is what you are visualizing over here right so you extracted this kind of features and now you are visualizing them in different color Maps right so error image plus prism roundness of error plus prism then error image with respect to nipp spectral and this is with respect to the roundness of error image with nippy Spectrum so yeah that's it with respect to what we are doing uh with Corner Foster I hope this is making sense that this is one of the example that we have fetched from this SK image. feature like this you can go and check any kind of different feature like this in the next video you will see that we are going to try one more feature extractor actually and that is multiscale basic features the local features so I'll talk about that in the next video and over here you can surely go ahead and try to check out some different feature by yourself try to implement it and just note that you need to know how it is working by looking into its documentation if you are able to look into that if you're able to do your research properly you can use any kind of feature for a specific task that you're looking forward to all right guys I'll see you in the next video hi everyone welcome to this last video of this particular particular module and here we are going to go ahead and understand how we can implement this skmh feature called as multiscale basic feature by following its documentation and just like what we did in our previous video the same stuff we'll be implementing over here and see what type of outputs we are able to achieve so let's get started so now let's try to look into one more feature that is present in the SK image that is uh known as multiscale basic features so I'm going to press contr F to search this multiscale I had already searched for that but I'm yeah that's where it is so over here it's going to take all of these kind of different parameters you can read its respective information for now I'm just going to pass the image and keep everything as default I'm not going to change anything obviously it's up to you how you want to change it and get the outputs the way you want and the output will be uh an array of the shape of whatever is the row and column plus some nend features so as you can clearly see that it's trying to detate multiscale basic features it's going to give us the uh local features for a single or multi- Channel end dimensional image right and it's going to be actually the intensity gradient intensity and local structure are computed at different scales thanks to gajan bluring so all of this kind of information is what we are having and what we are able to understand from this is that from a given image it it can give us multi Channel output and in each of the channel that we are going to get each channel will have one kind of feature that has been extracted so if I'm trying to implement this first of all I need to import this particular thing so I'm going to say that import this feature so from SK image do multiscale basic features oh I should say do feature import this name I'm just going to copy this very quickly and paste it over here and going to run this and now I'm going to create a featured let's say a feature image I'm going to call this with the help of this and I'm going to pass in the conval gray scale okay so this is the kind of input that I'm passing in and now I'm going to run this now let's say what is the type of this thing that we have got previously we had got tle right now let's see what do we get now it's a nump AR because that's what we expect over here as an output it's going to return an array so that's why we are seeing an array type in the return of this now let's look into the shape that's something important so this do shape is what so we got 300 by 300 and there are 24 local features that has been extracted and each of the channel is having some different types of extraction of this features and has been stored over with the respective channels over here now what we are going to do is we are going to extract each and every channel out of this and uh create a list out of it basically how we can do this I'm going to use CV2 functionality of split and I'm going to pass this featured image spit featured image I'll be creating a list of all the outputs that we get if I'm running this it's going to give us a total of uh if I check the length of this output it must be 24 the split means what it's going to split all the channels and it's going to give us as an output each and every channel and all the channels will be of the shape 300 by 300 so that's the kind of output that we are going to get so first of all I'm just going to like you know store it in P1 P2 P3 P4 and everything that's exactly what I'm going to do so I'm not going to write everything and make you guys bored what I'm going to do is I'm copy that part paste it over here say that this is equal to that if you notice because I was having 24 different outputs I'm having P1 all the way up to p24 if I want to check this P1 and also looking into the shape of that it must be 300 by 300 right just like that I can also check p24 do shape and yes because everything looks fine I'm going to go ahead and create a list out of this okay I'm simply going to go ahead and create a list out of this and call it as pixels different pixels that I have created right and my goal is to visualize all of this uh features that we have extracted uh in a particular color map any kind of of color map that you like I'll be choosing a color map called U I guess if I'm not wrong I'm going to choose pixel prism okay I hope it is present over here somewhere yeah this prism right so I'm just going to copy that where it is where it is where it is it's over here so I'm going to copy this come back where we were yeah and now finally visualize this kind of pixels in only one color map and uh there will be 24 different outputs so what I'm going to do is for feature in pixels what I want to do PLT do IMO of uh feature right I want to use color map only one color map that is this one prism color map and uh origin is equal to lower and PLT do title I can say that um this is feature one feature two like that I can give this kind of things I can also use enumerate over here enumerate so what is this enumerate going to do it's going to give me two things index values as well as the feature that is like what is present inside this pixels so with this I I'm going to so what is feature that is it feature one feature two right so it is Feature Feature then i+ one because index will start from zero so feature one all the way to feature 24 that's the kind of title that I'm giving and then PLT doxis I'm going to turn it off as usual and PLT do show so if I run this hopefully it's going to be running the way that I am expecting yes it is indeed feature four like this you will just see that the output we are getting over here we got feature 11 12 13 14 15 16 17 see how in all this image we are getting different kind of features that has been extracted right see all these kind of things all these kind of different features that are associated to this 24 outputs that we have got all of this we are able to visualize that and now we are able to visualize that in one color map that is called as prism right you can also do this with the help of DP SP also gray scale whatever you are comfortable right so yes these are the kind of outputs that we have got we can see this kind of uh all these kind of different features right and currently because we haven't defined any specific hypothesis that what exactly we are trying to look forward to so that we cannot prove anything over here it's just that I'm trying to show you that how with the help of this kind of feature extraction techniques that is present in SK image you are able to fetch this kind of information now any image that you are seeing over here any output whichever you think is describing the thing that you're looking for you look for that specific image and then write about that particular part in your thesis research work internship report whatever it is whatever you are working on right so yes guys that's the whole process let me just try to visualize this in nippy spectral I'm assuming that is going to look much better yeah this is my personal favorite guys okay nipp spect yes indeed it's giving us a good result right wherever there are this kind of spots the Stars we can clearly see that here is the nucleus of our particular anoma Galaxy over here also we are able to see something right so all this kind of information over here we also able to spot this kind of stars in the background right even this kind of feature over here this feature over here all of them are highlighted so yeah that's the beauty about this kind of feature extractors and obviously I'm not going into the details of what all kind of things you can extract let's say if your image is having some kind of jets coming out from the center of the uh Galaxy it might be indicating that it's coming from some kind of a like you know x-ray sources and that x-ray sources are nothing but indicating a presence of black hole or something that is ejecting this kind of high energy uh x-ray beams right so with respect to that whatever kind of particles you can associate with you can create your hypothesis and uh work on that so yes guys that was about how you can use different image processing techniques once you are importing the image I have shown you how you can apply different type of image uh processing techniques by implementing two different filters and also two different feature extractors so yes guys that was about this particular video all right guys so with this being said over here we are finally done completing each and every module of this program now I'll be creating one more video after this to conclude everything in just one video from the start till the end and what are some kind of further steps that you can take in order to continue your journey in terms of astronomical image processing or some of the other stuff that can help you from the programs that we have uploaded on udm itself so stay tuned for that hi everyone I welcome you all for one final time in this program on astronomic research data analysis first of all I congratulate each and every one of you to successfully complete all the four modules of the program now let's go ahead and conclude this whole program that we had conducted so to start with in the module one we looked into the very basics of python that you need in order to create cre some amazing visualizations that you have created by the end of module 4 in each of these modules you were creating some kind of different types of visualization so yeah for those things we uh understood some basic uh of the Python after that we moved on to module two where we took the tabul boring kind of data of stars and converted some amazing visualizations on top of that we created the bar plot we created the line chart we created a lot of different visualizations including the HR diagram then we moved on on to module 3 over there we took the data from the astronomical surveys like sdss DSS and then did some pixel scaling on the image that we have got in order to find some interesting things that you can see in that particular image then in module 4 we use the output from module 3 in order to enhance the features that were present in that image which we couldn't see till module 3 but in module 4 we saw a lot of things depending on some kind of feature extraction techniques that we had seen from the SK image so by now you must be having this kind of an idea that whatever type of visualization you want to create in Python you are now eligible to do that you can save this visualizations and use this in any kind of your research work that you are doing uh or maybe internship report or even the thesis work all of these kind of things you can surely go ahead and use this so with all these things being said I'll Bid Farewell to all of you guys and I hope to see you anytime soon in future thank you guys\n"