llondon6 / nrutils_dev

Python API for low-level analysis of NR data: Psi4, strain, modeling, lal+pycbc interface when appropriate
MIT License
9 stars 4 forks source link

nrutils_dev package not working with ipython notebooks #6

Closed Cyberface closed 8 years ago

Cyberface commented 8 years ago

Hey guys,

I'm trying to use nrutils_dev with ipython notebooks.

Just try the following commands in an ipython notebook

from nrutils.core.nrsc import *
A = scsearch(keyword="base",unique=True,verbose=True)
y = gwylm( scentry_obj = A[0], lm=[2,2], dt=0.4, verbose=True )

I get the following output :(

(gwylm)>> Found clean (=False) keyword.
(gwylm)>> Found dt (=0.4) keyword.
(gwylm)>> Found lm (=[2, 2]) keyword.
(gwylm)>> Found load (=True) keyword.
(gwylm)>> Found scentry_obj (=<nrutils.core.nrsc.scentry instance at 0x10d0781b8>) keyword.
(gwylm)>> Found verbose (=True) keyword.
(load)>> Loading: psi3col.r5.l5.l2.m2.gz
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-15-9453ca2f6cbe> in <module>()
      1 # Convert a single simulation into a waveform object with desired multipoles
----> 2 y = gwylm( scentry_obj = A[0], lm=[2,2], dt=0.4, verbose=True )

/Users/sebastian/git/nrutils_dev/nrutils/core/nrsc.pyc in __init__(this, scentry_obj, lm, lmax, extraction_parameter, dt, load, clean, verbose)
   1278 
   1279         # Load the waveform data
-> 1280         if load==True: this.__load__(lmax=lmax,lm=lm)
   1281 
   1282         # Characterize the waveform's start and store related information to this.starting

/Users/sebastian/git/nrutils_dev/nrutils/core/nrsc.pyc in __load__(this, lmax, lm)
   1349             else: # Else, if lm is a single mode index
   1350                 #
-> 1351                 this.load(lm=lm)
   1352 
   1353     # load the waveform data

/Users/sebastian/git/nrutils_dev/nrutils/core/nrsc.pyc in load(this, lm, file_location, dt, output)
   1420             # Enforce internal sign convention for Psi4 multipoles
   1421             msk_ = y_.amp > 0.01*max(y_.amp)
-> 1422             external_sign_convention = mode( sign( y_.dphi[msk_] ) ).mode[0]
   1423             if M_RELATIVE_SIGN_CONVENTION != external_sign_convention:
   1424                 wfarr[:,2] = -wfarr[:,2]

AttributeError: 'tuple' object has no attribute 'mode'
Cyberface commented 8 years ago
In [2]: print numpy.__version__
1.10.4
llondon6 commented 8 years ago

thanks

llondon6 commented 8 years ago

sorry -- what's your scipy version?

Version 0.13.0b1 is seen in my ipython notebook and reproduces the error, while my terminal's ipython sees version 0.16.1 and does not reproduce the error.

There should be a simple workaround for this. Maybe a version check when evaluating the sign of the gwf frequency.

Cyberface commented 8 years ago

in terminal my version is:

In [8]: scipy.__version__
Out[8]: '0.17.0'

in ipython notebook I get '0.13.0b1'

I guess that's it then...

llondon6 commented 8 years ago

I have added a scipy version check to the related code. I have also added an ipython notebook example. Please give this another try and let me know how it goes.

llondon6 commented 8 years ago

Any luck, Cyberface?

Cyberface commented 8 years ago

Sorry just tried it now and it works!!

I loaded a bam waveform using my bam.ini file and I noticed a small problem. The "l" with is something to do with the extraction level or the resolution at which the data was extracted was hard coded to 5 as below but for this particular data set only l=6 was available. So I had to change my bam.ini file first as below and then it worked.

So I think we should add this as an option for the bam waveforms or something.

; data_file_name_format = Psi4ModeDecomp/psi3col.r%i.l5.l%i.m%i.gz
data_file_name_format = Psi4ModeDecomp/psi3col.r%i.l6.l%i.m%i.gz
data_file_param_order = extraction_parameter, l, m

i.e., we add another variable to data_file_param_order = extraction_parameter, l, m

llondon6 commented 8 years ago

Thanks!

Also thanks for letting me know about the extraction parameter issue with the BAM interface (maybe best to start a new issue). I have typically solved this by making the extraction parameter a loading input; e.g. the gwylm object would be called with an extraction parameter input. The user would know to do this after the code informs them that their requested file could not be found.