diff --git a/prereise/gather/demanddata/bldg_electrification/const.py b/prereise/gather/demanddata/bldg_electrification/const.py index ddccd74de..d8a91b66e 100644 --- a/prereise/gather/demanddata/bldg_electrification/const.py +++ b/prereise/gather/demanddata/bldg_electrification/const.py @@ -73,8 +73,7 @@ ) # Reference temperatures for computations -temp_ref_res = 18.3 -temp_ref_com = 16.7 +temp_ref = {"res": 18.3, "com": 16.7} # Unit conversions conv_kw_to_mw = 1 / 1000 diff --git a/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_com.csv b/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_com.csv index 38cd818fb..7ba4ff069 100644 --- a/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_com.csv +++ b/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_com.csv @@ -1,13 +1,13 @@ month,US,AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY -10-Jan,517573959,4435249,2278289,4234071,6609838,28436614,10013272,6995602,1795047,2913970,5731499,11576031,170068,2375767,36369664,15564333,10238301,6971751,7422846,3731126,910486,11410111,12888873,27234731,17852992,3519578,12174380,3299734,5824829,4150074,1547204,29702791,4445619,42754473,10059937,1879044,28738381,8662061,4162518,24712747,1970300,3657499,2138294,10178155,28244769,6874273,403393,11757506,6969677,3874232,15852619,1857267 -10-Feb,457170783,3998672,1699643,3766384,6123485,27228509,9059232,6147336,1708976,2827899,5652687,10059937,148291,1791936,29370951,13398040,8262816,5593578,6918864,3624315,764269,9923053,11999127,24445201,14238010,3457358,10479922,2801974,5007673,3376472,1270325,23573084,4234071,39203785,9240707,1620831,28848303,8038824,3073668,23052510,1662311,3483283,1673718,9540400,25099548,5031524,369172,10994274,5747054,3661647,12393187,1491206 -10-Mar,349658771,3511282,1857267,3485357,5327069,21843368,7022564,4685166,1165588,1910154,5528247,6983158,151402,1638460,24190099,7825202,5964824,4305624,4199850,3047743,628422,7308776,8109340,18426453,9855648,2869379,7731872,2148664,4583540,3165961,993446,18108094,3431433,30841417,5343661,1186328,18596521,6681391,2839306,17081464,1253733,2371619,1303509,7520324,22687486,4515098,268583,7095154,5005599,2861083,8887090,1318027 -10-Apr,223343875,2101999,1369877,2855898,3161813,21965734,4825161,2687904,750788,1160403,5076115,3092334,170068,1267214,12320597,3417952,2962709,2036668,1654015,2135183,466650,4173925,5310477,13331672,5632984,1424838,3812012,1582462,2571760,2762568,618052,12464740,2642276,20462084,2790567,583831,10147045,3921934,2565538,9153599,690642,1509872,684420,3684461,14701549,3878380,197030,4189480,4593910,1655052,5085448,1043222 -10-May,167116698,1282769,851377,2412062,2166293,19811885,3292475,2340509,630496,909449,4094076,2517836,145180,934337,8757465,2903600,2176663,1131367,1251659,1684088,322507,3326696,3639870,7348182,4418657,1070184,2477393,1265140,1481873,2206736,401319,10109713,1580388,17429896,2477393,482205,5908826,1993114,1983781,5986601,451095,1310768,556869,2328065,11778246,2571760,125477,2981375,3675128,1571055,3768458,793305 -10-Jun,134511344,1144848,659532,2066741,2026298,16655257,1693421,1744234,561017,795379,3738385,2204662,155550,661606,6813090,2187033,1969263,988261,1039074,1553426,236436,2692052,2446283,5397585,2913970,1026630,1828231,792268,1185291,1928820,305915,8339554,1153144,13361745,2050149,283101,4766052,1582462,1530612,4618798,284138,1180106,340136,2116517,11386260,1863489,89182,2759457,2967894,983076,2940932,505019 -10-Jul,124629771,1043222,637755,1873859,1931931,15544630,1623942,1786751,619089,781898,3621204,2188070,161772,502945,6425252,2118591,1837564,1014186,1045296,1451800,222955,2055334,2110295,4740127,2441098,974780,1744234,668865,1124108,1672681,251991,7980752,836859,13783804,1997262,254065,4222664,1476688,1108553,4146963,227103,1239215,320433,1947486,10619917,1179069,70516,2859009,2246142,1083665,2477393,337025 -10-Aug,131359901,1076406,710345,1733864,2034594,15407746,1830305,2019039,664717,787083,3607723,2181848,155550,473909,6686576,2107184,1760826,991372,1103368,1486021,226066,3202256,2919155,4651982,2695163,985150,1859341,660569,861747,1643645,275842,10723617,807823,15120497,2169404,297619,4552430,1364692,996557,4529616,301767,1256844,293471,1788825,10525550,1049444,73627,2581093,2202588,1152107,2473245,300730 -10-Sep,137862928,1019371,858636,1831342,2157997,19230128,1781566,1853119,590053,801601,3542392,2171478,139995,642940,7722539,2736643,1965115,843081,1247511,1563796,231251,2890119,2363323,5232702,2580056,974780,1972374,687531,912560,1685125,279990,9908535,820267,13435372,2523021,370209,5199518,1430023,985150,4683092,402356,1292102,376431,2034594,11072049,1151070,81923,3010411,2119628,1110627,2997967,345321 -10-Oct,192194469,1222623,1291065,2057408,2585241,21329016,3272772,2314584,843081,1220549,4033930,2941969,146217,936411,11286708,4640575,2928488,1111664,1752530,1683051,430355,4582503,3736311,8393478,4961008,1215364,3095445,1241289,1391654,1963041,551684,13105606,1035963,19797367,3232329,563091,8373775,1525427,1804380,8639247,566202,1533723,586942,2906711,11901649,2065704,166957,4168740,4082669,1528538,4786792,659532 -10-Nov,297303752,2534428,1798158,3061224,2955450,23223615,7160485,3673054,1208105,1855193,4695536,5190185,144143,1893562,21329016,7346108,5236850,2933673,3242699,2267919,657458,6287331,6814127,13926910,9683506,1554463,5840384,2757383,3545503,2611166,853451,15188939,1817861,27710714,5382030,1283806,14930726,2113406,3287290,14314748,1067073,2178737,1294176,4635390,15691884,4442508,250954,6661688,6344366,2352953,8734651,1337730 -10-Dec,484663727,4702795,2497096,3749792,4639538,26495350,8216151,5914011,2108221,3269661,6744648,11270116,154513,2472208,34090338,14445410,8280445,5053301,7302554,3780902,948855,12203416,12381780,24855853,16017502,2889082,10442590,3311141,4685166,3399286,1366766,28990372,3278994,44121239,11038865,1879044,27909818,4578355,3916749,26022478,1969263,3998672,1864526,9591213,22073582,5261738,375394,12404594,7279740,3995561,14847766,1578314 +1,517573959,4435249,2278289,4234071,6609838,28436614,10013272,6995602,1795047,2913970,5731499,11576031,170068,2375767,36369664,15564333,10238301,6971751,7422846,3731126,910486,11410111,12888873,27234731,17852992,3519578,12174380,3299734,5824829,4150074,1547204,29702791,4445619,42754473,10059937,1879044,28738381,8662061,4162518,24712747,1970300,3657499,2138294,10178155,28244769,6874273,403393,11757506,6969677,3874232,15852619,1857267 +2,457170783,3998672,1699643,3766384,6123485,27228509,9059232,6147336,1708976,2827899,5652687,10059937,148291,1791936,29370951,13398040,8262816,5593578,6918864,3624315,764269,9923053,11999127,24445201,14238010,3457358,10479922,2801974,5007673,3376472,1270325,23573084,4234071,39203785,9240707,1620831,28848303,8038824,3073668,23052510,1662311,3483283,1673718,9540400,25099548,5031524,369172,10994274,5747054,3661647,12393187,1491206 +3,349658771,3511282,1857267,3485357,5327069,21843368,7022564,4685166,1165588,1910154,5528247,6983158,151402,1638460,24190099,7825202,5964824,4305624,4199850,3047743,628422,7308776,8109340,18426453,9855648,2869379,7731872,2148664,4583540,3165961,993446,18108094,3431433,30841417,5343661,1186328,18596521,6681391,2839306,17081464,1253733,2371619,1303509,7520324,22687486,4515098,268583,7095154,5005599,2861083,8887090,1318027 +4,223343875,2101999,1369877,2855898,3161813,21965734,4825161,2687904,750788,1160403,5076115,3092334,170068,1267214,12320597,3417952,2962709,2036668,1654015,2135183,466650,4173925,5310477,13331672,5632984,1424838,3812012,1582462,2571760,2762568,618052,12464740,2642276,20462084,2790567,583831,10147045,3921934,2565538,9153599,690642,1509872,684420,3684461,14701549,3878380,197030,4189480,4593910,1655052,5085448,1043222 +5,167116698,1282769,851377,2412062,2166293,19811885,3292475,2340509,630496,909449,4094076,2517836,145180,934337,8757465,2903600,2176663,1131367,1251659,1684088,322507,3326696,3639870,7348182,4418657,1070184,2477393,1265140,1481873,2206736,401319,10109713,1580388,17429896,2477393,482205,5908826,1993114,1983781,5986601,451095,1310768,556869,2328065,11778246,2571760,125477,2981375,3675128,1571055,3768458,793305 +6,134511344,1144848,659532,2066741,2026298,16655257,1693421,1744234,561017,795379,3738385,2204662,155550,661606,6813090,2187033,1969263,988261,1039074,1553426,236436,2692052,2446283,5397585,2913970,1026630,1828231,792268,1185291,1928820,305915,8339554,1153144,13361745,2050149,283101,4766052,1582462,1530612,4618798,284138,1180106,340136,2116517,11386260,1863489,89182,2759457,2967894,983076,2940932,505019 +7,124629771,1043222,637755,1873859,1931931,15544630,1623942,1786751,619089,781898,3621204,2188070,161772,502945,6425252,2118591,1837564,1014186,1045296,1451800,222955,2055334,2110295,4740127,2441098,974780,1744234,668865,1124108,1672681,251991,7980752,836859,13783804,1997262,254065,4222664,1476688,1108553,4146963,227103,1239215,320433,1947486,10619917,1179069,70516,2859009,2246142,1083665,2477393,337025 +8,131359901,1076406,710345,1733864,2034594,15407746,1830305,2019039,664717,787083,3607723,2181848,155550,473909,6686576,2107184,1760826,991372,1103368,1486021,226066,3202256,2919155,4651982,2695163,985150,1859341,660569,861747,1643645,275842,10723617,807823,15120497,2169404,297619,4552430,1364692,996557,4529616,301767,1256844,293471,1788825,10525550,1049444,73627,2581093,2202588,1152107,2473245,300730 +9,137862928,1019371,858636,1831342,2157997,19230128,1781566,1853119,590053,801601,3542392,2171478,139995,642940,7722539,2736643,1965115,843081,1247511,1563796,231251,2890119,2363323,5232702,2580056,974780,1972374,687531,912560,1685125,279990,9908535,820267,13435372,2523021,370209,5199518,1430023,985150,4683092,402356,1292102,376431,2034594,11072049,1151070,81923,3010411,2119628,1110627,2997967,345321 +10,192194469,1222623,1291065,2057408,2585241,21329016,3272772,2314584,843081,1220549,4033930,2941969,146217,936411,11286708,4640575,2928488,1111664,1752530,1683051,430355,4582503,3736311,8393478,4961008,1215364,3095445,1241289,1391654,1963041,551684,13105606,1035963,19797367,3232329,563091,8373775,1525427,1804380,8639247,566202,1533723,586942,2906711,11901649,2065704,166957,4168740,4082669,1528538,4786792,659532 +11,297303752,2534428,1798158,3061224,2955450,23223615,7160485,3673054,1208105,1855193,4695536,5190185,144143,1893562,21329016,7346108,5236850,2933673,3242699,2267919,657458,6287331,6814127,13926910,9683506,1554463,5840384,2757383,3545503,2611166,853451,15188939,1817861,27710714,5382030,1283806,14930726,2113406,3287290,14314748,1067073,2178737,1294176,4635390,15691884,4442508,250954,6661688,6344366,2352953,8734651,1337730 +12,484663727,4702795,2497096,3749792,4639538,26495350,8216151,5914011,2108221,3269661,6744648,11270116,154513,2472208,34090338,14445410,8280445,5053301,7302554,3780902,948855,12203416,12381780,24855853,16017502,2889082,10442590,3311141,4685166,3399286,1366766,28990372,3278994,44121239,11038865,1879044,27909818,4578355,3916749,26022478,1969263,3998672,1864526,9591213,22073582,5261738,375394,12404594,7279740,3995561,14847766,1578314 diff --git a/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_res.csv b/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_res.csv index 33dc25f9f..6f4ec945d 100644 --- a/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_res.csv +++ b/prereise/gather/demanddata/bldg_electrification/data/ng_monthly_mmbtu_2010_res.csv @@ -1,13 +1,13 @@ month,US,AL,AK,AZ,AR,CA,CO,CT,DE,DC,FL,GA,HI,ID,IL,IN,IA,KS,KY,LA,ME,MD,MA,MI,MN,MS,MO,MT,NE,NV,NH,NJ,NM,NY,NC,ND,OH,OK,OR,PA,RI,SC,SD,TN,TX,UT,VT,VA,WA,WV,WI,WY -10-Jan,967111385,9543511,2831010,7719428,8578064,73280642,23560640,9027085,2278289,2925377,3232329,30627795,53924,3928156,86153960,32019449,15853656,16307862,12357929,9985273,227103,18017875,23997217,59935489,26775340,6204371,24996885,3639870,8163264,7747427,1353285,45146832,6949974,73867584,17876843,2101999,59388990,16832584,6900198,45310678,3254106,7806536,2708644,17314789,51706894,12375558,557906,19630410,11425666,5754313,26451796,2426580 -10-Feb,824185823,8049194,2129998,6237555,7598099,60784792,21396421,7779574,2013854,2599759,2685830,25890779,44591,3074705,71091535,25450054,12364151,12905465,11405963,8451550,192882,15311305,19372197,51099212,20460010,5626762,20941178,3094408,7101376,6145262,1071221,38838761,6529989,67036865,15252196,1781566,53875261,13827358,5074041,40881651,2928488,6342292,2197403,15244937,49039730,8629914,512278,17609297,9007382,5188111,20197649,1818898 -10-Mar,600674991,6856644,2199477,5355068,6497842,53948888,16100462,5575949,1357433,1399950,2883897,16907248,45628,2729384,55367504,15131904,8594656,10020531,6510286,7222705,149328,9223078,15062425,37957311,13239379,4301476,14898579,2329102,6628504,4916417,808860,23825075,5218184,49468011,7876015,1228845,35292221,10946572,4388584,28763269,1969263,4084743,1554463,11539736,35976641,7918532,370209,9477143,8242076,3080927,13681141,1552389 -10-Apr,324758327,3097519,1632238,3146258,2850713,46362196,11223451,3246847,606645,562054,1782603,5781275,51850,2123776,27693085,6371328,3646092,4469470,1916376,2849676,110959,3900157,8971087,25456276,6205408,1403061,5820681,1818898,3273809,3375435,481168,11424629,3525800,27902559,2008669,584868,15924172,5314625,4092002,13678030,888709,1191513,851377,4170814,14898579,6802720,279990,3644018,7122116,1551352,7450845,1223660 -10-May,204820981,1185291,981002,2044964,1071221,34306034,7219594,2087481,360876,334951,1172847,4188443,43554,1452837,15790399,4557615,2703459,2056371,1080554,1517131,64294,2585241,5724240,14002611,5121743,681309,3138999,1385432,1537871,2370582,310063,8392441,1885266,18212831,1298324,463539,9895054,2292807,2904637,8582212,656421,552721,651236,1522316,7812758,4271403,160735,2208810,5158038,836859,5040857,941596 -10-Jun,138997406,873154,691679,1470466,803675,27814414,3268624,1228845,236436,271694,797453,3438692,43554,849303,10167785,2757383,1463207,1572092,929152,1379210,36295,1831342,4121038,8181930,3172183,662643,2344657,844118,1079517,1752530,206363,5456694,1120997,11119751,976854,225029,6019785,1540982,2008669,4980711,432429,505019,269620,1250622,6338144,2768790,98515,1834453,3513356,413763,3321511,512278 -10-Jul,115425359,760121,653310,1162477,661606,24317650,2947154,1023519,202215,247843,724863,3340177,44591,455243,8091711,2501244,1243363,1192550,876265,1257881,27999,1710013,3462543,6148373,2456653,605608,1698606,483242,768417,1294176,164883,4676870,867969,9091379,915671,178364,5411066,1241289,1186328,4124149,344284,498797,217770,1074332,6089264,1813713,75701,1649867,2260660,362950,2518873,298656 -10-Aug,111035738,734196,629459,1071221,648125,22902145,3194997,1041148,199104,232288,693753,3393064,42517,435540,7908162,2586278,1147959,1046333,871080,1194624,29036,1413431,4501617,5555209,2577982,562054,1682014,378505,731085,1142774,186660,4967230,847229,8540732,937448,206363,4965156,1100257,968558,4136593,484279,439688,203252,991372,5403807,1523353,66368,1321138,1998299,401319,2563464,236436 -10-Sep,121639063,682346,799527,1157292,667828,23633230,3361954,986187,186660,253028,699975,3508171,36295,717604,9375517,2516799,1332545,1063962,916708,1258918,32147,1855193,4080595,6809979,3204330,601460,1797121,589016,664717,1272399,158661,4810643,858636,10320224,1048407,294508,6054006,1163514,990335,4773311,410652,516426,284138,1081591,5563505,1669570,71553,1732827,2080222,452132,2937821,305915 -10-Oct,209038460,870043,1585573,1427949,947818,28911560,7236186,1761863,306952,652273,860710,5130039,38369,1348100,16741328,5322921,2294881,1605276,1926746,1474614,66368,3365065,7569063,14084534,5925418,802638,3154554,1076406,1095072,1580388,350506,9709431,1090924,18221127,1942301,558943,13747509,1441430,2149701,10276670,865895,779824,535092,1806454,7010120,3109963,179401,3312178,5079226,1284843,5804089,621163 -10-Nov,463332637,2859009,2093703,2947154,1980670,47136835,16886508,3773643,782935,1402024,1188402,11700471,38369,3502986,39903760,14716067,7144930,5614318,5105151,2808196,131699,8526214,12527997,31316363,14044091,1828231,9322630,2543761,3850381,3277957,687531,24398536,2442135,38526624,7269370,1311805,28355728,2980338,5130039,21989585,1845860,2864194,1422764,5898456,14308526,7872904,311100,8571842,10394888,2899452,13361745,1533723 -10-Dec,878340037,8264890,3178405,5471212,5275219,69800470,19683297,6777832,1969263,3230255,2715903,29896710,43554,4245478,83696270,29603239,13118050,11747136,12506220,7801351,210511,19192796,20861329,55043960,24361204,4875974,21566489,3465654,6722871,5960676,1206031,45602075,5221295,72630443,19875142,1991040,55271063,9167080,6537248,44421969,3489505,8048157,2393396,15170273,30674460,9775799,507093,20425789,12067569,5793719,24861038,1921561 +1,967111385,9543511,2831010,7719428,8578064,73280642,23560640,9027085,2278289,2925377,3232329,30627795,53924,3928156,86153960,32019449,15853656,16307862,12357929,9985273,227103,18017875,23997217,59935489,26775340,6204371,24996885,3639870,8163264,7747427,1353285,45146832,6949974,73867584,17876843,2101999,59388990,16832584,6900198,45310678,3254106,7806536,2708644,17314789,51706894,12375558,557906,19630410,11425666,5754313,26451796,2426580 +2,824185823,8049194,2129998,6237555,7598099,60784792,21396421,7779574,2013854,2599759,2685830,25890779,44591,3074705,71091535,25450054,12364151,12905465,11405963,8451550,192882,15311305,19372197,51099212,20460010,5626762,20941178,3094408,7101376,6145262,1071221,38838761,6529989,67036865,15252196,1781566,53875261,13827358,5074041,40881651,2928488,6342292,2197403,15244937,49039730,8629914,512278,17609297,9007382,5188111,20197649,1818898 +3,600674991,6856644,2199477,5355068,6497842,53948888,16100462,5575949,1357433,1399950,2883897,16907248,45628,2729384,55367504,15131904,8594656,10020531,6510286,7222705,149328,9223078,15062425,37957311,13239379,4301476,14898579,2329102,6628504,4916417,808860,23825075,5218184,49468011,7876015,1228845,35292221,10946572,4388584,28763269,1969263,4084743,1554463,11539736,35976641,7918532,370209,9477143,8242076,3080927,13681141,1552389 +4,324758327,3097519,1632238,3146258,2850713,46362196,11223451,3246847,606645,562054,1782603,5781275,51850,2123776,27693085,6371328,3646092,4469470,1916376,2849676,110959,3900157,8971087,25456276,6205408,1403061,5820681,1818898,3273809,3375435,481168,11424629,3525800,27902559,2008669,584868,15924172,5314625,4092002,13678030,888709,1191513,851377,4170814,14898579,6802720,279990,3644018,7122116,1551352,7450845,1223660 +5,204820981,1185291,981002,2044964,1071221,34306034,7219594,2087481,360876,334951,1172847,4188443,43554,1452837,15790399,4557615,2703459,2056371,1080554,1517131,64294,2585241,5724240,14002611,5121743,681309,3138999,1385432,1537871,2370582,310063,8392441,1885266,18212831,1298324,463539,9895054,2292807,2904637,8582212,656421,552721,651236,1522316,7812758,4271403,160735,2208810,5158038,836859,5040857,941596 +6,138997406,873154,691679,1470466,803675,27814414,3268624,1228845,236436,271694,797453,3438692,43554,849303,10167785,2757383,1463207,1572092,929152,1379210,36295,1831342,4121038,8181930,3172183,662643,2344657,844118,1079517,1752530,206363,5456694,1120997,11119751,976854,225029,6019785,1540982,2008669,4980711,432429,505019,269620,1250622,6338144,2768790,98515,1834453,3513356,413763,3321511,512278 +7,115425359,760121,653310,1162477,661606,24317650,2947154,1023519,202215,247843,724863,3340177,44591,455243,8091711,2501244,1243363,1192550,876265,1257881,27999,1710013,3462543,6148373,2456653,605608,1698606,483242,768417,1294176,164883,4676870,867969,9091379,915671,178364,5411066,1241289,1186328,4124149,344284,498797,217770,1074332,6089264,1813713,75701,1649867,2260660,362950,2518873,298656 +8,111035738,734196,629459,1071221,648125,22902145,3194997,1041148,199104,232288,693753,3393064,42517,435540,7908162,2586278,1147959,1046333,871080,1194624,29036,1413431,4501617,5555209,2577982,562054,1682014,378505,731085,1142774,186660,4967230,847229,8540732,937448,206363,4965156,1100257,968558,4136593,484279,439688,203252,991372,5403807,1523353,66368,1321138,1998299,401319,2563464,236436 +9,121639063,682346,799527,1157292,667828,23633230,3361954,986187,186660,253028,699975,3508171,36295,717604,9375517,2516799,1332545,1063962,916708,1258918,32147,1855193,4080595,6809979,3204330,601460,1797121,589016,664717,1272399,158661,4810643,858636,10320224,1048407,294508,6054006,1163514,990335,4773311,410652,516426,284138,1081591,5563505,1669570,71553,1732827,2080222,452132,2937821,305915 +10,209038460,870043,1585573,1427949,947818,28911560,7236186,1761863,306952,652273,860710,5130039,38369,1348100,16741328,5322921,2294881,1605276,1926746,1474614,66368,3365065,7569063,14084534,5925418,802638,3154554,1076406,1095072,1580388,350506,9709431,1090924,18221127,1942301,558943,13747509,1441430,2149701,10276670,865895,779824,535092,1806454,7010120,3109963,179401,3312178,5079226,1284843,5804089,621163 +11,463332637,2859009,2093703,2947154,1980670,47136835,16886508,3773643,782935,1402024,1188402,11700471,38369,3502986,39903760,14716067,7144930,5614318,5105151,2808196,131699,8526214,12527997,31316363,14044091,1828231,9322630,2543761,3850381,3277957,687531,24398536,2442135,38526624,7269370,1311805,28355728,2980338,5130039,21989585,1845860,2864194,1422764,5898456,14308526,7872904,311100,8571842,10394888,2899452,13361745,1533723 +12,878340037,8264890,3178405,5471212,5275219,69800470,19683297,6777832,1969263,3230255,2715903,29896710,43554,4245478,83696270,29603239,13118050,11747136,12506220,7801351,210511,19192796,20861329,55043960,24361204,4875974,21566489,3465654,6722871,5960676,1206031,45602075,5221295,72630443,19875142,1991040,55271063,9167080,6537248,44421969,3489505,8048157,2393396,15170273,30674460,9775799,507093,20425789,12067569,5793719,24861038,1921561 diff --git a/prereise/gather/demanddata/bldg_electrification/ff_model.py b/prereise/gather/demanddata/bldg_electrification/ff_model.py index 7ece86280..28b2e27f9 100644 --- a/prereise/gather/demanddata/bldg_electrification/ff_model.py +++ b/prereise/gather/demanddata/bldg_electrification/ff_model.py @@ -8,32 +8,23 @@ from prereise.gather.demanddata.bldg_electrification import const -def calculate_state_slopes(puma_data): - # 2010 ff data used for fitting - start_date = "2010-01-01" - end_date = "2011-01-01" - yr_temps = 2010 - - # Computing number of hours each month for normalization in the fitting code below - dt = pd.date_range(start=start_date, end=end_date, freq="H").to_pydatetime().tolist() - datetimes = pd.DataFrame( - {"date_time": [dt[i].strftime("%Y-%m-%d %H:%M:%S") for i in range(len(dt) - 1)]} - ) - month_hrly = [int(dt[i].strftime("%m")) for i in range(len(dt) - 1)] +def calculate_state_slopes(puma_data, year): + dti = pd.date_range(start=f"{year}-01-01", end=f"{year}-12-31 23:00:00", freq="H") + hours_in_month = dti.month.value_counts() # Load in historical 2010 fossil fuel usage data - dir_path = os.path.dirname(os.path.abspath(__file__)) - ng_usage_data_res = pd.read_csv( - os.path.join(dir_path, "data", "ng_monthly_mmbtu_2010_res.csv") - ) - ng_usage_data_com = pd.read_csv( - os.path.join(dir_path, "data", "ng_monthly_mmbtu_2010_com.csv") - ) + data_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), "data") + ng_usage_data = { + clas: pd.read_csv( + os.path.join(data_dir, f"ng_monthly_mmbtu_2010_{clas}.csv"), index_col=0 + ) + for clas in {"res", "com"} + } fok_usage_data = pd.read_csv( - os.path.join(dir_path, "data", "fok_data_bystate_2010.csv") + os.path.join(data_dir, "fok_data_bystate_2010.csv"), index_col="state" ) othergas_usage_data = pd.read_csv( - os.path.join(dir_path, "data", "propane_data_bystate_2010.csv") + os.path.join(data_dir, "propane_data_bystate_2010.csv"), index_col="state" ) # Initialize dataframes to store state heating slopes @@ -56,33 +47,39 @@ def calculate_state_slopes(puma_data): for state in const.state_list: # Load puma data - puma_data_it = puma_data[puma_data["state"] == state].reset_index() + puma_data_it = const.puma_data.query("state == @state") n_tracts = len(puma_data_it) # Load puma temperatures temps_pumas = temps_pumas = pd.read_csv( - f"https://besciences.blob.core.windows.net/datasets/pumas/temps_pumas_{state}_{yr_temps}.csv" + f"https://besciences.blob.core.windows.net/datasets/pumas/temps_pumas_{state}_{year}.csv" ) temps_pumas_transpose = temps_pumas.T for clas in const.classes: - - temp_ref_it = const.temp_ref_res if clas == "res" else const.temp_ref_com - - # percentage of puma area that uses fossil fuel - frac_ff_sh = puma_data_it[f"frac_ff_sh_{clas}_2010"] - frac_ff_dhw = puma_data_it[f"frac_ff_dhw_{clas}_2010"] - frac_ff_cook = puma_data_it["frac_ff_cook_com_2010"] + # puma area * percentage of puma area that uses fossil fuel + areas_ff_sh_it = ( + puma_data_it[f"{clas}_area_2010_m2"] + * puma_data_it[f"frac_ff_sh_{clas}_2010"] + ) + areas_ff_dhw_it = ( + puma_data_it[f"{clas}_area_2010_m2"] + * puma_data_it[f"frac_ff_dhw_{clas}_2010"] + ) + areas_ff_cook_it = ( + puma_data_it[f"{clas}_area_2010_m2"] + * puma_data_it["frac_ff_cook_com_2010"] + ) if clas == "res": - frac_ff_other = puma_data_it["frac_ff_other_res_2010"] + areas_ff_other_it = ( + puma_data_it[f"{clas}_area_2010_m2"] + * puma_data_it["frac_ff_other_res_2010"] + ) else: - frac_ff_other = puma_data_it["frac_ff_sh_com_2010"] - - # puma area * percentage - areas_ff_sh_it = [puma_data_it[f'{clas}_area_2010_m2'][i] * frac_ff_sh[i] for i in range(len(puma_data_it))] - areas_ff_dhw_it = [puma_data_it[f'{clas}_area_2010_m2'][i] * frac_ff_dhw[i] for i in range(len(puma_data_it))] - areas_ff_other_it = [puma_data_it[f'{clas}_area_2010_m2'][i] * frac_ff_other[i] for i in range(len(puma_data_it))] - areas_ff_cook_it = [puma_data_it[f'{clas}_area_2010_m2'][i] * frac_ff_cook[i] for i in range(len(puma_data_it))] + areas_ff_other_it = ( + puma_data_it[f"{clas}_area_2010_m2"] + * puma_data_it["frac_ff_sh_com_2010"] + ) # sum of previous areas to be used in fitting sum_areaff_sh = sum(areas_ff_sh_it) @@ -91,90 +88,48 @@ def calculate_state_slopes(puma_data): sum_areaff_cook = sum(areas_ff_cook_it) # Load monthly natural gas usage for the state - natgas = list( - ng_usage_data_res[state] if clas == "res" else ng_usage_data_com[state] - ) - sum_natgas = sum(natgas) + natgas = ng_usage_data[clas][state] # Load annual fuel oil/kerosene and other gas/propane usage for the state - fok = list( - fok_usage_data[fok_usage_data["state"] == state][f"fok.{clas}.mmbtu"] - )[0] - other = list( - othergas_usage_data[othergas_usage_data["state"] == state][ - f"propane.{clas}.mmbtu" - ] - )[0] - totfuel = fok + sum_natgas + other + fok = fok_usage_data.loc[state, f"fok.{clas}.mmbtu"] + other = othergas_usage_data.loc[state, f"propane.{clas}.mmbtu"] + totfuel = fok + other + natgas.sum() # Scale total fossil fuel usage by monthly natural gas - ff_usage_data_it = [ - natgas[i] / sum_natgas * (totfuel) for i in range(len(natgas)) - ] - - temp_ref_lin_dec_it = temp_ref_it - temp_ref_lin_inc_it = temp_ref_it + ff_usage_data_it = totfuel * natgas / natgas.sum() + # Fossil fuel average monthly mmbtu, normalized by hours in month + ff_monthly_it = ff_usage_data_it / hours_in_month + + # Hourly heating degrees for all pumas in a given state, multiplied by their corresponding area and percent fossil fuel, summed up to one hourly list + hd_hourly_it_sh = ( + temps_pumas_transpose.applymap( + lambda x: max(const.temp_ref[clas] - x, 0) + ) + .mul(areas_ff_sh_it, axis=0) + .sum(axis=0) + ) + hd_monthly_it_sh = hd_hourly_it_sh.groupby(dti.month).mean() if clas == "res": - - # Hourly heating degrees for all pumas in a given state, multiplied by their corresponding area and percent fossil fuel, summed up to one hourly list - hd_hourly_it_sh = ( - temps_pumas_transpose.applymap( - lambda x: temp_ref_lin_dec_it - x - if temp_ref_lin_dec_it - x >= 0 - else 0 - ) - .mul(areas_ff_sh_it, axis=0) - .sum(axis=0) - ) hd_hourly_it_dhw = ( - temps_pumas_transpose.applymap(lambda x: temp_ref_lin_dec_it - x) + temps_pumas_transpose.applymap(lambda x: const.temp_ref[clas] - x) .mul(areas_ff_dhw_it, axis=0) .sum(axis=0) ) - - # Average hd per month - df_hourly_it = pd.DataFrame( - { - "month": month_hrly, - "hd_hourly_it_sh": hd_hourly_it_sh, - "hd_hourly_it_dhw": hd_hourly_it_dhw, - } - ) - hd_group_sh = df_hourly_it["hd_hourly_it_sh"].groupby(df_hourly_it["month"]) - hd_group_dhw = df_hourly_it["hd_hourly_it_dhw"].groupby( - df_hourly_it["month"] - ) - df_monthly_it = pd.DataFrame( - { - "hd_avg_sh": hd_group_sh.mean(), - "hd_avg_dhw": hd_group_dhw.mean(), - "n_hrs": hd_group_sh.count(), - } - ) - # Fossil fuel average monthly mmbtu, normalized by hours in month - df_monthly_it["ff_monthly_mmbtu"] = [ - ff_usage_data_it[i] / list(df_monthly_it["n_hrs"])[i] - for i in range(len(df_monthly_it)) - ] + hd_monthly_it_dhw = hd_hourly_it_dhw.groupby(dti.month).mean() # Fitting function: Returns difference between fitted equation and actual fossil fuel usage for the least_squares function to minimize def func_r(par, sh, dhw, ff): err = ff - ( par[0] * sh - + (sum_areaff_dhw * par[1] + const.dhw_lin_scalar * par[1] * dhw) - + sum_areaff_other * par[2] + + par[1] * (sum_areaff_dhw + const.dhw_lin_scalar * dhw) + + par[2] * sum_areaff_other ) return err - # Input data points for fitting - data_sh = np.array(df_monthly_it["hd_avg_sh"]) - data_dhw = np.array(df_monthly_it["hd_avg_dhw"]) - data_ff = df_monthly_it["ff_monthly_mmbtu"] - # Least squares solver lm_it = least_squares( func_r, const.bounds_lower_res, - args=(data_sh, data_dhw, data_ff), + args=(hd_monthly_it_sh, hd_monthly_it_dhw, ff_monthly_it), bounds=(const.bounds_lower_res, const.bounds_upper_res), ) @@ -188,9 +143,9 @@ def func_r(par, sh, dhw, ff): residuals = list(lm_it.fun) sumres = 0 sumtot = 0 - for i in range(len(list(data_ff))): + for i in range(len(list(ff_monthly_it))): sumres += residuals[i] ** 2 - sumtot += (list(data_ff)[i] - np.mean(data_ff)) ** 2 + sumtot += (list(ff_monthly_it)[i] - np.mean(ff_monthly_it)) ** 2 r2 = 1 - (sumres / sumtot) # Add coefficients to output dataframe @@ -203,53 +158,15 @@ def func_r(par, sh, dhw, ff): par_dhw_l, par_other_c, ] - else: - - # Hourly heating degrees for all pumas in a given state, multiplied by their corresponding area and percent fossil fuel, summed up to one hourly list - hd_hourly_it_sh = ( - temps_pumas_transpose.applymap( - lambda x: temp_ref_lin_dec_it - x - if temp_ref_lin_dec_it - x >= 0 - else 0 - ) - .mul(areas_ff_sh_it, axis=0) - .sum(axis=0) - ) hd_hourly_it_other = ( temps_pumas_transpose.applymap( - lambda x: x - temp_ref_lin_inc_it - if x - temp_ref_lin_inc_it >= 0 - else 0 + lambda x: max(x - const.temp_ref[clas], 0) ) .mul(areas_ff_other_it, axis=0) .sum(axis=0) ) - - # Average hd per month - df_hourly_it = pd.DataFrame( - { - "month": month_hrly, - "hd_hourly_it_sh": hd_hourly_it_sh, - "hd_hourly_it_other": hd_hourly_it_other, - } - ) - hd_group_sh = df_hourly_it["hd_hourly_it_sh"].groupby(df_hourly_it["month"]) - hd_group_other = df_hourly_it["hd_hourly_it_other"].groupby( - df_hourly_it["month"] - ) - df_monthly_it = pd.DataFrame( - { - "hd_avg_sh": hd_group_sh.mean(), - "hd_avg_other": hd_group_other.mean(), - "n_hrs": hd_group_sh.count(), - } - ) - # Fossil fuel average monthly mmbtu, normalized by hours in month - df_monthly_it["ff_monthly_mmbtu"] = [ - ff_usage_data_it[i] / list(df_monthly_it["n_hrs"])[i] - for i in range(len(df_monthly_it)) - ] + hd_monthly_it_other = hd_hourly_it_other.groupby(dti.month).mean() # Fitting function: Returns difference between fitted equation and actual fossil fuel usage for the least_squares function to minimize def func_c(par, sh, other, ff): @@ -261,16 +178,11 @@ def func_c(par, sh, other, ff): ) return err - # Input data points for fitting - data_sh = np.array(df_monthly_it["hd_avg_sh"]) - data_other = np.array(df_monthly_it["hd_avg_other"]) - data_ff = df_monthly_it["ff_monthly_mmbtu"] - # Least squares solver lm_it = least_squares( func_c, const.bounds_lower_com, - args=(data_sh, data_other, data_ff), + args=(hd_monthly_it_sh, hd_monthly_it_other, ff_monthly_it), bounds=(const.bounds_lower_com, const.bounds_upper_com), ) @@ -285,9 +197,9 @@ def func_c(par, sh, other, ff): residuals = list(lm_it.fun) sumres = 0 sumtot = 0 - for i in range(len(list(data_ff))): + for i in range(len(list(ff_monthly_it))): sumres += residuals[i] ** 2 - sumtot += (list(data_ff)[i] - np.mean(data_ff)) ** 2 + sumtot += (list(ff_monthly_it)[i] - np.mean(ff_monthly_it)) ** 2 r2 = 1 - (sumres / sumtot) # Add coefficients to output dataframe @@ -307,11 +219,7 @@ def func_c(par, sh, other, ff): if __name__ == "__main__": - puma_data = pd.read_csv( - os.path.join(dir_path, "data", "puma_data.csv"), index_col=False - ) - - state_slopes_res, state_slopes_com = calculate_state_slopes(puma_data) + state_slopes_res, state_slopes_com = calculate_state_slopes(const.puma_data) state_slopes_res.to_csv( os.path.join(dir_path, "data", "state_slopes_ff_res.csv"), index=False ) @@ -323,6 +231,10 @@ def func_c(par, sh, other, ff): # Space heating slope adjustment for climate # ############################################## + puma_data = pd.read_csv( + os.path.join(dir_path, "data", "puma_data.csv"), index_col=False + ) + # Create data frames for space heating fossil fuel usage slopes at each PUMA puma_slopes_res = pd.DataFrame( columns=(["state", "puma", "htg_slope_res_mmbtu_m2_degC"]) @@ -356,7 +268,7 @@ def func_c(par, sh, other, ff): # Load puma temperatures temps_pumas = pd.read_csv( - f"https://besciences.blob.core.windows.net/datasets/pumas/temps_pumas_{state}_{yr_temps}.csv" + f"https://besciences.blob.core.windows.net/datasets/pumas/temps_pumas_{state}_{year}.csv" ) temps_pumas_transpose = temps_pumas.T