Refactored code to follow PEP8 guidelines. Added more detailed comments and shell for optical density calculations.