Skip to content

Commit

Permalink
feat(data-layers): use log values for oc.chlor_a
Browse files Browse the repository at this point in the history
  • Loading branch information
pwambach committed Sep 2, 2020
1 parent 8a89118 commit 7b1aa82
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
1 change: 1 addition & 0 deletions data/downloads/odp-ftp-oc.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ do

curl --silent $FTP_URL > $FILENAME

python ./data/log-values.py --file $FILENAME --variable chlor_a
python ./data/drop-unused-vars.py --file $FILENAME --variable chlor_a
done
8 changes: 4 additions & 4 deletions data/gdal-colors/colors-chlor_a.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
30 245 245 208
3 142 211 186
0.3 34 150 193
0.03 37 56 159
1.47, 245, 245, 208
0.47, 142, 211, 186
-0.52, 34, 150, 193
-1.52, 37, 56, 159
nv 0 0 0 0
15 changes: 15 additions & 0 deletions data/log-values.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import os
import xarray as xr
from argparse import ArgumentParser

parser = ArgumentParser()
parser.add_argument("-f", "--file", dest="file")
parser.add_argument("-v", "--variable", dest="variable")
args = parser.parse_args()

ds = xr.open_dataset(args.file, decode_coords=True, decode_cf=True)
da = ds[args.variable]
ds[args.variable] = xr.ufuncs.log10(da)

os.remove(args.file)
ds.to_netcdf(args.file, format='NETCDF4', mode='w')

0 comments on commit 7b1aa82

Please sign in to comment.