OSOceanAcoustics / echopype

Enabling interoperability and scalability in ocean sonar data analysis
https://echopype.readthedocs.io/
Apache License 2.0
89 stars 70 forks source link

AZFP file contains empty "DS" field? #1256

Open ZHANGGU opened 5 months ago

ZHANGGU commented 5 months ago

General description of problem

Required I cannot convert AZFP data

Computing environment

Required

Minimum example

Required: A minimum code snippet that reproduces your problem. The following code reproduces the errors I encountered:

CODE SNIPPET

import echopype as ep import os from datetime import datetime

src_dir = r'G:\2023200002-ANTARCTIC-PROVIDER\DATA-INNKOMMENDE\HYDROAKUSTIKK-ASL-AZFP\DATA' dst_dir = r'E:\MyWork\Krill\2023200002-ANTARCTIC-PROVIDER\ASL_AZFP'

xml_fp = r'G:\2023200002-ANTARCTIC-PROVIDER\DATA-INNKOMMENDE\HYDROAKUSTIKK-ASL-AZFP\DATA\202002\20021418.XML' post_fix = '01A' for c in os.listdir(src_dir): sub_c = os.path.join(src_dir, c) for f in os.listdir(sub_c): if f.find(post_fix)>0: fp = os.path.join(sub_c, f) fmtime = os.path.getmtime(fp) mo_datetime = datetime.fromtimestamp(fmtime) ftimestamp = datetime.strftime(mo_datetime, '%Y%m%%dT%H%M%S') ed = ep.open_raw(fp, sonar_model='AZFP', xml_path=xml_fp) nc_fp = os.path.join(dst_dir, f.replace(post_fix, '{:}.nc'.format(ftimestamp))) ed.to_netcdf(save_path=nc_fp) print('{:} converted'.format(f))

Error message printouts

Required: Copy-paste the entire error messages you encounter here. Below is the error messages I received when running the above code:

ERROR MESSAGES

TypeError: 'float' object is not subscriptable

Provide an example file

Required: An example file that allow reproducing the problem.

Troubleshooting

Optional but preferred: Explain any steps that you have taken to identify the cause of conversion error.

This is a float that has no reference [freq_ch] v = (np.log10(v) - 2.5) (8 65535) * self.parameters["DS"][freq_ch] image

praneethratna commented 5 months ago

@ZHANGGU Thanks for reporting this! could you share the data files so that we can debug this better?

ZHANGGU commented 5 months ago

I tried to correct the bug but some other bugs came out as well. It cannot read my AZFP file of the version 01A [Uploading 20021600.zip…]() . I uploaded a sample file. would you plz share the data specification?

praneethratna commented 5 months ago

@ZHANGGU The link points to github issue, could you upload the data files and share a link to same here?

ZHANGGU commented 5 months ago

[Uploading 20021600.zip…]()

leewujung commented 4 months ago

@ZHANGGU : Could you provide a new link to an example file? The previous link does not point to a file.

ZHANGGU commented 4 months ago

Desktop.zip sorry late reply. plz find the files as enclosed

ctuguinay commented 3 months ago

Hi @ZHANGGU, in your zip above, you only included the .01A files, but the parsing of AZFP needs .XML files too. Could you resend a zip with the .01A and .XML files?

leewujung commented 2 months ago

Hey @ZHANGGU : Could you provide an XML file for this so that we can look into the issue?

ZHANGGU commented 2 months ago

14021116.zip @leewujung uploaded

ctuguinay commented 2 months ago

@ZHANGGU

So @leewujung and I looked at your file and we saw that there are two sections here that imply different things about the frequency: The first section implies that there is 1 frequency in the DS and it's stated to be 125kHz, and the second section implies that there are 4 frequencies. Does your current setup have 4 125 kHz channels?

ZHANGGU commented 2 months ago

only 125 kHz was used. Azfp link can export without problems

leewujung commented 2 months ago

@ZHANGGU : We are not part of ASL and don't have access to AZFP link source code.

@ctuguinay : The only place I can see the association between the active channels and the parameters is using the entries under AZFP_Parameters/Header/Boards: This is from the provided file:

Screenshot 2024-04-19 at 5 53 02 AM

This is from one of our test files:

Screenshot 2024-04-19 at 5 53 37 AM

But it's not clear to me how this is mapped to the info under Phases that tells the instrument when to transmit. Let's connect with ASL to find out.

ZHANGGU commented 2 months ago

Azfp supports 4 frequencies but we did configured only 1 frequency of 125 kHz! It does not need to use 4 frequencies in practice. The code should reflect practices. thx

leewujung commented 2 months ago

@ZHANGGU : We don't have access to the info until ASL gets back to us. You are free to propose code changes via PR on this repo.