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

Parse AZFP pressure data when available #1181

Closed
emiliom opened this issue Sep 24, 2023 · 6 comments
Closed

Parse AZFP pressure data when available #1181

emiliom opened this issue Sep 24, 2023 · 6 comments
Assignees
Labels
enhancement This makes echopype better

Comments

@emiliom
Copy link
Collaborator

emiliom commented Sep 24, 2023

AZFP deployments can contain a pressure sensor. However, the echopype AZFP parser currently does not look for and read pressure data, as it does for temperature. Add this.

When read, it should be used to populate Platform.vertical_offset while also setting Platform.water_level to 0. See https://echopype.readthedocs.io/en/stable/data-proc-additional.html#vertical-coordinate-z-axis-variables

We'll need to obtain a sample data file that includes pressure data.

@emiliom
Copy link
Collaborator Author

emiliom commented Oct 15, 2023

After parsing the pressure data, the data array needs to be written into the EchoData object.

I think there are two steps here:

  1. Store pressure in the Environment group, via the set_env class method. Populate its variable attributes. Base this on what's done for temperature, but modifying attribute values to correspond to pressure. Here are the attribute values to use:
    • "long_name": "Sea water pressure"
    • "standard_name": "sea_water_pressure_due_to_sea_water"
    • "units": "dbar"
  2. Use pressure and a standard seawater equation ("equations of state") to calculate depth (meters). Then set Platform.vertical_offset to this depth array, multiplied by -1 (see here). LoadAZFP.m has this conversion in the computeDepth function. It doesn't look like we have a seawater density function in echopype, but we can incorporate one. The "ideal" package would be https://github.com/TEOS-10/GSW-Python, but unfortunately it depends on a C library. Note that GSW-Python already includes a function to go from pressure to depth (see gsw.conversions.z_from_p), but it requires at least one parameter that may not be available: latitude. @leewujung should we use simplifications for density (we'll have to use a default salinity anyways) and omit a latitude adjustment? We could try to extract pure-Python code from the now-deprecated package https://github.com/TEOS-10/python-gsw

@emiliom emiliom moved this from Todo to In Progress in Echopype Oct 23, 2023
@emiliom
Copy link
Collaborator Author

emiliom commented Oct 23, 2023

PR #1189 addressed item 1 above: parsing and storing pressure data, plus tests.

For item 2, we'll need to decide what conversion formula / algorithm / library to use to convert from pressure to depth.

@emiliom
Copy link
Collaborator Author

emiliom commented Oct 24, 2023

For reference, here's the functionality used by the AZFP Matlab toolbox to calculate density (The links below are to a private repo):

  • In LoadAZFP.m, computeDepth function:
    g = 9.815;
    dens = sw_dens(Parameters.Salinity,T,Pressure);
    Depth = Pressure*10000 / (dens * g);
  • sw_dens is found in the same toolbox, in sw_dens.m. It's based on the "Density of Sea Water using UNESCO 1983 (EOS 80) polynomial." It calls two other functions, sw_dens0.m and sw_seck.m

@emiliom
Copy link
Collaborator Author

emiliom commented Oct 24, 2023

Hmm, the python-gsw function z_from_p doesn't require a density calculation, or salinity. It does require latitude, naturally, but since AZFP data will lack latitude, we could input a mid-range value, say, 45 degrees.

@emiliom
Copy link
Collaborator Author

emiliom commented Oct 26, 2023

@praneethratna Ok, I now have a recommendation for implementing the conversion from pressure to depth. Let's use the UNESCO 1983 formulation (pages 25-27). This site lists the equations nicely and includes a calculator. We'll make the standard seawater assumption used in that site: salinity of 35 PSU and temperature of 0 C. That makes the $ΔD$ term in UNESCO 1983 equation 25 become zero. That equation is then identical as eq. 3 in the other site.

Let's implement this as a new function depth_from_pressure in utils/misc.py. The arguments will be:

  • pressure (numpy array)
  • latitude (scalar), with a default of 30
  • atm_pres_surf (scalar), with a default of 0 (atmospheric pressure at the surface)

In the function, atm_pres_surf will be subtracted from the pressure array.

The function returns a depth numpy array.

PS. I'm including here other references I consulted. No need to look at them. I just want to be able to find them after I close those tabs in my browser 😉.

@ctuguinay
Copy link
Collaborator

ctuguinay commented Apr 24, 2024

This should be closed by the merging of #1189 and #1207

@github-project-automation github-project-automation bot moved this from In Progress to Done in Echopype Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This makes echopype better
Projects
Status: Done
Development

No branches or pull requests

4 participants