#!/bin/sh
echo "ncks-Turbulence_NPS: reduce data to those required for NPS Turbulence package"
vars="Time,time,depth,latitude,longitude,^sea_water_temperature,^sea_water_salinity,Turbulence_NPS.*"
echo $vars
# pull desired variables from slate.nc in each subdirectory
for ncf in ./Logs/*/slate.nc
    do
        ncks -O -v $vars $ncf $ncf.for_NPS
    done
# concatenate the filtered files along the record dimension
ncrcat -O ./Logs/*/slate.nc.for_NPS ./Logs/temp.nc
#TODO# concatenate the filtered files using time as the dimension
# remove the global variables
ncatted -O -a ,global,d,, ./Logs/temp.nc ./Logs/for_NPS.nc && rm ./Logs/temp.nc
#
echo "nc manipulation complete"
tar -cjf ./Logs/for_NPS.nc.tar.bz2 ./Logs/for_NPS.nc
echo "completed nc file tar/bzip"
