Skip to content
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

implementation of spectral estimates for complex arrays #30

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

apatlpo
Copy link

@apatlpo apatlpo commented Jun 25, 2019

No description provided.

@apatlpo
Copy link
Author

apatlpo commented Jun 25, 2019

This is very much WIP at this stage and not functional yet

@apatlpo apatlpo mentioned this pull request Jun 25, 2019
@apatlpo
Copy link
Author

apatlpo commented Jun 26, 2019

getting there but the functionality it not certain yet

@apatlpo
Copy link
Author

apatlpo commented Jun 26, 2019

It seems it's not functional yet.

In the following example, I cannot plot E without producing an error:

import numpy as np
from mtspec import mtspec
import matplotlib.pyplot as plt

ti = np.arange(0,256)
data = np.cos(2*np.pi/20*ti) - 1j*np.sin(2*np.pi/20*ti)
print(data.dtype)
E, f = mtspec(data=data, delta=1./24., time_bandwidth=4., \
        number_of_tapers=6, quadratic=True)
print(E)
print(f)
plt.plot(E)

leads to:

[-4.4318754e-20 -4.6489929e-20 -3.7117733e-20 -5.0900811e-18
 -1.4576420e-17 -2.4307027e-17 -3.1485909e-17 -3.1295965e-17
 -2.3651286e-17 -1.1811272e-17 -2.7214600e-18 -1.4852743e-25
 -9.6215933e-29 -2.6517997e-27 -2.5299975e-27 -1.2042038e-27
 -4.1102142e-28 -9.9541448e-29 -1.8026155e-29 -3.2024532e-29
 -7.8070658e-29 -1.2975003e-28 -1.7463777e-28 -2.1021020e-28
 -2.3627597e-28 -2.5409191e-28 -2.6519516e-28 -2.7104358e-28
 -2.7288383e-28 -2.7172893e-28 -2.6837858e-28 -2.6345318e-28
 -2.5742837e-28 -2.5066573e-28 -2.4343822e-28 -2.3595040e-28
 -2.2835448e-28 -2.2076261e-28 -2.1325637e-28 -2.0589424e-28
 -1.9871696e-28 -1.9175186e-28 -1.8502835e-28 -1.7843032e-28
 -1.7251457e-28 -1.6596362e-28 -1.6066409e-28 -1.5491918e-28
 -1.4965918e-28 -1.4457327e-28 -1.3970208e-28 -1.3503406e-28
 -1.3056008e-28 -1.2627101e-28 -1.2215677e-28 -1.1825253e-28
 -1.1417525e-28 -1.1135817e-28 -1.0669077e-28 -1.0422802e-28
 -1.0063883e-28 -9.7587099e-29 -9.4585489e-29 -9.1693928e-29
 -8.8904008e-29 -8.6210119e-29 -8.3606996e-29 -8.1089451e-29
 -7.8658596e-29 -7.6269257e-29 -7.4055942e-29 -7.1745242e-29
 -6.9655831e-29 -6.7543976e-29 -6.5515972e-29 -6.3541442e-29
 -6.1621194e-29 -5.9753096e-29 -5.7935415e-29 -5.6166822e-29
 -5.4463698e-29 -5.2509758e-29 -5.2204323e-29 -4.7816528e-29
 -4.9449882e-29 -4.6053406e-29 -4.5183168e-29 -4.3740969e-29
 -4.2417358e-29 -4.1151411e-29 -3.9947576e-29 -3.8809983e-29
 -3.7743147e-29 -3.6751841e-29 -3.5840924e-29 -3.5015215e-29
 -3.4279419e-29 -3.3638368e-29 -3.3097961e-29 -3.2667678e-29
 -3.2366324e-29 -3.2234434e-29 -3.2359917e-29 -3.2930056e-29
 -3.4335699e-29 -3.7379134e-29 -4.3687795e-29 -5.6585994e-29
 -8.2299627e-29 -1.3543098e-28 -2.3944892e-28 -4.4970623e-28
 -8.5679028e-28 -1.5824810e-27 -2.5474404e-27 -2.7438722e-27
 -7.4597491e-26 -2.8396150e-25 -1.9498607e-18 -8.5565829e-18
 -1.7295323e-17 -2.2948161e-17 -2.3117190e-17 -1.7807233e-17
 -1.0535285e-17 -3.5249690e-18 -8.4455899e-28 -3.6090958e-24
 -5.0427033e-28 -3.6090958e-24 -8.4455899e-28 -3.5249690e-18
 -1.0535285e-17 -1.7807233e-17 -2.3117190e-17 -2.2948161e-17
 -1.7295323e-17 -8.5565829e-18 -1.9498607e-18 -2.8396150e-25
 -7.4597491e-26 -2.7438722e-27 -2.5474404e-27 -1.5824810e-27
 -8.5679028e-28 -4.4970623e-28 -2.3944892e-28 -1.3543098e-28
 -8.2299627e-29 -5.6585994e-29 -4.3687795e-29 -3.7379134e-29
 -3.4335699e-29 -3.2930056e-29 -3.2359917e-29 -3.2234434e-29
 -3.2366324e-29 -3.2667678e-29 -3.3097961e-29 -3.3638368e-29
 -3.4279419e-29 -3.5015215e-29 -3.5840924e-29 -3.6751841e-29
 -3.7743147e-29 -3.8809983e-29 -3.9947576e-29 -4.1151411e-29
 -4.2417358e-29 -4.3740969e-29 -4.5183168e-29 -4.6053406e-29
 -4.9449882e-29 -4.7816528e-29 -5.2204323e-29 -5.2509758e-29
 -5.4463698e-29 -5.6166822e-29 -5.7935415e-29 -5.9753096e-29
 -6.1621194e-29 -6.3541442e-29 -6.5515972e-29 -6.7543976e-29
 -6.9655831e-29 -7.1745242e-29 -7.4055942e-29 -7.6269257e-29
 -7.8658596e-29 -8.1089451e-29 -8.3606996e-29 -8.6210119e-29
 -8.8904008e-29 -9.1693928e-29 -9.4585489e-29 -9.7587099e-29
 -1.0063883e-28 -1.0422802e-28 -1.0669077e-28 -1.1135817e-28
 -1.1417525e-28 -1.1825253e-28 -1.2215677e-28 -1.2627101e-28
 -1.3056008e-28 -1.3503406e-28 -1.3970208e-28 -1.4457327e-28
 -1.4965918e-28 -1.5491918e-28 -1.6066409e-28 -1.6596362e-28
 -1.7251457e-28 -1.7843032e-28 -1.8502835e-28 -1.9175186e-28
 -1.9871696e-28 -2.0589424e-28 -2.1325637e-28 -2.2076261e-28
 -2.2835448e-28 -2.3595040e-28 -2.4343822e-28 -2.5066573e-28
 -2.5742837e-28 -2.6345318e-28 -2.6837858e-28 -2.7172893e-28
 -2.7288383e-28 -2.7104358e-28 -2.6519516e-28 -2.5409191e-28
 -2.3627597e-28 -2.1021020e-28 -1.7463777e-28 -1.2975003e-28
 -7.8070658e-29 -3.2024532e-29 -1.8026155e-29 -9.9541448e-29
 -4.1102142e-28 -1.2042038e-27 -2.5299975e-27 -2.6517997e-27
 -9.6215933e-29 -1.4852743e-25 -2.7214600e-18 -1.1811272e-17
 -2.3651286e-17 -3.1295965e-17 -3.1485909e-17 -2.4307027e-17
 -1.4576420e-17 -5.0900811e-18 -3.7117733e-20 -4.6489929e-20]
