Created
September 16, 2019 00:23
-
-
Save jd-lara/53d68de39a15f716b52048c2448330b5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##########Function Defs################### | |
function obtain_raw_data(base_dir::String, sha::String) | |
data_path = joinpath(base_dir,"raw_input_data") | |
ispath(data_path) && rm(data_path, recursive = true) | |
mkpath(data_path) | |
if Sys.iswindows() | |
POWERSYSTEMSTESTDATA_URL = "https://github.com/GridMod/RTS-GMLC/archive/$(sha).zip" | |
else | |
POWERSYSTEMSTESTDATA_URL = "https://github.com/GridMod/RTS-GMLC/archive/$(sha).tar.gz" | |
end | |
tempfilename= Base.download(POWERSYSTEMSTESTDATA_URL) | |
Sys.iswindows() && unzip_windows(tempfilename, base_dir) | |
Sys.islinux() && unzip_unix(tempfilename, base_dir) | |
Sys.isapple() && unzip_unix(tempfilename, base_dir) | |
mv(joinpath(base_dir, "RTS-GMLC-$(sha)"), data_path, force=true) | |
return data_path | |
end | |
function unzip_unix(filename, directory) | |
@assert success(`tar -xvf $filename -C $directory`) "Unable to extract $filename to $directory" | |
end | |
function unzip_windows(filename, directory) | |
home = (Base.VERSION < v"0.7-") ? JULIA_HOME : Sys.BINDIR | |
@assert success(`$home/7z x $filename -y -o$directory`) "Unable to extract $filename to $directory" | |
end | |
#### Data Get ######### | |
import PowerSystems | |
import Dates | |
const PSY = PowerSystems | |
sha = "367916992a15d5fccf6ce23220c4abae1c27de3d" | |
base_dir = "~/Desktop" | |
RTS_ROOT = obtain_raw_data(base_dir, sha) | |
RTS_DIR = joinpath(RTS_ROOT,"RTS_Data/SourceData/") | |
rts_data = PSY.PowerSystemTableData(RTS_DIR, | |
100.0,joinpath(RTS_ROOT,"RTS_Data/FormattedData/SIIP/user_descriptors.yaml")) | |
sys_DA = PSY.System(rts_data; forecast_resolution = Dates.Hour(1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment