Type2625 JSON Printer

The installer has been released.

You can download it from the download link at the end of this article. If you experience any problems, please leave a comment on this article.

A while ago, I improved TRNSYS Type65 and created a prototype of a component that outputs files in JSON format.

I tried it out for a while, but when I used it, I wanted to modify the component to output the JSON format in various ways. Specifically,

  • I wanted to output time steps in date and time format instead of hour.
  • I want to be able to switch between exponential and decimal notation for numbers.
  • I also want a plugin for settings.

etc. However, if I add more parameters to support these enhancements, it will no longer be compatible with the existing Type65.

Type2625 JSON Printer

For the reasons mentioned above, I decided to create a new dedicated component from scratch.

The main new features are as follows.

  • Supports both JSON and CSV formats.
  • Time steps can be either regular hours or date/time
  • Exponential and decimal notation supported

When installed, the “JSON Printer” folder will appear in the Direct Access Toolbar in Simulation Studio.

TRNSYS Type2625 JSON Printer

Switching between JSON and CSV

The output can be switched between JSON and CSV using the parameters. The following shows an example of the output.

JSON format

The data below is an excerpt of three time steps taken at 0.25h (15-minute) intervals. The date and time and the values can be seen at a glance.

{
    "1995-01-01T00:00:00.000":{
        "DryBulb":0.000000,
        "DewPoint":0.000000,
        "RH":0.000000,
        "TI":0.000000
    },
    "1995-01-01T00:15:00.000":{
        "DryBulb":21.250000,
        "DewPoint":18.350000,
        "RH":83.125000,
        "TI":0.000000
    },
    "1995-01-01T00:30:00.000":{
        "DryBulb":21.150000,
        "DewPoint":18.250000,
        "RH":83.375000,
        "TI":0.000000
    },

CSV format

This is also an excerpt of three steps. The date and time are expressed in decimal notation for easy reading. This format is more convenient for everyday use.

TIME,	DryBulb,	DewPoint,	RH,	TI,
1995/01/01 00:00:00,  0.000000,  0.000000,  0.000000,  0.000000,
1995/01/01 00:15:00,  21.250000,  18.350000,  83.125000,  0.000000,
1995/01/01 00:30:00,  21.150000,  18.250000,  83.375000,  0.000000,

The CSV format can be opened directly in Excel. As shown in the image below, it is loaded in the correct format, including the date and time.

Of course, you can switch to the usual exponential notation in the settings.

TIME,	DryBulb,	DewPoint,	RH,	TI,
+0.0000000000000000E+00,  +0.0000000000000000E+00,  +0.0000000000000000E+00,  +0.0000000000000000E+00,  +0.0000000000000000E+00,
+2.5000000000000000E-01,  +2.1250000000000000E+01,  +1.8349999999999998E+01,  +8.3125000000000000E+01,  +0.0000000000000000E+00,
+5.0000000000000000E-01,  +2.1149999999999999E+01,  +1.8250000000000000E+01,  +8.3375000000000000E+01,  +0.0000000000000000E+00,

JSON Printer Plug-in

A dedicated plug-in has been prepared for JSON Printer. It is possible to switch between file formats, date/time formats and value formats.

Output examples are also displayed according to the settings, so you can check the format. (Note: This is a sample for checking. As you don’t know what data will be coming in until the calculation is executed, the actual output will differ. )

TRNSYS Type2625 JSON Printer Plugi-in

Example of reading JSON

JSON format files are a standard format. They can be read and expanded using a simple program.

The following is an example of reading data using Python, Pandas, and Matplot, and drawing daily averages and graphs.

Reading JSON and calculating daily averages

The process of reading data using Pandas and calculating daily averages is as simple as three lines of code, as you can see.

import pandas as pd
df = pd.read_json(r"WeatherData_single.json", orient='index')
df.resample('d').mean()# Daily Average

Drawing graphs using the data you have read

Next, here is an example of drawing a chart using the data you have read in using matplot.

You can draw a chart by specifying only specific data as follows.

Download

Test Environment

It has been confirmed that the software works in the following environments.

  • Windows10 Pro(64bit, 24H2)
  • TRNSYS18.06.0002(64bit)
  • Microsoft Visual Studio Professional 2022
Pocket

Leave a Comment

Your email address will not be published. Required fields are marked *