[  0.        0.09375   0.1875    0.28125   0.375     0.46875   0.5625
   0.65625   0.75      0.84375   0.9375    1.03125   1.125     1.21875
   1.3125    1.40625   1.5       1.59375   1.6875    1.78125   1.875
   1.96875   2.0625    2.15625   2.25      2.34375   2.4375    2.53125
   2.625     2.71875   2.8125    2.90625   3.        3.09375   3.1875
   3.28125   3.375     3.46875   3.5625    3.65625   3.75      3.84375
   3.9375    4.03125   4.125     4.21875   4.3125    4.40625   4.5
   4.59375   4.6875    4.78125   4.875     4.96875   5.0625    5.15625
   5.25      5.34375   5.4375    5.53125   5.625     5.71875   5.8125
   5.90625   6.        6.09375   6.1875    6.28125   6.375     6.46875
   6.5625    6.65625   6.75      6.84375   6.9375    7.03125   7.125
   7.21875   7.3125    7.40625   7.5       7.59375   7.6875    7.78125
   7.875     7.96875   8.0625    8.15625   8.25      8.34375   8.4375
   8.53125   8.625     8.71875   8.8125    8.90625   9.        9.09375
   9.1875    9.28125   9.375     9.46875   9.5625    9.65625   9.75
   9.84375   9.9375   10.03125  10.125    10.21875  10.3125   10.40625
  10.5      10.59375  10.6875   10.78125  10.875    10.96875  11.0625
  11.15625  11.25     11.34375  11.4375   11.53125  11.625    11.71875
  11.8125   11.90625  12.      -11.90625 -11.8125  -11.71875 -11.625
 -11.53125 -11.4375  -11.34375 -11.25    -11.15625 -11.0625  -10.96875
 -10.875   -10.78125 -10.6875  -10.59375 -10.5     -10.40625 -10.3125
 -10.21875 -10.125   -10.03125  -9.9375   -9.84375  -9.75     -9.65625
  -9.5625   -9.46875  -9.375    -9.28125  -9.1875   -9.09375  -9.
  -8.90625  -8.8125   -8.71875  -8.625    -8.53125  -8.4375   -8.34375
  -8.25     -8.15625  -8.0625   -7.96875  -7.875    -7.78125  -7.6875
  -7.59375  -7.5      -7.40625  -7.3125   -7.21875  -7.125    -7.03125
  -6.9375   -6.84375  -6.75     -6.65625  -6.5625   -6.46875  -6.375
  -6.28125  -6.1875   -6.09375  -6.       -5.90625  -5.8125   -5.71875
  -5.625    -5.53125  -5.4375   -5.34375  -5.25     -5.15625  -5.0625
  -4.96875  -4.875    -4.78125  -4.6875   -4.59375  -4.5      -4.40625
  -4.3125   -4.21875  -4.125    -4.03125  -3.9375   -3.84375  -3.75
  -3.65625  -3.5625   -3.46875  -3.375    -3.28125  -3.1875   -3.09375
  -3.       -2.90625  -2.8125   -2.71875  -2.625    -2.53125  -2.4375
  -2.34375  -2.25     -2.15625  -2.0625   -1.96875  -1.875    -1.78125
  -1.6875   -1.59375  -1.5      -1.40625  -1.3125   -1.21875  -1.125
  -1.03125  -0.9375   -0.84375  -0.75     -0.65625  -0.5625   -0.46875
  -0.375    -0.28125  -0.1875   -0.09375]
