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

can't load saved correlation data in DASDAE format #434

Closed
ahmadtourei opened this issue Sep 24, 2024 · 2 comments
Closed

can't load saved correlation data in DASDAE format #434

ahmadtourei opened this issue Sep 24, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@ahmadtourei
Copy link
Collaborator

Description

Cross-correlated results (without an idft applied) are saved in DASDAE format but I cannot read the cc patches out of the saved spool.

Example

import dascore as dc

sp = dc.spool("/path/to/spool")
cc_dir = "/path/for/cc/results"

pa = sp[0]
padded_pa = pa.select(distance=(0, 10), samples=True).pad(time="correlate") 
dft_pa = padded_pa.dft("time", real=True)        
cc_pa = dft_pa.correlate(distance=[0, 1, 2], samples=True)
write_path = f"{cc_dir}{cc_pa_name}"
cc_pa.io.write(write_path, "dasdae")

sp_cc = dc.spool(cc_dir)
sp_cc[0]

It raises the following CoordError:

---------------------------------------------------------------------------
CoordError                                Traceback (most recent call last)
Cell In[27], [line 2](vscode-notebook-cell:?execution_count=27&line=2)
      [1](vscode-notebook-cell:?execution_count=27&line=1) sp_cc = dc.spool(cc_dir)
----> [2](vscode-notebook-cell:?execution_count=27&line=2) sp_cc[0]

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\core\spool.py:376, in DataFrameSpool.__getitem__(self, item)
    [370](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:370)     out = self.new_from_df(
    [371](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:371)         df=new_df,
    [372](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:372)         instruction_df=new_inst,
    [373](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:373)         source_df=new_source,
    [374](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:374)     )
    [375](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:375) else:  # a single index was used, should return a single patch
--> [376](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:376)     out = self._unbox_patch(self._get_patches_from_index(item))
    [377](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:377) return out

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\core\spool.py:405, in DataFrameSpool._get_patches_from_index(self, df_ind)
    [403](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:403) assert not df1.empty
    [404](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:404) joined = df1.join(source.drop(columns=df1.columns, errors="ignore"))
--> [405](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:405) return self._patch_from_instruction_df(joined)

File c:\Users\tourei\dasmasw\dasmsw_testing\.venv\lib\site-packages\dascore\core\spool.py:415, in DataFrameSpool._patch_from_instruction_df(self, joined)
    [412](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:412) for patch_kwargs in df_dict_list:
    [413](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:413)     # convert kwargs to format understood by parser/patch.select
    [414](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/spool.py:414)     kwargs = _convert_min_max_in_kwargs(patch_kwargs, joined)
...
-> [1172](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/coordmanager.py:1172)     raise CoordError(msg)
   [1173](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/coordmanager.py:1173) cval = coord[1]
   [1174](file:///C:/Users/tourei/dasmasw/dasmsw_testing/.venv/lib/site-packages/dascore/core/coordmanager.py:1174) # pull out any relevant info from attrs.

CoordError: Coordinate specified invalid dimension(s) {''}. Valid dimensions are ('ft_time', 'distance', 'source_distance')

Expected behavior

Versions

  • OS [e.g. Ubuntu 20.04]: Windows 10
  • DasCore Version [e.g. 0.0.5]: 0.1.3
  • Python Version [e.g. 3.10]: 3.10
@ahmadtourei ahmadtourei added the bug Something isn't working label Sep 24, 2024
@ahmadtourei
Copy link
Collaborator Author

ahmadtourei commented Sep 24, 2024

tried writing the results in "Pickle" format and it worked with no error loading one patch but got the same error for multiple patches spool.

@ahmadtourei
Copy link
Collaborator Author

Closed after #440.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant