Sunday, August 24, 2025

#5 Visualization & Project Work

 ๐Ÿ‘ — here’s a more detailed Module 6: Visualization & Project Work code set for your mini course.

This module focuses on Matplotlib, Seaborn, and optional GeoPandas for civil engineering visualization.


๐Ÿ”น 1. Stress–Strain Curve (Lab Data Visualization)

import matplotlib.pyplot as plt # Sample lab data stress = [0, 50, 100, 150, 200, 250, 280] strain = [0, 0.001, 0.002, 0.0032, 0.0042, 0.005, 0.006] plt.figure(figsize=(6,4)) plt.plot(strain, stress, marker='o', color='b', label="Stress-Strain") plt.xlabel("Strain") plt.ylabel("Stress (N/mm²)") plt.title("Stress-Strain Curve") plt.grid(True) plt.legend() plt.show()

๐Ÿ”น 2. Rainfall vs. Runoff Relationship

import numpy as np rainfall = [20, 40, 60, 80, 100, 120] # mm runoff = [5, 15, 28, 40, 60, 85] # mm plt.figure(figsize=(6,4)) plt.scatter(rainfall, runoff, color='green', label="Observed Data") plt.plot(rainfall, runoff, linestyle="--", color="black") plt.xlabel("Rainfall (mm)") plt.ylabel("Runoff (mm)") plt.title("Rainfall vs Runoff") plt.legend() plt.grid(True) plt.show()

๐Ÿ”น 3. Bar Bending Schedule (BBS) Automation

import pandas as pd # Example BBS data (Beam reinforcement) data = { "Bar Mark": ["B1", "B2", "B3"], "Diameter (mm)": [12, 16, 20], "Length (m)": [6, 8, 12], "No. of Bars": [10, 8, 6] } bbs = pd.DataFrame(data) bbs["Total Length (m)"] = bbs["Length (m)"] * bbs["No. of Bars"] bbs["Weight (kg)"] = bbs["Total Length (m)"] * bbs["Diameter (mm)"] * 0.006165 # IS formula print("Bar Bending Schedule:\n") print(bbs)

๐Ÿ”น 4. Traffic Flow Line Graph

time = np.arange(0, 11) # minutes vehicles = [50, 55, 60, 70, 85, 90, 95, 92, 88, 85, 80] plt.figure(figsize=(6,4)) plt.plot(time, vehicles, marker="o", color="red") plt.xlabel("Time (minutes)") plt.ylabel("Number of Vehicles") plt.title("Traffic Flow Simulation") plt.grid(True) plt.show()

๐Ÿ”น 5. Optional: Plotting Survey/GIS Data (GeoPandas)

# Uncomment if geopandas is installed # import geopandas as gpd # world = gpd.read_file(gpd.datasets.get_path('naturalearth_lowres')) # world[world.name == "India"].plot() # plt.title("India Map - Example for Civil GIS Work") # plt.show()

✅ With these codes, students can visualize structural, hydrological, and transportation data.

No comments:

Post a Comment

#6 Civil Applications using Python

 Let’s dive deeper into civil engineering applications with Python . I’ll give you detailed, explained code for three real-world tasks: ...