glm python库

glm的Python项目详细描述


glmPyPIPython version compatibility statusBuild Status

一个快速的GridLAB-D到json(和后面的)解析器。

  • 快速glm到json的转换。
    • 支持嵌套对象、计划、定义、指令、模块、包含和时钟对象
  • 快速json到glm的转换。
  • 对python的本机支持,返回嵌套字典。

  • 无法分析gridlab-d模型文件时的描述性错误消息。

  • 在gridlab-d源代码库中的所有示例上进行了测试。

安装

转到python的latest releases page或各种操作系统的cli。

Python

您可以从pypi安装软件包,也可以在下载后使用wheel(扩展名为.whl的文件)或直接从releases页面的url安装软件包。

下面从pypi安装最新的用于windows、macosx或linux的glm包。 这对Python2或Python3有效。

pip install glm

这还会安装glm2jsonjson2glmcli实用程序。

cli

如果要使用cli,可以从操作系统的releases页面解压缩文件。 文件夹中将有两个可执行文件,glm2jsonjson2glm。 在windows上,您可能需要重命名文件,以便在可执行文件的末尾添加.exe,以便在windows cmd提示符下运行它。 您将能够在git bash提示符下运行它,而无需重命名它。 您可以使用以下命令下载和解压缩相应操作系统上的文件。

windows

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
curl -LO "https://github.com/NREL/glm/releases/download/$VERSION/glm-windows-amd64.zip"
unzip glm-windows-amd64.zip

osx

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
curl -LO "https://github.com/NREL/glm/releases/download/$VERSION/glm-osx-amd64.tar.xz"
tar -zxvf glm-osx-amd64.tar.xz

linux

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
curl -LO "https://github.com/NREL/glm/releases/download/$VERSION/glm-linux-amd64.tar.xz"
tar -zxvf glm-linux-amd64.tar.xz

压缩存档的内容将包含一个命令行可执行文件和一个可以导入python的模块。

文档

您可以在命令行中使用此命令,如下所示:

Usage:
  glm2json [required&optional-params]
Convert from glm/json to json/glm
  Options(opt-arg sep :|=|spc):
  -h, --help                            write this help to stdout
  --version           bool    false     write version to stdout
  -p=, --pathToFile=  string  REQUIRED  set pathToFile
  --pretty            bool    false     set pretty
./glm2json --path-to-file ./tests/data/4node.glm --pretty                                                                                                                            ✔  10397  18:20:47
{
  "clock": {
    "timestamp": "2000-01-01 0:00:00",
    "timezone": "EST+5EDT"
  },
  "includes": [],
  "objects": [
    {
      "name": "overhead_line_conductor:100",
      "attributes": {
        "name": "PhaseCond",
        "geometric_mean_radius": "0.0244 ft",
        "resistance": "0.306"
      },
      "children": []
    },
    {
      "name": "overhead_line_conductor:101",
      "attributes": {
        "name": "NeutralCond",
        "geometric_mean_radius": "0.00814 ft",
        "resistance": "0.592"
      },
      "children": []
    },
    {
      "name": "line_spacing:200",
      "attributes": {
        "name": "LineSpacing",
        "distance_AB": "2.5",
        "distance_BC": "4.5",
        "distance_AC": "7.0",
        "distance_AN": "5.656",
        "distance_BN": "4.272",
        "distance_CN": "5.0"
      },
      "children": []
    },
    {
      "name": "line_configuration:1",
      "attributes": {
        "name": "LineConf",
        "conductor_A": "PhaseCond",
        "conductor_B": "PhaseCond",
        "conductor_C": "PhaseCond",
        "conductor_N": "NeutralCond",
        "spacing": "LineSpacing"
      },
      "children": []
    },
    {
      "name": "overhead_line",
      "attributes": {
        "name": "Line1",
        "phases": "ABCN",
        "from": "Node1",
        "to": "Node2",
        "length": "2000 ft",
        "configuration": "LineConf",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "overhead_line",
      "attributes": {
        "name": "Line2",
        "phases": "ABCN",
        "from": "Node3",
        "to": "Node4",
        "length": "2500 ft",
        "configuration": "LineConf",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "node",
      "attributes": {
        "name": "Node1",
        "phases": "ABCN",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "node",
      "attributes": {
        "name": "Node2",
        "phases": "ABCN",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "node",
      "attributes": {
        "name": "Node3",
        "phases": "ABCN",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "node",
      "attributes": {
        "name": "Node4",
        "phases": "ABCN",
        "nominal_voltage": "124.0"
      },
      "children": []
    },
    {
      "name": "tape.recorder",
      "attributes": {
        "interval": "4.0",
        "parent": "network_node2",
        "limit": "21600",
        "file": "./csv_output/network_node2.csv",
        "property": "measured_real_power, measured_real_energy, voltage_A, voltage_B, voltage_C"
      },
      "children": []
    }
  ],
  "modules": [
    {
      "name": "powerflow",
      "attributes": {}
    },
    {
      "name": "tape",
      "attributes": {}
    }
  ],
  "directives": [],
  "definitions": [],
  "schedules": []
}

问题

如果某个问题没有按预期工作,请随时打开问题。

开发人员指南

  • 安装Nim
  • 运行nimble install -y生成二进制文件

如果要从github安装最新版本,可以使用以下命令。 github版本与pypi上的版本相同。

windows

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
pip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#"v"}-py2.py3-none-win_amd64.whl

osx

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
pip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#"v"}-py2.py3-none-macosx_10_7_x86_64.whl

linux

export VERSION=$(curl -s "https://github.com/NREL/glm/releases/latest" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')
pip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#"v"}-py2.py3-none-manylinux1_x86_64.whl

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
如何下载多个。java中的PDF文件   linux Java打开文件,形成实际用户主页~/   java如何在时间线内维护TableView选择?   java Hibernate注释@Where vs@WhereJoinTable   Java读/写访问异常FileNotFoundException(访问被拒绝)   继承在Java中是否可以扩展最后一个类?   Android HttpClient使用java使应用程序崩溃。lang.OutOfMemoryError:pthread_create   java为什么即使我在proguardproject中添加了jar文件,也会出现这种错误。txt?   如果添加JButton,swing Java FocusListener和KeyListener将无法工作   java使用solrj检索json格式的SolrDocument   使用Microsoft Visual Studio代码进行Java编程   java NoClassDefFoundError:org/apache/log4j/Logger   哈希集中包含相等对象的java   java中的参数化构造函数是否需要有一个主体?   java类似于NetBeans不必要的代码检测器   Java实践问题   java Blackberry“[projectname].调试文件丢失”和“I/O错误:找不到程序”jar