Latest / CyberSecurity Summary / Python for Civil and Structural Engineers
Transcript
- 0:00Speaker 1: All right, let's kick off this deep dive. Today. We're
- 0:03Speaker 1: diving headfirst into a challenge that's probably well, pretty familiar
- 0:07Speaker 1: if you're an engineer. The sheer volume of calculations, right,
- 0:11Speaker 1: the endless streams of data, and sometimes just feeling like
- 0:14Speaker 1: the tools you've always used, maybe spreadsheets, they kind of
- 0:17Speaker 1: hit a wall.
- 0:18Speaker 2: They absolutely do, especially when problems get really complex, or
- 0:22Speaker 2: you know, you find yourself doing the same tedious thing over.
- 0:25Speaker 3: And over again.
- 0:26Speaker 1: Yeah, exactly. Every engineer is looking for that edge. You
- 0:28Speaker 1: want more speed, more flexibility, and just rock solid accuracy
- 0:33Speaker 1: in your work.
- 0:34Speaker 2: And that's really where programming starts to look very appealing.
- 0:37Speaker 2: It offers a different way to tackle those challenges.
- 0:40Speaker 1: And specifically today we're doing a deep dive into Python.
- 0:44Speaker 1: You've probably heard the name. It's a programming language that's
- 0:46Speaker 1: just incredibly versatile.
- 0:47Speaker 3: Yeah, it's popping up everywhere, and.
- 0:49Speaker 1: It's rapidly becoming well, almost indispensable in civil and structural engineering.
- 0:54Speaker 1: We've been digging into a guide that's literally written for
- 0:57Speaker 1: engineers wanting to jump into this.
- 0:59Speaker 2: World, right, and our goal here in this deep dive
- 1:02Speaker 2: is to take that source material and really pull out
- 1:04Speaker 2: the core concepts. We want to show you how Python,
- 1:08Speaker 2: especially when you pair it with some really powerful specialized libraries,
- 1:12Speaker 2: can just fundamentally change how you work. So streamlining workflows,
- 1:16Speaker 2: streamlining workflows, tackling problems that may be felt impossible before
- 1:20Speaker 2: automating those tasks that just eat up your time.
- 1:23Speaker 1: Yeah yeah, So why should you our listener care? Because
- 1:29Speaker 1: what we learn diving into this guide, it feels like
- 1:32Speaker 1: it offers a genuine shortcut, a shortcut to what though,
- 1:36Speaker 1: a way to handle those real world engineering problems faster,
- 1:40Speaker 1: more efficiently, and honestly with a level of flexibility that's
- 1:43Speaker 1: just tough to get with the traditional methods alone.
- 1:45Speaker 3: Okay, let's unpack that.
- 1:46Speaker 1: Then where do you even begin?
- 1:48Speaker 2: Well, the guide we look at starts right there with
- 1:50Speaker 2: the motivations the why bother for an engineer to learn
- 1:52Speaker 2: Python right, and one of the big ones is exactly
- 1:55Speaker 2: what you said, moving beyond the limits of spreadsheets, especially
- 1:59Speaker 2: when data gets big or the calculations get intricate, you
- 2:02Speaker 2: need something faster, more adaptable.
- 2:04Speaker 1: So it's not like ditch Excel immediately. It's more like
- 2:07Speaker 1: adding a new powerful.
- 2:09Speaker 3: Tool exactly right.
- 2:10Speaker 2: The source material is pretty clear you can still use
- 2:13Speaker 2: Python in a professional setting, even when you need to
- 2:16Speaker 2: share data in common formats like Excel files. Okay, we'll
- 2:20Speaker 2: see how a library called pandas makes that surprisingly seamless.
- 2:23Speaker 1: Actually, and another motivation.
- 2:25Speaker 2: Learning practical engineering applications. This isn't just abstract coding theory.
- 2:29Speaker 2: It's directly applicable. We're talking about solving the kinds of
- 2:33Speaker 2: structural or civil problems you face day to day.
- 2:36Speaker 1: Yeah, and who wouldn't want to say, automate creating reports,
- 2:40Speaker 1: maybe getting them into professional formats like latex or PDF.
- 2:44Speaker 2: Or generating really sharp publication quality plots straight from your analysis.
- 2:48Speaker 1: Exactly. These are all things Python enables. It's not about
- 2:51Speaker 1: replacing everything, No.
- 2:53Speaker 3: Not at all.
- 2:53Speaker 2: It's about empowering you with this adaptable tool set that
- 2:57Speaker 2: really complements the skills in the software.
- 2:59Speaker 3: You already use.
- 3:00Speaker 1: Okay, so Python it is. But where do you literally start,
- 3:03Speaker 1: like installing it, typing the code? The guide gives us
- 3:06Speaker 1: those first steps.
- 3:07Speaker 2: Yeah, for beginners, the usual recommendation is anaconda. It's a
- 3:11Speaker 2: distribution basically a package okay that bundles Python itself along
- 3:16Speaker 2: with most of the essential libraries you'll need. It just
- 3:18Speaker 2: saves a ton of set up headaches right, gets you
- 3:20Speaker 2: going faster, and the environment for actually writing the code
- 3:23Speaker 2: that material mention Jupiter notebooks. Jupiter notebooks are fantastic, especially
- 3:27Speaker 2: for this kind of work. They let you mix things up.
- 3:29Speaker 2: How So you have code cells where you write and
- 3:32Speaker 2: run your Python code, right, Yeah, but you also have markdown.
- 3:35Speaker 1: Cells ah for text and explanations.
- 3:38Speaker 2: Exactly, write explanations, put in equations, add images, basically document
- 3:42Speaker 2: your whole thought process alongside the actual calculations.
- 3:46Speaker 1: So it's like a living document your analysis and your
- 3:49Speaker 1: explanation all in one place.
- 3:51Speaker 2: Which is just invaluable for checking your work later or
- 3:54Speaker 2: sharing it with colleagues. Makes things reproducible.
- 3:57Speaker 1: Okay, environment set up. Now, what about the absolute bedrock,
- 4:01Speaker 1: the foundational Python concepts an engineer needs to.
- 4:05Speaker 2: Get so the source runs through the core syntax pretty quickly.
- 4:08Speaker 2: Things like comments in your code using the hash symbol
- 4:11Speaker 2: hashtag for a single line or triple quotes for multiple lines.
- 4:16Speaker 1: Essential for clarity, absolutely essential.
- 4:18Speaker 2: It's not just telling the computer what to do, but
- 4:20Speaker 2: reminding yourself or telling others why you're doing.
- 4:23Speaker 3: It that way.
- 4:24Speaker 1: Good practice. Easy to skip when you're in a hurry, though.
- 4:27Speaker 2: Oh definitely. Then you've got variables obviously, and understanding the
- 4:30Speaker 2: basic data.
- 4:31Speaker 1: Types like numbers and texts right in.
- 4:33Speaker 2: For integers whole numbers, float for numbers with decimal points,
- 4:39Speaker 2: booll for true or false conditions, which are key for logic,
- 4:43Speaker 2: and string for text. Think of them like labeled boxes
- 4:46Speaker 2: for different kinds of information.
- 4:48Speaker 1: And grouping data.
- 4:49Speaker 2: Collections.
- 4:50Speaker 1: Yeah, Python has built in collections. The list is probably
- 4:53Speaker 1: the most common. It's like a flexible array or vector
- 4:55Speaker 1: flexible hot. It's ordered, you can change things in it,
- 4:58Speaker 1: and you grab elements using an index starting from zero.
- 5:01Speaker 1: That's important, index zero. It can even hold different types
- 5:04Speaker 1: of data like numbers and strings together, okay.
- 5:07Speaker 2: And dictionaries a dick Yeah, that's more like a lookup table.
- 5:11Speaker 2: It stores data as key value pairs, so you find
- 5:15Speaker 2: a value using its unique key, not its position like
- 5:18Speaker 2: in a list.
- 5:19Speaker 1: Un ordered gotcha and tupuls tuple.
- 5:22Speaker 2: It's ordered like a list, but the big difference is
- 5:24Speaker 2: you can't change it once you create it.
- 5:26Speaker 3: Immutable.
- 5:26Speaker 1: Why use that?
- 5:27Speaker 3: Then?
- 5:27Speaker 2: They're often used when a function needs to return multiple results.
- 5:31Speaker 2: You bottle them in a tuple and then you can
- 5:33Speaker 2: easily unpack them back into separate variables.
- 5:36Speaker 1: H okay, makes sense. Basic math is obvious plus velmad
- 5:40Speaker 1: But what about powers exponents.
- 5:43Speaker 2: Right, Engineers use those all the time. Python uses double asterisks,
- 5:47Speaker 2: so two in three is too cubed. Not the care
- 5:49Speaker 2: ensemble you might see elsewhere.
- 5:50Speaker 3: That's a common.
- 5:51Speaker 1: Gotcha good tip for powers.
- 5:53Speaker 3: Also useful are.
- 5:54Speaker 2: The assignment operators like plus or make just shorthand ways
- 5:57Speaker 2: to update of variables of value like x plus one
- 6:00Speaker 2: is the same as x plus one.
- 6:01Speaker 3: There's a bit of typing.
- 6:02Speaker 1: And making decisions logic flow.
- 6:05Speaker 2: That's your if yes, which is short for l if
- 6:08Speaker 2: and l statements. They work based on conditions that evaluate
- 6:11Speaker 2: too true or.
- 6:11Speaker 1: False, using comparison operators exactly for checking equality. Is this
- 6:15Speaker 1: equal to that? For not equal, then your standard edge.
- 6:18Speaker 2: A and I remember the source flag A really common mistake.
- 6:21Speaker 1: Here, Oh yeah, the classic versus Everyone does it at first.
- 6:25Speaker 1: Single equals is assignment right, x equals five, assigns five
- 6:29Speaker 1: to x, double equals x and equals five, so this
- 6:32Speaker 1: is equal to five. Huge difference in meaning. Get that
- 6:34Speaker 1: wrong and your logic goes haywire.
- 6:36Speaker 2: And you combine conditions with and or not standard logic yep.
- 6:40Speaker 2: No Python structure It's all about the spacing, isn't it indentation?
- 6:45Speaker 1: Yes, this is fundamental Python. Where other languages might use
- 6:49Speaker 1: curly braces or keywords like ndif to show code blocks
- 6:52Speaker 1: belonging to an if statement or a loop, Python uses
- 6:55Speaker 1: indentation consistent spacing.
- 6:58Speaker 3: And it's not just for looks.
- 6:59Speaker 1: No, it's syntactically mandatory. If your indentation is wrong, your
- 7:03Speaker 1: code won't run, or worse, it'll run in correctly. It
- 7:05Speaker 1: forces a certain level of visual clarity, which is actually
- 7:07Speaker 1: a good thing.
- 7:08Speaker 2: Okay, what about doing things repeatedly?
- 7:10Speaker 1: Loops?
- 7:11Speaker 2: Four loops are the main tool here. You use them
- 7:13Speaker 2: to iterate over sequences like the items in a list,
- 7:16Speaker 2: or to just repeat an action a specific.
- 7:18Speaker 3: Number of times.
- 7:19Speaker 1: And that range function comes up.
- 7:20Speaker 2: A lot very often with four loops. Dot range n
- 7:24Speaker 2: gives you a sequence of numbers from zero up two,
- 7:26Speaker 2: but not including n.
- 7:27Speaker 1: So range five is zero, one, two, three, four exactly.
- 7:31Speaker 2: That n one end point is crucial to remember.
- 7:34Speaker 1: Can you control the loop while it's running like stop early, yep.
- 7:37Speaker 2: Break, exits the loop, immediately, continue, skips the rest of
- 7:40Speaker 2: the current iteration, and jump straight to the next one.
- 7:43Speaker 2: Very handy sometimes.
- 7:44Speaker 1: Okay, last basic concept functions key for organization totally.
- 7:48Speaker 2: Think of a function as a named, reusable chunk of
- 7:51Speaker 2: code that does one specific job. You define it with
- 7:54Speaker 2: a deaf keyword, give it a name, give it inputs, right,
- 7:57Speaker 2: specify any inputs it needs in parentheses. Then it performs
- 8:01Speaker 2: its operations and usually uses the return keyword to send
- 8:04Speaker 2: back a result.
- 8:05Speaker 1: An output keeps your code cleaner, reusable.
- 8:08Speaker 2: Exactly avoids repeating yourself. The source also mentioned variable scope.
- 8:12Speaker 1: Ah, yes, local versus global important stuff.
- 8:15Speaker 2: Variables created inside of function are local. They only exist
- 8:19Speaker 2: within that function and disappear when it finishes.
- 8:22Speaker 1: So they don't mess with things outside.
- 8:24Speaker 3: Right.
- 8:24Speaker 2: Global variables are defined outside functions and can generally be
- 8:27Speaker 2: accessed from anywhere. Understanding scope helps prevent unexpected side effects.
- 8:32Speaker 1: The trapezoid area function example and the source was pretty clear.
- 8:36Speaker 2: Yeah, good, simple example. You pass in the bases in height,
- 8:40Speaker 2: The function calculates the area using the formula and returns
- 8:43Speaker 2: that single value.
- 8:44Speaker 1: And you mentioned tiples before for returning multiple things.
- 8:47Speaker 3: Yep.
- 8:48Speaker 2: The source showed how you can set default values for
- 8:50Speaker 2: function inputs, making them optional, and how returning a twopole
- 8:54Speaker 2: lets a function give back say both the area and perimeter,
- 8:58Speaker 2: which you can then easily unpack, and two separate variables
- 9:01Speaker 2: where you call.
- 9:01Speaker 3: It the function.
- 9:02Speaker 1: Okay, that covers the Python fundamentals. Now, the real power
- 9:05Speaker 1: boost for engineers comes from the libraries, right or absolutely.
- 9:09Speaker 2: This is where Python transforms from a general purpose language
- 9:12Speaker 2: into a specialized engineering powerhouse. The guide really focuses on
- 9:16Speaker 2: four core libraries that are well game changers.
- 9:19Speaker 1: Let's start with the big one for numbers, numb PI.
- 9:21Speaker 3: Numb PI.
- 9:22Speaker 2: It's fundamental if you're doing numerical work in Python, especially
- 9:25Speaker 2: with the rays. This is the standard. The core element
- 9:29Speaker 2: is the end array, the ind dimensional array.
- 9:30Speaker 1: How is it different from a standard Python list.
- 9:33Speaker 2: It's like a list, but highly optimized for math, generally
- 9:36Speaker 2: much faster for calculations. Crucially, all elements in a NUMBPI
- 9:40Speaker 2: array usually have to be the same data type, like
- 9:42Speaker 2: all floats or all integers.
- 9:44Speaker 3: Lists can mix types.
- 9:46Speaker 1: Got it? How do you use it?
- 9:47Speaker 2: Standard practice is import nump is NP. Everyone uses NP
- 9:51Speaker 2: as the shorthand.
- 9:52Speaker 1: Okay, creating a raise easy.
- 9:54Speaker 2: NP dot zeros makes an array full of zeros mp
- 9:57Speaker 2: dot range is like Python's range, but gives you an
- 9:59Speaker 2: actual numbpire right, and np dot lends space is super
- 10:02Speaker 2: useful for engineers.
- 10:03Speaker 1: Lends space.
- 10:04Speaker 2: Yeah, np dot lends space, go start stopping them. It
- 10:06Speaker 2: creates an array with numb evenly spaced points between start
- 10:10Speaker 2: and stop, including the stop point, perfect for creating X
- 10:13Speaker 2: coordinates along a beam or points for plotting.
- 10:15Speaker 1: Okay, and doing math with these arrays.
- 10:18Speaker 2: Numb pi shines here. You can get properties like dimensions,
- 10:21Speaker 2: want to be in shape, shape shape sized, data type
- 10:24Speaker 2: d type basic math plus a at even for powers
- 10:28Speaker 2: works element wisele limit wise, meaning if you have two
- 10:32Speaker 2: arrays A and B the same shape A plus B,
- 10:35Speaker 2: adds the first element of A to the first of B,
- 10:37Speaker 2: the second to the second, and so on same. For
- 10:39Speaker 2: multiplication to B, it applies the operation to corresponding elements.
- 10:42Speaker 1: But wait, matrix multiplication, that's different, right, crucial for structural analysis.
- 10:47Speaker 3: Absolutely crucial. This trists people up.
- 10:48Speaker 2: The standard asterisk is element wise multiplication. For true matrix
- 10:52Speaker 2: multiplication like you need for transformations or solving systems, use
- 10:56Speaker 2: the AT symbol an b okay.
- 10:58Speaker 1: At for matrix math element wise got it?
- 11:01Speaker 3: Remember at B.
- 11:02Speaker 2: You can also slice arrays like lists using start end
- 11:05Speaker 2: dot step, but it works across multiple dimensions too, and
- 11:08Speaker 2: you can reshape them, stack them vertically, v stack a pend,
- 11:12Speaker 2: or insert elements. Lots of manipulation tools.
- 11:14Speaker 1: The guide had a great practical example calculating moment and
- 11:18Speaker 1: sheer along a simple beam.
- 11:19Speaker 2: Yeah, that really shows the element wise power. You create
- 11:22Speaker 2: your X ray along the beam using np dot line space.
- 11:25Speaker 2: Then you just write the standard beam equations for moment
- 11:28Speaker 2: M and sheer V, but using the entire x ray
- 11:31Speaker 2: in the.
- 11:31Speaker 1: Formula like M equals l x two w x two
- 11:35Speaker 1: two exactly.
- 11:36Speaker 2: Numpi automatically applies that calculation to every single value in
- 11:40Speaker 2: the X ray all at once. You get the entire
- 11:43Speaker 2: M diagram or v diagram as a Numpi array instantly,
- 11:46Speaker 2: super efficient.
- 11:47Speaker 1: Wow. Okay, so numb pie handles the heavy numerical lifting.
- 11:50Speaker 1: What if you need to deal with the math before
- 11:52Speaker 1: you have numbers, like solving equations symbolically.
- 11:55Speaker 2: That's where simp comes in. It's a library for symbolic mathematics.
- 11:57Speaker 2: Think of it as a computer algebra system or see
- 12:00Speaker 2: right inside Python.
- 12:01Speaker 1: So algebra with symbols, not just numbers.
- 12:03Speaker 2: Percisely, you import simpsky. Then you define symbols like xsp
- 12:07Speaker 2: dot symbols x or maybe EI lsp dot symbols EIL
- 12:11Speaker 2: for engineering properties.
- 12:13Speaker 3: Then you can write.
- 12:13Speaker 2: Equations using these symbols. Simps functions like sp dot solve
- 12:17Speaker 2: set to solve an equation for a specific symbol, or
- 12:19Speaker 2: sp dot lens solve to solve systems of linear equations
- 12:22Speaker 2: symbolically calculus two differentiation integration.
- 12:25Speaker 1: The guide mentioned a display function for making it look nice.
- 12:29Speaker 2: Yeah, especially in Jupiter notebooks. Display your SIMP expression often
- 12:33Speaker 2: renders the output using latex math formatting, so complicated formulas
- 12:38Speaker 2: look like they do in a textbook, much easier to
- 12:40Speaker 2: read and check.
- 12:41Speaker 1: How does this help with a real problem? The source
- 12:44Speaker 1: used a two span beam example, again perfect case.
- 12:47Speaker 2: A continuous beam like that is often statically indeterminate. Basic
- 12:51Speaker 2: equilibrium equations aren't enough to find all the support reactions, right.
- 12:54Speaker 1: You need compatibility equations considering deflections or slopes Exactly.
- 12:59Speaker 2: With SIMP, you can say up both the equilibrium equations
- 13:01Speaker 2: and the compatibility equations using your defined symbols for unknown
- 13:05Speaker 2: reactions like va VC and maybe an unknown internal moment MX. Okay,
- 13:10Speaker 2: Then you use simply solvers like sp dot len solve
- 13:13Speaker 2: to solve that system of symbolic equations. It gives you
- 13:16Speaker 2: the algebraic expressions for those unknown reactions in terms of
- 13:20Speaker 2: the symbolic loads and lengths WL, etc.
- 13:23Speaker 1: So you solve the underlying indeterminate structure problem algebraically first.
- 13:28Speaker 2: Yes, before you even plug in a single number. It
- 13:31Speaker 2: helps you verify the fundamental mechanics and let simply handle
- 13:34Speaker 2: the messy algebra. Then you can substitute numbers into those
- 13:37Speaker 2: symbolic solutions later using numb pie.
- 13:39Speaker 1: Perhaps that's powerful. Okay, From symbolic math to data wrangling.
- 13:44Speaker 2: Pandas If numbpie is for a numerical arrays, PANDAS is
- 13:47Speaker 2: for tabular data think spreadsheets, tables with rows and columns.
- 13:52Speaker 2: It's built for handling potentially large structured data sets, especially
- 13:56Speaker 2: reading and writing common file formats.
- 13:58Speaker 1: Like Excel and CSV files.
- 13:59Speaker 2: Exactly dot xlsx, dot csv. PANDAS makes working with those
- 14:04Speaker 2: super easy. The core structure in PANDAS is.
- 14:06Speaker 1: The data frame day frame like a table.
- 14:08Speaker 2: Pretty much imagine a two D table, but with powerful extras.
- 14:12Speaker 2: It has labeled columns like spreadsheet headers, and labeled rose
- 14:16Speaker 2: called the index. It's designed for easily selecting, filtering, cleaning,
- 14:19Speaker 2: and analyzing that kind of data.
- 14:21Speaker 1: What kind of things can you do? Easily?
- 14:23Speaker 2: Create them from scratch or from numpire rays access data
- 14:26Speaker 2: by column name or row index, lots of data cleaning
- 14:29Speaker 2: tools built in sorting, sort values, renaming columns or the index, rename,
- 14:34Speaker 2: dropping rose or columns, drop handling missing data, resetting the
- 14:37Speaker 2: index if it gets messed up, reset index. You can
- 14:40Speaker 2: also combine data frames CONCAT.
- 14:42Speaker 1: The guide really highlighted working with external files. That sounds
- 14:45Speaker 1: incredibly useful.
- 14:46Speaker 2: It is probably one of the most common uses for engineers.
- 14:49Speaker 2: PDA dot redexl mydata dot xl sx or pd dot
- 14:53Speaker 2: recsv results dot csv one line and your data isn't
- 14:57Speaker 2: a data.
- 14:57Speaker 1: Frame, even if the files a bit messy like multiple
- 15:00Speaker 1: header rows.
- 15:01Speaker 2: Yeah canas has options for that. You can specify header
- 15:04Speaker 2: zero one if the headers pans the first two rows,
- 15:06Speaker 2: for example, or index col zero if the first column
- 15:08Speaker 2: the file should be used as the roll labels the index.
- 15:10Speaker 1: And cleaning that imported data, getting rid of empty rows
- 15:13Speaker 1: or junk.
- 15:14Speaker 2: PANDAS makes that much easier than doing it manually. In Excel,
- 15:17Speaker 2: you can drop those extra header levels that sometimes come
- 15:19Speaker 2: in DF dot columns DOT drop level, remove rows with
- 15:22Speaker 2: any missing values, DF dot drop and selectively drop rows.
- 15:25Speaker 1: Or columns and getting data back out to share with colleagues.
- 15:29Speaker 2: Maybe just as easy df dot to excel output dot
- 15:32Speaker 2: XLSX or df dot t s sv cleanda dot csv.
- 15:36Speaker 2: You can control whether the index is written and other formatting.
- 15:40Speaker 2: It bridges the gap between your Python analysis and standard
- 15:42Speaker 2: office formats.
- 15:43Speaker 3: Really well.
- 15:44Speaker 1: How did the two span beam example use pandas it.
- 15:47Speaker 2: Showed using a data frame to manage results from multiple
- 15:50Speaker 2: load cases.
- 15:51Speaker 3: So you use simply.
- 15:52Speaker 2: Numpi to calculate the M and V diagrams for dead lows,
- 15:55Speaker 2: live load, windload, et cetera. Okay, you can store each
- 15:58Speaker 2: MRA and vra as a in a Panda's data frame
- 16:01Speaker 2: with columns labeled maybe mddvdad, MLIV.
- 16:04Speaker 3: Live and so on.
- 16:04Speaker 1: Ah, so everything is organized together.
- 16:06Speaker 2: Exactly, all results in one table. Makes it super easy
- 16:09Speaker 2: to then compare load cases, find maximums or minimums across cases, envelopes,
- 16:13Speaker 2: or apply load combinations.
- 16:14Speaker 1: Right, Okay, we've calculated, we've solved symbolically, we've organized the data.
- 16:19Speaker 1: Now we need to see it visualization with matt plotlib.
- 16:22Speaker 2: Mat plotlib it's the workhorse. Plotting library of Python very versatile.
- 16:27Speaker 2: You can create anything of simple line graphs to complex
- 16:30Speaker 2: publication quality technical figures.
- 16:32Speaker 1: How do you get started?
- 16:33Speaker 2: The standard import is importmattplotlib dot piplot as PLT. Everyone
- 16:38Speaker 2: uses PLT. The key concept is the figure and axis
- 16:42Speaker 2: figure and axis.
- 16:43Speaker 3: The figure is like.
- 16:44Speaker 2: The overall window or canvas. The axis usually just one.
- 16:47Speaker 2: AX is the actual plot area within that figure where
- 16:50Speaker 2: your data gets drawn, the part with the xy axis,
- 16:53Speaker 2: the lines, the points, and.
- 16:54Speaker 1: The guide recommended A specific way to set this up.
- 16:56Speaker 2: Yeah, the object oriented approach is generally preferred for control.
- 17:00Speaker 2: You start with fig AX, it goes PLT dot subplots.
- 17:04Speaker 2: This creates both a figure FIG and a single axis.
- 17:07Speaker 1: Object AX, and then you plot on AX exactly.
- 17:10Speaker 2: You call messods directly on the AX object AC dot
- 17:12Speaker 2: plot x data white data for a line plot, x
- 17:15Speaker 2: dot scatter for scatterplots, et cetera. Then you use PLT
- 17:19Speaker 2: dot show at the end to actually display the figure.
- 17:21Speaker 1: Why that way instead of just PLT dot plot.
- 17:23Speaker 2: Using the AX object gives you much finer control over
- 17:26Speaker 2: everything on that specific plot labels, titles, ticks, legends, colors.
- 17:30Speaker 2: It's much more robust, especially if you end up wanting
- 17:32Speaker 2: multiple plots in the same figure later makes sense.
- 17:35Speaker 1: Customization is obviously key for engineering plots totally.
- 17:38Speaker 2: And map plot labelts. You customize almost anything at access
- 17:41Speaker 2: labels with AX dot sets label and act dot set
- 17:44Speaker 2: the label. Set a title with ax dot set title
- 17:47Speaker 2: at a legend if you have multiple lines using ax dot.
- 17:50Speaker 1: Legend line styles colors.
- 17:52Speaker 2: YEP control line styles, solid dash colors, ad markers.
- 17:55Speaker 3: At data points.
- 17:56Speaker 2: You can fill areas between curves using ax dot fill
- 17:58Speaker 2: between really useful for showing moment envelopes or maybe the
- 18:02Speaker 2: feasible region in an interaction diagram.
- 18:05Speaker 1: Oh nice, ticks and labels too.
- 18:07Speaker 3: Full control.
- 18:07Speaker 2: Customize the locations and labels of the tick marks on
- 18:10Speaker 2: both axis sex sticks set tis. You can even rotate
- 18:13Speaker 2: the dick labels sixtick labels rotation if they overlap essential
- 18:17Speaker 2: for clear technical plots.
- 18:18Speaker 1: Scatterplots were also mentioned for discrete points right at that'skay.
- 18:23Speaker 2: A cool feature there is you can color each point
- 18:25Speaker 2: based on a third variable using the C argument and
- 18:28Speaker 2: a color map. See that, then add a color bar
- 18:31Speaker 2: fig dot color bar to show what the colors mean.
- 18:32Speaker 2: Great for visualizing things like stress levels or utilization. Ratio
- 18:35Speaker 2: is at different points.
- 18:36Speaker 1: And putting multiple plots together like a dashboard.
- 18:39Speaker 2: Peel dot subplots PLF booze creates a grid. If you
- 18:42Speaker 2: do fig axs egals PLT dot subplots two two axis
- 18:46Speaker 2: becomes a two by two array and you can plot
- 18:48Speaker 2: on AXI zero zero, access rule one, et cetera.
- 18:51Speaker 3: To arrange four plots in one.
- 18:52Speaker 1: Figure and getting the plot out of Python, saving it.
- 18:55Speaker 2: Easy PLT dot safig, myplot, dot pdf or dot png,
- 18:59Speaker 2: dot s VG lots of formats saves the current figure
- 19:02Speaker 2: to a file ready to be included in reports.
- 19:05Speaker 1: So practically this ties back to visualizing those beam diagrams
- 19:09Speaker 1: from numb pi, or maybe plotting something complex like that
- 19:12Speaker 1: MN interaction domain for concrete Exactly.
- 19:15Speaker 2: You do the heavy lifting with NUMPI, simply manage it
- 19:17Speaker 2: with pandas, and then matt plotlib gives you the visual
- 19:20Speaker 2: insight and the communication tool.
- 19:21Speaker 3: It completes the picture.
- 19:22Speaker 1: Okay, so we've got the basics, we've got the core
- 19:24Speaker 1: libraries numb PI, SIMPI, panas maplotlib. The really cool part
- 19:27Speaker 1: is seeing them all work together on actual engineering problems.
- 19:30Speaker 1: The source had some great examples of this integration.
- 19:33Speaker 3: Yeah, this is where you see the synergy.
- 19:35Speaker 2: Like calculating properties for a custom steel section, maybe it
- 19:38Speaker 2: built up welded shape.
- 19:39Speaker 1: How would that work?
- 19:40Speaker 2: You might use SIMPI first symbolically to set up the
- 19:43Speaker 2: equations for finding the centroid location YG using the principle
- 19:47Speaker 2: of moments of area. Solve that algebraically. Okay, Then you
- 19:51Speaker 2: switch to Python a numb pie. You implement the standard
- 19:54Speaker 2: formulas for area moment of inertia like I gole sum
- 19:57Speaker 2: in a local plus eighty two section modulus using the
- 20:00Speaker 2: dimensions of the section parts may be stored in NUMPI arrays.
- 20:04Speaker 2: You plug the symbolic centroid result into these numerical calculations.
- 20:08Speaker 1: So combining the symbolic set up with the numerical calculation precisely.
- 20:12Speaker 2: Or take the concrete MS interaction domain. That's a complex
- 20:16Speaker 2: nonlinear problem.
- 20:17Speaker 1: Yeah, involves iterating through stream profiles.
- 20:19Speaker 3: Right. The guide shows how numb pi is crucial.
- 20:21Speaker 1: Here.
- 20:22Speaker 2: You use a rays to discretize the concrete section into
- 20:25Speaker 2: layers and to find different possible linear strain profiles across
- 20:28Speaker 2: the depth.
- 20:29Speaker 1: Then calculate forces for each strain profile exactly.
- 20:32Speaker 2: For each assumed strain profile, you find the stress in
- 20:35Speaker 2: each layer using the concrete and steel stress strain curves.
- 20:39Speaker 2: Then you use NUMPI functions like MP dot traps for
- 20:42Speaker 2: numerical integration to sum up the forces in all layers.
- 20:46Speaker 2: This gives you the total axial force n and bending
- 20:49Speaker 2: moment M for that specific.
- 20:51Speaker 1: Strain state, and you repeat that many times.
- 20:53Speaker 3: You repeat that for.
- 20:54Speaker 2: Many, many possible strain profiles. Each one gives you a
- 20:57Speaker 2: point n M on the back boundary of the interaction domain.
- 21:01Speaker 2: Collect all those points.
- 21:02Speaker 1: And plot them with matt plotlib.
- 21:04Speaker 3: You got it.
- 21:05Speaker 2: Plot all the n M pairs and maybe use fill
- 21:07Speaker 2: between to shade the feasible region. It shows how programming
- 21:10Speaker 2: lets you tackle these really fundamental iterative mechanics problems that
- 21:14Speaker 2: would be incredibly painful manually.
- 21:16Speaker 1: Yeah, impossible with just a spreadsheet.
- 21:18Speaker 2: Really pretty much. And it's steel column design example that
- 21:22Speaker 2: highlighted pandas in automation. Oh so, pannas is perfect for
- 21:25Speaker 2: managing potentially hundreds of load combinations in a data frame.
- 21:29Speaker 2: Each row could be a combo with columns for actual
- 21:31Speaker 2: fource moments, et cetera. Then the design checks, say calculating
- 21:34Speaker 2: buckling reduction factors like G and k according to eurocode
- 21:38Speaker 2: or another standard. You implement those checks as Python code,
- 21:43Speaker 2: maybe in functions, often using numb pi for the math involved.
- 21:46Speaker 1: And the key is applying the check systematically.
- 21:48Speaker 2: Yes, you write the code for the check once, then
- 21:51Speaker 2: you apply that function to every single row, every load
- 21:54Speaker 2: combination in your PANDAS data frame, maybe storing the result
- 21:58Speaker 2: pass fail utiless ratio.
- 22:01Speaker 3: In a new column.
- 22:02Speaker 1: Automating code compliance checks across all scenarios.
- 22:05Speaker 2: That's huge, massive timesaver ensure its consistency, reduces errors. It
- 22:10Speaker 2: automates a critical and often tedious part of design.
- 22:13Speaker 1: Okay, so it's not just about calculation and analysis. Engineers
- 22:16Speaker 1: need to communicate results. The guide finish up talking about
- 22:19Speaker 1: reporting and automation.
- 22:21Speaker 2: Right absolutely, and the Jupiter Notebook itself is a big
- 22:23Speaker 2: part of that story because you can mix your live code,
- 22:26Speaker 2: the actual output from running that code, numbers, tables the
- 22:28Speaker 2: plots you generated, and explanatory text using markdown, all in
- 22:32Speaker 2: one document. The notebook essentially becomes your working report draft.
- 22:36Speaker 1: Your analysis document is the report draft.
- 22:38Speaker 2: That's efficient, it really is, and getting results out, especially
- 22:42Speaker 2: tables pandas is great here too. You can take a
- 22:44Speaker 2: data frame, maybe your load combination result and export it
- 22:47Speaker 2: directly to LATEX format using DF, dot TOLA texts. Latex
- 22:51Speaker 2: is the standard for high quality technical documents.
- 22:54Speaker 1: You can format it too, yep, control things.
- 22:56Speaker 2: Like bolding, rows, column alignment. You can even embed LATEX
- 23:01Speaker 2: math symbols directly in your data frame column headers if needed,
- 23:04Speaker 2: and have them render correctly in the output. It connects
- 23:06Speaker 2: your calculations directly to professional documentation.
- 23:09Speaker 1: Cuts out copy pasting, reduces errors again for sure.
- 23:12Speaker 2: And the plots from that plotlib, yes, save them, save
- 23:15Speaker 2: them using PLT, dot SA, fig is, BDF or p
- 23:18Speaker 2: and G files and then include those image files in
- 23:20Speaker 2: your LATEX document or word DOOC or whatever you're using.
- 23:23Speaker 1: And there was a final step converting the whole notebook.
- 23:27Speaker 2: Yeah, the source mentioned at command line tool Jupiter andb convert.
- 23:30Speaker 2: You can use it to take your dot IPNB notebook
- 23:33Speaker 2: file and automatically convert it into different final formats like
- 23:37Speaker 2: dot text for LATEX, or even directly to PDF if
- 23:40Speaker 2: you have LATEX installed, HTML and others.
- 23:42Speaker 1: So it automates turning that dynamic analysis notebook into a
- 23:46Speaker 1: static shareable report exactly.
- 23:48Speaker 3: It completes the workflow loop.
- 23:50Speaker 1: Wow, so thinking about it, it's a whole ecosystem setting
- 23:53Speaker 1: up the problem using numpi and simply for the heavy math,
- 23:57Speaker 1: managing data and loadcases with pandas, visualizing insights with matt plotlib,
- 24:02Speaker 1: and then automating the report output potentially all linked together
- 24:05Speaker 1: in a Jupiter notebook. That is genuinely powerful.
- 24:08Speaker 3: It really is.
- 24:09Speaker 2: And I think what this deep dive into the source
- 24:11Speaker 2: shows is that if you're an engineer who has been
- 24:13Speaker 2: maybe curious about programming, this is the kind of potential
- 24:16Speaker 2: that's there. Those first steps getting Anaconda installed, learning the
- 24:20Speaker 2: core Python syntax, they're the launch pat They.
- 24:22Speaker 1: Open the door to all these advanced capabilities.
- 24:24Speaker 2: Yeah, and the guide really hammered this home practice is key.
- 24:28Speaker 2: You can't just read about it. You have to try
- 24:30Speaker 2: applying these tools to the kinds of problems.
- 24:32Speaker 3: You actually work on.
- 24:33Speaker 1: Makes sense. The more you use it, the more natural
- 24:35Speaker 1: it feels.
- 24:35Speaker 2: Exactly, it becomes more intuitive, you get faster, you start
- 24:39Speaker 2: seeing new ways to apply it. It's a skill that
- 24:41Speaker 2: just enhances everything else you do as an engineer. Boost
- 24:44Speaker 2: efficiency improves accuracy, lets you tackle problems that maybe felt out.
- 24:49Speaker 3: Of reach before.
- 24:49Speaker 1: So let's leave our listeners with a final thought, if
- 24:52Speaker 1: you can use these Python tools to, say, analyze complex
- 24:56Speaker 1: individual components like beams or columns, manage huge sets of
- 24:59Speaker 1: low cases, automate design checks, and generate reports. Where could
- 25:04Speaker 1: you take that next?
- 25:06Speaker 3: What are the bigger possibilities?
- 25:08Speaker 1: Could you scale these techniques up to analyze entire structural
- 25:11Speaker 1: systems more effectively? Could you use Python to run iterative
- 25:15Speaker 1: design optimizations, maybe searching for the most efficient beam size
- 25:19Speaker 1: or trust geometry, or what.
- 25:20Speaker 2: About connecting to real world data, analyzing sensor readings coming
- 25:24Speaker 2: off a bridge or building in near real time.
- 25:27Speaker 1: Exactly when you combine those fundamental engineering principles with the
- 25:30Speaker 1: kind of computational power and flexibility Python offers, well, the
- 25:35Speaker 1: possibilities start to look pretty vast, don't they