gw-odw / odw-2019

GNU General Public License v3.0
24 stars 32 forks source link

Problem running a cell #9

Closed iarat closed 4 years ago

iarat commented 5 years ago

I am having a problem while running this cell: ''''from pycbc.waveform import get_td_waveform

apx = 'IMRPhenomD'

hp1, _ = get_td_waveform(approximant=apx, mass1=10, mass2=10, delta_t=1.0/sample_rate, f_lower=25)

The amplitude of gravitational-wave signals is normally of order 1E-20. To demonstrate our method

on white noise with amplitude O(1) we normalize our signal so the cross-correlation of the signal with

itself will give a value of 1. In this case we can interpret the cross-correlation of the signal with white

noise as a signal-to-noise ratio.

hp1 = hp1 / max(numpy.correlate(hp1,hp1, mode='full'))**0.5

pylab.figure() pylab.title("The waveform hp1") pylab.plot(hp1.sample_times, hp1) pylab.xlabel('Time (s)') pylab.ylabel('Normalized amplitude')

waveform_start = numpy.random.randint(0, len(data) - len(hp1)) data[waveform_start:waveform_start+len(hp1)] += 10 * hp1.numpy()

pylab.figure() pylab.title("Looks like random noise, right?") pylab.plot(hp1.sample_times, data[waveform_start:waveform_start+len(hp1)]) pylab.xlabel('Time (s)') pylab.ylabel('Normalized amplitude')

pylab.figure() pylab.title("Signal in the data") pylab.plot(hp1.sample_times, data[waveform_start:waveform_start+len(hp1)]) pylab.plot(hp1.sample_times, 10 * hp1) pylab.xlabel('Time (s)') pylab.ylabel('Normalized amplitude') ''''

The error is this one: TypeError: slice indices must be integers or None or have an index method

I have also tired to run the "new version" - that I took from here: https://github.com/gw-odw/odw-2019/blob/38c7bc75a8aca9117471ccc7e373fdc201a7e89a/Day_2/Tuto_2.1_Matched_filtering_introduction.ipynb

The strange thing is, if I change the value of sample_rate for 4096 (as indicated in 2018's version) it works. After making it work using the new value for sample_rate, I get another error in another cell - # 11 - Generate a PSD for whitening the data. In this cell the error is this one: ValueError: different delta_f

spxiwh commented 5 years ago

Sorry to hear this isn't working for you, but I haven't been able to reproduce this error. A few questions to try to help me reproduce this:

Can you state what python version you are running? Are you running this on a local machine or on something like SciServer? Can you indicate at which line the error is occurring? Did you install the dependencies as listed in requirements.txt at the top of the notebook?

iarat commented 5 years ago

Thanks for answering.

I have been trying with two different versions of python (2.7 and 3.7) and running the scripts in a cloud platform (conda). Also, the notebook I use is jupyter.

With python 3.7: When I tried to install the dependencies listed in requirements.txt (following the commands indicated) I get this error while installing healpy: 'Failed to build healpy'. I have also tried to update the healpy, after checking their website, and it did not work out. Even not having healpy properly installed, I was able to arrive until "An introduction to matched-filtering" part where I had the error above-mentioned. The line at which this error is occuring is this one: "---> 19 hp1_whitened = (hp1.to_frequencyseries() / psd_hp1*0.5).to_timeseries() 1E-21"

After trying with python 3.7, which I did not succeded, I tried py 2.7 as indicated in the pyCBC webpage. I tried with py 3.7 first because I know that version 2.7 will reach the end of its life on January 1st, 2020. Anyways, with 2.7 version I've got some other problems while installing the dependencies (following the commands indicated). The first one is: "ERROR: pycbc 1.13.5 has requirement numpy<1.15.3,>=1.13.0, but you'll have numpy 1.16.2 which is incompatible." To fix it, I simply installed the numpy indicated version presented in the error and it worked. Running again the cell, another error occurs: problem istalling healpy. After that, I've decided to install all dependencies not using the command indicated, but instead, I installed each dependency separately with pip install (numpy 1.15.0, pycbc 1.13.5 and so on). Again here I've got an error while installing healpy. After checking their webpage, I decided to installed it following the commands indicated there (which is not that different from the command I have been using though). Again the same error: "Failed to build healpy" The problem where is that I got stuck already in part 1.1 CatalogDATA. Well, I know that it is from last year, but I really wanted to try it out. For me, as a beginner, is an important step. Here, which is a surprise, I got this error: '---> 24 pylab.plot(ts_han.sample_times, ts_han)' , "RuntimeError: Failed to find implementation of (<function _scheme_matches_base_array at 0x11d43dd70>) for cpu scheme." This is because of old version of numpy.

I have also tried out another thing: google colab, where I literally must just click on play. This time I have decided just to go for the latest tutorials (2019 ones). Here "https://colab.research.google.com/github/gw-odw/odw-2019/blob/master/Day_1/Tuto%201.4%20Generating%20waveforms.ipynb#scrollTo=tjXzeer7rjvk" already in the first cell I've got the same errors when I was using python 2.7: ""ERROR: pycbc 1.13.5 has requirement numpy<1.15.3,>=1.13.0, but you'll have numpy 1.16.2 which is incompatible. ERROR: fastai 0.7.0 has requirement torch<0.4, but you'll have torch 1.1.0 which is incompatible. ERROR: albumentations 0.1.12 has requirement imgaug<0.2.7,>=0.2.5, but you'll have imgaug 0.2.9 which is incompatible."" The first tutorial from day one, 1.4, I did it. I got a problem with tutorial 2.1: "----> 1 from pycbc.waveform import get_td_waveform".

Sorry for the long description, but I have tried multiples ways and nothing.

jkanner commented 4 years ago

Hi,

Thank you for the question.

Using the Google co-lab approach, please note this message in the notebook: "Important: With Google Colab, you may need to restart the runtime after running the cell above."

I tried the following, which worked for me:

1) Follow the Google co-lab link: https://colab.research.google.com/github/gw-odw/odw-2019/blob/master/Day_1/Tuto%201.4%20Generating%20waveforms.ipynb#scrollTo=s-NVxZE_qZne

2) Click “run all” from the “Runtime” menu. You will get an error message. 3) Click “Restart and run all” from the runtime menu. At least for me, this ran the notebook through to the end.

I was also able to run the 2019 “Tuto 1.4” notebook on my mac, using the conda ligo-py27 enviornment. See “Option 2” here: https://www.gw-openscience.org/tutorial00/ In this case, you may be able to skip the “pip install” step in the first cell.

Please let us know if you continue to have problems. We appreciate your feedback.

Best, jonah

iarat commented 4 years ago

Hello, In fact, my problem was with my conda. I was using anaconda, not miniconda. So after uninstalling conda e installing miniconda, I got no more errors.

Thx a lot for the help

jkanner commented 4 years ago

Oh, that’s interesting. I’m glad it is working now. Thanks for the feedback. -jonah

iarat commented 4 years ago

Even with miniconda I had to manually change the pycbc version inside the file requirements.txt present in the tutorials. I changed to the latest version of PyCBC(1.14.1) otherwise I would have got other errors. There is an incompatibility between numpy 1.16.2 and PyCBC 1.13.5. thx again

jkanner commented 4 years ago

The version conflict between numpy and pycbc has been resolved by using the IGWN conda distribution