-
Notifications
You must be signed in to change notification settings - Fork 35
Add CTD thermal lag correction, YAML constants reader, and GSW salini… #234
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
Closed
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
bd3aab9
Add CTD thermal lag correction, YAML constants reader, and GSW salini…
19b4bdf
Fix deploymentyaml handling (support dict or path)
f52ddb5
Added mask and interpolation parameters to CTD function to make it mo…
1a5a89b
Added mask and interpolation parameters to CTD function to make it mo…
1ccd302
Add adjust_CTD docs and ignore Jupyter checkpoints
9dc7cf6
Update docs and add CTD adjustment guidance
53a221f
Adjusted pip installation
2d28aa4
Add CTD adjustment documentation page and include in toctree
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,3 +6,6 @@ dist | |
|
|
||
| *.png | ||
| .DS_Store | ||
| *.ipynb_checkpoints | ||
| Untitled*.ipynb | ||
| *.py.save | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "cells": [], | ||
| "metadata": {}, | ||
| "nbformat": 4, | ||
| "nbformat_minor": 5 | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,118 @@ | ||
| # PyGlider: Adjust CTD variables | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be incorporated in the rest of the docs somehow. |
||
|
|
||
| PyGlider applies a post-processing protocol to conductivity, temperature, and salinity variables in NetCDF timeseries files, and subsequently generates NetCDF depth–time grids using Python and `xarray`. The resulting NetCDF files are largely CF-compliant. | ||
|
|
||
| The basic workflow consists of converting a NetCDF timeseries into an adjusted timeseries and corresponding depth–time grids. This follows the `binary_to_timeseries` (for Slocum gliders) and `raw_to_timeseries` (for Alseamar gliders) protocols, which convert raw glider data into NetCDF format. The variable `outname` refers to the timeseries output from this prior step. | ||
|
|
||
| ```python | ||
| outname_ctd = pyglider.ncprocess.adjust_CTD( | ||
| outname, | ||
| deploymentyaml, | ||
| l1tsdir, | ||
| griddir, | ||
| dTdC=None, | ||
| tau=None, | ||
| alpha=None, | ||
| maskfunction=None, | ||
| interp_variables=None | ||
| ) | ||
| ``` | ||
|
|
||
| Data are read from and written to directories, and metadata are supplied via a YAML file. | ||
|
|
||
| --- | ||
|
|
||
| ## Post-processing steps within `pyglider.ncprocess.adjust_CTD` | ||
|
|
||
| ### 1. Identify anomalous conductivity values | ||
|
|
||
| We identify and flag conductivity values that are clearly unphysical, typically caused by air bubbles in the conductivity cell. | ||
|
|
||
| A two-step statistical criterion is applied: | ||
|
|
||
| - First, data points more than **5 standard deviations** from the mean are temporarily flagged within each depth and profile bin. | ||
| - The mean and standard deviation are then recomputed excluding these points. | ||
| - Values still exceeding **3 standard deviations** from the recomputed mean are flagged as **bad (QC = 4)** in `conductivity_QC`. | ||
|
|
||
| However, if the deviation is smaller than the sensor accuracy (0.0003 S/m for the GPCTD), the data are retained. | ||
|
|
||
| This procedure is applied using: | ||
|
|
||
| - Profile bins of 50 profiles | ||
| - Depth bins of 5 m | ||
|
|
||
| Using profile-index binning (rather than time or temperature) helps isolate unphysical values. | ||
|
|
||
| Salinity (`salinity_QC`) is flagged as bad (QC = 4) wherever `conductivity_QC` is QC4. | ||
|
|
||
| --- | ||
|
|
||
| ### 2. Determine what dTdC, tau, and alpha are used in the correction | ||
|
|
||
| We correct for: | ||
|
|
||
| - Sensor misalignment between temperature and conductivity (`dTdC`) | ||
| - Thermal lag effects (`tau`, `alpha`) | ||
|
|
||
| Where: | ||
|
|
||
| - `dTdC` = time lag (seconds) between temperature and conductivity sensors | ||
| - `tau` = thermal response time constant (seconds) | ||
| - `alpha` = scaling of thermal coupling between water and the conductivity cell | ||
|
|
||
| Further details and methods for determining these parameters are available at: | ||
| https://cproof.uvic.ca/gliderdata/deployments/reports/ | ||
|
|
||
| For recent C-PROOF missions, these values are included in the YAML file. However, users may: | ||
|
|
||
| - Provide custom values for `dTdC`, `tau`, and `alpha`, or | ||
| - Skip corrections by setting parameters to `None` | ||
|
|
||
| If user-supplied values differ from those in the YAML file, a warning is issued, but the user-provided values are used. | ||
|
|
||
| New variables introduced: | ||
|
|
||
| - `temperature_adjusted` | ||
| - `salinity_adjusted` | ||
| - `temperature_adjusted_QC` | ||
| - `salinity_adjusted_QC` | ||
|
|
||
| --- | ||
|
|
||
| ### 3. Recalculate derived variables | ||
|
|
||
| Using TEOS-10, we recompute: | ||
|
|
||
| - `potential_density_adjusted` | ||
| - `potential_temperature_adjusted` | ||
|
|
||
| Their corresponding QC variables: | ||
|
|
||
| - `potential_density_adjusted_QC` | ||
| - `potential_temperature_adjusted_QC` | ||
|
|
||
| These are flagged as bad (QC = 4) wherever `salinity_adjusted_QC` is QC4. | ||
|
|
||
| --- | ||
|
|
||
| ### 4. Convert the adjusted NetCDF timeseries to a NetCDF depth-time grid | ||
|
|
||
| The adjusted timeseries is converted into a gridded NetCDF dataset. | ||
|
|
||
| - Default binning: | ||
| - 1 m depth bins | ||
| - Profile bins | ||
|
|
||
| - Variables are averaged within each bin. | ||
|
|
||
| QC variables use a `QC_protocol` that selects the maximum QC value within each bin, ensuring that bad data are not diluted. | ||
|
|
||
| Optional parameters: | ||
|
|
||
| - `maskfunction` | ||
| - `interp_variables` | ||
|
|
||
| C-PROOF applies: | ||
|
|
||
| - `pyglider.ncprocess.CPROOF_mask` to exclude QC4 data from gridded products | ||
| - `pyglider.ncprocess.interpolate_vertical` to interpolate over vertical gaps up to 50 m | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not include junk!