2019-06-26 15:42:20.387 python[51571:60266591] -[NSApplication _setup:]: unrecognized selector sent to instance 0x7fe4c697f570
2019-06-26 15:42:20.388 python[51571:60266591] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSApplication _setup:]: unrecognized selector sent to instance 0x7fe4c697f570'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff309cfcfd __exceptionPreprocess + 256
	1   libobjc.A.dylib                     0x00007fff5b075a17 objc_exception_throw + 48
	2   CoreFoundation                      0x00007fff30a49b06 -[NSObject(NSObject) __retain_OA] + 0
	3   CoreFoundation                      0x00007fff30971b8f ___forwarding___ + 1485
	4   CoreFoundation                      0x00007fff30971538 _CF_forwarding_prep_0 + 120
	5   libtk8.6.dylib                      0x000000010ba6d154 TkpInit + 324
	6   libtk8.6.dylib                      0x000000010b9c50ee Initialize + 2622
	7   _tkinter.cpython-36m-darwin.so      0x000000010b7eea46 _tkinter_create + 1174
	8   python                              0x00000001001ca538 _PyCFunction_FastCallDict + 200
	9   python                              0x00000001002a158f call_function + 143
	10  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	11  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	12  python                              0x00000001002a2165 _PyFunction_FastCallDict + 373
	13  python                              0x0000000100148c80 _PyObject_FastCallDict + 320
	14  python                              0x00000001001703d8 method_call + 136
	15  python                              0x00000001001502de PyObject_Call + 62
	16  python                              0x00000001001f18d5 slot_tp_init + 117
	17  python                              0x00000001001f5e21 type_call + 241
	18  python                              0x0000000100148bf1 _PyObject_FastCallDict + 177
	19  python                              0x0000000100150e47 _PyObject_FastCallKeywords + 327
	20  python                              0x00000001002a1688 call_function + 392
	21  python                              0x000000010029f1c1 _PyEval_EvalFrameDefault + 46993
	22  python                              0x00000001002a194c fast_function + 188
	23  python                              0x00000001002a15ec call_function + 236
	24  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	25  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	26  python                              0x00000001002a2165 _PyFunction_FastCallDict + 373
	27  python                              0x0000000100148c80 _PyObject_FastCallDict + 320
	28  python                              0x00000001001703d8 method_call + 136
	29  python                              0x00000001001502de PyObject_Call + 62
	30  python                              0x000000010029f320 _PyEval_EvalFrameDefault + 47344
	31  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	32  python                              0x00000001002a19fa fast_function + 362
	33  python                              0x00000001002a15ec call_function + 236
	34  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	35  python                              0x00000001002a194c fast_function + 188
	36  python                              0x00000001002a15ec call_function + 236
	37  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	38  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	39  python                              0x00000001002a19fa fast_function + 362
	40  python                              0x00000001002a15ec call_function + 236
	41  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	42  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	43  python                              0x00000001002a19fa fast_function + 362
	44  python                              0x00000001002a15ec call_function + 236
	45  python                              0x000000010029f111 _PyEval_EvalFrameDefault + 46817
	46  python                              0x0000000100292869 _PyEval_EvalCodeWithName + 425
	47  python                              0x00000001002eb0bc PyRun_FileExFlags + 252
	48  python                              0x00000001002ea594 PyRun_SimpleFileExFlags + 372
	49  python                              0x00000001003111f6 Py_Main + 3766
	50  python                              0x0000000100140d19 main + 313
	51  libdyld.dylib                       0x00007fff5c8433d5 start + 1
	52  ???                                 0x0000000000000002 0x0 + 2
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Abort trap: 6

@apatlpo
Copy link
Author

apatlpo commented Jun 26, 2019

but I run out of ideas to fix this ... help would be needed

@apatlpo apatlpo changed the title implementation of complex data for mtspec implementation of spectral estimates for complex arrays Jul 15, 2019
@apatlpo
Copy link
Author

apatlpo commented Jul 15, 2019

Some progress with the latest push but frequencies are not right, see the following example

@dcherian
Copy link

@apatlpo I ahve used mtspec to construct a rotary psd, see here: https://github.com/dcherian/dcpy/blob/56f8b32822426552279922ee5b25860d069b2fb6/dcpy/ts.py#L681

No error bounds though...

@apatlpo
Copy link
Author

apatlpo commented Jul 16, 2019

thanks @dcherian !
I'll turn to your solution if I get stuck.

I can see you have lots of useful goodies for oceanographers in your dcpy ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants