|
| 1 | +2. Trimming to Deployed period |
| 2 | +============================== |
| 3 | + |
| 4 | +This document outlines the **trimming** step in the oceanarray processing workflow. Trimming refers to the process of isolating the valid deployment period from a time series—typically corresponding to the interval between instrument deployment and recovery. It also produces summary plots. |
| 5 | + |
| 6 | +This step may need to be run several times, adjusting the start and end of the deployment periods. |
| 7 | + |
| 8 | +It corresponds to **Stage 2** from RAPID data processing and management, which uses as input the RDB format and outputs (in RDB format) the `*.use`` file. |
| 9 | + |
| 10 | +1. Overview |
| 11 | +----------- |
| 12 | + |
| 13 | +Raw mooring records often contain extraneous data before deployment or after recovery (e.g., deck recording, values during ascent/descent, post-recovery handling). These segments must be trimmed to retain only the time interval when the instrument was collecting valid in-situ measurements at the nominal depth during deployment. In this stage: |
| 14 | + |
| 15 | +- Visualised to identify data issues (e.g., deployment start/end spikes only) |
| 16 | +- Optionally low-pass filtered (e.g., 2-day Butterworth) |
| 17 | +- Inspected manually |
| 18 | +- Optionally adjusted: |
| 19 | + - Revised trimming bounds |
| 20 | +- Prepared for further processing (e.g., gridding) |
| 21 | + |
| 22 | +2. Purpose |
| 23 | +---------- |
| 24 | + |
| 25 | +- Remove non-oceanographic data before deployment and after recovery |
| 26 | +- Ensure temporal consistency across instruments on the same mooring |
| 27 | +- Define the usable deployment interval for each instrument |
| 28 | +- Generate summary plots for review and archiving |
| 29 | + |
| 30 | + |
| 31 | +3. Input |
| 32 | +-------- |
| 33 | + |
| 34 | +- Standardised `xarray.Dataset` containing raw time series (`TIME`, `TEMPERATURE`, etc.) |
| 35 | +- Metadata indicating deployment and recovery times, either: |
| 36 | + - Attached to the dataset (e.g., `ds.attrs["start_time"]`) |
| 37 | + - Auxiliary logs (optional): info.dat with mooring latitude and longitude, and deployment times (anchor away) and recovery times (all gear on deck) |
| 38 | + |
| 39 | +4. Output |
| 40 | +--------- |
| 41 | + |
| 42 | +- Trimmed `xarray.Dataset` with: |
| 43 | + - `TIME` restricted to deployment period |
| 44 | + - Attributes updated with `trimmed = True` and `start_time`, `end_time` |
| 45 | +- Summary plots (e.g., `.png` or `.pdf` of raw and filtered time series) |
| 46 | +- Updated deployment metadata (e.g., revised start/end time if needed) in `info.dat` or similar human-readable format |
| 47 | + |
| 48 | + |
| 49 | +Common plots include: |
| 50 | + |
| 51 | +- Full record: `TEMPERATURE`, `CONDUCTIVITY`, `PRESSURE` |
| 52 | +- 2-day Butterworth filtered versions |
| 53 | + |
| 54 | + |
| 55 | +5. Example |
| 56 | +---------- |
| 57 | + |
| 58 | +.. code-block:: python |
| 59 | +
|
| 60 | + from oceanarray.methods.trimming import trim_to_deployment |
| 61 | +
|
| 62 | + ds_trimmed = trim_to_deployment(ds_std, start="2021-01-05T20:00", end="2023-02-25T17:00") |
| 63 | +
|
| 64 | +.. code-block:: text |
| 65 | +
|
| 66 | + <xarray.Dataset> |
| 67 | + Dimensions: (TIME: 104576) |
| 68 | + Coordinates: |
| 69 | + * TIME (TIME) datetime64[ns] ... |
| 70 | + Data variables: |
| 71 | + TEMPERATURE (TIME) float32 ... |
| 72 | + PRESSURE (TIME) float32 ... |
| 73 | + Attributes: |
| 74 | + start_time: 2021-01-05T20:00 |
| 75 | + end_time: 2023-02-25T17:00 |
| 76 | + trimmed: True |
| 77 | +
|
| 78 | +6. Implementation Notes |
| 79 | +----------------------- |
| 80 | + |
| 81 | +- Deployment periods should be specified in UTC or provided in the mooring `*info.dat` file as in the RAPID data processing and management framework. |
| 82 | +- Start and end times may come from cruise logs or recovery reports |
| 83 | +- Optionally: implement automatic detection of stable deployment periods (e.g., threshold in pressure) |
| 84 | + |
| 85 | +7. FAIR Considerations |
| 86 | +---------------------- |
| 87 | + |
| 88 | +- Trimmed intervals should be **documented transparently** in dataset attributes |
| 89 | +- Retain untrimmed data for provenance if needed |
| 90 | +- Enhances **reusability** and **accuracy** in further processing |
| 91 | + |
| 92 | +See also: :doc:`standardisation` |
| 93 | + |
| 94 | +Legacy Script (RAPID) |
| 95 | +--------------------- |
| 96 | + |
| 97 | +The RAPID script shows how the Seabird format data were changed into the RDB format. |
| 98 | + |
| 99 | + |
| 100 | + |
| 101 | +- `microcat_raw2use_003.m <../_static/code/microcat_raw2use_003.m>`__ |
| 102 | + |
| 103 | +This script was part of the original RAPID processing chain used to convert MicroCAT `.asc` or `.cnv` output to `.raw` files in RODB format. It includes parsing logic, metadata extraction from `info.dat`, time adjustment, and basic diagnostic plotting. |
| 104 | + |
| 105 | + |
| 106 | + |
| 107 | +.. literalinclude:: ../_static/code/microcat_raw2use_003.m |
| 108 | + :language: matlab |
| 109 | + :lines: 1-40 |
| 110 | + :linenos: |
| 111 | + :caption: Excerpt from `microcat_raw2use_003.m` |
0 commit comments