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

Issues with occam 2d reading data #64

Open
alkirkby opened this issue Oct 17, 2024 · 1 comment
Open

Issues with occam 2d reading data #64

alkirkby opened this issue Oct 17, 2024 · 1 comment

Comments

@alkirkby
Copy link
Collaborator

alkirkby commented Oct 17, 2024

When I read an occam data file with code below I get an error in Occam2DData

ocd = Occam2DData()
ocd.read_data_file(r'U:\scratch\alisonk\MT\synthetic_data\Forward.fwd')

The problem is line , line 456 :df = df.groupby(["station", "period"]).agg("first")

Really not sure what is going on here!
I have spent quite a bit of time trying to debug but no luck.

I attached the file I am trying to read, it's a forward model from Occam (but have had problems with other files)
Forward.txt

Traceback (most recent call last):

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\spyder_kernels\customize\utils.py:209 in exec_encapsulate_locals
exec_fun(compile(code_ast, filename, "exec"), globals)

File occam_resolution_test_setup_inv.py:12
ocd.read_data_file(r'U:\scratch\alisonk\MT\synthetic_data\Forward.fwd')

File C:\git\mtpy-v2\mtpy\modeling\occam2d\data.py:456 in read_data_file
df = df.groupby(["station", "period"]).agg("first")

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\generic.py:1432 in aggregate
result = op.agg()

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\apply.py:187 in agg
return self.apply_str()

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\apply.py:603 in apply_str
return self._apply_str(obj, func, *self.args, **self.kwargs)

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\apply.py:693 in _apply_str
return f(*args, **kwargs)

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\groupby.py:3400 in first
return self._agg_general(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\groupby.py:1906 in _agg_general
result = self._cython_agg_general(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\groupby.py:1998 in _cython_agg_general
new_mgr = data.grouped_reduce(array_func)

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\internals\managers.py:1473 in grouped_reduce
applied = blk.apply(func)

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\internals\blocks.py:393 in apply
result = func(self.values, **kwargs)

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\groupby.py:1973 in array_func
result = self._grouper._cython_operation(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\ops.py:830 in _cython_operation
return cy_op.cython_operation(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\ops.py:549 in cython_operation
return self._cython_op_ndim_compat(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\ops.py:344 in _cython_op_ndim_compat
return self._call_cython_op(

File ~\AppData\Local\miniforge3\envs\mtpy-v2\Lib\site-packages\pandas\core\groupby\ops.py:418 in _call_cython_op
func(

File groupby.pyx:1477 in pandas._libs.groupby.__pyx_fused_cpdef

TypeError: No matching signature found

@alkirkby
Copy link
Collaborator Author

alkirkby commented Nov 4, 2024

I have written a work-around (bit clunky but does the job). See latest branch occam2d_fixes_2. I will do a PR, @kujaku11, you might want to take a look and replace with the proper pandas functions. Or you might not :)

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

1 participant