Though my first Julia MATPOWER network data package for importing MATPOWER network data was successful, it has a significant issue. Miles Lubin pointed out that it requires Python to work. This does seem a rather silly dependency for a data import package to have. I decided to re-work the package using MAT.jl.
MATLAB side
I copied all caseformat .m
files from MATPOWER into a new directory:
cp case* mfiles
Next I wrote MATLAB code to run each .m
file and store the resulting caseformat data in a .mat
file. Here are the lines that do this for the 118-bus network:
networkData = case118;
save('matfiles/case118.mat', 'networkData')
I’m sure there is a more elegant way to loop through the .m
files in MATLAB, but this is a one-time operation, and I wanted to get back to Julia.
Julia side
With all the .mat
files in the matfiles
directory, the next step is to write a Julia function to import data for a user-selected network.
function loadcase(caseName::ASCIIString)
matread("$(dirname(@__FILE__))/$(caseName).mat")["networkData"]
end
Recall from my previous post that @__FILE__
refers to the path of the file in Julia’s package directory, not in the user’s working directory.
I included the function in a new package called “MatpowerCases”, which I pushed to Github. It is now possible for anyone to load caseformat transmission network data into Julia using:
Pkg.clone("https://github.com/kersulis/MatpowerCases.jl.git")
using MatpowerCases
networkData = loadcase("case118")
Update (2015-01-29): MatpowerCases is now a registered package. :)
Just got my first @JuliaLanguage package registered! Use Pkg.add("MatpowerCases") to install it.
https://t.co/2K9gmWkoSi
— Jonas Kersulis (@TonyKersulis) January 29, 2015