次のコードは、netcdf ファイルから数値を抽出し、ループごとにそれらを別の netcdf ファイルに格納します。
mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is squeeze. So look in the text files for all the spaces and replace them by newline '/n'
mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)
echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"
outputNumber="$(ls -lq *_??????.nc | wc -l)"
echo "the number of output netcdf fles is ${outputNumber}"
valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)
for ((i=1; i<=outputNumber; i++))
do
echo "geknoei$i.nc"
ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
done
スペースの問題により、入力ファイルを圧縮する必要があり、このコードは機能しなくなりました。ループ内でファイルを (一度に 1 つずつ) 解凍し、必要なものを抽出して、ループの最後に再圧縮するコードを作成できるかどうか疑問に思っています。
つまり、次のようになります:
mapfile Latitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLatitude.txt) #tr is transform from to -s is search. So look in the text files for all the spaces and replace them by newline '/n'
mapfile Longitude < <(tr -s ' ' '\n' < final_ADCP_Saved.matLongitude.txt)
echo "length of Lat is ${#Latitude[@]}"
echo "length of Lon is ${#Longitude[@]}"
outputNumber="$(ls -lq *_??????.nc | wc -l)"
echo "the number of output netcdf fles is ${outputNumber}"
valueI=`cat I.txt`
valueJ=`cat J.txt`
arrI=($valueI)
arrJ=($valueJ)
for ((i=1; i<=outputNumber; i++))
do
echo "geknoei$i.nc"
gunzip *_??????.nc.gz
ncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
gzip *_??????.nc
done
問題は、これによりすべてのファイルが一度に解凍され、多くのスペースが占有されることです。一度に 1 つのファイルを解凍すると、利用可能なすべての解凍された .nc ファイルから抽出されるため、ncrcat コードは機能しなくなります。
回線を動作させながら、一度に 1 つの .nc ファイルを解凍するにはどうすればよいでしょうかncrcat -C -F -d nj_u,${arrJ[i]},${arrJ[i+1]} -d ni_u,${arrI[i]},${arrI[i+1]} -v vel_u *_??????.nc gekneoi$i.nc
?