This repository has been archived by the owner on May 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
refactor: move all logic within functions or if block #26
Merged
Conversation
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
BainanXia
approved these changes
Dec 1, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
0745e22
to
e233753
Compare
I figured out the error I was getting on my end that was preventing testing. Now that the error is resolved, I've filled in the remaining variables that needed to be passed to the lower-level functions and this is tested to produce an identical output CSV (at least for LADWP in 2019). |
evanpatz
reviewed
Dec 2, 2021
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
evanpatz
approved these changes
Dec 2, 2021
danielolsen
added a commit
that referenced
this pull request
Jan 4, 2022
danielolsen
added a commit
that referenced
this pull request
Jan 5, 2022
mbwaite
pushed a commit
that referenced
this pull request
Jan 20, 2022
mbwaite
added a commit
that referenced
this pull request
Jan 25, 2022
* feat: puma latitude and longitude added to puma_data dataframe * feat: puma latitude/longitude csv to be appeneded to puma_data * feat: national pumas and balanacing authorities shapefiles * feat: zone profile generator * refactor: linting * refactor: linting * refactor: replace while loop in bkpt_scale() with a sorting method * refactor: move all logic within functions or if block (#26) * refactor: simplify hourly_load_fit and improve pandas 1.3 compatibility (#27) * zone_profile_gen.py updates from Evan - puma.area error fix, cooling equations update, zonal_data() refactor, wb/db fit update, profile year added * feat: updated min daily number of load/temp points to fit to from 8 to 10 * feat: folder for generated profiles * feat: folder for zone day hour coefficients * feat: hourly fits graphs, profile stats export * "profiles, hourly fits, and profile graphs" * graphs * profiles for zones in NY, CA, and TX. update to zone_profile_generator to account for puma_data year update * linting * linting * feat: add wetbulb temp and darkness fraction functions to era5_data_a… (#29) * feat: add wetbulb temp and darkness fraction functions to era5_data_agg.py, now renamed weather_data_agg.py * chore: code style cleanup * chore: import sorting * chore: linting fixes Co-authored-by: Daniel Olsen <[email protected]> * Mike/weather write fix (#30) * fix: reference const.state_list * refactor: save dark_frac output to local files * refactor: save temps_wetbulb to local files * chore: remove unused state_list * style: linting fixes with black * fix: remove 2010 reference for cdd65 * chore: update puma_data * refactor: use base_year from const.py * refactor: rename load_year to base_year * Yinbo/zone profile gen refactor (#32) * Fix: create output folders if the address is not exist on local machine; Refactor: add plot_boolean to control whether or not plot result profiles * test * style: style correction using 'black' * style:switch the order of package importing * style * chore: change os.path.exists to os.path.isdir in order to avoid same file names * chore: add docstring * style: docstring style fixed Co-authored-by: danielolsen <[email protected]> Co-authored-by: Daniel Olsen <[email protected]> Co-authored-by: mbwaite <[email protected]> Co-authored-by: yinboHU <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request doc
Purpose
Move all logic within functions or an
if __name__ == "__main__":
block, so that the module can still be run as a script or can be looped without needing to modify the code, and to enable more granular testing of lower-level functions.What the code is doing
main
function is added, which orchestrates all of the lower-level functions.Anhourly_fits_df
input is added to thetemp_to_energy
function so that this function no longer relies on a module-scope variable (there may be more places where similar parameters need to be added, this was the only one that jumped out at me so far).Several variables were only defined within module scope and not passed to analysis functions that needed them; these parameters have now been made explicit.
main
function with 'default' value is moved within anif __name__ == "__main__":
block, so the module can be run as a script like before, or the newmain
function could be called within a loop to go through many different zones.Testing
Not tested yet, since I'm still working through an error I'm getting when I tried to run the original code (may be a local issue on my end). Will update when I can test successfully before and after the refactor.EDIT: tested, output CSVs evaluate as identical.Time estimate
15 minutes.