glm


Nameglm JSON
Version 0.4.4 PyPI version JSON
download
home_pagehttps://github.com/NREL/glm
Summaryglm Python library
upload_time2023-04-11 18:30:24
maintainer
docs_urlNone
authorDheepak Krishnamurthy
requires_python
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # glm [![PyPI](https://img.shields.io/pypi/v/glm.svg)](https://pypi.python.org/pypi/glm) [![Python version compatibility status](https://img.shields.io/pypi/pyversions/glm.svg)](https://pypi.python.org/pypi/glm) [![Build Status](https://travis-ci.com/NREL/glm.svg?branch=master)](https://travis-ci.com/NREL/glm)

A fast [GridLAB-D](https://github.com/gridlab-d/gridlab-d) to JSON (and back) parser.

- Fast GLM to JSON converter.
    - Supports nested objects, schedules, definitions, directives, modules, includes and clock objects
- Fast JSON to GLM converter.
- Native support for Python, returns nested dictionaries.

![](./docs/img/python-example.png)

- Descriptive error messages when unable to parse a GridLAB-D model file.

![](./docs/img/error-example.png)

- Tested on all examples in the GridLAB-D source repository.

## Install

Go to the [latest releases page](https://github.com/NREL/glm/releases/latest) for the Python or the CLI for various operating systems.

### Python

You can pip install the package from PyPI or using the wheel (files with extension .whl) after downloading it or directly from the URL from the releases page.

The following installs the latest glm package for Windows, MacOSX or Linux from PyPI.
This will work for Python2 or Python3.

```
pip install glm
```

This also installs the `glm2json` and `json2glm` cli utilities.

## Documentation

You can use this from the command line as follows:

```
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": []
}
```

## Issues

Feel free to open an issue if something is not working as expected.


## Developer Guide

- Install [Nim](https://nim-lang.org/install.html)
- Run `nimble install -y` to generate binaries

If you want to install the latest version from GitHub, you can use the following commands.
The GitHub release is identical to that on 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
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NREL/glm",
    "name": "glm",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Dheepak Krishnamurthy",
    "author_email": "me@kdheepak.com",
    "download_url": "",
    "platform": null,
    "description": "# glm [![PyPI](https://img.shields.io/pypi/v/glm.svg)](https://pypi.python.org/pypi/glm) [![Python version compatibility status](https://img.shields.io/pypi/pyversions/glm.svg)](https://pypi.python.org/pypi/glm) [![Build Status](https://travis-ci.com/NREL/glm.svg?branch=master)](https://travis-ci.com/NREL/glm)\n\nA fast [GridLAB-D](https://github.com/gridlab-d/gridlab-d) to JSON (and back) parser.\n\n- Fast GLM to JSON converter.\n    - Supports nested objects, schedules, definitions, directives, modules, includes and clock objects\n- Fast JSON to GLM converter.\n- Native support for Python, returns nested dictionaries.\n\n![](./docs/img/python-example.png)\n\n- Descriptive error messages when unable to parse a GridLAB-D model file.\n\n![](./docs/img/error-example.png)\n\n- Tested on all examples in the GridLAB-D source repository.\n\n## Install\n\nGo to the [latest releases page](https://github.com/NREL/glm/releases/latest) for the Python or the CLI for various operating systems.\n\n### Python\n\nYou can pip install the package from PyPI or using the wheel (files with extension .whl) after downloading it or directly from the URL from the releases page.\n\nThe following installs the latest glm package for Windows, MacOSX or Linux from PyPI.\nThis will work for Python2 or Python3.\n\n```\npip install glm\n```\n\nThis also installs the `glm2json` and `json2glm` cli utilities.\n\n## Documentation\n\nYou can use this from the command line as follows:\n\n```\nUsage:\n  glm2json [required&optional-params]\nConvert from glm/json to json/glm\n  Options(opt-arg sep :|=|spc):\n  -h, --help                            write this help to stdout\n  --version           bool    false     write version to stdout\n  -p=, --pathToFile=  string  REQUIRED  set pathToFile\n  --pretty            bool    false     set pretty\n```\n\n```\n./glm2json --path-to-file ./tests/data/4node.glm --pretty                                                                                                                           \ue0b2 \u2714 \ue0b2 10397 \ue0b2 18:20:47\n{\n  \"clock\": {\n    \"timestamp\": \"2000-01-01 0:00:00\",\n    \"timezone\": \"EST+5EDT\"\n  },\n  \"includes\": [],\n  \"objects\": [\n    {\n      \"name\": \"overhead_line_conductor:100\",\n      \"attributes\": {\n        \"name\": \"PhaseCond\",\n        \"geometric_mean_radius\": \"0.0244 ft\",\n        \"resistance\": \"0.306\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"overhead_line_conductor:101\",\n      \"attributes\": {\n        \"name\": \"NeutralCond\",\n        \"geometric_mean_radius\": \"0.00814 ft\",\n        \"resistance\": \"0.592\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"line_spacing:200\",\n      \"attributes\": {\n        \"name\": \"LineSpacing\",\n        \"distance_AB\": \"2.5\",\n        \"distance_BC\": \"4.5\",\n        \"distance_AC\": \"7.0\",\n        \"distance_AN\": \"5.656\",\n        \"distance_BN\": \"4.272\",\n        \"distance_CN\": \"5.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"line_configuration:1\",\n      \"attributes\": {\n        \"name\": \"LineConf\",\n        \"conductor_A\": \"PhaseCond\",\n        \"conductor_B\": \"PhaseCond\",\n        \"conductor_C\": \"PhaseCond\",\n        \"conductor_N\": \"NeutralCond\",\n        \"spacing\": \"LineSpacing\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"overhead_line\",\n      \"attributes\": {\n        \"name\": \"Line1\",\n        \"phases\": \"ABCN\",\n        \"from\": \"Node1\",\n        \"to\": \"Node2\",\n        \"length\": \"2000 ft\",\n        \"configuration\": \"LineConf\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"overhead_line\",\n      \"attributes\": {\n        \"name\": \"Line2\",\n        \"phases\": \"ABCN\",\n        \"from\": \"Node3\",\n        \"to\": \"Node4\",\n        \"length\": \"2500 ft\",\n        \"configuration\": \"LineConf\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"node\",\n      \"attributes\": {\n        \"name\": \"Node1\",\n        \"phases\": \"ABCN\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"node\",\n      \"attributes\": {\n        \"name\": \"Node2\",\n        \"phases\": \"ABCN\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"node\",\n      \"attributes\": {\n        \"name\": \"Node3\",\n        \"phases\": \"ABCN\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"node\",\n      \"attributes\": {\n        \"name\": \"Node4\",\n        \"phases\": \"ABCN\",\n        \"nominal_voltage\": \"124.0\"\n      },\n      \"children\": []\n    },\n    {\n      \"name\": \"tape.recorder\",\n      \"attributes\": {\n        \"interval\": \"4.0\",\n        \"parent\": \"network_node2\",\n        \"limit\": \"21600\",\n        \"file\": \"./csv_output/network_node2.csv\",\n        \"property\": \"measured_real_power, measured_real_energy, voltage_A, voltage_B, voltage_C\"\n      },\n      \"children\": []\n    }\n  ],\n  \"modules\": [\n    {\n      \"name\": \"powerflow\",\n      \"attributes\": {}\n    },\n    {\n      \"name\": \"tape\",\n      \"attributes\": {}\n    }\n  ],\n  \"directives\": [],\n  \"definitions\": [],\n  \"schedules\": []\n}\n```\n\n## Issues\n\nFeel free to open an issue if something is not working as expected.\n\n\n## Developer Guide\n\n- Install [Nim](https://nim-lang.org/install.html)\n- Run `nimble install -y` to generate binaries\n\nIf you want to install the latest version from GitHub, you can use the following commands.\nThe GitHub release is identical to that on PyPI.\n\n**Windows**\n\n```\nexport VERSION=$(curl -s \"https://github.com/NREL/glm/releases/latest\" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')\npip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#\"v\"}-py2.py3-none-win_amd64.whl\n```\n\n**OSX**\n\n```\nexport VERSION=$(curl -s \"https://github.com/NREL/glm/releases/latest\" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')\npip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#\"v\"}-py2.py3-none-macosx_10_7_x86_64.whl\n```\n\n**Linux**\n\n```\nexport VERSION=$(curl -s \"https://github.com/NREL/glm/releases/latest\" | grep -o 'tag/[v.0-9]*' | awk -F/ '{print $2}')\npip install https://github.com/NREL/glm/releases/download/$VERSION/glm-${VERSION#\"v\"}-py2.py3-none-manylinux1_x86_64.whl\n```\n\n\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "glm Python library",
    "version": "0.4.4",
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "658b5bf2d33961f3b865fb830877210032b1634a6c2820da29eb451418216642",
                "md5": "b1de0ce11e7ed391d55700ead16f1348",
                "sha256": "5a1f083a32ca7a340c71b0c11666bce9182d0107e297307b95e413b2596cec2c"
            },
            "downloads": -1,
            "filename": "glm-0.4.4-py2.py3-none-macosx_10_7_x86_64.whl",
            "has_sig": false,
            "md5_digest": "b1de0ce11e7ed391d55700ead16f1348",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 90512,
            "upload_time": "2023-04-11T18:30:24",
            "upload_time_iso_8601": "2023-04-11T18:30:24.170099Z",
            "url": "https://files.pythonhosted.org/packages/65/8b/5bf2d33961f3b865fb830877210032b1634a6c2820da29eb451418216642/glm-0.4.4-py2.py3-none-macosx_10_7_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3afa77191d678b296a99fc6d26a2f0c15be1ca07267dc7ba483438cbde2ab3d",
                "md5": "58286f6d883b04b6670b53739cbf618a",
                "sha256": "a77753b5a781a9afe0cb196b7a1e8f156d94c0829da90d8947d77a674613bc7a"
            },
            "downloads": -1,
            "filename": "glm-0.4.4-py2.py3-none-manylinux1_x86_64.whl",
            "has_sig": false,
            "md5_digest": "58286f6d883b04b6670b53739cbf618a",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 97177,
            "upload_time": "2023-04-11T18:30:26",
            "upload_time_iso_8601": "2023-04-11T18:30:26.194484Z",
            "url": "https://files.pythonhosted.org/packages/b3/af/a77191d678b296a99fc6d26a2f0c15be1ca07267dc7ba483438cbde2ab3d/glm-0.4.4-py2.py3-none-manylinux1_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4905f47bf9692e765ee1abb0d23d76bc4ca8ca1c3e7ce132994829616bcc74cc",
                "md5": "85ff4fb2d0e2f4de77ca3c73bcf1cd2b",
                "sha256": "73e0f1b68cddbe98ad3476e91f3867092d5da848da64df08622d00944bfe1ad1"
            },
            "downloads": -1,
            "filename": "glm-0.4.4-py2.py3-none-win_amd64.whl",
            "has_sig": false,
            "md5_digest": "85ff4fb2d0e2f4de77ca3c73bcf1cd2b",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": null,
            "size": 156749,
            "upload_time": "2023-04-11T18:30:27",
            "upload_time_iso_8601": "2023-04-11T18:30:27.879243Z",
            "url": "https://files.pythonhosted.org/packages/49/05/f47bf9692e765ee1abb0d23d76bc4ca8ca1c3e7ce132994829616bcc74cc/glm-0.4.4-py2.py3-none-win_amd64.whl",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-04-11 18:30:24",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "NREL",
    "github_project": "glm",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "glm"
}
        
Elapsed time: 4.03712s