Skip to content
This repository has been archived by the owner on May 27, 2022. It is now read-only.

Yinbo/zone profile gen refactor #32

Merged
merged 8 commits into from
Jan 24, 2022

Conversation

yinboHU
Copy link
Collaborator

@yinboHU yinboHU commented Jan 21, 2022

Pull Request doc

Purpose

Fix errors when running on local machines.

What the code is doing

Changes are on 'zone_profile_generator.py'

  • Create output folders if the address is not exist on local machine.
  • Add plot_boolean to control whether or not plot result profiles.

Testing

The code is able to run

Where to look

  • 'zone_profile_generator.py'

Usage Example/Visuals

Time estimate

5 mins

…ne; Refactor: add plot_boolean to control whether or not plot result profiles
@yinboHU yinboHU requested a review from mbwaite January 21, 2022 21:19
@mbwaite
Copy link
Contributor

mbwaite commented Jan 21, 2022

How was this tested to ensure folders are created if none exist? Was the plot_boolean functionality tested?

@mbwaite
Copy link
Contributor

mbwaite commented Jan 21, 2022

Will need to clean up history by getting rid of the test commit.

@mbwaite
Copy link
Contributor

mbwaite commented Jan 21, 2022

Run black and check formatting issues in "Details" of linting failure.

@yinboHU
Copy link
Collaborator Author

yinboHU commented Jan 21, 2022

How was this tested to ensure folders are created if none exist? Was the plot_boolean functionality tested?

Add condition line: if not os.path.exists() to decide if the folder is existed
plot_boolean is tested by running the code on my local machine

How was this tested to ensure folders are created if none exist? Was the plot_boolean functionality tested?

@yinboHU
Copy link
Collaborator Author

yinboHU commented Jan 21, 2022

Will need to clean up history by getting rid of the test commit.

There's some changes that I made to get rid of some debugging lines, e.g. print(). So can I just delete the comment, but keep the changes to code?

Comment on lines +224 to 227
def hourly_load_fit(load_temp_df, plot_boolean):
"""Fit hourly heating, cooling, and baseload functions to load data

:param pandas.DataFrame load_temp_df: hourly load and temperature data
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add text describing this input - see ":param pandas.DataFrame..." and other examples in other functions/scripts. This should include two requested possible values (e.g. "yes" and "no"). There should be a default for it to not produce plots, e.g. plot_boolean="no"

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done with docstring

Comment on lines +589 to 592
def main(zone_name, zone_name_shp, base_year, year, plot_boolean=False):
"""Run profile generator for one zone for one year.

:param str zone_name: name of load zone used to save profile.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment

)
plt.xlabel("Temp (°C)")
plt.ylabel("Load (MW)")
if not os.path.exists('./dayhour_fits/dayhour_fits_graphs'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use os.path.isdir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

+ str(round(np.mean(profile), 2))
+ " MW"
)
if not os.path.exists('./Profiles/Profiles_graphs'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use os.path.isdir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


if not os.path.exists('./Profiles/Profiles_stats'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use os.path.isdir

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@yinboHU yinboHU merged commit 5c918b9 into evan/zone_profile_gen Jan 24, 2022
@yinboHU yinboHU deleted the Yinbo/zone_profile_gen_refactor branch January 24, 2022 20:50
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.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants