-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Plot class for ramp visualization and data analysis routines (isse #63) #89
Conversation
|
||
valid_units = ('kW',"W","MW","GW","TW") | ||
class Run: | ||
|
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.
It would be good to add a docsting to the class so that the people can run help(Run)
To me these methods should be added to the existing Usecase
class because here Run is simply a Usecase
instance with only one User
. If it is integrated into Usecase
then the usage I envision for the future is to always take a Usecase
class which has a method run
and for which one can define datatimeIndexes. The method generate_profiles
could be included into Usecase.generate_daily_load_profiles
method for example
ramp/post_process/post_process.py
Outdated
A Plot object | ||
""" | ||
|
||
if file.split(".")[-1] == "csv": |
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.
You can also use file.endswith(".csv")
This is just a side comment
elif file.split(".")[-1] == "xlsx": | ||
|
||
df = pd.read_excel(file,sheet_name=sheet_name,index_col=0,header=0) | ||
|
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.
Maybe an error message if the extension is not supported?
ramp/post_process/post_process.py
Outdated
class LinePlot: | ||
"""Line plot functions for Plotly and matplotlib engine | ||
""" | ||
def plotly(df,**layout): |
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.
def plotly(df,**layout): | |
def plotly(self, df,**layout): |
If this is a method class, you should add self
, same goes for many occurences
ramp/post_process/post_process.py
Outdated
""" | ||
df = self.df.copy() | ||
|
||
df = eval(f"df{conversion}") |
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.
df = eval(f"df{conversion}") | |
df = df * conversion |
Using eval
can lead to safety issues, it is considered good practice not to use it in code that you publish. As you only use it once, there is certainly a way around using eval we can find :)
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.
Sure!
ramp/post_process/post_process.py
Outdated
|
||
|
||
|
||
class LinePlot: |
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.
You seem to only use LinePlot
, AreaPlot
and ShadowPlot
classes once in each of the corresponding methods of the class Plot
. To me it would make the code easier to read/understand if those are discarded and their code simply added inside the line
, area
and shadow
methods of Plot. Especially because most of the logic of
lineis in
LinePlot`. if there is a bigger plan for future use of such classes let me know, otherwise I would strongly recommand moving the code into the methods
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.
would you keep to different functions for plotly and matplotlib for each type of plot, or simply use an if/else statement inside a plot function for the two options.
the main reason for having separate classes was to encapsulate the two plotting engine for each plot type, mainly for making it more readable.
ramp/post_process/post_process.py
Outdated
df = df.sort_values(by=column,ascending=False) | ||
df.index = [i for i in range(1,len(df.index)+1)] | ||
|
||
return getattr(LinePlot,engine)(df,**kwargs) |
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.
Here you could for example use return self.line(df,**kwargs)
and make such that line does not take df=self.df
it df
is recieved as an argument
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.
Hello @mohammadamint , great work!
I made some comments to integrate your work in a more maintainable way, let me know if anything is unclear.
Shouldn't we move the rest of the functions like export_series
into Plot
class as this function turns anyway the profiles into a DataFrame and uses to_csv
method. We should then look for other uses of post_processing function in the examples and fix them, to avoid that people use both ways. I would suggest to keep old ways to not break code but that we replace the code inside the function and use Plot
methods inside those "deprecated" functions.
We should maybe discuss live in which order to merge the PRs and rebase your PR on top of the latest development
branch if your branch is to be the last one to be merged. Let us contact each other via email to find a moment which fits us both :)
If you don't have time at the moment I could also make a PR onto this PR with my suggested changes.
Thanks for the nice comments. I would like to implement them before merging the PR, as they seem very useful to improve the readability of the code. I can do it in the upcoming days if it is fine! Regarding the use of the existing functionalities into the Plot class, I absolutely agree with that, I can explore and work on this if needed. I have quiet an open agenda this week! so we can meet almost everyday based on your availability! |
ramp/post_process/post_process.py
Outdated
@@ -90,6 +90,9 @@ def export_series(stoch_profiles_series, j=None, fname=None, ofname=None): | |||
else: | |||
print("No path to a file was provided to write the results") | |||
<<<<<<< HEAD | |||
<<<<<<< HEAD |
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.
You have pushed conflicted files here
@mohammadamint - if you rebased the branch onto development, how come there are still conflicts? |
Yes! Indeed. Not sure how that happened, but the conflicts are very easy to solve. if everything else, I can solve the conflict and merge it. |
What is wierd is that it shows 25 commits, whereas I remember there where two, rebasing should keep the number of commits constant |
@mohammadamint - I did rebase locally on a copy of |
Yes I did. but, I am not able to fix the conflicts that arose after rebasing properly. Would creating a new branch from the latest development work? |
I am not sure what you did, did you force push the |
As soon as the solution works, it doesn't matter :-) . |
3ad01e7
to
1c3d195
Compare
Is the conflict still there? @Bachibouzouk |
Yes I reforced push your branch because I had to prepare dinner and I will tackle this now |
1c3d195
to
61af5b6
Compare
@mohammadamint - now it is fixed (I still have locally the old branch |
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.
Thanks for the modifications @mohammadamint
Is the class Run
being used at all? I couldn't find an instance of Run(
in the whole project. I would say we leave it here and merge it into UseCase in a subsequent PR :)
Indeed I kept for the future UseCase uses. |
@mohammadamint - maybe we can merge the test PR first, then we rebase this one onto |
Sure! |
The tests-related PRs have all been approved. You may proceed with rebasing and then we could merge this one too (: |
Shall I wait for your your PR on docs also to be merged? |
yes, I think that would make sense. Is for one between you and @Bachibouzouk to review that one before merging. |
So I think that the only needed step here is not to update the PR to incorporate the newest commits to development, right? |
Yes. I have some issues with rebasing, and if it is ok, I will wait till tomorrow to check this with Pierre. I see that some of the commits I had on this PR are kind of lost. |
The new features added will allow the user to perform some data analysis and visualization routines: changes ------ *. ramp/post_process/post_process.py - the class Plot is the main class carrying on the plotting and data analysis functionalities with custom APIs providing access to some pd.DataFrame features also easy to plot functions conencting to plotly and matplotlibe methods. - different plotting classes that include a specific plot type visualiztion using two different engines (plotly & matplotlib) *. ramp.__init__.py - adding the Plot class to the init. documentation ------------- - the functions API docuemntation is added to the API documentaiton - A full example titled "Plot class" is added to the example gallery describing the full potential of the new functionalities
61af5b6
to
511d90b
Compare
Are there still lost @mohammadamint ? This rebase is onto the latest version |
@Bachibouzouk All correct now! |
Ok now only the problem of RTD then. by looking at the dependencies locally, I see that docs/source/api_document is missing all the Plot methods, could this be that we just need to commit them? |
@Bachibouzouk I see that the docs action is also failed. It can't find the API doc for Appliance.eq! Is that normal? |
@mohammadamint The problem was the missing |
Thanks for your great support, and looking forward to your git course ;-) |
The new features added will allow the user to perform some data analysis and visualization routines:
changes
*. ramp/post_process/post_process.py
the class Plot is the main class carrying on the plotting and data analysis functionalities with custom APIs providing access to some pd.DataFrame features also easy to plot functions conencting to plotly and matplotlibe methods.
different plotting classes that include a specific plot type visualiztion using two different engines (plotly & matplotlib)
*. ramp.init.py
documentation