#!/usr/bin/env python # coding: utf-8 # # Case I/O # AMS supprots multiple case formats. # Still, first import the `ams` library and configure the logger level. # In[1]: import os import ams import datetime # In[2]: print("Last run time:", datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")) print(f'ams:{ams.__version__}') # In[3]: ams.config_logger(stream_level=20) # ## Input # ### AMS Execel # In[4]: sp_xlsx = ams.load(ams.get_case('ieee14/ieee14_uced.xlsx'), setup=True, no_output=True,) sp_xlsx.summary() # ### AMS JSON # In[5]: sp_json = ams.load(ams.get_case('ieee14/ieee14.json'), setup=True, no_output=True,) sp_json.summary() # ### MATPOWER # In[6]: sp_mp = ams.load(ams.get_case('matpower/case14.m'), setup=True, no_output=True,) sp_mp.summary() # Note that AMS also supports PYPOWER format py-file. # ### PSS/E RAW # AMS also supports PSS/E RAW format for power flow analysis. # In[7]: sp_raw = ams.load(ams.get_case('ieee14/ieee14.raw'), setup=True, no_output=True,) sp_raw.summary() # ## Output # Vice versa, AMS supports multiple output formats. # In[8]: ams.io.xlsx.write(system=sp_xlsx, outfile='out.xlsx',) # In[9]: os.remove('out.xlsx') # Similarly, JSON output formats can be achieved by using `ams.io.json.write`.