-
Notifications
You must be signed in to change notification settings - Fork 3
[WIP] added plot script for multi waveforms #2
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
base: master
Are you sure you want to change the base?
Conversation
| @@ -0,0 +1,28 @@ | |||
| import make_waveforms | |||
| import pylab as pl | |||
| import numpy as np | |||
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.
Put numpy and pylab imports above make_waveforms
| import make_waveforms | ||
| import pylab as pl | ||
| import numpy as np | ||
|
|
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.
Add docstrings for all new functions.
| import numpy as np | ||
|
|
||
|
|
||
| hp,hc= make_waveforms.make_tidal_waveform(mass1= 10, mass2 = 8, s1z=0, approx = "SpinTaylorT4") |
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 are hardcoding the values of hp and hc. Instead, you should write a function that will take in the values of the set of parameters that are required to make the waveforms. that way every time you want to run the code with different parameters you will not have to change the code. Changing the code will mean you will have to again add, commit and push in git, again create pull request, and again this process.
| def get_times(hp): | ||
| t=[] | ||
| for t in range (0,10): | ||
| t=np.arange(0, -hp.epoch.gpsSeconds - hp.epoch.gpsNanoSeconds*1e-9 + hp.deltaT, hp.deltaT) | ||
| t=t[:hp.data.length] | ||
| return t |
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 initialized a list t, but then you wrote for t in range (0,10):, which will overwrite the empty list t by the iterating integer. Then inside the loop you are creating a numpy array t which is the actual array of time. Finally, you are cropping the array up to the length of the waveform. So the first two t are actually never used. Your for loop is doing nothing, except the same computation t=np.arange(0, -hp.epoch.gpsSeconds - hp.epoch.gpsNanoSeconds*1e-9 + hp.deltaT, hp.deltaT) is repeated 10 times. This whole thing can be replaced by this:
def get_times(hp):
t = np.arange(0, -hp.epoch.gpsSeconds - hp.epoch.gpsNanoSeconds*1e-9 + hp.deltaT, hp.deltaT)
return t[:hp.data.length]
| pl.plot(get_times(hp), hp.data.data, label= "Without Spin") | ||
|
|
||
| #t=np.arange(0, -hp.epoch.gpsSeconds -hp.epoch.gpsNanoSeconds*1e-9 +hp.deltaT, hp.deltaT) | ||
| #t=t[:hp.data.length] | ||
| #return t | ||
| pl.plot(get_times(hp2), hp2.data.data, label= "With Spin") | ||
| pl.plot(get_times(hp3), hp3.data.data, label= "With Negative Spin") | ||
| pl.xlabel("Time (s)") | ||
| pl.ylabel("Strain") | ||
| pl.legend() | ||
| pl.savefig("MultiPlot1.png") |
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.
This plotting script needs to be generalized so that it can work with any number of waves. Right now if I ask you add another wave, you will have to add that line in the code.
added plot script for waveform and changed the make to add more arguments.