Understanding Optics with Python
  1. 359 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

About this book

Optics is an enabling science that forms a basis for our technological civilization. Courses in optics are a required part of the engineering or physics undergraduate curriculum in many universities worldwide. The aim of Understanding Optics with Python is twofold: first, to describe certain basic ideas of classical physical and geometric optics; second, to introduce the reader to computer simulations of physical phenomena. The text is aimed more broadly for those who wish to use numerical/computational modeling as an educational tool that promotes interactive teaching (and learning). In addition, it offers an alternative to developing countries where the necessary equipment to carry out the appropriate experiments is not available as a result of financial constraints. This approach contributes to a better diffusion of knowledge about optics. The examples given in this book are comparable to those found in standard textbooks on optics and are suitable for self-study. This text enables the user to study and understand optics using hands-on simulations with Python. Python is our programming language of choice because of its open-source availability, extensive functionality, and an enormous online support. Essentials of programming in Python 3.x, including graphical user interface, are also provided. The codes in the book are available for download on the book's website.



  • Discusses most standard topics of traditional physical and geometrical optics through Python and PyQt5


  • Provides visualizations and in-depth descriptions of Python's programming language and simulations


  • Includes simulated laboratories where students are provided a "hands-on" exploration of Python software


  • Coding and programming featured within the text are available for download on the book's corresponding website.

"Understanding Optics with Python by Vasudevan Lakshminarayanan, Hassen Ghalila, Ahmed Ammar, and L. Srinivasa Varadharajan is born around a nice idea: using simulations to provide the students with a powerful tool to understand and master optical phenomena. The choice of the Python language is perfectly matched with the overall goal of the book, as the Python language provides a completely free and easy-to-learn platform with huge cross-platform compatibility, where the reader of the book can conduct his or her own numerical experiments to learn faster and better."
— Costantino De Angelis, University of Brescia, Italy

"Teaching an important programming language like Python through concrete examples from optics is a natural and, in my view, very effective approach. I believe that this book will be used by students and appreciated greatly by instructors. The topic of modelling optical effects and systems where the students should already have a physical background provides great motivation for students to learn the basics of a powerful programming language without the intimidation factor that often goes with a formal computer science course."
— John Dudley, FEMTO-ST Institute, Besançon, France

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription.
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn more here.
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 1000+ topics, we’ve got you covered! Learn more here.
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more here.
Yes! You can use the Perlego app on both iOS or Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Yes, you can access Understanding Optics with Python by Vasudevan Lakshminarayanan,Hassen Ghalila,Ahmed Ammar,L. Srinivasa Varadharajan in PDF and/or ePUB format, as well as other popular books in Physical Sciences & Mathematical & Computational Physics. We have over one million books available in our catalogue for you to explore.

Information

1
Introduction to Python
The main aim of this chapter is to provide the reader with sufficient information to start programming in Python. All the programs/simulations in this book are in the Python programming language. The focus in this chapter is on introducing the Python syntax and the various most commonly used Python packages. Eager readers who want to get started with Python scripting as quickly as possible can jump to Section 1.2 to set up their environment and dive into the examples. Our approach in this chapter is to stick with the basics and explore more advanced features of Python as and when the need arises.
1.1 WHY PYTHON?
Python (https://www.python.org/) is an interpreted, interactive, object-oriented programming language that is opensource and easy to learn. It provides high level data structures such as associative arrays called dictionaries, dynamic typing and dynamic binding, modules, classes, exceptions, automatic memory management, etc. It has a remarkably simple and elegant syntax that allows programmers proficient in any other language to pick up the Python syntax very quickly. Beginners will find the clean syntax and indentation structure easy to learn. Python is used for software development at companies and organizations such as Google, Yahoo, CERN, NASA, etc., and the list only keeps growing.
Python was developed in 1990 by Guido van Rossum (1956–). Like many other scripting languages, it is free, even for commercial purposes, and can be run on practically any modern computer. A Python program is compiled automatically by the interpreter into a platform-independent bytecode that is then interpreted. A large number of specialized modules or applications are written in Python. Modules in Python are simply Python files with the “.py” extension that implement a set of functions or instructions. Modules can be imported from or into other modules, thereby facilitating the development of complex software. The full list of built-in modules in the Python standard library can be found at https://docs.python.org/3/library/. In addition to the standard library, there is a growing collection of several thousand user contributions that vary in complexity from individual programs and modules to packages and entire application development frameworks, which are available from the Python Package Index (https://pypi.python.org/pypi).
Assuming that you have some experience with programming in some type-safe language, this chapter helps you to upgrade your knowledge about scripting using the Python language. Python has many attractive features that in our view make it stand out from other dynamically typed languages. These include:
It is a general-purpose language.
• Python is easy to learn because of the very clean syntax.
• It is an interpreted language and hence there is no need to compile.
• It has excellent garbarge collection.
• It is cross-platform, i.e., the same program can be run in Linux, Mac OS X, or Windows without any (or only very little) modification.
• It has extensive built-in run-time checks that help to detect bugs and decrease development time.
• Programming with nested, heterogeneous data structures is easy.
• Object-oriented programming is quite easy in Python.
• There is support for efficient numerical computing; this is especially what we are interested in.
• The integration of Python with C, C++, Fortran, and Java is very well supported.
1.2 PYTHON SETUP
Python software can be downloaded for free from www.python.org. There are downloadable versions for many operating systems and computer types. Once the installation of Python from www.python.org is completed succesfully, you will have the Python interpreter and the standard library in your computer. We will be using in this book some other libraries in addition to the standard library. Hence, you will have to install these additional libraries one by one. The problem is that some of these libraries might have dependencies that could frustrate a beginner in the process of installation. An alternative solution is to install a distribution of Python that has all these libraries preinstalled. This will solve the problem and one can then go safely through all the chapters of this book.
1.2.1 WHICH DISTRIBUTION DO WE NEED?
A number of distributions of Python offer some support or bundling advantages. Whereas the official language comes from www.python.org, distributors of the language, some of who are commercial, have added features beyond the language, such as, a number of preinstalled software packages, better development environments, program debuggers, and editors. However, sometimes these distributions may have connections to operating system features. Figure 1.1 shows the general picture for a few distributions.
The figure shows that all distributions start with www.python.org, and then add their own branding. Each of those branded distributions copy from the c...

Table of contents

  1. Cover
  2. Half Title
  3. Title Page
  4. Copyright Page
  5. Dedication
  6. Table of Contents
  7. Preface
  8. Chapter 1 Introduction to Python
  9. Chapter 2 GUI Programming with Python and Qt
  10. Chapter 3 Electromagnetic Waves
  11. Chapter 4 Radiometry and Photometry
  12. Chapter 5 Fermat’s Principle, Reflection, and Refraction
  13. Chapter 6 Lenses and Mirrors
  14. Chapter 7 Thick Lenses and Lens Systems
  15. Chapter 8 Polarization
  16. Chapter 9 Interference
  17. Chapter 10 Coherence
  18. Chapter 11 Diffraction
  19. Appendix A Fresnel Integrals
  20. Index