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

Climatology test errors when period is specified #66

Open
lgarzio opened this issue Sep 17, 2021 · 1 comment
Open

Climatology test errors when period is specified #66

lgarzio opened this issue Sep 17, 2021 · 1 comment

Comments

@lgarzio
Copy link

lgarzio commented Sep 17, 2021

I'm using the latest version of ioos_qc (2.0.1), and I get the following error when period is specified in the climatology test configuration:

Traceback (most recent call last):
File "/Users/garzio/opt/anaconda3/envs/ioos_qc_test/lib/python3.9/site-packages/ioos_qc/qartod.py", line 384, in check
flag_arr[(values_idx & ~fail_idx & suspect_idx)] = QartodFlags.SUSPECT
File "/Users/garzio/opt/anaconda3/envs/ioos_qc_test/lib/python3.9/site-packages/numpy/ma/core.py", line 3375, in setitem
_data[indx] = dval
IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis (None) and integer or boolean arrays are valid indices

Here is my example code:

import numpy as np
from ioos_qc.qartod import ClimatologyConfig, climatology_test

c = ClimatologyConfig()
c.add(tspan=[150, 270],
period='dayofyear',
vspan=[3.4, 5],
zspan=[0, 1000])

inp = np.array([0. , np.nan, 0. , np.nan, np.nan, np.nan, 4.16743, 4.23101, 4.23322])
t = np.array(['2021-07-16T19:01:01.313999872', '2021-07-16T19:01:02.315000064',
'2021-07-16T19:01:02.903000064', '2021-07-16T19:01:03.903000064',
'2021-07-16T19:01:04.903000064', '2021-07-16T19:01:05.903000064',
'2021-07-16T19:01:06.903000064', '2021-07-16T19:01:07.336000000',
'2021-07-16T19:01:07.903000064'], dtype='datetime64[ns]')
z = np.array([0. , np.nan, 0. , np.nan, np.nan, np.nan, 0.08931513, 0.15878244, 0.11908684])

results = climatology_test(config=c,
inp=inp,
tinp=t,
zinp=z)

When I debug this error, it looks like the issues is with line 345 of qartod.py
https://github.com/ioos/ioos_qc/blob/master/ioos_qc/qartod.py#L345

I changed tinp_copy = getattr(tinp, m.period).to_series() to tinp_copy = getattr(tinp, m.period) on my local machine, and the test ran correctly.

@lgarzio lgarzio changed the title Climatology test fails when period is specified Climatology test errors when period is specified Sep 17, 2021
@kwilcox
Copy link
Member

kwilcox commented Sep 22, 2021

Thanks for the test case/data, I'll plug it in and check it out!

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

No branches or pull requests

2 participants