Skip to content

Commit

Permalink
updated docs for download script
Browse files Browse the repository at this point in the history
  • Loading branch information
John-Ragland committed Nov 6, 2024
1 parent 36fccfe commit a004577
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
8 changes: 3 additions & 5 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,17 +151,15 @@ spec1 = hdata_broadband.compute_spectrogram()

There is a program for batch downloading ooi hydrophone data provided with the installation of ooipy. You can access it from your terminal:
```console
download_ooi_hydrophone_data
download_hydrophone_data --csv <path to csv> --output_path <path to save files>
```

This script downloads hydrophone data that is specified in a csv.

Here is an example csv file:

```csv
node,start_time,end_time,file_format,downsample_factor
LJ03A,2019-08-03T08:00:00,2019-08-03T08:01:00,mat,64
AXBA1,2019-08-03T12:01:00,2019-08-03T12:02:00,mat,1
LJ03A,2019-08-03T08:00:00,2019-08-03T08:01:00,wav,1
AXBA1,2019-08-03T12:01:00,2019-08-03T12:02:00,wav,1
```

## Download CTD Data
Expand Down
30 changes: 18 additions & 12 deletions src/ooipy/scripts/download_hydrophone_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,23 @@
example csv file:
-----------------
node,start_time,end_time,file_format
LJ03A,2019-08-03T08:00:00,2019-08-03T08:01:00,pkl
LJ03A,2019-08-03T12:01:00,2019-08-03T12:02:00,pkl
- create a csv file with the above contents and save it in your working path
script usage:
-------------
python download_broadband.py --csv path/to/csv --output_path path/to/output
```csv
node,start_time,end_time,file_format,downsample_factor
LJ03A,2019-08-03T08:00:00,2019-08-03T08:01:00,wav,1
AXBA1,2019-08-03T12:01:00,2019-08-03T12:02:00,wav,1
```
usage:
```console
download_hydrophone_data --csv path/to/csv --output_path path/to/output
```
"""

import argparse
import sys

import pandas as pd
from tqdm import tqdm

import numpy as np
import ooipy


Expand Down Expand Up @@ -109,9 +109,15 @@ def format_bytes(size):
if hdata is None:
print(f"no data found for {item.node} between {start_time_d} and {end_time_d}")
continue

# fill masked values with mean
hdata.data = np.ma.filled(hdata.data, np.mean(hdata.data.mean()))

# downsample
downsample_factor = item.downsample_factor
if item.downsample_factor <= 16:
if item.downsample_factor == 1:
hdata_ds = hdata
elif item.downsample_factor <= 16:
hdata_ds = hdata.decimate(item.downsample_factor)
else:
hdata_ds = hdata
Expand Down

0 comments on commit a004577

Please sign in to comment.