python计算5分钟粒度车公里数

 昨天写了下计算5分钟粒度车公里数的代码。

对于发车、到达时间都在5分钟粒度内,直接取两站间距;

对于发车时间小于5分钟间隔左届,以及到达时刻大于右届的,按比例计算。

首先,写一个获得时间粒度左右届的函数,对想要计算的时间进行切片。

代码中,周期和频率可以根据需要填写。

用&对条件进行合并,此处不能用and;

对3种不同情况需要分别提取符合条件的数据,进行计算。

import pandas as pd
import numpy as np
def get_different_time(data):
    time = pd.date_range(start="20211201060000", periods=205, freq="5T")  # 得到时间序列
    for time_sec in range(len(time) - 1):
        low = time[time_sec]  # 开始时间
        high = time[time_sec + 1]  # 终止时间

        low_text = str(low)[-8:-3]  # 对时间切片
        high_text = str(high)[-8:-3]

        data1 = data[(data["Departure_TIME"] >= low) & (data["Arrive_TIME"] <= high)]  # 读取指定时间间隔内的数据
        data2 = data[(data["Departure_TIME"] >= low) & (data["Departure_TIME"] < high) & (data[&#
  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
计算电动公里加速需要知道以下几个参: - 辆质量 - 发动机最大功率 - 发动机最大扭矩 - 变速箱传动比 - 轮半径 - 辆空气阻力系 - 辆滚动阻力系 假设我们已经知道了上述参,可以使用如下的 Python 代码计算电动公里加速时间: ```python import math # 辆质量(kg) mass = 1500 # 发动机最大功率(kW) power = 50 # 发动机最大扭矩(Nm) torque = 150 # 变速箱传动比 gear_ratio = 6 # 轮半径(m) wheel_radius = 0.3 # 空气阻力系 air_resistance_coefficient = 0.3 # 滚动阻力系 rolling_resistance_coefficient = 0.01 # 计算辆阻力 def calculate_resistance(speed): # 空气阻力 air_resistance = 0.5 * 1.2 * air_resistance_coefficient * 3.14 * wheel_radius * wheel_radius * speed * speed # 滚动阻力 rolling_resistance = rolling_resistance_coefficient * mass * 9.8 resistance = air_resistance + rolling_resistance return resistance # 计算公里加速时间 def calculate_acceleration_time(): # 转换单位 power = power * 1000 torque = torque * gear_ratio # 计算轮转速 wheel_speed = 60 * power / (2 * 3.14 * torque * wheel_radius) # 计算最大速度 max_speed = 3.6 * wheel_speed * gear_ratio # 计算加速度 acceleration = torque * gear_ratio / mass # 计算公里加速时间 time = 100 / (3.6 * acceleration) # 计算公里平均速度 average_speed = 100 / time # 计算公里耗电量(假设电池能量密度为150 Wh/kg) energy_consumption = mass * acceleration * wheel_radius * 0.0015 # 计算辆阻力 resistance = calculate_resistance(max_speed) # 计算公里续航里程 mileage = 100 / (energy_consumption - resistance * max_speed / 3600) return time, average_speed, mileage # 测试 time, average_speed, mileage = calculate_acceleration_time() print("百公里加速时间:%.2f 秒" % time) print("百公里平均速度:%.2f km/h" % average_speed) print("百公里续航里程:%.2f km" % mileage) ``` 上述代码中,我们定义了两个函 `calculate_resistance()` 和 `calculate_acceleration_time()`,其中 `calculate_resistance()` 函用来计算辆阻力,`calculate_acceleration_time()` 函用来计算公里加速时间、百公里平均速度和百公里续航里程。在 `calculate_acceleration_time()` 函中,我们先将发动机最大功率和最大扭矩转换成标准单位,然后根据轮半径和传动比计算轮转速,根据轮转速和传动比计算最大速度,根据发动机最大扭矩和质量计算加速度,根据加速度计算公里加速时间,根据百公里加速时间计算公里平均速度,根据能量密度和加速度计算公里耗电量,根据最大速度计算辆阻力,最后根据能量密度、辆阻力和百公里平均速度计算公里续航里程。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值