1+ import argparse
12import io
23from pathlib import Path
3- from typing import cast
44
55import polars as pl
66from cloudpathlib import S3Path
@@ -183,22 +183,24 @@ def map_electric_tariff(
183183 return
184184
185185
186- if __name__ == "__main__" :
187- data_path = S3Path ( "s3://data.sb/nrel/resstock/ " )
188- release_dir = data_path / "res_2024_amy2018_2"
189- state = "NY "
190- upgrade_id = "04"
191- metadata_path = (
192- release_dir
193- / "metadata "
194- / f"state= { state } "
195- / f"upgrade= { upgrade_id } "
196- / "metadata-sb.parquet "
186+ def main () :
187+ parser = argparse . ArgumentParser ( description = "Map electrical tariff. " )
188+ parser . add_argument (
189+ "--metadata_path" , required = True , help = "Base path for resstock data "
190+ )
191+ parser . add_argument ( "--state" , required = True , help = "State code (e.g. RI)" )
192+ parser . add_argument (
193+ "--electric_utility" , required = True , help = "Electric utility (e.g. Coned) "
194+ )
195+ parser . add_argument (
196+ "--SB_scenario_name" , required = True , help = "SB scenario name (e.g. default_1) "
197197 )
198+ args = parser .parse_args ()
198199
199200 #########################################################
200201 # For now, we will manually add the electric utility name column. Later on, the metadata parquet will be updated to include this column.
201202 # Assign first ~1/3 to Coned, next ~1/3 to National Grid, last ~1/3 to NYSEG.
203+ metadata_path = S3Path (args .metadata_path )
202204 metadata_df = pl .read_parquet (io .BytesIO (metadata_path .read_bytes ()))
203205 n = len (metadata_df )
204206 metadata_df = (
@@ -221,12 +223,16 @@ def map_electric_tariff(
221223
222224 map_electric_tariff (
223225 SB_metadata_path = temp_path ,
224- electric_utility = cast ( electric_utility , "Coned" ) ,
225- SB_scenario_name = cast ( SB_scenario , "default_1" ) ,
226- state = state ,
226+ electric_utility = args . electric_utility ,
227+ SB_scenario_name = args . SB_scenario_name ,
228+ state = args . state ,
227229 )
228230
229231 #########################################################
230232 # Remove the temp file that contains electric utility name column.
231233 temp_path .unlink ()
232234 #########################################################
235+
236+
237+ if __name__ == "__main__" :
238+ main ()
0 commit comments