data.set_index(data.columns.drop(data.columns[[1, -1]]).tolist() + ['Measurement_Time'])
  X5zJxoD00Cah 2023年11月02日 41 0
import numpy as np
import pandas as pd

# 定义物料数量
num_materials = 40

# 定义每个物料的温度测量次数和时间间隔
num_measurements = 10
time_interval_hours = 6

# 创建一个时间数组,模拟测量时间点
measurement_times = np.arange(0, num_measurements * time_interval_hours, time_interval_hours)

# 创建一个空的DataFrame来存储数据
data = pd.DataFrame(columns=['Material_ID', 'Measurement_Time', 'Width', 'Thickness', 'Weight', 'Workshop_Temperature',
                             'Annealing_Type', 'Cooling_Type', 'Temperature'])

# 模拟每个物料的数据
for material_id in range(1, num_materials + 1):
    # 生成物料特征数据(宽度、厚度、重量、车间温度、退火类型、冷却类型)
    width = np.random.uniform(5, 20)  # 宽度范围在5到20之间
    thickness = np.random.uniform(1, 5)  # 厚度范围在1到5之间
    weight = np.random.uniform(10, 100)  # 重量范围在10到100之间
    workshop_temperature = np.random.uniform(20, 30)  # 车间温度范围在20到30之间
    annealing_type = np.random.choice(['O态', 'H2态'])  # 随机选择退火类型
    cooling_type = np.random.choice(['自然冷却', '单面风机', '双面风机'])  # 随机选择冷却类型
    
    # 模拟温度数据(指数衰减)
    initial_temperature = np.random.uniform(100, 200)  # 初始温度范围在100到200之间
    decay_rate = np.random.uniform(0.01, 0.1)  # 衰减速率范围在0.01到0.1之间
    temperature_data = initial_temperature * np.exp(-decay_rate * measurement_times)
    
    # 创建一个临时DataFrame来存储物料的数据
    material_data = pd.DataFrame({
        'Material_ID': [material_id] * num_measurements,
        'Measurement_Time': measurement_times,
        'Width': [width] * num_measurements,
        'Thickness': [thickness] * num_measurements,
        'Weight': [weight] * num_measurements,
        'Workshop_Temperature': [workshop_temperature] * num_measurements,
        'Annealing_Type': [annealing_type] * num_measurements,
        'Cooling_Type': [cooling_type] * num_measurements,
        'Temperature': temperature_data
    })
    
    # 将物料数据添加到总体数据中
    data = pd.concat([data, material_data], ignore_index=True)


data_1 = data.set_index(data.columns.drop(data.columns[[1, -1]]).tolist() + ['Measurement_Time'])

data.to_csv(r'data.csv', encoding="utf_8_sig")
【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月08日 0

暂无评论

推荐阅读
  gBkHYLY8jvYd   2023年12月09日   30   0   0 cii++数据
  gBkHYLY8jvYd   2023年12月10日   25   0   0 #include数组i++
X5zJxoD00Cah